InitiateTransaction Example

To initiate a transaction for a customer you need to call Initiate Transaction on the POLi API.

For the technical details of the API call, click here.

For an overview of how POLi works, click here.

You need to provide: your merchant code and authentication code to identify yourself, and the transaction details.

  • Your private merchant code and authentication code
  • Amount- the full transaction amount the customer should be charged
  • CurrencyCode - The currency of the transaction (note, this must match the currency of your merchant account)
  • MerchantReference - is a larger merchant data field for any other data you would like on the transaction
  • MerchantReferenceFormat - used to specify a New Zealand reconciliation format. See NZReconciliation for more details.
  • MerchantData field is for the merchant transaction reference
  • MerchantHomepageURL - the full merchant URL is displayed in the merchant information on the POLi landing page.
  • SuccessURL - full URL to redirect the customer to if the transaction is successful
  • FailureURL- full URL to redirect the customer to if the transaction is not successful
  • CancellationURL- full URL used to redirect the customer to if they cancel the transaction.
  • NotificationURL - full URL where to make the Nudge call to. see What is the POLi Nudge?.
  • Timeout - the timeout for the transaction in seconds, which defaults to 900 (15 minutes)
  • SelectedFICode- Used for pre-selecting banks in order to skip the POLi Landing page

This code example shows you how to call Initiate Transaction.

  • PHP
  • C#
Loading ...
$json_builder = '{
 $auth = base64_encode('S61xxxxx:AuthCode123');
 $header = array();
 $header[] = 'Content-Type: application/json';
 $header[] = 'Authorization: Basic '.$auth;
 $ch = curl_init("");
 //See the cURL documentation for more information:
 //We recommend using this bundle:
 curl_setopt( $ch, CURLOPT_CAINFO, "ca-bundle.crt");
 curl_setopt( $ch, CURLOPT_HTTPHEADER, $header);
 curl_setopt( $ch, CURLOPT_HEADER, 0);
 curl_setopt( $ch, CURLOPT_POST, 1);
 curl_setopt( $ch, CURLOPT_POSTFIELDS, $json_builder);
 curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0);
 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
 $response = curl_exec( $ch );
 curl_close ($ch);
 $json = json_decode($response, true);
 header('Location: '.$json["NavigateURL"]);

Once you have initiated the transaction, there are other integration steps required. Return to the Integration Overview to understand and complete the remaining integration work.

initiateexample.txt · Last modified: 2017/10/24 10:03 (external edit)