#JonnyDenGro
1 messages · Page 1 of 1 (latest)
How are you accepting the subscription payment? In a custom flow with the payment element? Or in our hosted Checkout flow?
We are using custom code along with the Stripe API
$this->stripeSubscriptionRepository->add($object->customer, $object->price, $object->taxRate, $object->coupon);
$payload = [
'customer' => $customer->customer_id,
'trial_from_plan' => $customer->can_trial,
'billing' => 'charge_automatically',
'items' => [
[
'plan' => $billingPrice->price_id,
'quantity' => 1,
],
],
'expand' => ['latest_invoice', 'latest_invoice.payment_intent'],
];
if ($coupon !== null) {
$payload['coupon'] = $coupon->id;
}
if ($taxRate !== null) {
$payload['default_tax_rates'] = [$taxRate->id];
}
if ($customer->is_invoiced === true) {
$payload['billing'] = 'send_invoice';
$payload['days_until_due'] = 30;
}
return $this->stripeClient->subscriptions->create($payload);
So is the customer online providing his payment method details? Or are you creating a subscription after you've already collected the payment method details?
We are generally creating a subscription after we've already collected the payment method details
Ok gotcha. And out of curiosity, why do you need this delay?
We have had a customer complain, basically when they created their subscription, they were charged for the first product (a licence for our product).
A few minutes later the incremented this and added another 3 licences.
Now as these weren't added to the initial invoice, next months invoice has 4 licences (full payment for the upcoming month) and 3 licences (prorated for the current month)
So having a slight delay here would have captured the extra licences in the initial invoice
Got it
So you could pass default_incomplete when creating the subscription. You'll have to manually pay the first invoice to make the sub active
Okay thank you, I shall take a read over the linked documentation
No problem