Skip to content

Commit

Permalink
Merge branch 'release/5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Apr 9, 2024
2 parents be098f6 + adc62be commit 602504c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- v4
- develop
- main
pull_request:
Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Release Notes for Stripe for Craft Commerce

## 5.0.0
## 5.0.1 - 2024-04-09

- Fixed a bug where floating point rounding precision could cause payments/refunds to fail. ([#296](https://github.com/craftcms/commerce-stripe/pull/296))
- Fixed a PHP error that could occur when handling a webhook request. ([#294](https://github.com/craftcms/commerce-stripe/issues/294))

## 5.0.0 - 2024-03-25

- Stripe now requires Craft Commerce 5.0.0-beta.1 or later.

## 4.1.2.2 - 2024-04-09

- Fixed a PHP error that could occur when handling a webhook request. ([#294](https://github.com/craftcms/commerce-stripe/issues/294))

## 4.1.2.1 - 2024-03-28

- Fixed a bug where floating point precision could cause payments/refunds to fail. ([#296](https://github.com/craftcms/commerce-stripe/pull/296))

## 4.1.2 - 2024-03-25

- Fixed a bug where redirects could break when adding a new payment source. ([#259](https://github.com/craftcms/commerce-stripe/issues/259), [#289](https://github.com/craftcms/commerce-stripe/issues/289))
Expand Down Expand Up @@ -59,6 +72,11 @@
- Deprecated creating new payment sources via the `commerce/subscriptions/subscribe` action.
- Fixed a bug where `craft\commerce\stripe\base\SubscriptionGateway::getSubscriptionPlans()` was returning incorrectly-formatted data.

## 3.1.2 - 2024-04-09

- Fixed a PHP error that could occur when handling a webhook request. ([#294](https://github.com/craftcms/commerce-stripe/issues/294))
- Plans’ data is now updated when the associated plan is updated in Stripe. ([#240](https://github.com/craftcms/commerce-stripe/issues/240))

## 3.1.1 - 2023-05-10

- Stripe customers’ default payment methods are now kept in sync with Craft users’ primary payment sources. ([#235](https://github.com/craftcms/commerce-stripe/issues/235))
Expand Down
4 changes: 3 additions & 1 deletion src/base/SubscriptionGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,9 @@ protected function handleInvoiceCreated(array $data): void
]));
}

$canBePaid = empty($stripeInvoice['paid']) && $stripeInvoice['billing'] === 'charge_automatically';
$stripeInvoiceBilling = isset($stripeInvoice['billing']) && $stripeInvoice['billing'] ? $stripeInvoice['billing'] : null;

$canBePaid = empty($stripeInvoice['paid']) && $stripeInvoiceBilling === 'charge_automatically';

if (StripePlugin::getInstance()->getSettings()->chargeInvoicesImmediately && $canBePaid) {
$invoice = $this->getStripeClient()->invoices->retrieve($stripeInvoice['id']);
Expand Down
6 changes: 3 additions & 3 deletions src/gateways/PaymentIntents.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function refund(Transaction $transaction): RequestResponseInterface
try {
$request = [
'charge' => $transaction->reference,
'amount' => $transaction->paymentAmount * (10 ** $currencyService->getSubunitFor($currency)),
'amount' => (int) bcmul($transaction->paymentAmount, 10 ** $currencyService->getSubunitFor($currency)),
];
$refund = $this->getStripeClient()->refunds->create($request);

Expand All @@ -304,7 +304,7 @@ public function refund(Transaction $transaction): RequestResponseInterface
if ($stripePaymentIntent->status == 'succeeded') {
$refund = $this->getStripeClient()->refunds->create([
'payment_intent' => $stripePaymentIntent->id,
'amount' => $transaction->paymentAmount * (10 ** $currencyService->getSubunitFor($currency)),
'amount' => (int) bcmul($transaction->paymentAmount, 10 ** $currencyService->getSubunitFor($currency)),
]);

return $this->createPaymentResponseFromApiResource($refund);
Expand Down Expand Up @@ -640,7 +640,7 @@ protected function authorizeOrPurchase(Transaction $transaction, PaymentIntentFo
}

// Normalized amount for Stripe into minor units
$amount = $transaction->paymentAmount * (10 ** $currencyService->getSubunitFor($currency));
$amount = (int) bcmul($transaction->paymentAmount, 10 ** $currencyService->getSubunitFor($currency));

/** @var PaymentIntentForm $form */
if ($form->paymentFormType == self::PAYMENT_FORM_TYPE_CHECKOUT) {
Expand Down

0 comments on commit 602504c

Please sign in to comment.