From 0ff14186f39b357c06fa603396a79d1200788a08 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Wed, 25 Sep 2024 16:16:33 +0100 Subject: [PATCH] #82 Update pending refunds to be marked as processing --- CHANGELOG.md | 4 ++++ src/responses/RefundResponse.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18729f6..7d09381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for PayPal Checkout for Craft Commerce +## Unreleased + +- Fixed a bug where refunds could be incorrectly marked as failed. ([#82](https://github.com/craftcms/commerce-paypal-checkout/issues/82)) + ## 2.1.3 - 2023-06-27 [CRITICAL] - Added `craft\commerce\paypalcheckout\gateways\Gateway::showPaymentFormSubmitButton()`. diff --git a/src/responses/RefundResponse.php b/src/responses/RefundResponse.php index 4b11ed6..a0caff1 100644 --- a/src/responses/RefundResponse.php +++ b/src/responses/RefundResponse.php @@ -44,7 +44,7 @@ public function isSuccessful(): bool */ public function isProcessing(): bool { - return false; + return $this->data && isset($this->data->result->status) && $this->data->result->status == 'PENDING'; } /** @@ -132,6 +132,10 @@ public function getMessage(): string return $this->data->result['message']; } + if (is_array($this->data->result) && isset($this->data->result['status_details']['reason'])) { + return $this->data->result['status_details']['reason']; + } + if (isset($this->data->result->message)) { return $this->data->result->message ?? ''; }