5

I am using PayPal with NVP API (using PHP) for express checkout. I am creating an invoice record in the database before redirecting the user to Paypal. In case the user doesn't return to my site after processing, I am using IPN to confirm the purchase and then update the invoice record that the payment is confirmed. I am still in the sandbox mode and trying to figure out how I will tie the transaction started with NVP to the confirmation I get with IPN.

I need to verify if the "PAYMENTREQUEST_n_INVNUM" sent in the NVP will come back as "invoice" in the IPN post.

It appears I cannot actually test this until I am live since the Sandbox IPN does not seem to be active with NVP initiated sandbox transactions - is this correct?

Thanks for your help.

mseifert
  • 5,390
  • 9
  • 38
  • 100
  • You could use custom field as pass through variable. Assign an ID, and use it to link the transactions. – Marcus Adams Dec 19 '11 at 22:20
  • Yes, the custom field was my second choice to store the invoice number. I was hoping that the 'invoice' would be dedicated to that purpose and I could use custom for some other data if needed. – mseifert Dec 19 '11 at 22:57

2 Answers2

6

You can test this in Sandbox. But if you're using "PayPal NVP", I assume you're using PayPal Express Checkout and calling the SetExpressCheckout and DoExpressCheckoutPayment API's.
If that's the case, you don't really need IPN, because a transaction will only be completed as soon as you call DoExpressCheckoutPayment.

In other words, buyers will always be redirected to the RETURNURL you specified in SetExpressCheckout, and the transaction is completed (or not) when you call DoExpressCheckoutPayment on this return page.

To get the invoice number, you could call GetExpressCheckoutDetails and supply the TOKEN you retrieved earlier (it's also appended to the GET of the RETURNURL).

Finally, check PAYMENTSTATUS=Completed in the DoExpressCheckoutPayment API response to see whether the transaction has completed or not.

Robert
  • 19,326
  • 3
  • 58
  • 59
  • You are correct, I am using PayPal Express Checkout and calling the SetExpressCheckout and DoExpressCheckoutPayment API's. I was under the impression that once the user clicks the 'Pay Now' button on Paypal's site it is paid for. If for any reason the user disconnects from my site before being rerouted, I will never get the confirmation of the sale. It seems safer have IPN as a backup for confirmation. – mseifert Dec 19 '11 at 22:40
  • No, the transaction is only finalized after you called `DoExpressCheckoutPayment` and you received a `PAYMENTSTATUS=Completed` in the API response. That's why Express Checkout doesn't show a 'Pay now' button in the checkout on the PayPal website. Rather, it lets the user authorize the payment, and if they're happy with it, they click a 'Continue' button to proceed. The 'Continue' button automatically returns to your website, no delay, no hassle, always, 100% of the time. If a buyer doesn't hit your return URL, it simply means they didn't want to go ahead with the PayPal transaction. – Robert Dec 19 '11 at 22:45
  • (Still, IPN is always good to have as a backup, I agree. PAYMENTREQUEST_0_INVNUM will match the 'invoice' parameter in the IPN POST). – Robert Dec 19 '11 at 22:46
  • I am setting useraction = commit which changes the 'continue' button to 'pay now', so they don't redirect till after they've confirmed the payment. Thanks. – mseifert Dec 19 '11 at 22:54
  • 1
    `useraction=commit` realistically only changes the wording on the button from 'Continue' to 'Pay now', it still doesn't automatically completes the payment. – Robert Dec 19 '11 at 23:14
  • Are you sure of that? According to Paypal: 'If you do not require the buyer to explicitly review and confirm the order on your site, you can configure Express Checkout such that the user commits the payment on PayPal.This reduces a step in the checkout flow. ... In most checkout flow implementations, the payment methods page is the last page the buyer sees before commiting to a transaction. If this true in your implementation, you can use this feature to streamline the buyer experience. The feature informs the buyer that they are commiting to the transaction if they proceed.' – mseifert Dec 19 '11 at 23:29
  • 1
    Yes, I am. By useraction=commit you can skip an order review page on your end (on the RETURNURL) and it lets you automatically call DoExpressCheckoutPayment, but it doesn't automatically complete the transaction for you. – Robert Dec 20 '11 at 09:33
  • @Robert Thank you very much. Just what I wanted to know. I wanted to eliminate complexity on my PayPal integration by extracting ipn variables during asynchronous communications like handling pending payments and refunds only. For express checkout, I'll just save the ipn on database for tracing purposes only. :) – Woppi Dec 13 '12 at 06:36
0

Thank you Robert for the clarity on the process - especially useraction=commit.

I finally realized that I could turn on IPN in the Sandbox for my test seller and test NVP with IPN together. I was able to verify that PAYMENTREQUEST_0_INVNUM matches the 'INVOICE' parameter in the IPN POST.

I will use the custom field to pass customer email from my system in case they use a different email to log into paypal with, therefore allowing me to have email/invoice number pair for confirmation.

mseifert
  • 5,390
  • 9
  • 38
  • 100