#devparry

1 messages · Page 1 of 1 (latest)

noble pulsarBOT
fresh vortex
#

Hi there, the product object doesn't carry information about prices. Instead, you should call the price list API with product field expanded.

viral sandal
#

Hi Jack thanks for your help

#

Actually, I need these price lists in the subscription.

#

as you can see under this product we have two prices one is monthly and 2nd is one time which only decudt first time

#

'add_invoice_items' => [['price' => '{{PRICE_ID}}']], under this i have to add 2nd price id

fresh vortex
#

So you want to get the price from an existing subscription?

viral sandal
#

no, only while creating new subscription

fresh vortex
#

Hmm, but you already know the price when creating a subscription.

viral sandal
#

Actually not, let me explain my requiremnt

#

we have already created a system where the admin can create plans under admin plans which create on stripe as well using stripe API https://stripe.com/docs/api/plans/create based on that users can take subscriptions that are already working fine with the help of Stripe subscription apis ( This functionality we have done in 2020 )

Now as per the Stripe new upgradation we are updating our system as well. One more additionally feature are want to add under it is First-time payment
E.g we have a Standard Plan containing $10 monthly changes + $5 for the first month only ( Installation Charges )
which means the user has to pay $15 for 1st month and next all month $10 each only

So i found it can be only done by this code.
$subscription = Subscription::create([ 'customer' => $stripe_customer_id, 'items' => [[ 'price' => $default_price_id, ]], 'add_invoice_items' => [['price' => '{{PRICE_ID}}']], 'payment_behavior' => 'default_incomplete', 'payment_settings' => ['save_default_payment_method' => 'on_subscription'], 'expand' => ['latest_invoice.payment_intent'], ]);

now I have to get the default price from the product. but i don't know how to get the 2nd price_id which i have to under add under
'add_invoice_items' => [['price' => '{{PRICE_ID}}']], {{PRICE_ID}}

fresh vortex
#

OK, then you should call the price List API and pass in the product ID, it will return you all prices that are created for given product