I have business and personal account set up, subscriptions, plans... all setup for simple paypal button POC in sandbox.
This is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width" />
<title></title>
</head>
<body>
<script src="https://www.paypal.com/sdk/js?client-id=xxxx&vault=true&intent=subscription"></script>
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-66899082RN487441DMXZKF7I'
});
},
onApprove: function(data, actions) {
console.log(data, '\n', actions);
alert('You have successfully subscribed to ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
</body>
</html>
(I've replaced the client id with xxxx, but in reality I've put valid client id instead)
However, I got 404 in the first place, when paypal plugin starts pinging its own endpoint: https://www.sandbox.paypal.com/v1/billing/subscriptions 404 error
following the bunch of errors in the console:
rest_api_v1_billing_subscriptions_create_error , create_order_error , Uncaught Error: Create Subscription Api response error ...etc.
I used the exact form form the official integration manual: https://developer.paypal.com/docs/subscriptions/integrate/
Where is P-66899082RN487441DMXZKF7I
from? We can only guess it was not generated with the client-id the JS SDK is being loaded with, hence the 404 error.
The simplest way to obtain a working identifier and client-id for sandbox mode is from the sandbox account interface at https://www.sandbox.paypal.com/billing/plans . Otherwise, you need to create a product and plan with the corresponding API calls, information (request+response) of which is not in your question. The "following the bunch of errors in the console" information is also incomplete.