express checkout: possible values of payment_status field in ipn after pending - paypal

I wonder what are possible values of field payment_status in ipn?
I can see in simulate in sanbox ipn with payment_status: Completed and Reverse.
Are other values possible for checkout transaction like Failed, Denied if transaction is
not completed after pending?
I implement paying using express checkout.
I process ipn to see if there are transaction with payment_status = 'Completed' if transaction had payment_status = 'Pending'.
If I cick Accept for pending transaction in checkbox, I receive ipn with payment_status = 'Completed' and implement purchase.
If I cick Deny for pending transaction in checkbox, I receive ipn with payment_status = 'Reversed' (but parent_txn_id is set to transaction not txn_id), which is rather suprising I thought it would be with payment_status Denied, I want to mark transaction denied in my system.
I wonder if I need to analyse other values to mark transaction as denied in my system.
How to analyze if payment is declined?

Open up PayPal's IPN Variables documentation and do a find on the page for payment_status. Step your way down the page to see where it could come up and what values might be.

Related

Get status of Paypal NVP correlationid

I have a transaction with "Correlationid" with Paypal's Express Checkout NVP API. How can I get the details for this correlationid as to whether the transaction was completed or denied?
The CorrelationID is pretty much useless as the transactionID is used in reference lookup such as this. The best solution here to do is run the GETTRANSACTIONDETAILS API call for Express Checkout using the:
PAYMENTSTATUS Status of the payment.
It is one of the following values:
None — No status
Canceled-Reversal — A reversal has been canceled, for example, when you win a dispute and the funds for the reversal have been returned to you.
Completed — The payment has been completed, and the funds have been added successfully to your account balance.
Denied — You denied the payment. This happens only if the payment was previously pending because of possible reasons described for the PendingReason element.
Expired — The authorization period for this payment has been reached.
Failed — The payment has failed. This happens only if the payment was made from your buyer's bank account.
In-Progress — The transaction has not terminated, for example, an authorization may be awaiting completion.
Partially-Refunded — The payment has been partially refunded.
Pending — The payment is pending. See the PendingReason field for more information.
Refunded — You refunded the payment.
Reversed — A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer. The reason for the reversal is specified in the ReasonCode element.
Processed — A payment has been accepted.
Voided — An authorization for this transaction has been voided.
Here is a document to assist you with this call and parameters:
GetTransactionsDetails API

Reject transaction after receiving IPN

Is it possible to reject / auto refund after receiving IPN message with COMPLETED status but the txn_id is duplicated or the price value is incorrect?
Or manual investigation need to be done to refund
If you are verifying your IPN calls with PayPal, this should (in theory) be impossible. PayPal never duplicates transaction IDs.
Is it possible to reject / auto refund after receiving IPN message with COMPLETED status but the txn_id is duplicated or the price value is incorrect?
You can't reject the transaction with IPN. You aren't in a transaction. You're getting notification that a transaction has already occurred.
You may be able to use another API to reverse the transaction, as suggested by #geewhiz.

PayPal IPN - what to do if details are wrong?

At the end of the IPN docs it says the following:
Important: After you have authenticated an IPN message (that is, received a VERIFIED response from PayPal), you must perform these important checks before you can assume that the IPN is both legitimate and has not already been processed:
1.Check that the payment_status is Completed.
2.If the payment_status is Completed, check the txn_id against the previous PayPal transaction that you processed to ensure the IPN message is not a duplicate.
3.Check that the receiver_email is an email address registered in your PayPal account.
4.Check that the price (carried in mc_gross) and the currency (carried in mc_currency) are correct for the item (carried in item_name or item_number).
What are you supposed to do if one of these checks fails? Are we supposed to call a PayPal API somehow to 'reject' the transaction'?
Most shops would mark an order / transaction that fails these checks as "Possible Fraud" or something along these lines.
The order status should raise awareness with the employee working the orders - a closer look should show which check has failed and further actions can be initiated.
This may range from refunding the transactions to contacting PayPal for possible fraud attempts. In any case, the order should be checked and not just treated as any other "Completed" order.
Sample scenario:
You're using unencrypted Website Payments Standard, HTML Forms to receive payments.
A fraudulent buyer finds out and starts modifying the price of an item through editing the submitted form
You receive the order as PAID and don't check the value of the order within your shop against the transaction
An employee doesn't spot this and an item worth 200$ is sent out for a payment of 0.01$

