TOPIC:

Payment gateways 2 years 11 months ago #243285

  • Topic Author
  • Rokhi
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 159
  • Thanks: 1
There was a missing )
"MerchantHomepageURL":'.json_encode(JURI::getInstance()->toString()) . ',

So tested that var ok.

added the curl code and now broken again.
Tried adding the bundle - still broken.
Tested the curl_init URI and it seems to post ok (in postman) - rejected for no authorisation.
any thoughts?

The json string is
{ "Amount":"1.2", "CurrencyCode":"NZD", "MerchantReference":"CustomerRef12345", "MerchantHomepageURL":"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1", "SuccessURL":"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1&poli_success=true", "FailureURL":"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1&poli_success=false", "CancellationURL":"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1&poli_cancel=true", "NotificationURL":"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1&poli_notification=true" }

so the page address looks like:
"https:\/\/martinboroughfair.org.nz\/index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=8&ff_page=1&poli_cancel=true"

Is that what it should be?

Please Log in or Create an account to join the conversation.

Last edit: Post by Rokhi.

Payment gateways 2 years 11 months ago #243288

  • Topic Author
  • Rokhi
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 159
  • Thanks: 1
If I omit the line:
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

I can run the code.
The response is
{"Success":true,"NavigateURL":"https://txn.apac.paywithpoli.com/?Token=PgsYSw7rOUvlOFXPOObxWdYkepbZeG62","ErrorCode":0,"ErrorMessage":null,"TransactionRefNo":"996476505241"}1

Please Log in or Create an account to join the conversation.

Payment gateways 2 years 11 months ago #243292

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Administrator
  • Administrator
  • Super Users
  • Posts: 10544
  • Thanks: 864
Hi,

a little bit weird that it works without returntransfer but if that works, even better.

Now please post the code you have so far, so I can add things.

Also let me know what currency you want to use and where the prices should be coming from (e.g. from an element selection, dropdown, etc).

Regards,
Markus

Please Log in or Create an account to join the conversation.

Payment gateways 2 years 11 months ago #243295

  • Topic Author
  • Rokhi
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 159
  • Thanks: 1
$json_builder = '{
    "Amount":"1.2",
    "CurrencyCode":"NZD",
    "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('SS64010180:bM9^bZAcNwB5V');
$header = array();
$header[] = 'Content-Type: application/json';
$header[] = 'Authorization: Basic '.$auth;

$ch = curl_init("https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate");
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);
 
print_r($json);
exit;
//header('Location: '.$json["NavigateURL"]);

currency NZD

data to send
Itemname: Hidden field stallholderID
ItemNumber: the record ID
Price: siteTotal

Please Log in or Create an account to join the conversation.

Payment gateways 2 years 11 months ago #243296

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Administrator
  • Administrator
  • Super Users
  • Posts: 10544
  • Thanks: 864
Ok, then try this. I am assuming the "stallholderID" is the "MerchantReference".
The field for the record id isn't required because end submit pieces have a populated $this->record_id.

Please try it out. It should forward to Poli and let you do payments.
If this works, we will add a final step, accepting the fail, success or cancelled notifications.
$this->execPieceByName('ff_InitLib');

$json_builder = '{
    "Amount": '.json_encode( ff_getSubmit('siteTotal') ).',
    "CurrencyCode":"NZD",
    "MerchantReference":'.json_encode( ff_getSubmit('stallholderID') ).',
    "MerchantHomepageURL":'.json_encode(JURI::getInstance()->toString()) . ',
    "SuccessURL":'.json_encode(JURI::getInstance()->toString() . '&poli_success=true&record_id=' . $this->record_id) .',
    "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('SS64010180:bM9^bZAcNwB5V');
$header = array();
$header[] = 'Content-Type: application/json';
$header[] = 'Authorization: Basic '.$auth;

$ch = curl_init("https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate");
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);
 
//print_r($json);
//exit;
header('Location: '.$json["NavigateURL"]);

Please Log in or Create an account to join the conversation.

Payment gateways 2 years 11 months ago #243300

  • Topic Author
  • Rokhi
  • Offline
  • Senior Member
  • Senior Member
  • Registered
  • Posts: 159
  • Thanks: 1
If I copy the NavigateURL from the response, I get to the gateway, but if I use the header('Location: '.$json["NavigateURL"]); I just come back to the form.

Please Log in or Create an account to join the conversation.

Time to create page: 0.084 seconds

Support Chat

Join our Discord chat and enter the Crosstec channels for live-support, chat forums and interact directly with the community!

After joining, please enter the Crosstec Area and use the #crosstec-support or #crosstec-general channels.

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Subscribe to news and updates!

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!