Bienvenido, Invitado
Recordarme

TEMA:

Payment gateways 1 año 4 meses antes #243271

  • Autor del tema
  • Rokhi
  • Fuera de línea
  • Senior Breezer
  • Senior Breezer
  • Mensajes: 111
  • Gracias recibidas: 1
Hi. I would like to use POLi payment gateway I have the code samples and api info. ( www.polipayments.com/InitiateTransaction ).

How would you suggest I incorporate it on a BF form?

Or would you know if I can adapt/use the PayPal element? Apparently the interface strategy is similar to PayPal in terms of using a target URL and pipe-delimited data.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Rokhi.

Payment gateways 1 año 4 meses antes #243276

  • Avatar de TheMuffinMan
  • TheMuffinMan
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 10064
  • Karma: 167
  • Gracias recibidas: 808
Hi,

I don't think you need to derive from these.

General Procedure:

I assume they provide some overlay for card payments, these would need to be loaded into the form, for example through a custom button click event.

Then at some point the form would be sent.

In a custom end submit (=PHP) which is executed after the form has been submitted, I would contact their API and forward the payment data to their API (either forwarding a new page load to their site, similar to paypal OR forward the data using their API, ex. Rest if they offer one).

Then they for sure got a payment confirmation message that will be returned. If it is similar to Stripe's or PayPal's notification APIs, I would use a before form piece to check for incoming approval notifications and store these in a custom field of the previously made records.

However, if you have an API/Developer documentation on this, we could go more into details. On a quick look I wasn't able to find any. Maybe they hand these out for actual customers, only?

Regards,
Markus

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Payment gateways 1 año 4 meses antes #243280

  • Autor del tema
  • Rokhi
  • Fuera de línea
  • Senior Breezer
  • Senior Breezer
  • Mensajes: 111
  • Gracias recibidas: 1
Thanks for the quick reply Markus

That link page has php and java transaction initiation sample code at the bottom which I assume I can use as you suggest.

Can you see it? www.polipayments.com/InitiateTransaction

cheers

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Payment gateways 1 año 4 meses antes #243282

  • Avatar de TheMuffinMan
  • TheMuffinMan
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 10064
  • Karma: 167
  • Gracias recibidas: 808
Ok, try it out, with some slight modifications (mostly due to SSL, for testing):

The below is just for testing. Please make sure to use the correct auth code, in the code below (between the base64_encde('')) and you also might need to change the url in curl_init if they are using a different testing url.

The code below should foward to the payment at Poli and return back on successful/failed payments and cancellations.

If that works, then we can go on further and add some spice to it.
There might be an issue with SSL, since they suggest to use a cert but I turned off all SSL checks for testing.
If that happens, we will need to adjust it a bit and add a certificate file on your server.

Copy this into your form => advanced => more options => submit pieces => end submit, and do a form submission:
$json_builder = '{
    "Amount":"1.2",
    "CurrencyCode":"AUD",
    "MerchantReference":"CustomerRef12345",
    "MerchantHomepageURL":'.json_encode(JURI::getInstance()->toString() . ',
    "SuccessURL":'.json_encode(JURI::getInstance()->toString() . '&poli_success=true').',
    "FailureURL":'.json_encode(JURI::getInstance()->toString() . '&poli_success=false').',
    "CancellationURL":'.json_encode(JURI::getInstance()->toString() . '&poli_cancel=true').',
    "NotificationURL":'.json_encode(JURI::getInstance()->toString() . '&poli_notification=true').' 
}';
 
$auth = base64_encode('S61xxxxx:AuthCode123');
$header = array();
$header[] = 'Content-Type: application/json';
$header[] = 'Authorization: Basic '.$auth;
 
$ch = curl_init("https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate");
//See the cURL documentation for more information: http://curl.haxx.se/docs/sslcerts.html
//We recommend using this bundle: https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
//curl_setopt( $ch, CURLOPT_CAINFO, "ca-bundle.crt");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
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"]);
                        

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by TheMuffinMan.

Payment gateways 1 año 4 meses antes #243283

  • Autor del tema
  • Rokhi
  • Fuera de línea
  • Senior Breezer
  • Senior Breezer
  • Mensajes: 111
  • Gracias recibidas: 1
I submitted via preview and got a page not found error. How can I trace that

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Payment gateways 1 año 4 meses antes #243284

  • Avatar de TheMuffinMan
  • TheMuffinMan
  • Fuera de línea
  • Developer
  • Developer
  • Mensajes: 10064
  • Karma: 167
  • Gracias recibidas: 808
That's probably the navigation url the API returns not being correct.
To what page it is trying to forward you?

You can debug this in the code by doing it like this in the end:
print_r($json);
exit;
//header('Location: '.$json["NavigateURL"]);

After submission, it should print the contents of the returned response from their server instead of trying to forward. If there is nothing or the response contains an error, it either means we need to adjust the SSL setup for curl and use that cert file or no access has been granted to the API.

Regards,
Markus

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Tiempo de carga de la página: 0.055 segundos