Skip to content

Commit

Permalink
Merge branch 'v4' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/gateways/PaymentIntents.php
  • Loading branch information
nfourtythree committed Mar 28, 2024
2 parents c956a81 + 332a55b commit 8b74363
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Release Notes for Stripe for Craft Commerce

## Unreleased

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

## 5.0.0

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

## 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
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 8b74363

Please sign in to comment.