I'm trying to implement a payment system using the new Paypal API (Adaptive Payment).
So far, I have this workflow :
AdaptivePayments/Pay
AdaptivePayments/PaymentDetails
to know the state of the payment.But I was wondering, how can I do if it's been more than 3 hours? (like in a refund?)
What is the sure way to do then?
Thanks for your help!
Well I'll answer myself on that one and after a bit of reading.
Instead of using the payKey given when calling AdaptivePayments/Pay
, and other solution is to use the trackingId.
Here's how :
First step, you create an AdaptivePayments/Pay
and you specify a trackingId (must be unique) :
{
"actionType":"PAY",
"currencyCode":"USD",
"receiverList":{"receiver":[{"amount":"1.00","email":"[email protected]"}]},
"returnUrl":"http://apigee.com/console/-1/handlePaypalReturn",
"cancelUrl":"http://apigee.com/console/-1/handlePaypalCancel?",
"trackingId":"abcde-12345-unique-of-course",
"ipnNotificationUrl":"http://apigee.com/console/-1/ipn",
"requestEnvelope":{"errorLanguage":"en_US", "detailLevel":"ReturnAll"}
}
In response, you will have the payKey that you'll redirect your buyer to, in order to do the payment.
Then, for the whole evolution of this payment, you will be notified to your IPN url (here, "http://apigee.com/console/-1/ipn").
When you'll receive a (POST) request at this adress, check the validity to paypal and you'll get a trackingId
in the parameter. Check that this trackingId exists and then ask AdaptivePayments/PaymentDetails
with that trackingId like this :
{
"trackingId":"{put here}",
"requestEnvelope":{"errorLanguage":"en_US", "detailLevel":"ReturnAll"}
}
And you will have a complete detailled status of your payment in return.
Now, you do the work to update your database, call your buyer, etc etc :)
What was helpful for me :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With