PayPal Express Checkout服务器端

时间:2017-07-13 21:22:40

标签: paypal server-side express-checkout

我一直试图弄清楚CREATE_PAYMENT_URL& EXECUTE_PAYMENT_URL是我应该在该页面上使用的代码。我已经在PayPal开发者网页上浏览了几个小时,但我无法理解它。

var CREATE_PAYMENT_URL  = 'http://localhost/paypal/create-payment';
var EXECUTE_PAYMENT_URL = 'http://localhost/paypal/execute-payment';

paypal.Button.render({

    env: 'sandbox', // Or 'sandbox'

    commit: true, // Show a 'Pay Now' button

    style: {
        label: 'pay', // checkout | credit | pay
        size: 'medium', // small | medium | responsive
        shape: 'rect', // pill | rect
        color: 'silver'      // gold | blue | silver
    },

    payment: function() {
        return paypal.request.post(CREATE_PAYMENT_URL).then(function(data) {
            return data.id;
        });
    },

    onAuthorize: function(data) {
        return paypal.request.post(EXECUTE_PAYMENT_URL, {
            paymentID: data.paymentID,
            payerID:   data.payerID
        }).then(function() {

            // The payment is complete!
            // You can now show a confirmation message to the customer
        });
    }

}, '#paypal-button');

0 个答案:

没有答案