#Magic Mage
1 messages · Page 1 of 1 (latest)
Hi 👋
Can you describe your overall question?
Basically so far in my code I never added anything that can be used as line items for invoices, and well I have the complex need to be able to credit differences for cases where a customer owes less than what they paid (when they change something after they paid). So for this I am asking if payment intents can accept in a negative amount to cover this use case?
Okay first off.
What are you trying to do with Stripe. It sounds like you are trying to create an Invoice but it's not clear
I create the payment intent like so:
public static async Task<string> CreatePaymentIntentAsync(string customerName, string email, decimal amount, string description)
{
// first obtain customer if it exists, if not then we create it for the payment intent to use.
var customerService = new CustomerService();
var customers = customerService.ListAutoPaging(new CustomerListOptions() { Email = email });
var customer = customers.Where(customer => customer.Email == email).FirstOrDefault();
if (customer == null)
{
var customerOptions = new CustomerCreateOptions
{
Name = customerName,
Email = email,
};
customer = customerService.Create(customerOptions);
}
var options = new PaymentIntentCreateOptions()
{
Amount = (long?)(amount * 100),
Description = description,
Currency = "usd",
Customer = customer.Id,
AutomaticPaymentMethods = new PaymentIntentAutomaticPaymentMethodsOptions()
{
Enabled = true,
},
SetupFutureUsage = "on_session",
};
var service = new PaymentIntentService();
var paymentIntent = await service.CreateAsync(options);
return paymentIntent.ClientSecret;
}
However, due to the lack of things to use invoices in the place of this it looks like I would need to use this, however I am wondering if this can work with negative amounts (for the case where customers need to be credited).
Okay let's keep zooming out then. What is the overall thing you are trying to achieve here? What is is that Payment Intents doesn't allow that is making you consider invoicing?
I was considering invoices for cases where say a user downgrades a "plan", then credit them, if a user upgrades a "plan", then charge more. However after reading it more, there is no way to update it (without creating a new invoice) after they initially pay.
Are you implementing a Subscription service?
I would like to make it like that yes, but it's also unclear if it would invoke the webhook every month on successful payments for each customer.
Webhook events aren't something you invoke. They are sent by Stripe and triggered when events occur on your Stripe Account, like a customer paying their invoice.
Yeah, I was wondering if it would be sent every month when their payments go through if I did it like that.
The webhook event will fire every time a Customer pays their invoice. We fire multiple webhook events in this case. I would recommend testing that process
ok
You can use the Stripe CLI to see the webhook events that will fire