#inquisitive_code
1 messages ¡ Page 1 of 1 (latest)
đ 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/1242423778563199058
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Will this automatically charge the customer? If yes, is there any way to verify it from the dashboard > invoices?
No, you'd need to confirm the intent that is generated by the invoice: https://docs.stripe.com/invoicing/integration?method=elements#accept-invoice-payment
Can't I simulate the automatic payment of subscription?
Sure, what's not working as you expect?
wont' it automatically charge the customer?
$invoice = $this->stripe->invoices->create([
'customer' => $stripeCustomer->id,
'collection_method' => 'charge_automatically',
'metadata' => $metaData,
'pending_invoice_items_behavior' => 'exclude'
]);
//add subscription invoice item
$this->stripe->invoiceItems->create([
'customer' => $stripeCustomer->id,
'price' => config('services.stripe.per_user_base_price_id'), // env
'quantity' => $perUserBillingDTO->baseCharge->quantity,
'description' => 'Per User Subscription Base Price',
'invoice' => $invoice->id
]);
//add extra invoice item
if(!empty($perUserBillingDTO->extraCharge->quantity)){
$this->stripe->invoiceItems->create([
'customer' => $stripeCustomer->id,
'price' => config('services.stripe.per_user_price_id'), // env
'quantity' => $perUserBillingDTO->extraCharge->quantity,
'description' => 'Extra Per User Subscription Fee',
'invoice' => $invoice->id
]);
}
//finalize invoice
$this->stripe->invoices->finalizeInvoice($invoice->id);
so you mean at the end I should attach the payment intent like this?
$stripe->invoices->finalizeInvoice(
'{{INVOICE_ID}}',
['expand' => ['payment_intent']]
);
The guide I linked has a full API integration guide
But no, invoices created via API won't auto charge a customer
so what should I be doing instead?
I think I already answered that
I still do not get it, that it looks like the code is passing the invoice to the payment page and user themselves is making the payment. Right?
Isn't there any other way to create a invoice on start of the month based on the usage of the customer on last month and let stripe collect the payment automatically?
I still do not get it, that it looks like the code is passing the invoice to the payment page and user themselves is making the payment. Right?
Well, if you need to collec tpayment information from them yes. That will facilitate collecting that. Otherwise, if there's already an payment method set on the invoice/intent you can just callconfirmPaymentand pass the existingpm_xxxID
Isn't there any other way to create a invoice on start of the month based on the usage of the customer on last month and let stripe collect the payment automatically?
Why are you not using the Subscriptions API to automate this? https://docs.stripe.com/billing/subscriptions/usage-based
yes they already do have the payment method
One way I do see is using $invoice->pay(). But instead of running the job I was looking for stripe trying themselves to collect payment
Stripe will do it, after the invoice is finalized we will eventually pick it up and attempt to charge it(I think it takes an hour). Or you can force payment earlier using the approaches discussed.
can I simulate to verify if it will charge the customer or not?
if so, how can I verify it. Also, this invoice is the one creating using the above shared code though.
https://docs.stripe.com/billing/testing/test-clocks should do it
Here
this was the invoice generated manually and is not related to any subscription. will i still be able to do it?