Paypal结账与重定向?

时间:2017-05-05 07:30:47

标签: javascript php paypal paypal-sandbox

我正在尝试实施paypal结帐。我发现这段代码对我来说非常完美,但不是很完美:

onAuthorize: function(data, actions) {
    // Get the payment details
    return actions.payment.get().then(function(data) {
        // Display the payment details and a confirmation button
        var shipping = data.payer.payer_info.shipping_address;
        document.querySelector('#recipient').innerText = shipping.recipient_name;
        document.querySelector('#line1').innerText     = shipping.line1;
        document.querySelector('#city').innerText      = shipping.city;
        document.querySelector('#state').innerText     = shipping.state;
        document.querySelector('#zip').innerText       = shipping.postal_code;
        document.querySelector('#country').innerText   = shipping.country_code;
        document.querySelector('#paypal-button-container').style.display = 'none';
        document.querySelector('#confirm').style.display = 'block';
        // Listen for click on confirm button
        document.querySelector('#confirmButton').addEventListener('click', function() {
            // Disable the button and show a loading message
            document.querySelector('#confirm').innerText = 'Loading...';
            document.querySelector('#confirm').disabled = true;
            // Execute the payment
            return actions.payment.execute().then(function() {
                // Show a thank-you note
                document.querySelector('#thanksname').innerText = shipping.recipient_name;
                document.querySelector('#confirm').style.display = 'none';
                document.querySelector('#thanks').style.display = 'block';
            });
        });
    });
}

我希望在付款授权后将用户重定向到其他php页面。我还能调用函数actions.payment.get()和actions.payment.execute()吗?如果是,我该如何打电话给他们?如果没有,为什么?

0 个答案:

没有答案