#dbjpanda

1 messages · Page 1 of 1 (latest)

dawn tinselBOT
dense wharf
sharp condor
#

I don't want to use a coupon. Is it possible to directly add an amount to be deducted?

dense wharf
#

No. That's what coupons and discounts are for

#

Actually, hold on

#

You can create a negative Invoice Item to add that one-time credit

sharp condor
#

I was trying to add an invoice with negative value. But it doesn't take negative umber

add_invoice_items: [{
price_data: {
currency: 'inr',
unit_amount: -900,
product: 'prod_NerxLA7HNPeeKx'
},
quantity: 1,
}],

dense wharf
#

There you go. Looks like you found the answer

sharp condor
#

It says Invalid non-negative integer

#
const subscriptionSwitched =  await stripe.subscriptions.update(
            userData.current_plan.subscription_id,
            {
                items: [{
                    id: userData.current_plan.item_id,
                    price: price_id,
                }],
                proration_behavior: 'none',
                add_invoice_items: [{
                    price_data: {
                        currency: 'inr',
                        unit_amount: '-900',
                        product: 'prod_NerxLA7HNPeeKx'
                    },
                    quantity: 1,
                }],
                payment_behavior: 'pending_if_incomplete',
                expand: ['latest_invoice.payment_intent'],
                billing_cycle_anchor : 'now'
            },
        );
#

@dense wharf ^^^

dense wharf
#

You can't create a negative Price. You have to use the amount attribute on the Invoice Item object

sharp condor
#

I could not get you. Can you modify above code?

dense wharf
#

const invoiceItem = await stripe.invoiceItems.create({
customer: 'cus_abc123',
amount: -100
currency: 'usd'
});

sharp condor
#

can't we directly add it inside stripe.subscriptions.update

dawn tinselBOT
dense wharf
#

Not as far as I know, because the Update+ Subscription API call only allows you to add a new Price

dawn tinselBOT