第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Authorize.Net 中的 Webhook 始終無法通過身份驗(yàn)證

Authorize.Net 中的 Webhook 始終無法通過身份驗(yàn)證

PHP
ITMISS 2022-05-27 13:12:40
在 Authorize.Net 中,使用 webhook 創(chuàng)建了訂閱和重復(fù)事件處理。當(dāng)我使用 web 掛鉤帳戶身份驗(yàn)證進(jìn)行測試時(shí),但在實(shí)際的 webhook 通知中始終無法通過身份驗(yàn)證if (isset($this->header['x-anet-signature'])) {        $json = Json::encode($this->body);        if ($json) {            //To check the header and signature is true         if (hash_equals(strtolower($this->header['x-anet-signature']),                    'sha512=' . hash_hmac('sha512',$json, $secret))            ) {              }else{                yii::info($json,'webhookhNotifications');                throw new \yii\web\ServerErrorHttpException('Authentication failed in Webhook');              return false;            }         }    }網(wǎng)絡(luò)鉤子 JSON{   "notificationId":"4bbba8fb-1d32-46b6-a513-a9ca2fed885c",   "eventType":"net.authorize.customer.subscription.created",   "eventDate":"2019-11-27T06:20:36.3621687Z",   "webhookId":"a2929d59-147e-4400-a2bb-b3bd25a0311d",   "payload":{      "name":"Test subscription",      "amount":290.00,      "status":"active",      "profile":{         "customerProfileId":1921894828,         "customerPaymentProfileId":1834842681,         "customerShippingAddressId":1879009509      },      "entityName":"subscription",      "id":"6168233"   }}密鑰F7B582AFFA9372866965456CFAC0D1B1219258F955FD5266D1A96BF9BE3C85F7D54C7CDFF9EF3EE7D3916EACB5EE920167F557BBB307288C17FBD169F0257AB4x-anet-簽名sha512=FDE5518801C115C4886311877B4C37F6C26ABACE01ADB973EF372FB51C8F1E5321A83717161AD7DEFFD46F5013900E68B6220F3B25E9302A4208A9C673D32749
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊

您的代碼應(yīng)該可以工作。我出于測試目的對(duì)其進(jìn)行了一些簡化,但使用您在上面提供的值確實(shí)可以成功驗(yàn)證:


$signature = 'sha512=FDE5518801C115C4886311877B4C37F6C26ABACE01ADB973EF372FB51C8F1E5321A83717161AD7DEFFD46F5013900E68B6220F3B25E9302A4208A9C673D32749';

$json = '{"notificationId":"4bbba8fb-1d32-46b6-a513-a9ca2fed885c","eventType":"net.authorize.customer.subscription.created","eventDate":"2019-11-27T06:20:36.3621687Z","webhookId":"a2929d59-147e-4400-a2bb-b3bd25a0311d","payload":{"name":"Test subscription","amount":290.00,"status":"active","profile":{"customerProfileId":1921894828,"customerPaymentProfileId":1834842681,"customerShippingAddressId":1879009509},"entityName":"subscription","id":"6168233"}}';

$secret = 'F7B582AFFA9372866965456CFAC0D1B1219258F955FD5266D1A96BF9BE3C85F7D54C7CDFF9EF3EE7D3916EACB5EE920167F557BBB307288C17FBD169F0257AB4';


if (hash_equals(strtolower($signature), 'sha512=' . hash_hmac('sha512', $json, $secret))) {

    echo 'valid';

}else{

    echo 'invalid';

}

演示


我認(rèn)為您的錯(cuò)誤是您正在對(duì)已經(jīng)是 JSON 的 JSON 進(jìn)行編碼。所以改變這一行:


$json = Json::encode($this->body);

新代碼:


if (isset($this->header['x-anet-signature'])) {

        $json = $this->body;

        if ($json) {

            //To check the header and signature is true

         if (hash_equals(strtolower($this->header['x-anet-signature']),

                    'sha512=' . hash_hmac('sha512',$json, $secret))

            ) { 



             }else{

                yii::info($json,'webhookhNotifications');

                throw new \yii\web\ServerErrorHttpException('Authentication failed in Webhook');

              return false;


            } 

        }

    }


查看完整回答
反對(duì) 回復(fù) 2022-05-27
  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)