3

How to check the status in subscription payment with paypal in e-commerce website

I am applying paypal payment on my website. For subscription payments I always get a pending status, so how can I check when it will succeed and when will it fail?

{
  "id":"I-TXXWY50EGMJX",
  "state":"Pending",
  "description":"Agreement for subscription salon owner",
  "start_date":"2020-04-17T07:00:00Z",
  "payer":{
    "payment_method":"paypal",
    "status":"verified",
    "payer_info":{
      "email":"sb-umuhk1452433@personal.example.com",
      "first_name":"John",
      "last_name":"Doe",
      "payer_id":"Z7CZSRCHLFWGY",
      "shipping_address":{
      }
    }
  },

  "plan":{  
  },
  "links":[
    {   
    }
  ],
  "agreement_details":{
    "outstanding_balance":{
      "value":"0.00"
    },
    "cycles_remaining":"0",
    "cycles_completed":"0",
    "final_payment_date":"1970-01-01T00:00:00Z",
    "failed_payment_count":"0"
  },
  "httpStatusCode":200
}
John Conde
  • 217,595
  • 99
  • 455
  • 496

1 Answers1

0

If you need to get the status of a Subscription at a later date, you can do so with the appropriate API call: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get

Your example seems to have been pending because it hadn't started billing yet.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
  • Not working, see https://www.paypal-community.com/t5/Sandbox-Environment/POST-https-www-sandbox-paypal-com-v1-billing-subscriptions-404/td-p/1953719 – Avatar Mar 24 '21 at 10:37
  • That's an old topic, so not sure what your particular issue is. You'll have to share full details. – Preston PHX Mar 24 '21 at 10:47
  • I found out my problem, I was using `POST` to get the status of the subscription instead of `GET`. For others having the same problem, remove `curl_setopt($ch, CURLOPT_POST, 1);` from the code. Or set it to `curl_setopt($ch, CURLOPT_POST, 0);` – Avatar Mar 24 '21 at 11:03
  • I ended up writing a complete tutorial about that. I hope it helps other developers: https://www.stacklounge.de/6328/tutorial-integrate-paypal-subscription-javascript-complete – Avatar Mar 26 '21 at 08:51