#tymm

1 messages ยท Page 1 of 1 (latest)

lime cliffBOT
green shadow
#

Hi there, can you tell me how you apply a coupon?

lyric sierra
#

paramsBuilder.setCoupon(couponCode); where paramsBuilder is of class SubscriptionCreateParams.Builder

#

then Subscription.create(paramsBuilder.build())

green shadow
#

Ok, so you apply the coupon on the subscription itself.

#

yes the coupon will be applied to the invoices generated by the subscription, including invoice items that you are adding to

lyric sierra
green shadow
lyric sierra
#

i cannot use invoice. i have to set things like proration date, backdate startdate, prorations, etc

#

and also i have all other stuffs built using subscriptions already

#

i want to be able to apply coupon to a subscription, at the same time also able to add a one time fee to the subscription and not get affected by the coupon

lime cliffBOT
thorn perch
#

you can't really, we don't support per-item discounts on Subscriptions today unfortunately, it's a known gap but the functionality was only implemented for one-off invoices and hasn't been prioritised to expand to subs . Make sure to write to https://support.stripe.com/?contact=true to raise feature requests for the team

without that, what is probably best is to add negative invoice items to the Subscription in order to apply discounts of an amount you calculate, instead of coupons.

lyric sierra
#

are we able to charge a one time arbitrary amount to a subscription?

thorn perch
#

in several ways yes.

lyric sierra
#

what i meant was i want to charge an extra amount on the fly , after reverse-calculating the amount of one time fee that would be charged after applying a coupon. i saw this api, seems promising, am still testing it.

if(coupon != null){
    charge = charge / (coupon.getPercentOff().doubleValue() / 100);
}
paramsBuilder.addAddInvoiceItem(
        SubscriptionCreateParams.AddInvoiceItem.builder()
                .setPriceData(SubscriptionCreateParams.AddInvoiceItem.PriceData.builder()
                        .setCurrency("myr")
                        .setProduct("Service Charge")
                        .setUnitAmount(charge.longValue())
                        .setTaxBehavior(SubscriptionCreateParams.AddInvoiceItem.PriceData.TaxBehavior.INCLUSIVE)
                        .build()
                )
                .build()
);
thorn perch
#

adding an invoice item will incorporate it into the next Invoice on the subscription. Or you can force the next invoice by updating the subscription with billing_cycle_anchor:"now" ; or you can create a separate one-off invoice for the customer with the item; or you can charge the customer's card directly with a PaymentIntent

lyric sierra
thorn perch
#

you can pass amount/currency directly instead of using a Price/Product (we just try to discourage that because we want you to have your product catalogue on Stripe)

lyric sierra
lyric sierra
thorn perch
#

you can though

#

i have tested this and i saw that the subsequent invoice doesnt have the service charge.
adding an invoice item with https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items is a one-time thing, it adds one item, and that one item is pulled into one future invoice. Maybe that wasn't clear? but you also never mentioned to me that you wanted anything recurring here, you just said 'charge a one time arbitrary amount to a subscription?' which is exactly what this is and what happened ๐Ÿ˜…

lyric sierra
#

ah maybe i misunderstood what u meant by next invoice.

yes, this one-time behavior is exactly what i want, minus the part where a MYR 1 service charge became MYR 0.5 due to a 50% off coupon being applied.
this is also why i said i planned to "reverse-calculate" the service charge manually, so that i would add a MYR 2 service charge and after the coupon is being calculated, the final service charge would theorically be MYR 1

thorn perch
#

minus the part where a MYR 1 service charge became MYR 0.5 due to a 50% off coupon being applied.
coupons apply to the entire Subscription Invoice, (as I said earlier, per-item discounts are not supported today)

#

so yeah, you can make the item 2 MYR instead I suppose so it nets out to the correct amount.

lyric sierra
thorn perch
#

can i actually use this on a subscription?
it adds an invoice item to the Customer and that item is charged in the next Invoice for the customer, e.g. in the next Subscription Invoice they have

#

so I don't understand the question, of course you can use it with a Subscription, you just did exactly that in the test you showed me

#

i want the service charge and the subscription be in one transaction tho
not sure what a 'transaction' means here, but like an Invoice with 100 items is only charging the customer's card once(for the total), not 100 times

lyric sierra
thorn perch
#

probably because we removed it from the Java SDK for the reasons I mentioned earlier of us wanting you to have a product catalogue

#

sorry, I know that's annoying but it's a policy that we have, we don't remove things from the API but sometimes we deprecate them from the SDKs to make them less discoverable/nudge people towards the integrations we want

#

you can still pass it using .putExtraParam("amount", "4242") on the Param Builder class

lyric sierra
thorn perch
#

no, it's one time

#

you can add it each month, technically; like listen to the invoice.upcoming event and add it then. But then why don't you simply add it as a normal recurring Product/Price to the Subscription? I think you need to take a step back and think over things

lyric sierra
#

no, one time is what i want, just making sure

#

because after looking at the docs i cannot understand how to use it still

#

so programmatically i would create the subscription first, then create an invoice item that links to the subscription ?

#

right now i would create a subscription, and from there i get the invoice object. do i add the one time charge there?

arctic copper
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

#

Just to summarise, you want to add a one-time item to an upcoming Invoice? Or charge the Customer outside of their normal billing cycle?

lyric sierra
#

i want to add a one-time charge onto a subscription when im creating the subscription

#

the subscription can have prorations, backdate and also coupon. the one-time charge should not be affected by those settings

arctic copper
lyric sierra
arctic copper
#

Have you tried this?

#

Coupons can be configured to apply to selected Products.

lyric sierra
#

ok let me try

#

ok it works

#

๐Ÿ˜†

#

but it would be too tedious to add all the other products one by one except for the service charge product that i do not want to add. is there a "excluding" feature on stripe?

#

else i think i could make a script to call to api then

arctic copper
#

You can generate the Coupon on the spot via API when the Subscription is created, and only include the items from Subscription.

lyric sierra
#

thanks

arctic copper
#

Happy to help!