paypal - 'subscription profiles not supported'
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_longmes开发者_开发技巧sage0: '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?
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.
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.
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.
精彩评论