如何显示在PayPal快速结帐产品详情

问题描述:

我已经实现快速结帐这样如何显示在PayPal快速结帐产品详情

//渲染PayPal按钮

paypal.Button.render({

// Set your environment 

env: 'sandbox', // sandbox | production 

// PayPal Client IDs - replace with your own 
// Create a PayPal app: https://developer.paypal.com/developer/applications/create 

client: { 
    sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R', 
    production: 'Aco85QiB9jk8Q3GdsidqKVCXuPAAVbnqm0agscHCL2-K2Lu2L6MxDU2AwTZa-ALMn_N0z-s2MXKJBxqJ' 
}, 

// Set to 'Pay Now' 

commit: true, 

// Wait for the PayPal button to be clicked 

payment: function() { 

    // Make a client-side call to the REST api to create the payment 

    return paypal.rest.payment.create(this.props.env, this.props.client, { 
     transactions: [ 
      { 
       amount: { total: '<?php echo $cart->total(); ?>', currency: 'USD' } 
      } 
     ] 
    }); 
}, 

// Wait for the payment to be authorized by the customer 

onAuthorize: function(data, actions) { 

    // Execute the payment 

    return actions.payment.execute().then(function() { 
     document.querySelector('#paypal-button-container').innerText = 'Payment Complete!'; 
     window.location.href = 'cartaction.php?action=place0rder'; 
    }); 
} 

}“ #贝宝键式容器');

其中$ cart-> total()是所有产品的总应付金额。它工作得很好。

但我想显示所有产品的名称价格和描述,如下图所示。

When we click Amount it shows item details

但在这里我的情况下,它只是显示一个如下量。

enter image description here

我应该在代码添加到实现这一目标。请帮忙吗?

就像REST API集成一样,实际上可以使用相同的参数。下面是这部分我的示例代码:

transactions: [ 
 
\t { 
 
\t \t amount: { total: '1.00', currency: 'USD' }, 
 
\t \t item_list: { 
 
\t \t \t items: [ 
 
\t \t \t \t { 
 
\t \t \t \t name: 'hat', 
 
\t \t \t \t description: 'Brown hat.', 
 
\t \t \t \t quantity: '1', 
 
\t \t \t \t price: '1.00', 
 
\t \t \t \t currency: 'USD' 
 
\t \t \t \t } 
 
\t \t \t ] 
 
\t \t } 
 
\t } 
 
]

+0

太感谢你了!像魅力一样工作! @habdulkarim –