Question

I'm using Omnipay 2.1 and CodeIgniter 2.1.4 to receive Paypal payments.

I use this line to complete the purchase and check if the payment was sent:

$bool = $gateway->completePurchase(array('amount' => $total, 'currency' => 'EUR'))
                ->send()
                ->isSuccessful();

But I noticed that the method isSuccessful() will also return true if the payment is on pending.

How can I use omnipay to check if it's a pending payment or not?

Was it helpful?

Solution

Looking at your raw response data, the important lines are:

[ACK] => Success
[PAYMENTINFO_0_CURRENCYCODE] => EUR
[PAYMENTINFO_0_PAYMENTSTATUS] => Pending
[PAYMENTINFO_0_PENDINGREASON] => multicurrency

So the payment was processed successfully, but is in a Pending state. Omnipay doesn't explicitly check for this, but I'm not sure that would be sensible anyway. From the customer's point of view, the payment was successful, and money has left their account.

Looking at the PayPal API documentation for PAYMENTINFO_0_PENDINGREASON:

multi-currency – You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment.

So basically the payment was successful, the only reason it is pending is that you are charging customers in a currency (EUR) that you haven't explicitly enabled in your PayPal account.

OTHER TIPS

I believe you shouldn't be chaining isSuccessful() fn. Try just send() then checking the response from gateway:

$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD')->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} else {
    // debug etc;
    print_r($response);
}

Otherwise you might be getting a bool for send() etc;

Recent versions of OmniPay have an isPending method in the Response class that you can use to check if a payment is pending.

If you see the possible reasons for a payment status being pending, some of these may lead to an unsuccessful payment.

E.g.

  • paymentreview
  • regulatory_review
  • echeck.

I would suggest its not a good idea to ship or confirm an order before checking this would not rely on the response isSuccessful method returning true by itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top