6

I'm using website payments standard to create recurring payments for subscriptions.

I need to find out when the next billing date is, so it looks like I can use GetRecurringPaymentsProfileDetails nvp api with the recurring payment profile id.

But when I send the recurring payment profile id I get a failure back:

{'ack':'Failure',.... l_longmessage0: 'Subscription profiles not supported by Recurring Payment APIs.',
'l_shortmessage0': 'Subscription Profiles not supported.',....

Does this mean that subscription button recurring payment profiles cannot be retrieved via the GetRecurringPaymentsProfilesDetails NVP api?

If that is the case, is there some other api to get this detail for a subscription profile?

dar
  • 6,520
  • 7
  • 33
  • 44

3 Answers3

7

GetRecurringPaymentsProfileDetails does not support subscription profiles created through payments standard, it only supports recurring payment profiles created through the nvp api.

As of this writing, there is no api to get the subscription details. If you want to know the current status, you have to use an IPN listener to capture and track all status changes yourself.

TTT
  • 22,611
  • 8
  • 63
  • 69
dar
  • 6,520
  • 7
  • 33
  • 44
  • Do you know if that's still the case, now that 2 years have passed since your answer? – Magne Nov 21 '12 at 15:14
  • 2
    SERIOUSLY, even I want to use API to cancel subscription .. any way ? – Vamshi Dec 05 '12 at 19:08
  • @Is there any solution after 6 years without ipn – Ashish Chaturvedi Sep 07 '15 at 11:55
  • @dar, Can you explain your last sentence? If I have the subscr_signup ipn message, is there something in it that would enable me to check the subscription status in the future? – TTT Nov 26 '15 at 20:19
  • @TTT as far as I know, no. IPNs are pushed to your endpoint, you cannot look up status. You have to listen for the events listed here: https://www.paypal.com/us/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside and act accordingly. You can look up the status in the on the website, but that is time consuming and manual. I have not kept up on the api recently. – dar Nov 28 '15 at 13:36
  • @dar - I agree. I submitted a clarification edit to your last sentence. – TTT Nov 28 '15 at 13:46
  • I just confirmed this is still unsupported, PayPal expects us to keep track of the subscription's status through the IPN notifications. For instance, you'd need to save a subscription entity in your database and update it every time an IPN is received that changes the status for it. – JoseMarmolejos Dec 10 '15 at 15:39
  • Here we are at year 7. :( – tofutim May 19 '16 at 22:10
  • @JudeCalimbas how do you cancel using the API? – tofutim May 19 '16 at 22:10
2

You can hijack API by using /v1/payments/billing-agreements/{billingid}/transactions?start_date=YYY-MM-DD$end_date=YYY-MM-DD... then you juste have to check if last transactions fit your period.

Cyril ALFARO
  • 1,616
  • 17
  • 35
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 as well as Cyril ALFARO.

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