2

i am developing a frontend webapp that allows users to become premium through a subscription button. After a user completes the subscription workflow, i have to inform my backend that a certain user has started a subscription.

From the backend point of view, what api call do i have to do to get the information about the subscription? https://api.sandbox.paypal.com/v1/payments/sale/ ? https://api.sandbox.paypal.com/v1/payments/authorization/ ?

On the frontend i'm using a subscription button and the only id i get from the PDT callback is the transaction-id. Is it the one i need or do i have to set up a IPN listener go get other information?

MauroSK
  • 93
  • 7

1 Answers1

1

IPN is all you need to manage your backend subscription status. When a customer completes a subscription, your IPN script will recieve a PayPal post-back message which is supposed to be like this:

txn_type=subscr_signup&subscr_id=I-T174N7E5R9YK&last_name=US&residence_country=US&mc_currency=USD&item_name=USM+Sample+Subscription&business=USM%40email.com&amount3=1.00&recurring=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AfmX-ZMkgBlWAFEHv-hrAdTpuXhH&payer_status=verified&test_ipn=1&payer_email=USP%40email.com&first_name=Payer&receiver_email=USM%40email.com&payer_id=8FMFQ2KVYYHTY&reattempt=1&item_number=S1&recur_times=2&subscr_date=20%3A41%3A18+Oct+25%2C+2015+PDT&charset=gb2312&notify_version=3.8&period3=6+D&mc_amount3=1.00&ipn_track_id=683b212770787 

You may want to look at the txn_type=subscr_signup and subscr_id=I-T174N7E5R9YK, the former one tells the transaction type (signup, cancelation, subscription payment, expiration, etc), and the latter one is for your database reconciliation usage (store the ID along with your customer profile entry into your database)

PDT is good for showing your customer order details when they return to your site after the payments, but is not recommended for backend order management use, as it's a synchronized method and could be 'aborted' by user browser behavior (back button, browser closed, etc)

pp_pduan
  • 3,392
  • 1
  • 9
  • 15
  • Thanks for the answer! Ye, i thought i had to implement an IPN listener, i just wasn't sure about what kind of information i needed to inform my backend about the status update. So paypal automatically comunicates to the IPN listener of any status update on a subscription? But using IPN async messages how can i match the paypal user with my site user? – MauroSK Oct 26 '15 at 09:40
  • The recommended method is to pass the `invoice` tag in your subscription button form code, to identify an unique ID of the subscription. This field will be posted back thru IPN then for matching with your database user entry. – pp_pduan Oct 26 '15 at 14:19
  • And yes, IPN is event-triggered async messaging, so you can rely on that to update your subscription profiles upon status changes (payments made / profile canceled / expired etc) – pp_pduan Oct 26 '15 at 14:21