0

Dear stackoverflow community,

Recently PayPal contacted me to upgrade my 'old-style' CodeIgniter e-commerce cart (an old standard paypal gateway with a simple form to related paypal endpoint) to a solution with access token and client_id + secret. I used omnipay-paypal, following a guide like this:

https://artisansweb.net/paypal-payment-gateway-integration-in-php-using-paypal-rest-api/

And everything seems working fine, but with old standard cart I used a notifyUrl to send payment post data to a controller that made something like this:

foreach ($_POST as $key => $value) {
$request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}

$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 120);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($curl);

If that $response is VERIFIED, I enable related order for delivery (paid). Issue is that notifyUrl isn't triggered at all with Omnipay and this avoids to fit the shoe.

I tried to setup notifyUrl parameter on purchase, completePurchase method, but nothing to do: no call is sent after payment confirmation and no payment data in the related $_POST object.

Someone could give me some hint or help?

I tried to force the notifyUrl in any possible way, but after transaction is complete and payment confirmed, the notifyUrl is not receiving the expected data with post.

Hijacker
  • 1
  • 1
  • Show how you are specifying this 'notifyUrl". Does the URL accept incoming connections for a browser? You can review your account's IPN history at https://www.paypal.com/merchantnotification/ipn/history ; it's possible it's become disabled at the account level if a notify url has failed (stopped responding with HTTP 200 OK when posted to) for too long. Anyway, this is an extremely old integration and you should change to something that does not use IPN when convenient. – Preston PHX Dec 23 '22 at 16:53
  • Hi Preston PHX, first of all, many thanks for your help! Following omnipay documentation, this is actual purchase method: $response = $gateway->purchase(array( 'amount' => $_POST['amount'], 'currency' => PAYPAL_CURRENCY, 'returnUrl' => PAYPAL_RETURN_URL, 'cancelUrl' => PAYPAL_CANCEL_URL, 'notifyUrl' => $_POST['notify_url'], )) Story doenst change with it in completePurchase method. I checked your url with IPN history, but seems there're only IPN from live website (with old cart), nothing from sandbox. – Hijacker Dec 23 '22 at 22:03
  • notifyUrl, in old cart, simply send payment data to a MVC (CodeIgniter) controller that used that info to validate transaction on PayPal endpoint with a curl (like shown in main thread). "this is an extremely old integration and you should change to something that does not use IPN when convenient." => Seems to me that notifyUrl is really useful to send data on payment confirmation, otherwise, at which stage I could have payment confirmation and how I grab the complete payment response from PayPal endpoint? – Hijacker Dec 23 '22 at 22:06
  • Sandbox IPN history is at https://www.sandbox.paypal.com/merchantnotification/ipn/history . It's still not clear if/how this "notifyUrl" (which is not a PayPal parameter name) is being set in your requests to PayPal. IPN is an asynchronous notification that happens after payment completion or in the case of future events such as refunds. – Preston PHX Dec 23 '22 at 22:55
  • Thanks again for help. Sandbox IPN logs are empty, this is proof that no call was sent that way. Following omnipay/paypal doc, the notifyUrl should produce the post call with payment details, after payment is confirmed from PayPal, so how can I set it better than using the 'notifyUrl' => $_POST['notify_url'] in purchase or completePurchase method? – Hijacker Dec 24 '22 at 15:14

0 Answers0