#oleg.moseiko

1 messages · Page 1 of 1 (latest)

balmy lilyBOT
cedar hazel
jaunty flare
#

like this

#

{
"subscription_items": {
"quantity": "8",
"id": "si_OaHaGmExydB3mm",
"price": "price_1Nj0ypCeECk9Gr0o2nVNj17k"
},
"customer": "cus_OaGRPP0tlXq0Lp"
}

#

i have error

#

bad understand doc about parameters

cedar hazel
#

You need to pass in an array, you're passing an object/hash

jaunty flare
#

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.

cedar hazel
#

So the subscription item you're passing doesn't actually belong to a subscription?

#

It does though right?
sub_1Nn5ulCeECk9Gr0o59m2bGt0

jaunty flare
#

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?

cedar hazel
#

have you tried passing it though? Do you see an error when you pass the ID?

jaunty flare
#

i have no error if i pass subscription id

cedar hazel
#

Great, do you see the calculations?

jaunty flare
#

yes

cedar hazel
#

Awesome! 👍

jaunty flare
#

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?

cedar hazel
#

Sorry not sure I follow

jaunty flare
#

if i will create $draftInvoice

#

and than call $stripe->invoices->upcoming

cedar hazel
#

Not sure, just try it out

jaunty flare
#

ok

#

thanks