stripe-payments - 连接帐户的 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 ...
我注意到,当我使用“直接收费”方法而不是此处描述的“目的地收费”时,不会出现此错误。
你能帮忙解决这个问题吗?
解决方案
stripeAccount
你应该在你的Javascript中省略。这仅适用于您使用 Direct Charges 的情况,其中 Checkout Session 对象是在连接的帐户上创建的。在您的情况下,您使用的是目的地费用,因此 Checkout Session 对象存在于您的平台帐户中,因此您不想使用stripeAccount
. 我认为,Stripe 的文档在这方面可能是错误的。
推荐阅读
- visual-studio - Merge issue TFVC
- scala - Scala 类型不匹配,无法解析符号 A,模式类型与预期类型不兼容
- json - 将在 Elasticsearch 中使用的 Json 文件
- robotframework - robotframework Page Should Contain Textfield variable with random input
- javascript - 如何猴子修补在另一个函数中声明的函数
- spring - throw not found exception if pubsub topic is not available
- javascript - 无法在反应中读取未定义的属性“道具”,将数据从父级传递给子级
- teradata - Teradata - 计算来自不同行号的两个日期之间的差异
- python - 如何从单词列表中找到它在字符串中找到的单词
- python - 是否可以使用 GitLab CI 将文件写入您的机器(本地驱动器)?