Reputation: 3229
I'm trying to integrate the last version of Stripe Checkout on my website with a connected account and a platform fee using destination charges.
So first of all, I create a session :
$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',
]);
Then, in my JS code, I provide the ID created by the session above and I reference the connected account that will receive the money :
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) {
});
});
But when I click on my button .btn-confirm-pay
, I am redirected to Stripe which shows the error "Something went wrong" and when I check the console, I see a 404 error from Stripe with the following message : Invalid payment_page id: cs_test_xxx...
I have noticed that this error doesn't show up when I use the "direct charges" method instead of the "destination charges" as described here.
Can you help fixing this issue?
Upvotes: 2
Views: 2890
Reputation: 7198
You should omit stripeAccount
in your Javascript. That's only for if you're using Direct Charges, where the Checkout Session object is created on the connected account. In your case, you're using a Destination charge, so the Checkout Session object lives on your platform account, so you don't want to use stripeAccount
. Stripe's docs might be wrong on this, I think.
Upvotes: 5