Help us understand the problem. What is going on with this article?

stripeエンドポイント作成 php

stripe custom webhook
ダッシュボードがトリガー

webhook.php
<?php
ストライプキー挿入
//
// Webhook の署名を確認する
// https://stripe.com/docs/webhooks/signatures#verify-official-libraries
//
$endpoint_secret = 'えんどポイントダッシュボードのエンドポイントにて';


$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) {
    // Invalid payload
    http_response_code(400); // PHP 5.4 or greater
    exit();
} catch(\Stripe\Error\SignatureVerification $e) {
    // Invalid signature
    http_response_code(400); // PHP 5.4 or greater
    exit();
}

//
// $eventに対しての処理を行う
//
$event_json = json_decode($payload);
// $event_json = json_decode($payload);
// ダッシュボードのテストでは0だからうまく行かない ここら辺の
// $event_id = $event_json->id;
// try {
//     $event = \Stripe\Event::retrieve($event_id);
// } catch(\Stripe\Error\InvalidRequest $e) {
//     // Invalid payload
//     http_response_code(400);
//     exit();
// } catch(\Stripe\Error $e) {
//     // Invalid payload
//     http_response_code(400);
//     exit();
// }

if ($event->type == 'customer.created') {
}
if ($event->type == 'account.updated') {
  $account = $event->data->object;
  handleAccountUpdate($account);
  // var_dump($event_json);
}

//ここにうまくいったときと処理
if ($event->type == 'checkout.session.completed') {
dbやらメールなど
      var_dump($event_json); 




}

if ($event->type == 'customer.subscription.deleted') {
}

if ($event->type == 'customer.subscription.updated') {
}

if ($event->type == 'invoice.payment_succeeded') {
}

http_response_code(200);

function handleAccountUpdate($account) {
  // Fulfill the purchase.
  echo $account;
};
?>
Shun_Takahashi
Super Fashionista です!! https://www.instagram.com/madonna.77768/
obniz
30秒で動き出すIoTデバイスobniz(オブナイズ)を開発・販売するスタートアップ
https://obniz.io/ja/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした