Q62

「決済」及び「開発」関連用語集

カテゴリー: QA  閲覧数:278 配信日:2019-08-22 16:01


Q62


Webhook::constructEventで、SignatureVerificationエラーになるのですが…
2019/8/22
前提
Stripe Conect の Standardアカウント directチャージ

Q
Charge Session の Webhookエンドポイントで、SignatureVerificationエラーを解決できません。
'No signatures found matching the expected signature for payload'
下記で何か気が付いたことがもしあれば教えてください。

コード抜粋
▼index.php
\Stripe\Stripe::setApiKey('xxxx');
\Stripe\Checkout\Session::create([
 'payment_method_types' => ['card'],
 'line_items' => [[
   'name' => "Checkout Session Direct Charges デモ3",
   'amount' => 200,
   'currency' => 'jpy',
   'quantity' => 10,
 ]],
 'payment_intent_data' => [
   'application_fee_amount' => 200,
 ],
 'success_url' => 'xxxx',
 'cancel_url' => 'xxxx',  
], [
 'stripe_account' => 'acct_xxxx',
]);


▼webhook.php
    \Stripe\Stripe::setApiKey('xxxx');  
   $endpoint_secret = 'whsec_xxxx';
   $payload = @file_get_contents('php://input');
   $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
   $event = null;
   try {
       $event = \Stripe\Webhook::constructEvent(
           $payload, $sig_header, $endpoint_secret
       );
   } catch(\UnexpectedValueException $e) {
       //ここでエラーが捕捉されます


※$payload変数内容と、捕捉されたエラー内容につきましてはファイル添付しています


Webhook設定
https://dashboard.stripe.com/test/webhooks/we_1FA4EeEfFqi3KPm3KnVgQ73H

親アカウント手数料。取得できています
https://dashboard.stripe.com/test/events/evt_1FAA1OEfFqi3KPm3cljUKB3t

子アカウントの処理自体は問題なく出来ていると思われます
https://dashboard.stripe.com/test/logs/req_INyZaaJergSzAl
https://dashboard.stripe.com/test/logs/req_ljN6xIo6f6nWbv
https://dashboard.stripe.com/test/logs/req_7TAWxtFJOr5ngi

▼debug.php
'----------payload----------'
'{
 "id": "evt_1FAA1OLlsmkNgPt89Y9Qvi5b",
 "object": "event",
 "account": "acct_xxxx",
 "api_version": "2019-08-14",
 "created": 1566456226,
 "data": {
   "object": {
     "id": "cs_test_G21JU02SWKqBwdMZxZOy6bcnIzU9eIb85HJgptXo1m107zQiqP8h86V4",
     "object": "checkout.session",
     "billing_address_collection": null,
     "cancel_url": "http://xxxx/stripe/charge-cancel",
     "client_reference_id": "2",
     "customer": "cus_FfV1HWhLR6GhM8",
     "customer_email": null,
     "display_items": [
       {
         "amount": 200,
         "currency": "jpy",
         "custom": {
           "description": null,
           "images": null,
           "name": "Checkout Session Direct Charges デモ3"
         },
         "quantity": 10,
         "type": "custom"
       }
     ],
     "livemode": false,
     "locale": null,
     "payment_intent": "pi_1FAA17LlsmkNgPt8igElJDpi",
     "payment_method_types": [
       "card"
     ],
     "submit_type": null,
     "subscription": null,
     "success_url": "http://xxxx/stripe/charge-success"
   }
 },
 "livemode": false,
 "pending_webhooks": 1,
 "request": {
   "id": null,
   "idempotency_key": null
 },
 "type": "checkout.session.completed"
}'
'----------SignatureVerification----------'
Stripe\Error\SignatureVerification::__set_state(array(
  'message' => 'No signatures found matching the expected signature for payload',
  'string' => '',
  'code' => 0,
  'file' => '/var/www/xxxx/lib/composer/vendor/stripe/stripe-php/lib/WebhookSignature.php',
  'line' => 55,
  'trace' =>
 array (
   0 =>
   array (
     'file' => '/var/www/xxxx/lib/composer/vendor/stripe/stripe-php/lib/Webhook.php',
     'line' => 27,
     'function' => 'verifyHeader',
     'class' => 'Stripe\\WebhookSignature',
     'type' => '::',
     'args' =>
     array (
       0 => '{
 "id": "evt_1FAA1OLlsmkNgPt89Y9Qvi5b",
 "object": "event",
 "account": "acct_xxxx",
 "api_version": "2019-08-14",
 "created": 1566456226,
 "data": {
   "object": {
     "id": "cs_test_G21JU02SWKqBwdMZxZOy6bcnIzU9eIb85HJgptXo1m107zQiqP8h86V4",
     "object": "checkout.session",
     "billing_address_collection": null,
     "cancel_url": "http://xxxx/stripe/charge-cancel",
     "client_reference_id": "2",
     "customer": "cus_FfV1HWhLR6GhM8",
     "customer_email": null,
     "display_items": [
       {
         "amount": 200,
         "currency": "jpy",
         "custom": {
           "description": null,
           "images": null,
           "name": "Checkout Session Direct Charges デモ3"
         },
         "quantity": 10,
         "type": "custom"
       }
     ],
     "livemode": false,
     "locale": null,
     "payment_intent": "pi_1FAA17LlsmkNgPt8igElJDpi",
     "payment_method_types": [
       "card"
     ],
     "submit_type": null,
     "subscription": null,
     "success_url": "http://xxxx/stripe/charge-success"
   }
 },
 "livemode": false,
 "pending_webhooks": 1,
 "request": {
   "id": null,
   "idempotency_key": null
 },
 "type": "checkout.session.completed"
}',
       1 => 't=1566456226,v1=664ea5151ae5598a24f10dbb76fd7450f2cabd7a0a24c9fa0787f53ca3182147',
       2 => 'whsec_xxxx',
       3 => 300,
     ),
   ),
   1 =>
   array (
     'file' => '/var/www/html/1-p46/0webapp/controllers/StripeController.php',
     'line' => 56,
     'function' => 'constructEvent',
     'class' => 'Stripe\\Webhook',
     'type' => '::',
     'args' =>
     array (
       0 => '{
 "id": "evt_1FAA1OLlsmkNgPt89Y9Qvi5b",
 "object": "event",
 "account": "acct_子アカウント",
 "api_version": "2019-08-14",
 "created": 1566456226,
 "data": {
   "object": {
     "id": "cs_test_G21JU02SWKqBwdMZxZOy6bcnIzU9eIb85HJgptXo1m107zQiqP8h86V4",
     "object": "checkout.session",
     "billing_address_collection": null,
     "cancel_url": "http://xxxx/stripe/charge-cancel",
     "client_reference_id": "2",
     "customer": "cus_FfV1HWhLR6GhM8",
     "customer_email": null,
     "display_items": [
       {
         "amount": 200,
         "currency": "jpy",
         "custom": {
           "description": null,
           "images": null,
           "name": "Checkout Session Direct Charges デモ3"
         },
         "quantity": 10,
         "type": "custom"
       }
     ],
     "livemode": false,
     "locale": null,
     "payment_intent": "pi_1FAA17LlsmkNgPt8igElJDpi",
     "payment_method_types": [
       "card"
     ],
     "submit_type": null,
     "subscription": null,
     "success_url": "http://xxxx/stripe/charge-success"
   }
 },
 "livemode": false,
 "pending_webhooks": 1,
 "request": {
   "id": null,
   "idempotency_key": null
 },
 "type": "checkout.session.completed"
}',
       1 => 't=1566456226,v1=664ea5151ae5598a24f10dbb76fd7450f2cabd7a0a24c9fa0787f53ca3182147',
       2 => 'whsec_xxxx',
     ),
   ),
   2 =>
   array (
     'file' => '/var/www/html/1-p46/0webapp/core/Controller.php',
     'line' => 63,
     'function' => 'webhookAction',
     'class' => 'StripeController',
     'type' => '->',
     'args' =>
     array (
       0 =>
       array (
         'controller' => 'stripe',
         'action' => 'webhook',
         0 => '/stripe/webhook',
       ),
     ),
   ),
   3 =>
   array (
     'file' => '/var/www/html/1-p46/0webapp/core/Application.php',
     'line' => 254,
     'function' => 'run',
     'class' => 'Controller',
     'type' => '->',
     'args' =>
     array (
       0 => 'webhook',
       1 =>
       array (
         'controller' => 'stripe',
         'action' => 'webhook',
         0 => '/stripe/webhook',
       ),
     ),
   ),
   4 =>
   array (
     'file' => '/var/www/html/1-p46/0webapp/core/Application.php',
     'line' => 215,
     'function' => 'runAction',
     'class' => 'Application',
     'type' => '->',
     'args' =>
     array (
       0 => 'stripe',
       1 => 'webhook',
       2 =>
       array (
         'controller' => 'stripe',
         'action' => 'webhook',
         0 => '/stripe/webhook',
       ),
     ),
   ),
   5 =>
   array (
     'file' => '/var/www/html/xxxx/xxxx/public_html/index.php',
     'line' => 12,
     'function' => 'run',
     'class' => 'Application',
     'type' => '->',
     'args' =>
     array (
     ),
   ),
 ),
  'previous' => NULL,
  'httpStatus' => NULL,
  'httpBody' => '{
 "id": "evt_1FAA1OLlsmkNgPt89Y9Qvi5b",
 "object": "event",
 "account": "acct_子アカウント",
 "api_version": "2019-08-14",
 "created": 1566456226,
 "data": {
   "object": {
     "id": "cs_test_G21JU02SWKqBwdMZxZOy6bcnIzU9eIb85HJgptXo1m107zQiqP8h86V4",
     "object": "checkout.session",
     "billing_address_collection": null,
     "cancel_url": "http://xxxx/stripe/charge-cancel",
     "client_reference_id": "2",
     "customer": "cus_FfV1HWhLR6GhM8",
     "customer_email": null,
     "display_items": [
       {
         "amount": 200,
         "currency": "jpy",
         "custom": {
           "description": null,
           "images": null,
           "name": "Checkout Session Direct Charges デモ3"
         },
         "quantity": 10,
         "type": "custom"
       }
     ],
     "livemode": false,
     "locale": null,
     "payment_intent": "pi_1FAA17LlsmkNgPt8igElJDpi",
     "payment_method_types": [
       "card"
     ],
     "submit_type": null,
     "subscription": null,
     "success_url": "http://xxxx/stripe/charge-success"
   }
 },
 "livemode": false,
 "pending_webhooks": 1,
 "request": {
   "id": null,
   "idempotency_key": null
 },
 "type": "checkout.session.completed"
}',
  'jsonBody' => NULL,
  'httpHeaders' => NULL,
  'requestId' => NULL,
  'stripeCode' => NULL,
  'sigHeader' => 't=1566456226,v1=664ea5151ae5598a24f10dbb76fd7450f2cabd7a0a24c9fa0787f53ca3182147',
  'xdebug_message' => '<tr><th align=\'left\' bgcolor=\'#f57900\' colspan="5"><span style=\'background-color: #cc0000; color: #fce94f; font-size: x-large;\'>( ! )</span> Stripe\\Error\\SignatureVerification: No signatures found matching the expected signature for payload in /var/www/html/lib/composer/vendor/stripe/stripe-php/lib/WebhookSignature.php on line <i>55</i></th></tr>
