#krilline_code
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/1440677491973947473
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐
Yeah you can't set application_fees_amount using Stripe Checkout
You can either calculate the approximate percentage that includes the 30cents
or change your integration to use Subscription APIs and Elements
Thank you for your answer, so let's say I calculate the percentage, I would need to recalculate the percentage if the user changes of product right ? And I tried using the subscription API, but I can only update the invoice when collection_method is set to send_invoice. But that makes the status of the subscription as active. So it doesn't work well with my webhook. I tried doing this:
$stripeSubscription = Subscription::create([
'customer' => (string) $user->getStripeCustomerId(),
'payment_behavior' => Subscription::PAYMENT_BEHAVIOR_DEFAULT_INCOMPLETE,
'collection_method' => Subscription::COLLECTION_METHOD_SEND_INVOICE,
'days_until_due' => 1,
'payment_settings' => [
'save_default_payment_method' => 'on_subscription',
],
'billing_mode' => [
'type' => 'classic',
],
'items' => $this->getCheckoutSessionLineItems($cart, true),
'automatic_tax' => [
'enabled' => true,
],
'transfer_data' => [
'destination' => $trainingUser->getStripeConnectAccountId(),
],
'expand' => ['latest_invoice']
]);
$stripeInvoice = $stripeSubscription->latest_invoice;
$stripeInvoice = Invoice::update($stripeInvoice->id, [
'application_fee_amount' => $this->getApplicationFeeAmount($trainingUser, $stripeInvoice)
]);
$stripeInvoice->finalizeInvoice([
'expand' => ['confirmation_secret']
]);
$stripeSubscription->latest_invoice->confirmation_secret = $stripeInvoice->confirmation_secret;
return $stripeSubscription;
Even if put default_incomplete, just adding send_invoice makes the subscription active
I would need to recalculate the percentage if the user changes of product right ?
You shouldn't create the Subscription untill the customer confirms that they want some product
You need to postpone the creation of the Subscriprion as far as possible. Otherwise, delete the old one and create another one if needed
Okay I see, thank you ๐