Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Trying To Use REST Method’s For POLi Integration In PHP , CURL

DZone's Guide to

Trying To Use REST Method’s For POLi Integration In PHP , CURL

·
Free Resource
// description of your code here

Does any body have an example of how we can use REST method for POLi payment gateway integration ? I have used CURL to send my request which is in XML format but is unable to get the proper response. the example which I tried is 

$xmlRequest = '

  

  
  
   
    xxx!
   
  
   
    
    
     1.00
    
    
    
     AUD
    
    
    
     http://localhost/test/checkout
    
    
    
     yyy
    
    
    
     MerchantDataAssociatedWithTransaction
    
    
    
     25 August 2008 14:31:32
    
    
    
     http://localhost/test/home
    
    
    
     MerchantReferenceAssociateWithTransaction
    
    
    
     http://localhost/test/notification
    
    
    
    
    
     http://localhost/test/successful
    
    
    
     1000
    
    
    
     http://localhost/test/unsuccessful
    
    
    
     192.100.100.42
    
  
   

  ';

/* Use CURL to execute XML POST and write output into a string */

$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($xmlRequest) . "\r\n";
$header[] = $xmlRequest;
 
$ch = curl_init();

$fh = fopen('error.txt', 'w');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fh); 

curl_setopt( $ch, CURLOPT_URL, "http://merchantapi.rega-staging.polipayments.com/MerchantAPIService.svc/Xml/transaction/initiate"); # URL to post to
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); # return into a variable
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); # custom headers, see above
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); # This POST is special, and uses its specified Content-type
curl_setopt( $ch, CURLOPT_ERRORBUFFER, 1);
$result = curl_exec( $ch ); # run!
 
echo $result;

fclose($fh);
echo "
".file_get_contents('error.txt').'
'; unlink('error.txt'); curl_close($ch);
I am getting the output * About to connect() to merchantapi.rega-staging.polipayments.com port 80 (#0) * Trying 212.188.185.73... * connected * Connected to merchantapi.rega-staging.polipayments.com (212.188.185.73) port 80 (#0) > POST /MerchantAPIService.svc/Xml/transaction/initiate HTTP/1.1 Host: merchantapi.rega-staging.polipayments.com Accept: */* Content-type: text/xml Content-length: 1351 xxx 1.00 AUD http://localhost/test/checkout yyy MerchantDataAssociatedWithTransaction 25 August 2008 14:31:32 http://localhost/test/home MerchantReferenceAssociateWithTransaction http://localhost/test/notification http://localhost/test/successful 1000 http://localhost/test/unsuccessful x.x.x.x < HTTP/1.1 400 Bad Request < Via: 1.1 DCSERVER < Connection: Keep-Alive < Proxy-Connection: Keep-Alive < Content-Length: 0 < Date: Wed, 17 Sep 2008 04:46:51 GMT < Server: Microsoft-IIS/6.0 < X-AspNet-Version: 2.0.50727 < Cache-Control: private * Connection #0 to host merchantapi.rega-staging.polipayments.com left intact
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}