Using sandbox code given in PayPal document 'Multiple Subscription buttons' I got many errors, the first being: Failed to load resource: the server responded with a status of 404 () related to https://www.sandbox.paypal.com/v1/billing/subscriptions.
I checked that al info regarding client ID and plan IDs were accurate, but the problem persists.
This is the code for my checkout:
<script
src="https://www.paypal.com/sdk/js?client-id=ID">
</script>
<div class="row">
<div class="col-sm-3">
<p>
PLAN 1<br />$70 {% translate 'per year' %}
</p>
<div id="paypal-button-container-P-XXX"></div>
<script>
paypal.Buttons({
createSubscription: function (data, actions) {
return actions.subscription.create({
'plan_id': 'P-XXX' // Replace with your plan ID
}).then(function (response) {
// Subscription created successfully
console.log('Subscription created:', response);
// Handle any further actions like redirecting user or updating UI
}).catch(function (error) {
// Subscription creation failed
console.error('Subscription creation failed:', error);
// Handle error, display message to user, etc.
});
},
onApprove: function (data, actions) {
alert('You have successfully subscribed to ' + data.subscriptionID); // Optional message given to subscriber
}
}).render('#paypal-button-container-P-XXX'); // Renders the PayPal button. Replace with your plan ID
</script>
<div class="col-sm-3">
<p>
PLAN 2<br />$7 {% translate 'per month' %}
</p>
<div id="paypal-button-container-P-YYY"></div> <!-- Replace with your plan ID -->
</div>
<script>
paypal.Buttons({
createSubscription: function (data, actions) {
return actions.subscription.create({
'plan_id': 'P-YYY' // Replace with your plan ID
}).then(function (response) {
// Subscription created successfully
console.log('Subscription created:', response);
// Handle any further actions like redirecting user or updating UI
}).catch(function (error) {
// Subscription creation failed
console.error('Subscription creation failed:', error);
// Handle error, display message to user, etc.
});
},
onApprove: function (data, actions) {
alert('You have successfully subscribed to ' + data.subscriptionID); // Optional message given to subscriber
}
}).render('#paypal-button-container-P-YYY'); // Replace with your plan ID
</script>
</div>
Impossible to be of specific help with how little information there is in the question, but general advice:
<script src="https://www.paypal.com/sdk/js?.....</script>elements from all but before the first button. As an extra check, when removing them verify that theclient-id=value was the same for all. (It should be the same, or that button is problematic and you should generate a new one and replace it)