(添加:对于这个问题,假设PayPal API上的操作是有效的并经过身份验证。)
PayPal Webhooks是否支持具有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
发布于 2017-06-28 10:21:42
HTTP不支持PayPal基本身份验证(在编写本文时)。
尝试使用URL (包括HTTP基本凭据)创建Web钩子时,如果出现以下错误,将失败:
{
"name" => "VALIDATION_ERROR",
"details" => [ { "field" => "url", "issue" => "Not a valid webhook URL" } ],
"message" => "Invalid data provided",
"information_link" => "https://developer.paypal.com/docs/api/webhooks/#errors"
}
对于希望这样做的开发人员,有几个建议:
==
等式检查容易受到定时攻击。有关定时和长度攻击的更多信息,请参见utils.rb#L22。发布于 2019-09-17 08:19:06
我们知道HTTP不支持PayPal基本身份验证,但是我们有一个解决方案来解决这类问题。我们需要一个没有HTTP基本认证的实时服务器,这样我们就可以在paypal应用程序中为web钩子URL在PHP文件上设置。
paypalWebhook.php
的PHP文件。下面是此文件的代码。$body = @file_get_contents('php://input');$url = 'events';//open connection $ch = curl_init();//设置url、post vars数量、POST数据curl_setopt($ch、CURLOPT_URL、$url);curl_setopt($ch、CURLOPT_POST、count($fields));curl_setopt($ch、CURLOPT_POSTFIELDS、$ch);//execute POST $ch=(#en22 20#);//关闭连接();
https://{live-server}/paypalWebhook.php
现在,您可以通过活动服务器将所有post值传递给devlopmentHTTP Basic身份验证服务器。
https://stackoverflow.com/questions/44764407
复制相似问题