PayPal PHP SDK not working for Subscriptions, get RESOURCE_NOT_FOUND

假如想象 提交于 2021-02-10 06:10:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!