#tymm

1 messages · Page 1 of 1 (latest)

stark stumpBOT
lament plank
#

Yep promotion code is mean to share with your customer, and they apply it when checkout on your website

#

And many customer can use the same promotion code

small dove
#

where should i put this code the customer typed when i call the upcoming invoice api?

lament plank
#

It's not compatible with Invoice unfortunately. Only coupon and discount can

small dove
#

ok thanks

#

hi, i applied a coupon that was not meant for a product. however the upcoming invoice api is not throwing error, how do u suggest i handle this? i am expecting error from the api

lament plank
#

Um if you use test clock to advance do you see the error you expected?

small dove
#

what do u mean

#

just tried calling the upcoming invoice api after advancing time , still same

lament plank
#

So if you use a Test Clock to test the Subcription, in the Upcoming Invoice API you expect an error because the coupon is not meant for that product, right. There is one way to validate, that if you advance the test clock to make the Upcoming Invoice really happen, you can see if it errored

#

I mean advance over the timing the Invoice will be generated

#

to see the real invoice

small dove
#

that would be too late and awkward in the flow. i want to show the user some error and stop them from proceeding to finalizing the invoice.

lament plank
#

I know, I mean we are just testing.

small dove
#

no error either

#

this is the invoiceid in_1Mh2JVLK0bfo5HSbwX461SRs

lament plank
#

Okie so there maybe misunderstanding about coupon and product

#

which coupon and how are you calling the Upcoming Invoice?

small dove
#
InvoiceUpcomingParams.Builder paramsBuilder = InvoiceUpcomingParams.builder()
                .setCustomer(customer.getId())
                .setSubscription(existingSub.getId())
                .setSubscriptionProrationBehavior(InvoiceUpcomingParams.SubscriptionProrationBehavior.ALWAYS_INVOICE)
                .addSubscriptionItem(
                        InvoiceUpcomingParams.SubscriptionItem.builder()
                                .setId(existingSiId)
                                .setPrice(priceId)
                                .build())
                .setSubscriptionProrationDate(nowEpoch)
                .setCoupon(couponCode == null ? "" : couponCode);

        return Invoice.upcoming(paramsBuilder.build());
#

coupon id = IMCRAZY

#

the final amount that the customer has to pay is not wrong, if it applied it would be half price. but the inconsistent behavior between applying an invalid coupon and a coupon that is not meant for a product is giving me trouble handling these cases elegantly

lament plank
#

Can you provide the request id? req_xxx

#

I can't locate coupon by just the Id

small dove
#

upcoming invoice should be this : req_ODOs8weetIJpBc or req_yuZBwXZqrYGdge

subscription : req_TJOaTuK3ThrTls

lament plank
#

req_ODOs8weetIJpBc or req_yuZBwXZqrYGdge is the request to get an Invoice. I meant the Upcoming Invoice API request

lament plank
#

Um only applied to a Products mean if there is a price of that product it will apply, otherwise it won't take any effect, but won't error at all