Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fix-stripe-options-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Dec 19, 2023
2 parents 6ab28b6 + b634dc4 commit 9dda183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes for Stripe for Craft Commerce

## Unreleased
- Payment method data is now stored in expanded form within transaction response data. ([#276](https://github.com/craftcms/commerce-stripe/pull/276))

## 4.0.1.1 - 2023-10-25

- Restored support for backend payments using the old payment form.
Expand Down Expand Up @@ -27,7 +30,7 @@
- Removed `craft\commerce\stripe\base\Gateway::normalizePaymentToken()`.
- Removed `craft\commerce\stripe\events\BuildGatewayRequestEvent::$metadata`. `BuildGatewayRequestEvent::$request` should be used instead.
- Deprecated the `commerce-stripe/default/fetch-plans` action.
- Deprecated creating new payment sources via the `commerce/subscriptions/subscribe` action.
- 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.1 - 2023-05-10
Expand Down
8 changes: 6 additions & 2 deletions src/gateways/PaymentIntents.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,17 @@ public function completePurchase(Transaction $transaction): RequestResponseInter
{
$data = Json::decodeIfJson($transaction->response);

$paymentIntentOptions = [
'expand' => ['payment_method'],
];

if ($data['object'] == 'payment_intent') {
$paymentIntent = $this->getStripeClient()->paymentIntents->retrieve($data['id']);
$paymentIntent = $this->getStripeClient()->paymentIntents->retrieve($data['id'], $paymentIntentOptions);
} else {
// Likely a checkout object
$checkoutSession = $this->getStripeClient()->checkout->sessions->retrieve($data['id']);
$paymentIntent = $checkoutSession['payment_intent'];
$paymentIntent = $this->getStripeClient()->paymentIntents->retrieve($paymentIntent);
$paymentIntent = $this->getStripeClient()->paymentIntents->retrieve($paymentIntent, $paymentIntentOptions);
}

return $this->createPaymentResponseFromApiResource($paymentIntent);
Expand Down

0 comments on commit 9dda183

Please sign in to comment.