首页 > 解决方案 > 连接帐户的 Stripe Checkout 给出“Invalid payment_page id”错误

问题描述

我正在尝试将我网站上最新版本的 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',
]); 

然后,在我的 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) {

    });

});

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

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

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

标签: stripe-payments

解决方案


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


推荐阅读