Payerid is not returned in Express Checkout GetExpressCheckoutDetails - paypal

Im currently using Sandbox.
I have returned a token from SetExpressCheckout and using this in GetExpressCheckoutDetails I have returned ACK=success here too, but no Payerid was included in the return parameters.
When I did the redirect using the returned url from SetExpressCheckout, I got to a paypal page saying the transaction had timed out. Should I have expected this or should I somehow sign into paypal sandbox as the buyer to approve the transaction. Not sure how this works in sandbox.

Related

paypal doExpressCheckoutPayment invalid PayerID every single time

Why is everything PayPal so crazy hard?
This is what I'm sending to https://api-3t.sandbox.paypal.com/nvp :
METHOD=DoExpressCheckoutPayment&
VERSION=108.0&
USER=my-sandbox-facilitator_api1.domain.com&
PWD=&
SIGNATURE=&
SUBJECT=&
TOKEN=EC-1GE68226PG526154U&
PAYERID=my-sandbox-buyer%40domain.com
PAYMENTREQUEST_0_PAYMENTACTION=SALE&
PAYMENTREQUEST_0_AMT=19.95&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
PAYMENTREQUEST_0_NOTIFYURL=
This is what I'm getting back:
TIMESTAMP=2015-12-12T21%3a35%3a34Z&
CORRELATIONID=d9a463bfa6bb4&
ACK=Failure&
VERSION=108.0&
BUILD=18308778&
L_ERRORCODE0=10406&
L_SHORTMESSAGE0=Transaction+refused+because+of+an+invalid+argument.+See+additional+error+messages+for+details.&
L_LONGMESSAGE0=The+PayerID+value+is+invalid.&
L_SEVERITYCODE0=Error
Just before this I did a METHOD=GetExpressCheckoutDetails without any problems.
PayerID wasn't invalid for that?!?!!
I have a token so I did a METHOD=SetExpressCheckout without any problems.
Ideas?
No amount of Google had a working answer for me.
Either did PP's 5(!) tech support sites.
It is the same issue even if I reconfigure and and shoot a similar transaction at my live PP.
PAYERID is a unique PayPal buyer account identification number as returned after SetExpressCheckout API call(after buyer login to paypal and gets redirected to your RETURN URL , you will need to copy that PAyer Id and use in Doexpresscheckout request. Payer is a 13 single-byte alphanumeric character and not an email address.
https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/

Paypal Sandbox ExpressCheckout NVP not creating transaction

I'm trying to integrate PayPal Classic API NVP to our website but I'm having issues with the SetExpressCheckout API call.
I'm using the useraction=commit parameter for the payer to confirm the sale directly at PayPal.
My issue is after "Pay now" is clicked, PayPal redirects to the URL I send as RETURNURL but I don't see the transaction on the sandbox account or by using TransactionSearch.
These are the parameters I send for checkout:
METHOD=SetExpressCheckout
EMAIL=payerEmail
SOLUTIONTYPE=Sole
RETURNURL=myReturnUrl
CANCELURL=myCancelUrl
PAYMENTREQUEST_0_AMT=30.00
PAYMENTREQUEST_0_ITEMAMT=30.00
PAYMENTREQUEST_0_CURRENCYCODE=USD
PAYMENTREQUEST_0_CUSTOM=myCustomId
PAYMENTREQUEST_0_PAYMENTACTION=Sale
L_PAYMENTREQUEST_0_QTY0=1
L_PAYMENTREQUEST_0_AMT0=30.00
L_PAYMENTREQUEST_0_NAME0=myProduct
After payment, PayPal redirects to
myReturnUrl?token={Token}&PayerID={PayerId}
It's normal. The transaction is set, but you need to complete it using the DoExpressCheckoutPayment api operation.
More information and an example here: https://devtools-paypal.com/guide/expresscheckout/dotnet?success=true&token=EC-7BD474648D4932937&PayerID=WNW7LMW2UXQJG

Paypal Digital Goods, Transactions not displaying

I've integrated Digital Goods with Express Checkout for my site and I've successfully tested with using sandbox. However I doesn't show any record of the transaction I've just completed in either the merchant account or the test account.
Should I be seeing a transaction? and if so, what could have gone wrong such that a transaction record isn't appearing?
You're most likely not calling the DoExpressCheckoutPayment API call to finalize the transaction.
DoExpressCheckoutPayment is a mandatory API call used to create a transaction out of a TOKEN and PAYERID (assuming the buyer has approved the transaction on the PayPal website).
The API doc (NVP) for DoExpressCheckoutPayment is available at developer.paypal.com.

Paypal NVP with IPN for confirmation - what ties them together

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.
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.
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.

Page Protection

I've had a difficult time working with PayPal express checkout... Basically I'm looking to protect a PAGE, not a download or anything. The user pays and they can access that page one time. And have to pay each time they want to access the page.
Does anyone have a simple PHP solution to protect my page until the person pays through PayPal? Or even a pre-written example of the PayPal code for Digital Goods for Express Checkout?
Thanks in advance.
PayPal doesn't have much to do with this -- it's all about the logic you place on your 'return page' (the page the buyer returns to after they have completed payment).
For a simple Express Checkout integration you would:
1. Call the SetExpressCheckout API
2. Supply the AMT, RETURNURL and CANCELURL
3. Retrieve the token as returned in the SetExpressCheckout response.
4. Redirect the buyer to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-xxxtoken-herexxx&useraction=commit
5. When the buyer agrees to the payment and is returned back to your RETURNURL, call the GetExpressCheckoutDetails API and supply the token to retrieve the PayerID (alternatively; the token is also appended in the GET array for your RETURNURL)
6. Call DoExpressCheckoutPayment to finalize the payment.
7. Now that the payment is complete, do whatever logic you have to to ensure the transaction is completed and provide the buyer access to the content you wish him/her to see (could be the RETURNURL page itself, or a completely different page).
Sample (NVP) API calls would look similar to the following:
SetExpressCheckout Request
METHOD=SetExpressCheckout&USER=yourAPIuser&PWD=yourAPIpwd&SIGNATURE=yourAPIsig&VERSION=78.0&AMT=0.01&RETURNURL=http://www.your-return-url.com/&CANCELURL=http://www.cancelurl.com/
SetExpressCheckout Response
......
Ack=Success
TOKEN=EC-12345678
.......
GetExpressCheckoutDetails Request
METHOD=SetExpressCheckout&USER=yourAPIuser&PWD=yourAPIpwd&SIGNATURE=yourAPIsig&VERSION=78.0&TOKEN=EC-12345678
GetExpressCheckoutDetails Response
.....
Ack=Success
PAYERID=ABCDEFGH
......
DoExpressCheckoutPayment Request
METHOD=SetExpressCheckout&USER=yourAPIuser&PWD=yourAPIpwd&SIGNATURE=yourAPIsig&VERSION=78.0&AMT=0.01&PAYERID=ABCEDFGH&TOKEN=EC-12345678
DoExpressCheckoutPayment Response
....
Ack=Success
PAYMENTSTATUS=Completed
....
See also
SetExpressCheckout: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
GetExpressCheckoutDetails: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails
DoExpressCheckoutPayment: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment
As well as https://www.x.com/ > API Reference.
Note: I'm using "useraction=commit" in the redirect URL to PayPal because that will change the 'Continue' button on the PayPal 'Review Your Payment' to a 'Pay now' button. Thus implying the buyer will be immediately charged as soon as he clicks on that button. It's just handy.