Paypal Express结帐:特定日期的定期付款

时间:2018-06-27 08:43:38

标签: javascript paypal

我正在尝试将我们的网站设置为在特定日期(每年6月1日为5英镑)接受定期付款,无论用户最初何时注册(5月份除外,那么第一笔重新付款都会在次年6月1日)

到目前为止,我的搜索结果表明Express Checkout(checkout.js)可能是我最好的选择。

我已经设法在沙盒模式下支付了5英镑的首付款,但是找不到有关如何设置定期付款的任何文档。

下面的代码

paypal.Button.render(
    {
        env: "sandbox", // 'production' Or 'sandbox',

        // Pass the client ids to use to create your transaction on sandbox and production environments

        client: {
            sandbox:
                [REDACTED], // from https://developer.paypal.com/developer/applications/
            production:
                [REDACTED] // from https://developer.paypal.com/developer/applications/
        },

        // Pass the payment details for your transaction
        // See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters

        payment: function(data, actions) {
            return actions.payment.create({
                transactions: [
                    {
                        amount: {
                            total: "5.00",
                            currency: "GBP"
                        }
                    }
                ]
            });
        },

        // Display a "Pay Now" button rather than a "Continue" button

        commit: true,

        // Pass a function to be called when the customer completes the payment

        onAuthorize: function(data, actions) {
            console.log(data);
            console.log(actions);
            return actions.payment.execute().then(function(response) {
                console.log("The payment was completed!");
            });
        },

        // Pass a function to be called when the customer cancels the payment

        onCancel: function(data) {
            console.log("The payment was cancelled!");
        }
    },
    "#paypal-button"
);  

0 个答案:

没有答案