Pierre-Jean Bergeron Pierre-Jean Bergeron - 7 months ago 37
PHP Question

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

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?

Answer

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.