{"id":217,"date":"2018-09-04T14:42:49","date_gmt":"2018-09-04T18:42:49","guid":{"rendered":"http:\/\/www.joonim.org\/?p=217"},"modified":"2018-09-04T14:42:49","modified_gmt":"2018-09-04T18:42:49","slug":"php-how-to-retrieve-credit-card-payment-reports-from-bambora","status":"publish","type":"post","link":"https:\/\/waterloobae.com\/blog\/2018\/09\/04\/php-how-to-retrieve-credit-card-payment-reports-from-bambora\/","title":{"rendered":"[PHP] How to retrieve credit card payment reports from Bambora"},"content":{"rendered":"<p>First of all, make sure if API access passcode under &#8220;administration -&gt; account settings -&gt; order settings&#8221; is generated and obtainable.<\/p>\n<p>Payment reports are retrieved by transaction dates. So, it should be cross checked with local DB transaction data in order to get one transaction information\u00a0 out of order number, customer&#8217;s name or other information after retrieving in date ranges.<\/p>\n<p>Bambora&#8217;s Payment APIs are the RESTful interface to the payment gateway. cURL is used to get payment report on PHP as below.<\/p>\n<p>[code language=&#8221;PHP&#8221;]<\/p>\n<p>$BAM_API_PASSCODE = &quot;Authorization: Passcode &quot;.&quot;your Bambora passcode&quot;<br \/>\n$reportURL = &quot;https:\/\/api.na.bambora.com\/v1\/reports&quot;;<br \/>\n$from_date = date(&quot;Y-m-d&quot;, strtotime(&quot;-1 days&quot;));<br \/>\n$to_date = date(&quot;Y-m-d&quot;, strtotime(&quot;+1 days&quot;));<\/p>\n<p>$crl = curl_init();<\/p>\n<p>$postData = array(<br \/>\n&quot;name&quot; =&gt; &quot;Search&quot;,<br \/>\n&quot;start_date&quot; =&gt; $from_date.&quot;T00:00:00&quot;,<br \/>\n&quot;end_date&quot; =&gt; $to_date.&quot;T23:59:59&quot;,<br \/>\n&quot;start_row&quot; =&gt; &quot;1&quot;,<br \/>\n&quot;end_row&quot; =&gt; &quot;1000&quot;<br \/>\n);<\/p>\n<p>$postData = json_encode($postData);<\/p>\n<p>$header = array();<br \/>\n$header[] = &#8216;Content-length: &#8216;.strlen($postData);<br \/>\n$header[] = &#8216;Content-type: application\/json&#8217;;<br \/>\n$header[] = $BAM_API_PASSCODE;<\/p>\n<p>curl_setopt($crl, CURLOPT_HTTPHEADER,$header);<br \/>\ncurl_setopt($crl, CURLOPT_URL, $reportURL);<br \/>\ncurl_setopt($crl, CURLOPT_RETURNTRANSFER, true);<br \/>\ncurl_setopt($crl, CURLOPT_POST,true);<br \/>\ncurl_setopt($crl, CURLOPT_POSTFIELDS, $postData);<\/p>\n<p>$output = curl_exec($crl);<br \/>\ncurl_close($crl);<\/p>\n<p>$output = json_decode($output, true);<br \/>\n$trns = $output[&#8216;records&#8217;];<\/p>\n<p>foreach( $trns as $trn){<br \/>\necho print_r($trn).&quot;&lt;br \/&gt;&lt;br \/&gt;&quot;;<br \/>\n}<\/p>\n<p>[\/code]<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First of all, make sure if API access passcode under &#8220;administration -&gt; account settings -&gt; order settings&#8221; is generated and obtainable. Payment reports are retrieved by transaction dates. So, it should be cross checked with local DB transaction data in order to get one transaction information\u00a0 out of order number, customer&#8217;s name or other information [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-217","post","type-post","status-publish","format-standard","hentry","category-it-tips"],"_links":{"self":[{"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/posts\/217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":0,"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions"}],"wp:attachment":[{"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/waterloobae.com\/blog\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}