<tr><th align=\'left\' bgcolor=\'#e9b96e\' colspan=\'5\'>Call Stack</th></tr>
<tr><th align=\'center\' bgcolor=\'#eeeeec\'>#</th><th align=\'left\' bgcolor=\'#eeeeec\'>Time</th><th align=\'left\' bgcolor=\'#eeeeec\'>Memory</th><th align=\'left\' bgcolor=\'#eeeeec\'>Function</th><th align=\'left\' bgcolor=\'#eeeeec\'>Location</th></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>1</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.0001</td><td bgcolor=\'#eeeeec\' align=\'right\'>396496</td><td bgcolor=\'#eeeeec\'>{main}(  )</td><td title=\'/var/www/html/xxxx/xxxx/public_html/index.php\' bgcolor=\'#eeeeec\'>.../index.php<b>:</b>0</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>2</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.0121</td><td bgcolor=\'#eeeeec\' align=\'right\'>432376</td><td bgcolor=\'#eeeeec\'>MiniBlogApplication->run(  )</td><td title=\'/var/www/html/xxxx/xxxx/public_html/index.php\' bgcolor=\'#eeeeec\'>.../index.php<b>:</b>12</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>3</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.0123</td><td bgcolor=\'#eeeeec\' align=\'right\'>432792</td><td bgcolor=\'#eeeeec\'>MiniBlogApplication->runAction(  )</td><td title=\'/var/www/html/1-p46/0webapp/core/Application.php\' bgcolor=\'#eeeeec\'>.../Application.php<b>:</b>215</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>4</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.2865</td><td bgcolor=\'#eeeeec\' align=\'right\'>439072</td><td bgcolor=\'#eeeeec\'>StripeController->run(  )</td><td title=\'/var/www/html/1-p46/0webapp/core/Application.php\' bgcolor=\'#eeeeec\'>.../Application.php<b>:</b>254</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>5</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.2865</td><td bgcolor=\'#eeeeec\' align=\'right\'>439112</td><td bgcolor=\'#eeeeec\'>StripeController->webhookAction(  )</td><td title=\'/var/www/html/1-p46/0webapp/core/Controller.php\' bgcolor=\'#eeeeec\'>.../Controller.php<b>:</b>63</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>6</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.2934</td><td bgcolor=\'#eeeeec\' align=\'right\'>443896</td><td bgcolor=\'#eeeeec\'>Stripe\\Webhook::constructEvent(  )</td><td title=\'/var/www/html/1-p46/0webapp/controllers/StripeController.php\' bgcolor=\'#eeeeec\'>.../StripeController.php<b>:</b>56</td></tr>
<tr><td bgcolor=\'#eeeeec\' align=\'center\'>7</td><td bgcolor=\'#eeeeec\' align=\'center\'>0.2935</td><td bgcolor=\'#eeeeec\' align=\'right\'>444536</td><td bgcolor=\'#eeeeec\'>Stripe\\WebhookSignature::verifyHeader(  )</td><td title=\'/var/www/html/lib/composer/vendor/stripe/stripe-php/lib/Webhook.php\' bgcolor=\'#eeeeec\'>.../Webhook.php<b>:</b>27</td></tr>
',
))







