Skip to content

Commit

Permalink
[14.x] Update to new Stripe version (#1417)
Browse files Browse the repository at this point in the history
* Bump to Stripe 2022-08-01 API version

* Fix issues with invoices
  • Loading branch information
driesvints authored Aug 11, 2022
1 parent e6bf980 commit 3934377
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Cashier
*
* @var string
*/
const STRIPE_VERSION = '2020-08-27';
const STRIPE_VERSION = '2022-08-01';

/**
* The base URL for the Stripe API.
Expand Down
5 changes: 2 additions & 3 deletions src/Concerns/ManagesInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public function invoice(array $options = [])
{
try {
$invoice = $this->createInvoice(array_merge([
'pending_invoice_items_behavior' => 'include_and_require',
'pending_invoice_items_behavior' => 'include',
], $options));

return $invoice->chargesAutomatically() ? $invoice->pay() : $invoice->send();
} catch (StripeCardException $exception) {
} catch (StripeCardException) {
$payment = new Payment(
$this->stripe()->paymentIntents->retrieve(
$invoice->asStripeInvoice()->refresh()->payment_intent,
Expand All @@ -148,7 +148,6 @@ public function createInvoice(array $options = [])
$parameters = array_merge([
'automatic_tax' => $this->automaticTaxPayload(),
'customer' => $this->stripe_id,
'pending_invoice_items_behavior' => 'exclude',
], $options);

$stripeInvoice = $this->stripe()->invoices->create($parameters);
Expand Down
12 changes: 0 additions & 12 deletions tests/Feature/InvoicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Laravel\Cashier\Exceptions\InvalidCustomer;
use Laravel\Cashier\Exceptions\InvalidInvoice;
use Laravel\Cashier\Invoice;
use Stripe\Exception\InvalidRequestException as StripeInvalidRequestException;
use Stripe\InvoiceItem as StripeInvoiceItem;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

Expand All @@ -20,17 +19,6 @@ public function test_require_stripe_customer_for_invoicing()
$user->invoice();
}

public function test_invoicing_fails_with_nothing_to_invoice()
{
$user = $this->createCustomer('invoicing_fails_with_nothing_to_invoice');
$user->createAsStripeCustomer();
$user->updateDefaultPaymentMethod('pm_card_visa');

$this->expectException(StripeInvalidRequestException::class);

$user->invoice();
}

public function test_invoices_can_be_created()
{
$user = $this->createCustomer('invoices_can_be_created');
Expand Down

0 comments on commit 3934377

Please sign in to comment.