【问题标题】:Specific line items in paypal checkout贝宝结帐中的特定行项目
【发布时间】:2019-07-05 13:16:35
【问题描述】:

我正在尝试设置 PayPal 以在我的网站上进行付款,并且我想为付款指定行项目(使用新的 SDK,而不是 javascript 版本)

我已尝试浏览此处列出的 API 文档:https://developer.paypal.com/docs/api/orders/v2/。但是,它说我的语法无效或缺少字段。

<head>
<script>
paypal.Buttons({
    createOrder: function(data, actions) {
    return actions.order.create({
        purchase_units: [{
        amount: {
            currency_code: 'USD',
            value: '0.01',
            amount_breakdown: {

            }

          },
            items: {
                item: {
                    name: 'Cake',
                    quantity:'1',
                    unit_amount:{
                        currency_code:'USD',
                        value:'0.01'
                    }
                }
            }



    }],
        application_context: {
            shipping_preference: 'NO_SHIPPING',
        }

      });
    },
    onApprove: function(data, actions) {
    return actions.order.capture().then(function(details) {
            alert('Transaction completed by ' + details.payer.name.given_name);
            // Call your server to save the transaction
            return fetch('/paypal-transaction-complete', {
          method: 'post',
          body: JSON.stringify({
            orderID: data.orderID
          })
        });
      });
}
  }).render('#paypal-button-container');
</script>
</head>

<body>
<div id="paypal-button-container"></div>
</body>

【问题讨论】:

    标签: paypal paypal-rest-sdk express-checkout


    【解决方案1】:

    这对我来说是正确的 purchase_units 代码。从这里得到它:

    https://github.com/paypal/paypal-checkout-components/issues/1016

    purchase_units: [{
                    amount: {
                        value: '7',
                        currency_code: 'USD',
                        breakdown: {
                            item_total: {value: '7', currency_code: 'USD'}
                        }
                    },
                    invoice_id: 'muesli_invoice_id',
                    items: [{
                        name: 'Hafer',
                        unit_amount: {value: '3', currency_code: 'USD'},
                        quantity: '1',
                        sku: 'haf001'
                    }, {
                        name: 'Discount',
                        unit_amount: {value: '4', currency_code: 'USD'},
                        quantity: '1',
                        sku: 'dsc002'
                    }]
                }]
    

    【讨论】:

    • sku 不是必填字段,尽管它可能对 Caleb 很重要
    猜你喜欢
    • 2017-01-21
    • 2020-08-19
    • 2021-12-29
    • 2014-03-06
    • 2014-09-06
    • 2014-07-01
    • 2020-01-19
    • 2015-04-12
    • 2020-09-23
    相关资源
    最近更新 更多