没有价值传递给付款



我在尝试使用PayPal快速结帐和结帐PayPal结帐时收到此错误.js从PayPal。

Object {error: "Error: Error: No value passed to payment↵    at Ob…://www.paypalobjects.com/api/checkout.js:2401:13)", timestamp: 1497283288966, windowID: "2832566843", pageID: "e2a3d3f3ff", referer: "http://m.coleman.renegade.local"…}country: "US"env: "sandbox"error: "Error: Error: No value passed to payment↵    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:8035:52)↵    at https://www.paypalobjects.com/api/checkout.js:3636:82↵    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)↵    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)↵    at https://www.paypalobjects.com/api/checkout.js:3597:33↵    at flush (https://www.paypalobjects.com/api/checkout.js:3520:43)↵    at Object.err [as onSuccess] (https://www.paypalobjects.com/api/checkout.js:3528:21)↵    at https://www.paypalobjects.com/api/checkout.js:3636:82↵    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)↵    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)↵    at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:2477:118)↵    at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2381:73)↵    at messageListener (https://www.paypalobjects.com/api/checkout.js:2401:13)"host: "www.sandbox.paypal.com"lang: "en"pageID: "e2a3d3f3ff"path: "/webapps/hermes/button"referer: "http://m.coleman.renegade.local"timestamp: 1497283288966uid: "bfd31206ee"ver: "4.0.82"windowID: "2832566843"__proto__: Object 
 Error: Error: No value passed to payment
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:8035:52)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at https://www.paypalobjects.com/api/checkout.js:3597:33
    at flush (https://www.paypalobjects.com/api/checkout.js:3520:43)
    at Object.err [as onSuccess] (https://www.paypalobjects.com/api/checkout.js:3528:21)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:2477:118)
    at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2381:73)
    at messageListener (https://www.paypalobjects.com/api/checkout.js:2401:13)
__webpack_require__.i.window.console.window.console.(anonymous function) @ index.js:536
types.js:122 Uncaught Error: Error: No value passed to payment
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:8035:52)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at https://www.paypalobjects.com/api/checkout.js:3597:33
    at flush (https://www.paypalobjects.com/api/checkout.js:3520:43)
    at Object.err [as onSuccess] (https://www.paypalobjects.com/api/checkout.js:3528:21)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:8035:52)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at https://www.paypalobjects.com/api/checkout.js:3597:33
    at flush (https://www.paypalobjects.com/api/checkout.js:3520:43)
    at Object.err [as onSuccess] (https://www.paypalobjects.com/api/checkout.js:3528:21)
    at https://www.paypalobjects.com/api/checkout.js:3636:82
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:3651:19)
    at SyncPromise.resolve (https://www.paypalobjects.com/api/checkout.js:3614:18)
    at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:2477:118)
    at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2381:73)
    at messageListener (https://www.paypalobjects.com/api/checkout.js:2401:13)
_RECEIVE_MESSAGE_TYPE.(anonymous function) @ types.js:122
receiveMessage @ index.js:94
messageListener @ index.js:119

这是使用actions.payment.create()方法随请求一起发送的数据

{"intent":"authorize","transactions":[{"amount":{"total":"105.00","currency":"USD"},"payee":{"email":"rashid-facilitator@somedomain.com"},"description":"Payment","item_list":{"items":[{"name":"Oleta Dresser","description":"","quantity":1,"price":"105.00","sku":"CST-203183","currency":"USD"}]}}],"redirect_urls":{"return_url":"https://www.sandbox.paypal.com","cancel_url":"https://www.sandbox.paypal.com"},"payer":{"payment_method":"paypal"}}

我无法完成这项工作。有人知道了吗?

这是完整的代码。

import React, { Component, PropTypes } from 'react';
export default class PaypalButton extends React.Component {
    constructor(props) {
        super(props);
        this.client = {
            sandbox:    'client id stripped',
            production: '<insert production client id>'
        };
        this.onCheckoutButtonClick = this.onCheckoutButtonClick.bind(this);
        this.onPaymentApproval = this.onPaymentApproval.bind(this);
    }
    render() {
        return <div id="paypal-button-container"></div>;
    }
    componentDidMount() {
        window.PAYPAL? this.renderPaypalButton(): loadScript('https://www.paypalobjects.com/api/checkout.js', true, () => {
            this.renderPaypalButton();
        });
    }
    onCheckoutButtonClick(data, actions) {
        // prepare item list from order summary
        let desc = '';
        let items = this.props.items.map(item => {
            if( item.type == 'bundle' ) {
                desc = item.products_option[0].required.items.join();
                if( item.products_option[0].optional )
                    desc += item.products_option[0].optional.items.join();
            }
            return {
                "name": item.name,
                "description": desc,
                "quantity": item.qty,
                "price": item.price,
                "sku": item.sku,
                "currency": "USD"
            }
        })
        // Make a call to the REST api to create the payment
        return actions.payment.create({
            intent: 'authorize',
            transactions: [
                {
                    amount: { 
                        total: this.props.totals.grand_total[0].value, 
                        currency: 'USD'
                    },
                    payee: { 
                        email: 'john-facilitator@example.com'
                    },
                    description: 'Payment',
                    item_list: {
                        items: items
                    }
                }
            ]
        }).then(data2 => {
            jQuery(document).trigger('onPaymentCreate.colemanReact', data2);
        });
    }
    onPaymentApproval(data, actions) {
        // Make a call to the REST api to execute the payment
        // this will get us an approved payment to be captured later
        return actions.payment.execute().then(function(data3) {
            // Show a thank-you note
            console.log('execute', data3);
            jQuery(document).trigger('onPaymentApproval.colemanReact', data3);
        });
    }
    onPaymentError(err) {
        console.log(err);
        jQuery(document).trigger('onPaymentError.colemanReact', err);
    }
    onPaymentCancellation(data, actions) {
        jQuery(document).trigger('onPaymentCancellation.colemanReact', data3);
    }
    renderPaypalButton() {
        paypal.Button.render({
            env: 'sandbox', // sandbox | production
            // PayPal Client IDs - replace with your own
            // Create a PayPal app: https://developer.paypal.com/developer/applications/create
            client: this.client,
            // Show the buyer a 'Pay Now' button in the checkout flow
            commit: false,
            // payment() is called when the button is clicked
            payment: this.onCheckoutButtonClick,
            // onAuthorize() is called when the buyer approves the payment
            onAuthorize: this.onPaymentApproval,
            // onCancel() is called when the buyer cancels the payment
            onCancel: this.onPaymentCancellation,
            // Show an error page here, when an error occurs
            onError: this.onPaymentError
        }, '#paypal-button-container');
    }
}

这是你的问题:

   return actions.payment.create({
        intent: 'authorize',
        transactions: [
            {
                amount: { 
                    total: this.props.totals.grand_total[0].value, 
                    currency: 'USD'
                },
                payee: { 
                    email: 'john-facilitator@example.com'
                },
                description: 'Payment',
                item_list: {
                    items: items
                }
            }
        ]
    }).then(data2 => {
        jQuery(document).trigger('onPaymentCreate.colemanReact', data2);
    });

您正在添加.then()但未在承诺中返回付款 ID。您可以尝试以下方法吗:

   return actions.payment.create({
        intent: 'authorize',
        transactions: [
            {
                amount: { 
                    total: this.props.totals.grand_total[0].value, 
                    currency: 'USD'
                },
                payee: { 
                    email: 'john-facilitator@example.com'
                },
                description: 'Payment',
                item_list: {
                    items: items
                }
            }
        ]
    }).then(data2 => {
        jQuery(document).trigger('onPaymentCreate.colemanReact', paymentID);
        return paymentID
    });

相关内容

  • 没有找到相关文章

最新更新