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?
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":"seller_1288085303_biz@gmail.com"}]},
"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 :