2017-06-12 10 views
1

Paypal Express Checkoutとcheckout.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":"[email protected]"},"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"}} 

を使用して要求して送信されたデータです。誰でも手掛かりを得た?

これは完全なコードです。

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

あなたは約束で.then()なく戻っ支払IDを追加している:

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: '[email protected]' 
        }, 
        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'); 
    } 
} 
+0

完全なコードを教えてください。 – bluepnume

+0

@bluepnumeフルコードを追加しました – rashid

答えて

0

はここにあなたの問題です。以下を試すことができます:

return actions.payment.create({ 
     intent: 'authorize', 
     transactions: [ 
      { 
       amount: { 
        total: this.props.totals.grand_total[0].value, 
        currency: 'USD' 
       }, 
       payee: { 
        email: '[email protected]' 
       }, 
       description: 'Payment', 
       item_list: { 
        items: items 
       } 
      } 
     ] 
    }).then(data2 => { 
     jQuery(document).trigger('onPaymentCreate.colemanReact', paymentID); 
     return paymentID 
    }); 
関連する問題