小编Tom*_*čák的帖子

如何在 stripe checkout.session.completed 上更新我的数据库

//non working code from stripe documentation

require_once "config.php";

// Set your secret key. Remember to switch to your live secret key in production!
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey('EXAMPLE_KEY');


// You can find your endpoint's secret in your webhook settings
$endpoint_secret = 'EXAMPLE_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);
    exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
    // Invalid signature
    http_response_code(400);
    exit(); …
Run Code Online (Sandbox Code Playgroud)

php

6
推荐指数
1
解决办法
4046
查看次数

标签 统计

php ×1