#jellybeer-_checkout-modes-prices
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1364632969129496580
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi 👋
I"m sorry but I do not understand how your question has to do with Stripe APIs. I don't know what "embed" means in this case
well okay, i made a payment page. on the left side of the page i got pdf that shows a invoice and on the right side i got the stripe payment. the stripe payment has ben embedded inside the page using 'ui_mode' => 'embedded',. now it worked fine when i only used one time payments. after that i wanted to add subscriptions together with the one time payments inside the embedded ui. that sadly doesnt work and only works without the embedded part.
this is my checkout.php without the subscription part:
this is my invoice.php (frontend that shows the checkout.php):
now is there a way on how i can put one time payments and subscriptions on one payments session inside the embedded ui?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
OH you mean the embedded Stripe Checkout?
yh sorry
What is the error you receive when attempting to create the Checkout Session?
When your PHP code attempts to create a Checkout Session you are making an API request to Stripe
Can you share an example API request ID? It will start with req_
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
okay so in the code i added this:
$line_items = [];
foreach ($_SESSION['data'] as $item) {
$price_data = [
'currency' => 'eur',
'unit_amount' => $item['unit_amount'],
'product_data' => [
'name' => $item['product_name'],
],
];
if ($item['recurring'] === 'month') {
$price_data['recurring'] = ['interval' => 'month'];
} elseif ($item['recurring'] === 'year') {
$price_data['recurring'] = ['interval' => 'year'];
}
// Als 'once' of onbekend, dan géén recurring toevoegen
$line_items[] = [
'quantity' => $item['quantity'],
'price_data' => $price_data,
'tax_rates' => [$tax_rate->id],
];
}
here is where it when wrong
the ID is: req_KulxeD167rtrO9
in the error its says this:
{
"error": {
"message": "You specified payment mode but passed a recurring price. Either switch to subscription mode or use only one-time prices.",
"param": "line_items[2]",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_KulxeD167rtrO9?t=1745424922",
"type": "invalid_request_error"
}
}
but i cant player payment subsciption and one time payments inside one session
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Okay great. The error message is correct. If you are mixing one-off and recurring prices you must use mode: "subscription" when creating the Checkout Session
you mean like this (line 3):
foreach ($_SESSION['data'] as $item) {
$price_data = [
'mode' => 'subscription',
'currency' => 'eur',
'unit_amount' => $item['unit_amount'],
'product_data' => [
'name' => $item['product_name'],
],
];
if ($item['recurring'] === 'month') {
$price_data['recurring'] = ['interval' => 'month'];
} elseif ($item['recurring'] === 'year') {
$price_data['recurring'] = ['interval' => 'year'];
}
// Als 'once' of onbekend, dan géén recurring toevoegen
$line_items[] = [
'quantity' => $item['quantity'],
'price_data' => $price_data,
'tax_rates' => [$tax_rate->id],
];
}
'mode' => 'subscription',, yes that is what I mean. Can you test that and share the request ID?
doesnt work..
req_yq0bhYAXZMjvNe
probaly because i got products with one time payments, monthly and yearly payments...
this is the json he gets his data from:
{
"recurring": "month",
"quantity": 1,
"product_name": "Maandelijkse onderhoud",
"unit_amount": "1999"
},
{
"recurring": "once",
"quantity": 1,
"product_name": "Extra pagina (per stuk)",
"unit_amount": "7500"
},
{
"recurring": "year",
"quantity": 1,
"product_name": "Domeinnaam (per jaar)",
"unit_amount": "999"
},
Oh wait sorry
The reason that request failed in you need to specify the mode as a top level parameter, NOT for each Line Item
If you look at that request, you will see you are still passing mode: "payment" in the top level parameter.
yas my bad i see the problem:
$line_items = [];
foreach ($_SESSION['data'] as $item) {
$price_data = [
** 'mode' => 'subscription',**
'currency' => 'eur',
'unit_amount' => $item['unit_amount'],
'product_data' => [
'name' => $item['product_name'],
],
];
if ($item['recurring'] === 'month') {
$price_data['recurring'] = ['interval' => 'month'];
} elseif ($item['recurring'] === 'year') {
$price_data['recurring'] = ['interval' => 'year'];
}
// Als 'once' of onbekend, dan géén recurring toevoegen
$line_items[] = [
'quantity' => $item['quantity'],
'price_data' => $price_data,
'tax_rates' => [$tax_rate->id],
];
}
$checkout_session = \Stripe\Checkout\Session::create([
'ui_mode' => 'embedded',
** 'mode' => 'payment',**
'return_url' => 'https://betaling.web4ever.nl/return.php',
'line_items' => $line_items,
]);
i put 2 modes haha. do i need to remove the first mode and change the mode payment to mode subscription?
Yes. So remove the mode in the $price_data array and set the top level mode to "subscription" and test that out
req_AI5TMbwOgxLYJV
rip this is the problem i was worried about
Okay yeah that is what I thought. Youn can't mix multiple billing intervals on the same Subscription.
is there a way i can still put mulitple billing intervals inside one checkout?
No
What you can do is save the customer's payment method as their default and create a second subscription using that saved payment method
Then the customer doesn't have to complete Checkout twice
is there a documentation for that?
i will try that thanks 🙂
Although you shouldn't need to change anything
If you use Checkout in subscription mode, Stripe automatically saves the payment method to charge it for subsequent payments.
That is referenced in this section
So what I recommend is this:
- Complete a checkout session in Test mode with mode "subscription"
- Examine the Customer and Payment Method associated with that Checkout Session