向 PayPal javascript SDK 添加描述和项目名称

Adding a description and item name to PayPal javascript SDK

我使用 PayPal Javascript SDK 创建了我的第一个立即购买按钮。我找到了如何添加“不送货”(这是针对数字商品),但我不知道如何添加商品编号和描述。谁能给我一些指点?

<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=CLIENT ID IS CORRECTLY ADDED&currency=USD"></script>

<script>
  paypal.Buttons({

    // Sets up the transaction when a payment button is clicked
    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          
          amount: {
            value: '1'
          },
            
        }],
        application_context: {
            shipping_preference: "NO_SHIPPING",
        }
         
      });
    },

    // Finalize the transaction after payer approval
    onApprove: function(data, actions) {
      return actions.order.capture().then(function(orderData) {
        // Successful capture! For dev/demo purposes:
        //    console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
        //    var transaction = orderData.purchase_units[0].payments.captures[0];
        //   alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');

        // When ready to go live, remove the alert and show a success message within this page. For example:
        // var element = document.getElementById('paypal-button-container');
        // element.innerHTML = '';
        // element.innerHTML = '<h3>Thank you for your payment!</h3>';
        actions.redirect('https://wwwwebsite.com/att_thanks.php?id=1640035591');
      });
    }
  }).render('#paypal-button-container');

</script> 

阅读 standard Checkout integration guide,其中提供了完整的代码示例...

createOrder: function(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"
              },
            ]
          }]
      });
    },

并链接到 the Orders v2 API reference 以获得完整的详细信息。