Reputation: 31
I am trying to subscribe paypal billing plan from Smart Payment Buttons. But continuously I am getting error "The specified resource does not exist."
paypal.Buttons({
createSubscription: function (data, actions) {
return actions.subscription.create({
'plan_id': 'P-1G3183167U24246113LMNZLY'
});
},
onApprove: function (data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
Subscription Api response error:
{ "name": "RESOURCE_NOT_FOUND", "message": "The specified resource does not exist.", "debug_id": "82ac38ce75745", "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" } ] }
Error image:
Upvotes: 2
Views: 4781
Reputation: 11337
I was having the identical issue, and found the solution (for me at least).
While having this issue, I was using the Plan-ID from an actual real Plan (in Draft status) that I had created in the PayPal web dashboard UI. I thought that was allowed while testing with the PayPal Sandbox. It's not.
You must follow PayPal's instructions here to create a Fake Test Product and Fake Test Plan using the PayPal REST API (via bash+curl or other API testing tool like Postman). You can't create your test Product+Plan via any web UI, and you can't test against a real-world Product+Plan, even if that Product is still in Draft status.
After creating your Fake Test Product+Plan via PayPal's REST API, then you can plug the Plan-ID returned by the REST API into your JavaScript for the PayPal buttons on your site.
Also: make sure that in your script tag, you are using the Client-ID from a PayPal Sandbox Business account, not your actual real-world PayPal account.
Upvotes: 7
Reputation: 928
I think the problem is this. 'plan_id': 'P-1G3183167U24246113LMNZLY'
. First you need to check whether your account has a plan with such a plan_id. If not you need to create a product first then create a plan and then you can use your plan_id in smart buy button.
Just follow the instructions in this page:
https://developer.paypal.com/docs/subscriptions/integrate/?mark=seat-based%20pricing#
Upvotes: 0
Reputation: 452
It looks like you're developing this against a live account, as per line 201 env: 'live'
which it is not a good practice, for instance, breaking functionality in a live site.
I had a the same issue using Java and apparently you can only use one billing plan per subscription, which means you need to create a billing plan for each subscription.
You can find more information in Paypal REST APIs documentation.
Upvotes: 0