javascript Paypal SDK,如何添加订单详情?

rqqzpn5f  于 2022-12-10  发布在  Java
关注(0)|答案(1)|浏览(151)

我正在使用贝宝SDK的Javascript,使我的页面订单。我看不到他们的文档中的任何关于如何添加订单描述,我怎么能?
Paypal订单摘要

paypal.Buttons({
            style: {
                shape: 'pill',
                color: 'gold',
                layout: 'vertical',
                label: 'paypal',
                height: 50,
            },

            createOrder: function (data, actions) {

                $.ajax
                ({
                    url: '@Url.Action("GetPaymentPrice", "Payment")',
                    method: "get",
                    data: { id: @Model.Id },
                    contentType: "application/json;charset=utf-8",
                    dataType: 'json',
                    beforeSend: function () {
                        $("#loaderDiv").show();
                    },
                    success: function (success) {
                        pricePaypal = success.Result.Total;
                    },
                    async: false,
                    error: function () {

                    }
                });

                return actions.order.create({
                    purchase_units: [{ "amount": { "currency_code": "EUR", "value": pricePaypal} }]
                });
            },

我试着在谷歌,贝宝文档中检查了很多帮助,但什么也没找到。

woobm2wo

woobm2wo1#

添加一个items数组和所需的金额细分。文档中的示例:

createOrder: (data, actions) => {
      return actions.order.create({
         "purchase_units": [{
            "amount": {
              "currency_code": "USD",
              "value": "100",
              "breakdown": {
                "item_total": {  /* Required when including the items array */
                  "currency_code": "USD",
                  "value": "100"
                }
              }
            },
            "items": [
              {
                "name": "First Product Name", /* Shows within upper-right dropdown during payment approval */
                "description": "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
                "unit_amount": {
                  "currency_code": "USD",
                  "value": "50"
                },
                "quantity": "2"
              },
            ]
          }]
      });
    },

相关问题