本文介绍了PayPal REST API-如何获取Webhook中返回的电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用checkout.js设置PayPal的REST API-

I'm setting up PayPal's REST API using checkout.js --

<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
  env: 'sandbox',
  client: {
    sandbox: 'XXXXXXXX'
  },
  payment: function (data, actions) {
    return actions.payment.create({
      transactions: [{
        amount: {
          total: '10.00',
          currency: 'USD'
        }
      }]
    });
  },
  onAuthorize: function (data, actions) {
    return actions.payment.execute()
      .then(function () {
        window.alert('Thank you for your purchase!');
      });
  }
}, '#paypal-button');
</script>

我测试该页面时效果很好.我设置了一个Webhook侦听器并获取:

The page works great when I test it. I set up a webhook listener and get:

...
[resource_type] => sale
[event_type] => PAYMENT.SALE.COMPLETED
...

那里也有其他东西,但其中不包含有关买家的任何信息!通常,我需要他们的电子邮件地址.

Other stuff in there too, but it does not include anything about the buyer! Mostly I need their email address.

如果我使用PayPal的 webhook模拟器并告诉它向我发送包含所有内容的CHECKOUT.ORDER.COMPLETED(而不是PAYMENT.SALE.COMPLETED):

I do get the buyer's info if I use PayPal's webhook simulator and tell it to send me a CHECKOUT.ORDER.COMPLETED (instead of a PAYMENT.SALE.COMPLETED) which comes with everything:

...
[resource_type] => checkout-order
[event_type] => CHECKOUT.ORDER.COMPLETED
...
[payer] => (Everything I need)

这个问题是:有没有办法将我的交易从PAYMENT.SALE.COMPLETED更改为CHECKOUT.ORDER.COMPLETED,或者至少告诉我要在Webhook中包含电子邮件地址?

So this question is: Is there a way to change my transaction from a PAYMENT.SALE.COMPLETED to a CHECKOUT.ORDER.COMPLETED, or at least to tell that I want the email address included in the webhook?

推荐答案

我发现的唯一答案是第二次调用,这次是GetExpressCheckoutDetails NVP API.完成工作,但这实际上不是必需的.

The only answer I found was to follow this up with a second call, this time to the GetExpressCheckoutDetails NVP API. Gets the job done, but it really shouldn't be necessary.

这篇关于PayPal REST API-如何获取Webhook中返回的电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:06