Skip to content

Commit

Permalink
Pass pay options to pay method (#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Oct 27, 2022
1 parent e168e65 commit 560ecfb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Concerns/ManagesInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Cashier\Concerns;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Laravel\Cashier\Exceptions\InvalidInvoice;
use Laravel\Cashier\Invoice;
Expand Down Expand Up @@ -118,11 +119,22 @@ public function invoicePrice($price, $quantity = 1, array $tabOptions = [], arra
public function invoice(array $options = [])
{
try {
$payOptions = Arr::only($options, $payOptionKeys = [
'forgive',
'mandate',
'off_session',
'paid_out_of_band',
'payment_method',
'source',
]);

Arr::forget($options, $payOptionKeys);

$invoice = $this->createInvoice(array_merge([
'pending_invoice_items_behavior' => 'include',
], $options));

return $invoice->chargesAutomatically() ? $invoice->pay() : $invoice->send();
return $invoice->chargesAutomatically() ? $invoice->pay($payOptions) : $invoice->send();
} catch (StripeCardException) {
$payment = new Payment(
$this->stripe()->paymentIntents->retrieve(
Expand Down

0 comments on commit 560ecfb

Please sign in to comment.