I’m using a Sandbox and I created a paypal plan with Paypal PHP SDK and activated it.
I’m following the integration guide to create a subscription to this plan (https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription).
But when I clic on the yellow button I have a Javascript Error in the console :
Error: Create Subscription Api response error:
{
"name": "RESOURCE_NOT_FOUND",
"message": "The specified resource does not exist.",
"debug_id": "23912dc1195d",
"details": [
{
"issue": "INVALID_RESOURCE_ID",
"description": "Requested resource ID was not found."
}
],
"links": [
{
"href": "https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
I checked if the plan exists and it’s OK with the Paypal PHP SDK.
Here is the Javascript code used :
<script src="https://www.paypal.com/sdk/js?client-id=sandbox_paypal_client_id&vault=true"></script>
<div id="paypal-button-container"></div>
<script>
// paypal.Buttons().render('#paypal-button-container');
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-8N6112936N290211KKMN5MZI'
});
},
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
In the paypal developer dashboard I see the API call for this action, but in orange…
Thanks in advance for your help.
5
Answers
I had the same problem and the following solved my issues:
In addition to what Harvey Kadyanji said make sure that:
If you are following the steps provided from paypal in this link:
https://developer.paypal.com/docs/subscriptions/integrate/ you will have to use the Subscriptions API to create the Plans and not the Billing Plans and Billing Agreements APIs.
Probably you are loading the button script with “client-id=sb” or no client id specified. In order to work with plans you created via API you need to explicitly set “client-id” to the client-id of your REST SDK app when loading the script. Then the buttons will find your created plan.
I also answered to basically the same problem in the PayPal community forum
I also ran into this problem. My confusion when following the Subscriptions Integration instructions was that I thought the SDK would work with Subscription Plans (API endpoint
/billing/plans
), but at the time of writing it doesn’t (at least the PHP and .NET versions) – the SDK only works with the older Billing Plans (/payments/billing-plans
) which are very similarly named (Plans for short).As @giannisrig says, you have to call the Subscription Plans part of the API directly (
/billing/plans
). I hope they’ll update the SDK soon – this seems like an important missing feature.Use the sandbox business account associated with the sandbox client ID you’re using and make the paypal smart subscription or plan through there. The planId and clientId need to belong to the same sandbox account.