I am implementing Stripe in my Laravel/Vue app and have defined 4 types of prices on a product. I am implementing a credits model where e.g:
1 EUR => 1 credit
3 EUR => 4 credits
4 EUR => 7 credits
7 EUR => 10 credits
I figured first one being a standard pricing (that one works), other 3 are defined as package pricing (e.g. 3 EUR for quantity of 4).
The flow should go like this; user picks from a slider how much credits would he like to purchase (1, 4, 7, 10) and clicking on purchase should lead him to stripe checkout with automatically assigned price for the given amount of credits.
If pricing was standard in a way that one credit costs 1 EUR, and every subsequent credit costs 1 EUR as well, this would be easy as I would only provide one price ID (defined on Stripe) and I would pick up the quantity from the frontend.
Now the issue I have is that when I try to create session:
$priceId = // id from Stripe. One of product prices
$stripeSession = Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price' => $priceId,
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => route('stripe.success') . '/?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => route('stripe.cancel')
]);
I am getting the error saying:
Checkout does not support package pricing, aka
transform_quantityin `line_items[price][0]
Can't seem to find that error in documentation, but even if I change quantity to 4 for second item, same thing happens.
'line_items' => [[
'price' => // price ID for second option,
'quantity' => 4,
]],
Also it is quite confusing as to what would this mean? The price for second item is already defined as being a package of 4, so does quantity 4 in this context mean that user would get 4x4=16 items?
How can I fetch packages in this context and know how much credits to give to the user given the need for gradual one time (non-recurring) pricing?