使用已连接帐户进行 Stripe Checkout 时出现“无效 payment_page id”错误

fra*_*ool 2 stripe-payments

我正在尝试将我网站上最新版本的 Stripe Checkout 与连接的帐户和使用目的地费用的平台费用集成。

首先,我创建一个会话:

$session = \Stripe\Checkout\Session::create([
    'customer_email' => $_SESSION["EMAIL"],
    'client_reference_id' => $_SESSION["USER_ID"],
    'payment_method_types' => ['card'],
    'line_items' => [[
        'name' => $listing["title"],
        'description' => $nb_days . " night(s) / " . $nb_guests . " guest(s) in " . $listing["title"],
        'images' => [URL . "img/logo.png"],
        'amount' => $total_stripe,
        'currency' => 'usd',
        'quantity' => 1,
    ]],
    'payment_intent_data' => [
        'application_fee_amount' => $total_fee,
        'transfer_data' => [
          'destination' => $owner_stripe_id,
        ],
    ],
    'success_url' => URL . 'order-success.php',
    'cancel_url' => URL . 'book-listing.php?action=order_error',
]); 
Run Code Online (Sandbox Code Playgroud)

然后,在我的 JS 代码中,我提供上面会话创建的 ID,并引用将接收资金的连接帐户:

var stripe = Stripe(STRIPE_PK_KEY, {
    stripeAccount: STRIPE_CONNECT_ID,
});

$(".btn-confirm-pay").click(function(e) {

    stripe.redirectToCheckout({
        sessionId: STRIPE_SESSION_ID,
    }).then(function (result) {

    });

});
Run Code Online (Sandbox Code Playgroud)

但是,当我单击按钮时.btn-confirm-pay,我被重定向到 Stripe,显示错误“出现问题”,当我检查控制台时,我看到 Stripe 出现 404 错误,并显示以下消息:无效的 payment_page id: cs_test_xxx...

我注意到,当我使用“直接收费”方法而不是此处所述的“目的地收费”时,不会出现此错误

你能帮忙解决这个问题吗?

kar*_*kko 5

stripeAccount你应该在 Javascript 中省略。这仅适用于您使用直接收费的情况,其中结帐会话对象是在连接的帐户上创建的。在您的情况下,您使用的是目的地费用,因此 Checkout Session 对象位于您的平台帐户中,因此您不想使用stripeAccount. 我认为 Stripe 的文档在这一点上可能是错误的。