Workflow with PayKey using Paypal Adaptive Payment

I am trying to implement a payment system using the new Paypal API (Adaptive Payment).

So far I have this workflow:

  • Send Paypal request for: AdaptivePayments/Pay
  • Create a payment request and return payKey valid 3 hours ( source )
  • Now I wait for paypal to send me a request via IPN. When this happens, I will get pay_key with it.
  • Using this pay_key, I will call AdaptivePayments/PaymentDetails to find out the status of the payment.

But I was wondering how can I do this if more than 3 hours have passed? (e.g. when returning?)

What is the right way?

Thank you for your help!

+4
source share
1 answer

Well, I will answer this and read a little.

Instead of using the payKey specified when calling AdaptivePayments/Pay , another solution is to use trackingId.

Here's how:

First step: you create AdaptivePayments/Pay , and you specify trackId (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 payKey that you redirect your buyer to complete the payment.

Then, for the entire evolution of this payment, you will be notified at your IPN URL (here, http://apigee.com/console/-1/ipn ") ..

When you receive a POST request at this address, check the payment is correct in PayPal, and you will receive a trackingId in the parameter. Verify that this tracking ID exists, and then request AdaptivePayments/PaymentDetails with this tracking ID as follows:

 { "trackingId":"{put here}", "requestEnvelope":{"errorLanguage":"en_US", "detailLevel":"ReturnAll"} } 

And you will have the full detailed status of your payment in return.

Now you are doing the work of updating the database, call your customer, etc. etc.:)

What was useful to me:

+10
source

Source: https://habr.com/ru/post/1392767/


All Articles