如何配置Authorize.Net webhooks

时间:2017-02-19 15:55:07

标签: php webhooks authorize.net php-curl authorize.net-webhooks

我已根据我的客户要求配置了 Authorize.net 接受托管付款方式,其中一切正常,但交易响应除外。根据Authorize.net,响应只能通过以下方式之一, webhooks CommunicatorUrl 。 CommunicatorUrl不适用于我的代码。所以,选择了webhooks。以下是我的代码。拜托,建议我。

我的怀疑是:

  1. 我的代码在调用可用的webhooks列表时显示此错误

    { "status": 405, "reason": "Method Not Allowed", "message": "The requested resource does not support http method 'POST' for given parameters.", "correlationId": "ff90ee25-0ba7-4006-bb1e-225ea64897e3" }

  2. 我应该在Merchant Panel中的任何位置配置webhook

  3. 如何使用webhook获取我的交易回复

      <?php
      $login_transKey = 'xxx:xxx'; //Login and Transaction Key of Authorize.net
      $jsonObj = '{
        "name": "Get WebHooks",
        "request": {
            "url": "http://localhost:81/hosted_payment_form/webhookstwo.php",
            "method": "GET",
            "header": [
                {
                    "key": "Content-Type",
                    "value": "application/json",
                    "description": ""
                },
                {
                    "key": "Authorization",
                    "value": "'.$login_transKey.'",
                    "description": ""
                }
            ],
            "body": {
                "mode": "formdata",
                "formdata": []
            },
            "description": ""
        },
        "response": []
    }';
    $jsonObj = json_encode($jsonObj);
    $url = "https://apitest.authorize.net/rest/v1/eventtypes";      
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonObj);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
    $content = curl_exec($ch);
    echo '<pre>'; print_r($content); die();
    curl_close($ch);
    ?>
    
  4. 请让我知道更多信息。

1 个答案:

答案 0 :(得分:0)

您需要在authorize.net帐户中指定Webhook网址。

此外,您还需要在设置页面中选择事件。

请确保Web挂钩URL始终返回HTTP 200响应。 否则,它将自动更改为非活动状态。

enter image description here