IPN payment_status variable

I am using PayPal's IPN service to confirm payment. My listener is checking the payment_status variable hoping to find "Completed". I don't want to do anything in my database unless the payment comes back "Completed". My question is, what if it does not come back with that status? Will PayPal continue to communicate with my listener until it is complete? For example, the status could come back as "Processed", which appears to be a step before "Completed". Below is a link to a document with all of the variables:
https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/ipnguide.pdf
On page 10:
Because IPN messages can be sent at various stages in a transaction’s progress, make sure
that the transaction’s payment status is “completed” before enabling shipment of
merchandise or allowing the download of digital media.
So yes, I think PayPal will always give you an IPN with Completed status.

PayPal express checkout handling "pending payments" with IPN

I cant find anny clear documentations about this.
If you use paypal express checkout, when a payment is pending what happens next?
Does paypal sends you by IPN an update if the states changes, do you have options?
Let say you do an DoExpressCheckoutPayment (with NVP)
and you get this:
&PAYMENTSTATUS=Pending
&PENDINGREASON= ECHECK //The payment is pending because it was made by an eCheck that has not yet cleared.
&REASONCODE=None
So you've made the payment and you want to wait until its cleared? What should you do next.
Update Some (external documentation) I found only sugest you could use (IPN?) to handle pending payments.
"If the Do Express Checkout Payment PENDINGREASON response is a value
other than none or completed , the payment is pending. Typically,
this means the customer has paid with aneCheck. In such a case, funds
are not guaranteed, and you should not ship or deliver items or
services until the payment has successfully completed. NOTE:
PayPal recommends that you block eChecks as a payment method if you
are unable tohandle pending state payments.To find out the status of a
pending payment, you can:
Submit an Inquiry transaction.
Check the status using PayPal Manager. See PayPal Manager online help
for details."
The paypal sandbox seems to have the option to check IPN messages for the express checkout type. The only correlation (if its ment to be used this way) between the DoExpressCheckoutPayment and the IPN seems you can use the "custom" field to keep track of a pending status. The txn_id (ipn) isn't given in DoExpressCheckoutPayment (nvp). Does any one have any experience with this?
The transaction ID is most certainly given in DoExpressCheckoutPayment, even if the PAYMENTSTATUS=Pending. A pending payment is still a transaction.
So yes, you would be notified via IPN when the transaction is completed. This typically takes a few working days.
Once it has completed, you can correlate the transaction from DoExpressCheckoutPayment to the IPN you will have received via the txn_id in the IPN.
Note: If you want to test a 'Pending' payment in the PayPal Sandbox, simply go to https://developer.paypal.com/ > Test account and click on 'Payment review' for the seller account you're testing with.
Once payment review is enabled on that seller account, any transactions it receives will be in a 'Pending' state.
Simply disable payment review to release the tranasctions afterwards.
I thought i'd add my two pence worth of thoughts to this.
I was getting a pending return status using Express Checkout via the dotNet SDK, according to the doc's and examples I should have been getting an 'approved' status.
I couldn't figure out why but it turned out to be because I was passing through a new currency, in our case 'GBP'. I had to log in as the facilitator sandbox account and decide what to do with the new currency.. convert it or setup a new balance in the currency. Once I did this, and set it as the default action, the pending return status no longer occurred.
hope that helps someone!
One thing not noted here and I haven't found anything else to confirm.. is that Paypal Express API doesn't support passing in the NOTIFYURL with the code. So you have to use the hardcoded IPN url set in your paypal account. This of course causes issues because you need a common callback file that can redirect to the individual payment options.
For example, if you are using Paypal Express AND Paypal Advanced.. Neither of those properly support a notifyurl passed in using the code. Paypal Advanced claims to, but it doesn't seem to work. So there needs to be a common IPN callback file that handles the redirection to each.
Unless someone else can confirm a working notify url for Express Checkout variable that can be passed in the code?