Skip to content

Commit 92eb7d8

Browse files
[11.x] Send invoice (#942)
* Use sendInvoice() when collection method is 'send_invoice' In some edge cases (like mine) we have clients that can't use a credit card, but we still want to have all the data in Stripe. So we create a subscription with collection_method = 'send_invoice' and the manually sent the invoices to be paid, once we received payment we just change the status manually in Stripe. ´´´ $model->invoice(['collection_method' => 'send_invoice']); $subscription->invoice(['collection_method' => 'send_invoice']); ´´´ When you use this collection method you can't apply $stripeInvoice->pay() function, you need to use the $stripeInvoice->sendInvoice(); When using the $stripeInvoice->pay() on when a colletion_method is 'send_invoice' it throws PaymentFailure, it doesn't require a payment method. The only two options in 'collection_methods' is charge_automatically (default) or 'send_invoice' there fore using a simple if else statement. https://stripe.com/docs/api/invoices/create#create_invoice-collection_method * Use constant Co-authored-by: Erik Larsson <eriklarsson@me.com>
1 parent 3c8ee44 commit 92eb7d8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Concerns/ManagesInvoices.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ public function invoice(array $options = [])
7676
/** @var \Stripe\Invoice $invoice */
7777
$stripeInvoice = StripeInvoice::create($parameters, $this->stripeOptions());
7878

79-
$stripeInvoice = $stripeInvoice->pay();
79+
if ($stripeInvoice->collection_method === StripeInvoice::COLLECTION_METHOD_CHARGE_AUTOMATICALLY) {
80+
$stripeInvoice = $stripeInvoice->pay();
81+
} else {
82+
$stripeInvoice = $stripeInvoice->sendInvoice();
83+
}
8084

8185
return new Invoice($this, $stripeInvoice);
8286
} catch (StripeInvalidRequestException $exception) {

0 commit comments

Comments
 (0)