2017-02-10 72 views
0

我剛剛開始使用此模塊玩:Paypal結帳 - 請不要要求非會員的送貨地址?

https://github.com/paypal/paypal-checkout

我試圖找出如何可以關閉送貨地址的客戶端。我知道在訂購版本中,您可以在URL中執行&NOSHIPPING=1,但我找不到有關API 4版本的任何信息。我的代碼是:

paypal.Button.render({ 

    // Pass the client ids to use to create your transaction on sandbox and production environments 
    locale: 'fr_FR', 

    //env: 'production', 
    env: 'sandbox', 

    client: { 
     sandbox: "...", 
     production: "..." 
    }, 

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

    payment: function() { 
     return paypal.rest.payment.create(this.props.env, this.props.client, { 
      transactions: [ 
       { 
        amount: { 
         total: window.my_config.grand_total, 
         currency: 'EUR', 
         details: { 
           "subtotal": window.my_config.price, 
           "tax": window.my_config.vat_amount 
         } 
        }, 
       } 
      ] 
     }); 
    }, 

    // 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) { 
     return actions.payment.execute().then(function() { 
      console.log('The payment was completed!'); 
      console.log(data, actions) 

      if (error === 'INSTRUMENT_DECLINED') { 
       actions.restart(); 
      } 

     }); 
    }, 

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

    onCancel: function(data) { 
     console.log('The payment was cancelled!'); 
    }, 
    style: { 
     shape: 'rect', 
     size: "medium" 
    } 

}, '#paypalContainerEl'); 

回答

1

您需要通過no_shipping選項experience下的payment功能,像這樣的新API:

return actions.payment.create(
{ 
    payment: 
    { 
     transactions: [ 
     { 
      amount: 
      { 
       total: "10", 
       currency: 'EUR' 
      } 
     }] 
    }, 
    experience: 
    { 
     input_fields: 
     { 
      no_shipping: 1 
     } 
    } 
}); 

在文檔中,herehere。儘管一個快速筆記,即使他們的送貨地址將不再被要求,仍然會要求客人提供他們的賬單地址。

相關問題