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 ?? ''; }