我在Authorize.Net Webhooks中观察到两个问题,并正在寻找解决方案。
但是,如果我在authorizenet上设置了一个非活动的Webhook并使用在线测试Webhook按钮,则会收到以下错误:
错误:ping操作失败。这可能是由于连接问题,无效的URL或服务器停机引起的。检查Webhook的网址详细信息,然后重试。
使用php curl脚本,我可以获得当前的webhooks:
[
{
"_links": {
"self": {
"href": "/rest/v1/webhooks/b8f7a92b-3d14-45d0-897f-95271faaf44b"
}
},
"webhookId": "b8f7a92b-3d14-45d0-897f-95271faaf44b",
"name": "dev_sub",
"status": "inactive",
"url": "https://devjesse.gettveverywhere.com/wp-json/authorizenet/subscription",
"eventTypes": [
"net.authorize.customer.subscription.updated",
"net.authorize.customer.subscription.created",
"net.authorize.customer.subscription.expiring",
"net.authorize.customer.subscription.suspended",
"net.authorize.customer.subscription.cancelled",
"net.authorize.customer.subscription.terminated"
]
}
]
,当使用我的php curl脚本调用ping时:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://apitest.authorize.net/rest/v1/webhooks/b8f7a92b-3d14-45d0-897f-95271faaf44b/pings');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode(API_LOGIN_ID . ':' . TRANSACTION_KEY),
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
我收到以下错误:
{
"status": 500,
"reason": "PING_FAILED",
"message": "The ping operation failed. This could be due to connectivity issues, invalid url or server downtime. Check the url details for the webhook and try again.",
"correlationId": "5003a88f-4a1f-4c77-b374-84bdc1256082"
}
我不确定为什么authorizenet webhook在这里失败。如果我使用自己的php curl脚本和通知信息的副本,则端点有效:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://devjesse.gettveverywhere.com/wp-json/authorizenet/customer');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: 410',
'X-Opnet-Transaction-Trace: 676a6e12-d5d2-4f72-b14f-fac44a714d87-15432-570877 Expect 100-continue',
'X-Anet-Signature: sha512=5860384727AC755D0AAFB387EB775F1436C409E2F2BF38C6ED08717399A23FB1275A2363DC16A35A89E5541DBB3CED599A515A2165AA02EFB54596BD920ECA93'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"notificationId":"365a8c21-088e-4303-a11a-6d3d827cc9a4","eventType":"net.authorize.customer.created","eventDate":"2019-07-02T16:27:41.5972635Z","webhookId":"5be521cb-5805-4b25-9952-1fb661c70e71","payload":{"paymentProfiles":[{"customerType":"individual","id":"1507794447"}],"merchantCustomerId":"2200","description":"Profile created by Subscription: 5869582","entityName":"customerProfile","id":"1508341513"}}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
但是有两个问题:
否https
仅发送一个完全错误的eventType(net.authorize.payment.authcapture.created)。