#ruben_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1258169057627213857
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
The only way to place a hold on the card is to work with the Payment Intent. There's no functionality to do that on an Invoice.
If you need to use a hold alongside an Invoice ahead of charging the Invoice you'd need to create and confirm a Payment Intent that's separate from the invoice, as far as I know
New to this so i'm asking AI for assistance:
Does this seem about right:
Explanation:
When you create a subscription with collection_method set to send_invoice and payment_behavior set to default_incomplete, Stripe generates an invoice in an incomplete status if the payment fails or hasn't been confirmed yet. This status indicates that the invoice is awaiting further action, such as payment confirmation or additional authentication. The invoice system in Stripe doesn't support placing a hold on the card directly; this functionality is specific to Payment Intents.
Approach to Solve the Problem:
Create and Confirm a Payment Intent Separately:
Since Stripe invoices don't support placing a hold directly, you should create a separate Payment Intent to place a hold on the card.
After the Payment Intent is confirmed and placed on hold, you can use it to pay the invoice when it's generated.
Workflow Example:
Step 1: Create a Payment Intent with capture_method set to manual to place a hold.
Step 2: Create the subscription and generate the invoice.
Step 3: When the invoice is generated, use the held Payment Intent to pay the invoice.
Step 1: Create a Payment Intent
php:
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => 39900, // The amount to hold
'currency' => 'usd',
'customer' => $customer->id,
'payment_method' => $customer->invoice_settings->default_payment_method, // Use the saved payment method
'capture_method' => 'manual',
'confirm' => true,
]);
Step 2: Create the Subscription
php:
$subscription = \Stripe\Subscription::create([
'customer' => $customer->id,
'items' => [
['price' => 'price_1PXyF7Bl8ntMl2lqJjFuAu8X'],
],
'billing_cycle_anchor' => $nextMonday,
'proration_behavior' => 'none',
'collection_method' => 'send_invoice',
'days_until_due' => 5,
'payment_behavior' => 'default_incomplete',
]);
Step 3: Use the Held Payment Intent to Pay the Invoice
When the invoice is generated and you forward time, retrieve the invoice and confirm the Payment Intent to pay the invoice:
php
// Retrieve the invoice created by the subscription
$invoice = \Stripe\Invoice::retrieve('in_1PYNoeBl8ntMl2lqOAxkQvvU');
// Use the Payment Intent created in Step 1 to pay the invoice
$paymentIntentId = $invoice->payment_intent;
$paymentIntent = \Stripe\PaymentIntent::retrieve($paymentIntentId);
if ($paymentIntent->status == 'requires_capture') {
$paymentIntent->capture();
}
Thanks for all your help ๐
New to discord. love it.
I believe you can go through that progression of actions, but you need to update the Invoice to turn auto_advance off (https://docs.stripe.com/api/invoices/update#update_invoice-auto_advance) and then you need to finalize the Invoice in order for the Payment Intent to be generated and attached to the Invoice (https://docs.stripe.com/api/invoices/finalize).
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
My man thank you so much for the response. A lot clearer for me. Thanks again