週間人気ページランキング / 4-18 → 4-24
順位 ページタイトル抜粋 アクセス数
1 YouTube | 動画サービス(課金販売できるプラットフォーム) 8
2 EMVレベル1 / EMVレベル2 / EMVCo とは? 6
3 EMVCo | クレジットカード仕様(仕様) 5
4 クレジットカード決済 | 課金 3
4 pixivFANBOX | クリエイター支援プラットフォーム(課金販売できるプラットフォーム) 3
5 Stripe webhook 配信の問題 / 実際に受け取った警告メールの受信例 2
5 Stripe Q73.CheckoutのSessionオブジェクトをcreateする際、'payment_intent_data'内の'metadata'として渡したデータを、webhookで受け取る件について | QA(Stripe) 2
5 Stripe Q55.Checkout\Session::createする際の、'client_reference_id'パラメータと'payment_intent_data.metadata'パラメータの違いについて | QA(Stripe) 2
5 ログイン 2
5 Stripeアカウントへログインする際、モバイル端末で受信したコード入力を求められる理由は? | その他エントリー(Stripe) 2
5 Off-session Payments with Payment Intents / Payment Intents を使用したオフセッション支払 2
5 Stripe Q32。Webhook のエンドポイントから適切な値を返さなかったときの停止措置について | QA(Stripe) 2
5 Stripe Q16。PaymentIntentの支払いで郵便番号入力を求められる。Radar rules の ZIP code を無効にしているのに | QA(Stripe) 2
5 プリペイドカード | カード 2
5 Squareは、デジタルコンテンツ(デジタル情報)の配信利用が認められないサービス | 「支払」機能を有する決済系サービス(決済サービス) 2
6 Twitchとは?/ Cheeringとは?/ Cheerとは? 1
6 ほしい物リスト | 投げ銭サービス(課金販売できるプラットフォーム) 1
6 Omise | 「支払」機能を有する決済系サービス(決済サービス) 1
6 決済用語 1
6 振込 | 送金 1
2024/4/25 1:02 更新
指定期間人気ページランキング / 2020-5-28 → 2024-4-24
順位 ページタイトル抜粋 アクセス数
1 Stripeアカウントへログインする際、モバイル端末で受信したコード入力を求められる理由は? | その他エントリー(Stripe) 2010
2 EMVCo | クレジットカード仕様(仕様) 1267
3 Stripe Q13。決済成功時に、「請求に紐づけられたメールアドレス」に対して、メール送信したいのですが、 | QA(Stripe) 943
4 Stripe Q16。PaymentIntentの支払いで郵便番号入力を求められる。Radar rules の ZIP code を無効にしているのに | QA(Stripe) 901
5 クレジットカード決済 | 課金 879
6 Twitch | ゲーム実況配信サービス(課金販売できるプラットフォーム) 876
7 決済用語 855
8 Stripe Q50。 Connect 「Standardアカウント」で、自身に連結された子アカウントを、ダッシュボードから削除するには? | QA(Stripe) 824
9 Omise | 「支払」機能を有する決済系サービス(決済サービス) 767
10 Stripe Q1。Stripeにおける個人事業主の定義 | QA(Stripe) 761
11 pixivFANBOX | クリエイター支援プラットフォーム(課金販売できるプラットフォーム) 741
12 Stripe Q31。ダッシュボードでの「支払い作成」の見方について | QA(Stripe) 738
13 EMVレベル1 / EMVレベル2 / EMVCo とは? 727
14 YouTube | 動画サービス(課金販売できるプラットフォーム) 670
15 プリペイドカード | カード 645
16 EPUB | ファイルフォーマット(電子書籍) 587
17 サブスクリプション | 課金 563
18 Stripeで"No such token: src"と表示されたら、最初にAPIキーを確認する | Stripe エラー(Stripe) 544
19 Stripe Q74.「お客様のビジネスの詳細」とは何ですか? | Stripe 542
20 ファンティア | クリエイター支援プラットフォーム(課金販売できるプラットフォーム) 482
2024/4/25 1:02 更新