POLi Payment Gateway Integration with PHP

Discussion in 'Payment Processing' started by Rizwan Mumtaz, Sep 16, 2011.

  1. #1
    Hey! i need to integrate POLi payment Gateway with my custom PHP. Can any body help in integrating it with PHP ..
    here is a list of integration method supported by POLi - >http://www.polipayments.com/smesolutions.aspx

    Here is a code which i have written.
    $xml='<?xml version="1.0" encoding="iso-8859-1"?>
    <InitiateTransactionRequest xmlns="http://schemas.datacontract.org/2004/07/Centricom.POLi.Services.MerchantAPI.Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <AuthenticationCode>xxxx</AuthenticationCode>
      <Transaction xmlns:dco="http://schemas.datacontract.org/2004/07/Centricom.POLi.Services.MerchantAPI.DCO">
        <dco:CurrencyAmount>1.00</dco:CurrencyAmount>
        <dco:CurrencyCode>AUD</dco:CurrencyCode>
        <dco:MerchantCheckoutURL>http://localhost/test/checkout</dco:MerchantCheckoutURL>
        <dco:MerchantCode>xxxx</dco:MerchantCode>
        <dco:MerchantData>MerchantDataAssociatedWithTransaction</dco:MerchantData>
        <dco:MerchantHomePageURL>http://localhost/test/home</dco:MerchantHomePageURL>
        <dco:MerchantRef>MerchantReferenceAssociateWithTransaction</dco:MerchantRef>
        <dco:NotificationURL>http://localhost/test/notification</dco:NotificationURL>
        <dco:SelectedFICode i:nil="true" />
        <dco:SuccessfulURL>http://localhost/test/successful</dco:SuccessfulURL>
        <dco:Timeout>1000</dco:Timeout>
        <dco:UnsuccessfulURL>http://localhost/test/unsuccessful</dco:UnsuccessfulURL>
        <dco:UserIPAddress>192.168.5.42</dco:UserIPAddress>
      </Transaction>
    </InitiateTransactionRequest>';
    Code (markup):
    $url='https://merchantapi.apac.paywithpoli.com/MerchantAPIService.svc/Xml/transaction/initiate';   
        $response=sendTransactionToGateway($url, $xml);
        
        echo '<pre>';
        print_r($response);
        echo '</pre>';
    Code (markup):
        function sendTransactionToGateway($url, $parameters) 
    {
          $server = parse_url($url);
          if (isset($server['port']) === false) {
            $server['port'] = ($server['scheme'] == 'https') ? 443 : 80;
          }
    
          if (isset($server['path']) === false) {
            $server['path'] = '/';
          }
    
          if (isset($server['user']) && isset($server['pass'])) {
            $header[] = 'Authorization: Basic ' . base64_encode($server['user'] . ':' . $server['pass']);
          }
    
          if (function_exists('curl_init')) {
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_PORT, $server['port']);
            curl_setopt($curl, CURLOPT_HEADER, 0);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
            curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
            curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);
    
            $result = curl_exec($curl);
    
            curl_close($curl);
          }
    return $result;
    }
    Code (markup):
    Now this is what i am getting back in response

    Receivera:InternalService
    FaultThe server was unable to process the request due to an internal error.
    For more information about the error, either turn on IncludeExceptionDetailInFaults
    (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior)
    on the server in order to send the exception information back to the client, or turn on
    tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
    What wrong with this code - Code has been copied from osCommerce POLi module.
     
    Rizwan Mumtaz, Sep 16, 2011 IP