#amfpaulo_api

1 messages ¡ Page 1 of 1 (latest)

paper lanternBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1268593557527330906

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

upbeat marlin
queen mountain
#

So there is not discount feature I have to hack the system to apply a discount ?

upbeat marlin
#

This isn't hacking the system

#

It's one of several ways to apply a discount

queen mountain
#

It looks like

upbeat marlin
#

What do you mean

queen mountain
#

This way will not work for me, what are other ways ?

#

I need to apply a discount to a invoice

#

A negative item involves creating a price the is negative, etc

queen mountain
#

All I need its apply a discount to the invoice also subscription

upbeat marlin
#

You just pass an amount

#

No need to create a price

upbeat marlin
queen mountain
#

just a second let me take a look on the code

upbeat marlin
#

All this is covered in the docs

#

(Including my initial suggestion of negative invoice items)

queen mountain
#

this is the way I am creating the item for my subscription:

Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions { Price = request.PriceId }
},

paper lanternBOT
queen mountain
#

Just adding another : new SubscriptionItemOptions { } to it with negative value ?

#

there is no property to inform a dollar value

#

Could you explaing how to do this ?

atomic olive
#

Hello
Taking over here

queen mountain
#

Hello hanzo

#

how are you doing today ?

#

PriceData is the field I should add a negative dollar amount ?

atomic olive
#

I'm doing well. Thanks for asking..
How can I help? I see you're trying to add a discount..

If you're trying to create an negative invoice item then you'd want to use InvoiceItems API for that: https://docs.stripe.com/api/invoiceitems/create

queen mountain
#

Lets start over, this is getting confuse

#

The previous support person advice me to use a negative item

atomic olive
#

Right, since you want to apply "an amount" as discount, that's the way to go

queen mountain
#

I am trying to acomplish the discount on a invoice, and I also need to apply to subscription

#

Invoice item have a field Amount

#

but subscription item do not have field amount, just priceId

#

it has a field PriceData, that i did not understand how to use

atomic olive
#

Is this discount one-time or recurring?

Do you want it to apply to one subscription invoice OR all invoices going forward?

queen mountain
#

its one time

#

its a one time thing, I have a point of sales, client ask for discount we negotiate and give unique discount one time only

atomic olive
#

You'd only create a subscription item if you want the item to be a recurring purchase

queen mountain
#

but every month, the discount will be applyind in case of amonthly subscription

atomic olive
#

Sorry I'm not sure I follow

#

you said it is a one-time thing but "but every month, the discount will be applyind in case of amonthly subscription"

#

what does that mean

queen mountain
#

I already have subscription and invoice working 100%, now the necessity to give the client a discount came along

#

if invoice one time only, if the purchase is a subiscription that price is $100 but I gave 10 dollar discount, so every month this client will be charged just 90

#

but if a product is not recurring and cost 100 and I give 10, just the time the product will cost 90

#

Is it making more sense now ?

atomic olive
#

so for subscriptions you want the discount to be recurring (apply every month)?

#

but for one-time invoices, it would be one-time discount

queen mountain
#

yes

atomic olive
queen mountain
#

but I am not using that couon anyware else

#

Its a client specific case

#

when a client negotiate for discount

atomic olive
#

So there's no way to apply recurring discount to a subscription without using a coupon

You can't create a negative amount subscription item

#

Other option would be to create a second price (cheaper than the original price) and update the subscription to use that

queen mountain
#

Ok, So, in this case, I'll need to create coupons for every discount I give ?

#

I cant create second price becaue this is not standarized discount, its negotiation discount

#

can be 1dollar, 10, 17, etc

atomic olive
#

Yeah you'd need to create a coupon for each negotiated discount and apply that to the subscription

queen mountain
#

ok.

#

what is the diff between : forever and repeating.

#

for duration

queen mountain
#

sorry about that, I missid this part . Ok, cool . got it

#

I have a last question related to invoice: Why When I pay a invoice using the Customer default card on file it takes one hour to have the invoice paid ?

#

On more question just to make sure I understand everything correctly for subscription discount: I create the discount coupon , then I add it to the Subscription Discounts field ?

atomic olive
queen mountain
#

cool. got it right about the subscription

#

About the invoice, this behavior cannot be altered? Everytime I select use card on file for client payment, it will take 1 hour?

atomic olive
queen mountain
#

We have a gym and customers are always grabbing a water or any other drink and asking us to charge the card on file, so we use a lot this feature

#

I am finalizing manually

#

this is my C# backend code:

try
{
var options = new InvoiceCreateOptions
{
Customer = request.CustomerId,
CollectionMethod = "charge_automatically",
AutoAdvance = true,
Metadata = new Dictionary<string, string> {
{ "comission", string.Join(',', request.SalesPersonIds) },
{ "discount", request.Discount.ToString() },
},
};

        if (!string.IsNullOrEmpty(request.SetupIntentId))
        {
            var paymentMethodId = GetLastPaymentMethod(request.SetupIntentId);
            UpdateDeaultPayment(request.CustomerId, paymentMethodId);

            options.DefaultPaymentMethod = paymentMethodId;
        }

        var invoiceService = new InvoiceService();
        var invoice = invoiceService.Create(options);

        new InvoiceItemService().Create(new InvoiceItemCreateOptions
        {
            Invoice = invoice.Id,
            Customer = request.CustomerId,
            Price = request.PriceId,                
        });

        invoiceService.FinalizeInvoice(invoice.Id);

        return CustomResponse(new { Success = true, SubscriptionId = invoice.Id });
    }
    catch (StripeException e)
    {
        NotifyError($"Error creating Invoice! {e.Message}");
        return CustomResponse();
    }
atomic olive
queen mountain
#

I thought about that, but was awkward from my perspective. So if I use the Pay API and do: service.Pay("in_xtp...."); the system will know the invoice client and also know it has a card on file as option to pay , moreover invoice would be paid ?

atomic olive
#

the system will know the invoice client
Not sure I understand this part

#

You're creating the invoice for the customer

#

If the customer doesn't have a card on the file then that would fail

queen mountain
#

I understand that

#

in my case, the invoice is for a customer that has a card on file

#

Anyways, I'll try progress here and if I need more help I'll make contact again. Your help was very good I can now progress with the solution

#

Thank you