1

PayPal subscription was created from PayPal website standard and the subscriber ID starts with "I". When i call getrecurringpaymentsprofiledetails its displaying below error subscription profiles not supported. Let me know any other way to fetch the subscription details created using PayPal standard without using IPN.

sharakan
  • 6,821
  • 1
  • 34
  • 61

2 Answers2

0

Unfortunately there isn’t away without relying on IPN and then running a query against your own database. Those API’s are mainly for recurring payments (those created via Express Checkout Recurring Payments with the CreateRecurringPayments API call), not the Website Payments Standard subscriptions that you are setting up. There are a few things you can do with the recurring API’s against the subscriptions but not all of the functionality is supported for subscriptions. This would be one of them.

Robert
  • 19,326
  • 3
  • 58
  • 59
PP_MTS_Chad
  • 7,311
  • 1
  • 15
  • 20
0

I am getting it through this way:

let options = {
 method: 'post', headers: {'content-type':'application/json','Access-Control-Allow-Credentials':true},
 auth:{'username':process.env.PAYPALID,'password':process.env.PAYPALPASSWORD},
 url: 'https://api.paypal.com/v1/oauth2/token',
 data: 'grant_type=client_credentials',
}
axios(options).then((response)=>{let paypaltoken=response.data.access_token
axios.get('https://api.paypal.com/v1/payments/billing-agreements/'+agreementid+'/transactions?start_date=2018-01-01&end_date=2019-07-07', { headers: { 'Authorization':'Bearer '+paypaltoken, 'Content-Type':'application/json', } })
.then((transaction)=>{console.log(transaction.data)})
.catch(err => {console.error(err);console.log('err: '+JSON.stringify(err)); res.send (err) })
})
.catch(err => {console.error(err);console.log('err: '+JSON.stringify(err)); res.send (err) })

then if you get just the transaction.data, you will get a series of transaction objects, whose status is == Completed only if the transaction went ok, that is, it has not been cancelled, so just check the last for plan controlling purposes. When status is == Canceled you know the agreement is not active anymore.

Another way to do it if you receive monthly payments is to set the first date to 2 months from "now()" and the second date to "now()". If you get no transactions then the status could be not active, but double-check: there is the random possibility there could have been some credit card problem. In that case I suppose status could be == to delayed or something else, but I had no possibilities to test it so I don't know. The idea came from this question and the relative second answer which deserves my gratitude.

Note that according to your case you may need to add 'Access-Control-Allow-Credentials':true in the headers instead of other withCredentials: true or similar in the request.

AMDP
  • 327
  • 2
  • 12