Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.x] Stripe API and SDK update #1615

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"illuminate/view": "^9.21|^10.0",
"moneyphp/money": "^4.0",
"nesbot/carbon": "^2.0",
"stripe/stripe-php": "^7.39|^8.0|^9.0|^10.0",
"stripe/stripe-php": "^13.0",
"symfony/http-kernel": "^6.0",
"symfony/polyfill-intl-icu": "^1.22.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Cashier
*
* @var string
*/
const STRIPE_VERSION = '2022-11-15';
const STRIPE_VERSION = '2023-10-16';

/**
* The base URL for the Stripe API.
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/ManagesInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,18 @@ public function createInvoice(array $options = [])
{
$this->assertCustomerExists();

$stripeCustomer = $this->asStripeCustomer();

$parameters = array_merge([
'automatic_tax' => $this->automaticTaxPayload(),
'customer' => $this->stripe_id,
'currency' => $stripeCustomer->currency ?? config('cashier.currency'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There cannot be multiple currencies anymore on invoices so we'll use the one from the customer or fallback to the Cashier default.

], $options);

if (isset($parameters['subscription'])) {
unset($parameters['currency']);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currency cannot be combined with subscription so we allow subscription to take precedence.

if (array_key_exists('subscription', $parameters)) {
unset($parameters['pending_invoice_items_behavior']);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Concerns/PerformsCharges.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function createPayment($amount, array $options = [])
$options['customer'] = $this->stripe_id;
}

if ($options['confirm'] ?? false) {
$options['return_url'] ??= route('home');
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a payment intent is being confirmed, we'll always need to supply a return url.

return new Payment(
static::stripe()->paymentIntents->create($options)
);
Expand Down
4 changes: 3 additions & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,9 @@ public function invoiceLineItems()
*/
public function tab($description, $amount, array $options = [])
{
$item = $this->owner()->tab($description, $amount, array_merge($options, ['invoice' => $this->invoice->id]));
$item = $this->owner()->tab($description, $amount, array_merge($options, [
'invoice' => $this->invoice->id,
]));

$this->refresh();

Expand Down
Loading