Here is the code to create subscription and user consent from paypal sandbox.
paypal.Buttons({
style: {
shape: 'rect',
color: 'white',
layout: 'horizontal',
label: 'subscribe',
tagline: false,
},
createSubscription: function(data, actions) {
if( subscriber_id !== null ){
return actions.subscription.revise(subscriber_id, {
'plan_id': "xxxxxxxx",
});
}else{
return actions.subscription.create({
'plan_id': "xxxxxxxx",
});
}
},
onApprove: function(data, actions) {
alert("Plan successfully Subscribed");
},
onCancel: function(data){
alert("Payment Cancelled");
},
onError : function(err){
alert("Error on payment");
}
}).render("#paypal_button_container");
It successfully return subscriber ID with this url : https://www.sandbox.paypal.com/v1/billing/subscriptions
Then it open popup window for sandbox url : https://www.sandbox.paypal.com/smart/api/billagmt/subscriptions/I-JM3GEG2DY222/cartid and it immediately close with following "create_order_error"
Object { err: "TOKEN_FAILUREnd/<@https://www.sandbox.paypal.com/smart/buttons?style.label=subscribe&style.layout=horizontal&style.color=white … }
It was working fine before 28-Oct-2022.
2
Answers
I am facing the exact same issue.
The Sandbox for testing subscription is broken.
I managed to pass the "token failure" this morning and another error message was reporting that the system is not available yet because of an internal problem so I guess the issue is on paypal side and hopefuly they are working on it.
So let’s just wait…
Unfortunately, PayPal’s business tools are a shameful mess. 404 not found, and Help info finding zero results on their own terms… Just try to make an unsubscribe button, I dare you.
I also couldn’t get the button (Javascript iframe inserted into HTML) to stop querying the sandbox even though the sandbox was never turned on and it showed ACTIVE.
My backend dev and I fiddled with PayPal for several days, including closing the account and opening a new one, and finally decided to try something else.
My tip is this: Shopify is what you would expect from a mature app like PayPal. I easily set up a Subscribe button using one of their suggested plugins (which is structured kind of like WordPress with a one-click install into Shopify).