从Paypal Express Checkout获取客户送货地址

时间:2019-06-21 11:51:29

标签: php paypal

我正尝试在May网站上添加Paypal Express Checkout,但是付款成功后我无法获得客户的收货地址。

这是您拥有的代码:

<script>
paypal.Buttons({
    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '0.01'
          }
        }]
      });
    },
    onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
                  alert('Transaction completed');


        // Call your server to save the transaction
        return fetch('Sample.php', {
          method: 'post',
          mode: "same-origin",
          credentials: "same-origin",
          headers: {"Content-Type": "application/json"},
          body: JSON.stringify({
              orderID: data.orderID, 
              time: details.create_time, 
              status: details.status, 
              nom: details.payer.name.given_name, 
              prenom: details.payer.name.surname, 
              email: details.payer.email_address, 
              country: details.payer.address.country_code, 
              address: details.payer.address.address_line_1, 
              valeur:details.purchase_units[0].amount.value
          })
        })
      });
    }
  }).render('#paypal-button-container');
</script>

因此,当我致电您的服务器以保存交易时,我无法获取所有信息,请保留“地址”。还有其他方法可以获取客户的送货地址吗?

0 个答案:

没有答案