【发布时间】:2017-11-29 13:41:24
【问题描述】:
(补充:对于这个问题,假设 PayPal API 上的操作正在运行并经过身份验证。)
PayPal Webhook 是否支持带有 HTTP 基本身份验证凭据的 URL,因此以下将创建一个使用给定凭据 foo:secret 的有效 Webhook?
webhook_attrs = {
# NOTE the URL has HTTP Basic credentials of
# user is 'foo' and password is 'secret':
url: 'https://foo:secret@example.com/paypal_events',
event_types: [
{ name: 'PAYMENT.AUTHORIZATION.CREATED' },
{ name: 'PAYMENT.AUTHORIZATION.VOIDED' }
]
}
webhook = PayPal::SDK::REST::Webhook.new(webhook_attrs)
if webhook.create && webhook.error.nil?
p "Created webhook:", webhook
else
p "Failed to create webhook:", webhook.error, webhook
end
【问题讨论】:
-
您可能应该阅读文档developer.paypal.com/docs/integration/direct/… 关于如何拨打第一个电话。您需要访问令牌才能将 URL 作为参数或标头传递。在您的情况下,您可以将其放在 URL 中,但您必须先完成所有步骤..获取 clientid 和 clientsecret 并将它们交换为访问令牌,就像文档中的示例一样。之后您可以使用访问令牌发出任何请求
-
感谢 Rada,并为不清楚的问题道歉。 API 身份验证工作正常。这个问题是关于 API 的不同方面的。我已对问题进行了澄清,并将很快添加答案。
标签: ruby paypal paypal-rest-sdk basic-authentication