#queen-subscription-proration
1 messages ยท Page 1 of 1 (latest)
queen-subscription-proration
@waxen thorn what you can do is calculate proration, create an InvoiceItem https://stripe.com/docs/api/invoiceitems/create for that amount and then update the Subscription to the new Price and create an Invoice for that specific proration to charge separately
Thanks. I tryed this way. I created an invoiceItem but this item was added to the next invoice which is at next year. I want to charge immediately. Is there anything I can do ?
Yes you do exactly what I said above: Create the Invoice after to invoice the customer for that amount
$stripe->invoiceItems->create([
'customer' => $user->stripe_customer_id,
'amount' => $firstTimePayment * 100,
]);
$subscription = $stripe->subscriptions->update(
$subscription->id,
[
'cancel_at_period_end' => false,
'proration_behavior' => 'None',
'items' => [
[
...
],
],
'metadata' => [
...
],
]
);
Like this ?
yes and no. That creates an InvoiceItem, then updates the Subscription. You never created an Invoice.
1/ the InvoiceItem should have subscription: 'sub_123' so that it's associated with it
2/ you're missing a call to create the Invoice after https://stripe.com/docs/api/invoices/create
$stripe->invoiceItems->create([
'customer' => 'cus_9s6XKzkNRiz8i3'
'amount' => $firstTimePayment * 100,
'subscription' => $subscription->id,
]);
$stripe->invoices->create([
'customer' => 'cus_9s6XKzkNRiz8i3',
'subscription' => $subscription->id,
]);
$subscription->update(...)
how about this ?
yes that should work, try it in Test mode end to end really!
Sure, thanks
Hi, this create a draft invoice successfully but can I auto charge that invoice as well?
Hey there
Stepping in as koopajah needed to step away
So you can hit the /pay endpoint if you want to charge it immediately
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
$stripe->invoiceItems->create([
'customer' => 'cus_xxx',
'amount' => $firstTimePayment * 100,
'subscription' => $subscription->id,
'currency' => 'usd',
]);
$invoice = $stripe->invoices->create([
'customer' => 'cus_xxx',
'subscription' => $subscription->id,
]);
$stripe->invoices->pay($invoice->id);
like this ?
Yep that looks good to me
thanks. That works
๐