#oleg.moseiko
1 messages · Page 1 of 1 (latest)
đź‘‹ You can use Upcoming invoice API to preview the calculations
https://stripe.com/docs/billing/subscriptions/prorations
like this
{
"subscription_items": {
"quantity": "8",
"id": "si_OaHaGmExydB3mm",
"price": "price_1Nj0ypCeECk9Gr0o2nVNj17k"
},
"customer": "cus_OaGRPP0tlXq0Lp"
}
i have error
{
"error": {
"message": "Invalid array",
"param": "subscription_items",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_xPw3xmoHqBMQ8U?t=1694005853",
"type": "invalid_request_error"
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
bad understand doc about parameters
You need to pass in an array, you're passing an object/hash
yes i got it few secons before))
but
subscription
optional
.... If neither subscription nor subscription_items is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.
So the subscription item you're passing doesn't actually belong to a subscription?
It does though right?
sub_1Nn5ulCeECk9Gr0o59m2bGt0
this subscription i try to update so i added subscription id and got invoice
but it is new not saved subscription i can not pass subscription
correct?
have you tried passing it though? Do you see an error when you pass the ID?
i have no error if i pass subscription id
Great, do you see the calculations?
yes
Awesome! 👍
what about draft invoice
?
/ Define an array of subscription items with prices
$subscriptionItems = [
[
'price' => 'price_1234567890', // Replace with the actual Price ID
'quantity' => 1,
],
// Add more subscription items if needed
];
// Create a draft invoice with the subscription items
$draftInvoice = $stripe->invoices->create([
'customer' => $customerID,
'subscription_items' => $subscriptionItems,
'auto_advance' => false, // Set to false to create a draft invoice
]);
// Retrieve the upcoming invoice for the customer with the draft invoice's ID
$upcomingInvoice = $stripe->invoices->upcoming([
'customer' => $customerID,
'subscription' => $draftInvoice->subscription, // Use the draft invoice's subscription ID
]);
what way is good?
Sorry not sure I follow
Not sure, just try it out