How to excute in Rest API if the return_url request lost after user has paid - rest

I am integrating Express Checkout payments in my web by using REST API, and setting the payment intent to sale for making an immediate payment.
Here follows my steps:
1. create a direct payment by /v1/payments/payment, and set redirect_urls;
2. redirect the buyer using the approval_url in the response of step1;
3. when the buyer approves the payment, the full page will be redicrected to the url that I've been provided in redirect_urls, and then I will execute the payment to complete the payment.
My question here:
what if the redirect_url lost in my step3? The buyer paid but I wouldn't be notified. I would not receive the PAYMENT.SALE.COMPLETED webhook neither because I didn't execute the payment.

Related

PayPal Subscription: Refund full or partial

I am using Paypal rest API on my site. Till now I have implemented flow for regular order -
Create checkout session
Approve Payment by Payer
Capture Payment
Refund against captured payment
For subscription, I have implemented -
Create a checkout session with a subscription
Approve subscription by the payer
But after this, I couldn't get any further to capture any payment even from webhook, against which I could initiate a refund. There is an API for subscription capture, but it only adjusts the outstanding balance with the current payment. Also, the API doesn't return any object that might carry any capture info to work on a refund.
Does PayPal have any way to refund against payments on recurring subscriptions?
Approved subscriptions will charge automatically on their schedule. That is the point of subscriptions.
To be notified of subscription payments, register a listener endpoint for the webhook event PAYMENT.SALE.COMPLETED.
To refund subscription payments, full or partially, use the rel:refund link within any such sale object to refund it. See the v1/payments/sale/.../refund API call.

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 shipment details

I am using PayPal Adaptive payments (chained payments).
If I set:
1. CREATE payment
2. In the SetPaymentOptions -> Requires shipping address selection = true
3. When I redirect user for the https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=[PA KEY] user after authentication is not shown any prompt for shipping address
why?
Accordingly to the
https://www.x.com/developers/paypal/documentation-tools/api/pay-api-operation
when using CREATE I should do: CREATE – Use this option to set up the payment instructions with SetPaymentOptions and then execute the payment at a later time with the ExecutePayment.
But as soon as I try to run ExecutePayment I get the following information:
This payment request must be authorized by the sender
How can I set additional payment options then?
The ExecutePayment call would only be used if you're utilizing delayed chained payments. Otherwise, the payment still happens as soon as the buyer logs in and approves it, so there is no need for ExecutePayment. Calling it at that point results in the error you're getting, that the paykey was already used.
Did the sender actually authorize the payment?
The flow should be like:
Call Pay API operation with actionType as CREATE
If paymentExecStatus=CREATED and ack=SUCCESS, obtain payKey (here, keep detailLevel=ReturnAll in RequestEnvelope field of your Pay API request)
Redirect user to Paypal https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=YOUR_PAYKEY_ABOVE
If user approves payment, you will be redirected to your returnURL sent as a part of Pay API request
Verify approval status using PaymentDetails API operation
Later you can execute the payment thus setup in step 4 using ExecutePayment API operation. Send the same payKey you obtained in step 2.
You have got error code 550001 since the user approval seems to be not yet done successfully. It may be due to:
The application did not redirect user/sender to Paypal for authorization
OR
The user did not enter correct login details
OR
There were not sufficient funds available
etc.

Not receiving money through Paypal Express Checkout API

I developed a small payment process that uses the Express Checkout API. I'm testing the code with my friend's account with $1. My payment process is redirecting to the live paypal site, he enters his information and pays, he is redirected to my confirmation thank you page, but I never receive funds. I've checked my API credentials in the code, and they are OK. I'm receiving a token and paypal payerid info on my confirmation screen. What could be the problem?
Thank you in advance.
See my answer in Why is DoExpressCheckoutPayment required for Paypal?
In order to use Express Checkout, you must call at least the following API calls:
1. SetExpressCheckout -- to set up the transaction.
2. DoExpressCheckoutPayment -- to finalize the transaction.
If you don't call DoExpressCheckoutPayment on the 'Thank you' page, the transaction is not completed. This is by design to allow for greater flexibility
Express Checkout is intended as a drop-in solution in your own checkout process. After Express Checkout redirects you back to your site, you're supposed to show an order confirmation where the buyer can review his/her final order details before initiating a button / link which initiates the final DoExpressCheckoutPayment API call. This is why DoExpressCheckoutPayment is required.