问题
I try to use PayPal Smart Button to purpose payment on a website.
I first created a plan, I got its ID, and I activated it, via commands with the API and the PayPal SDK in PHP.
The plan appears to be active.
<script src="https://www.paypal.com/sdk/js?client-id=sb-key&vault=true&disable-funding=card"></script>
<script>
paypal.Buttons({
env: 'sandbox',
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-85G86700MN...223CGEJWTI'
});
},
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
When I click on the PayPal button to pay. I get this error: RESOURCE_NOT_FOUND
I don't know what it all means, and people who have had the same problem have not received support.
回答1:
The old PayPal-PHP-SDK you are using should no longer be used for any new integration. It does not support the new Subscriptions API, and instead uses billing plans for something older, which is not compatible with what you are trying to do (RESOURCE_NOT_FOUND error is the result)
The new paypal/Checkout-PHP-SDK is what should be used for regular payments, but it too does not yet support the new Subscriptions API.
So unfortunately, there is no PHP SDK for subscriptions. To use the Subscriptions API, you'll need to implement direct HTTPS REST API calls to create the necessary products, plans, and agreements.
You could test with command-line curl
or postman calls first, to confirm it works, and then write the necessary PHP function to do your own HTTPS calls to PayPal with the oauth token.
来源:https://stackoverflow.com/questions/60064508/paypal-php-sdk-not-working-for-subscriptions-get-resource-not-found