diff --git a/README.md b/README.md index 6f71777..c95c12f 100644 --- a/README.md +++ b/README.md @@ -398,7 +398,8 @@ $result = SimplePay::rtp()->start(new RtpStartRequest( // Query RTP status $status = SimplePay::rtp()->query(Currency::HUF, transactionId: $id); -// Refund RTP (refund total, then the original total) +// Refund RTP (refund total, then the original total); always pass originalTotal: +// SimplePay rejects the refund without it (5020), required in the next major version SimplePay::rtp()->refund(Currency::HUF, $transactionId, 15000, originalTotal: 15000); // Reverse RTP diff --git a/examples/en/rtp.md b/examples/en/rtp.md index 2d290c8..ec21447 100644 --- a/examples/en/rtp.md +++ b/examples/en/rtp.md @@ -103,7 +103,7 @@ $query = SimplePay::rtp()->query(Currency::HUF, packageRef: 'PKG-2026-10'); ## Refund an RTP Transaction -Issue a refund for a completed RTP payment. +Issue a refund for a completed RTP payment. Always pass `originalTotal`, the original amount of the transaction: the parameter is optional in the method signature, but SimplePay rejects a refund without it with error `5020` (`OriginalTotalCheckFailed`). It becomes a required parameter in the next major version. ```php use Netipar\SimplePay\Facades\SimplePay; diff --git a/examples/hu/rtp.md b/examples/hu/rtp.md index e799031..35c9859 100644 --- a/examples/hu/rtp.md +++ b/examples/hu/rtp.md @@ -99,13 +99,17 @@ $query = SimplePay::rtp()->query(Currency::HUF, packageRef: 'PKG-2026-10'); ## RTP visszatérítés (refund) -RTP tranzakció visszatérítése: +Teljesült RTP tranzakció visszatérítése. Az `originalTotal`-t, vagyis az eredeti tranzakció összegét mindig add meg: a paraméter a metódus szignatúrájában opcionális, de nélküle a SimplePay `5020`-as hibával (`OriginalTotalCheckFailed`) elutasítja a visszatérítést. A következő major verzióban kötelező paraméter lesz. ```php +// Partial refund: the refund total, then the original total of the transaction SimplePay::rtp()->refund(Currency::HUF, '12345', 1000, originalTotal: 5000); + +// Full refund +SimplePay::rtp()->refund(Currency::HUF, '12345', 5000, originalTotal: 5000); ``` -A harmadik paraméter a visszatérítendő összeg, az `originalTotal` az eredeti tranzakció összege. Részleges visszatérítés is lehetséges. +A harmadik paraméter a visszatérítendő összeg; részleges visszatérítés is lehetséges. ## RTP sztornó (reverse) diff --git a/resources/boost/skills/simplepay-development/SKILL.md b/resources/boost/skills/simplepay-development/SKILL.md index e84fc69..0d0f831 100644 --- a/resources/boost/skills/simplepay-development/SKILL.md +++ b/resources/boost/skills/simplepay-development/SKILL.md @@ -351,6 +351,8 @@ $result = SimplePay::rtp()->do(new RtpDoRequest( // Query/refund/reverse RTP SimplePay::rtp()->query(Currency::HUF, transactionId: '12345'); +// Always pass originalTotal (the original amount): SimplePay rejects an RTP refund without it (5020); +// the parameter is optional in the signature and becomes required in the next major version SimplePay::rtp()->refund(Currency::HUF, transactionId: '12345', amount: 5000, originalTotal: 5000); SimplePay::rtp()->reverse(Currency::HUF, transactionId: '12345'); ``` diff --git a/src/Services/RtpService.php b/src/Services/RtpService.php index 4648e64..1c4ccc4 100644 --- a/src/Services/RtpService.php +++ b/src/Services/RtpService.php @@ -81,7 +81,7 @@ public function query(Currency $currency, ?string $transactionId = null, ?string /** * @param float $amount The amount to refund (`refundTotal`). - * @param float|null $originalTotal The original amount of the transaction, as the official SDK sends it. + * @param float|null $originalTotal The original amount of the transaction. Always pass it: SimplePay rejects a refund without it with error 5020; required in the next major version. * @return array * * @throws RandomException|ConnectionException diff --git a/tests/Unit/RtpServiceTest.php b/tests/Unit/RtpServiceTest.php index c40b457..13d9623 100644 --- a/tests/Unit/RtpServiceTest.php +++ b/tests/Unit/RtpServiceTest.php @@ -155,8 +155,8 @@ }); }); -it('sends refund request to /rtp/refund with the refund total', function () { - $response = $this->rtpService->refund(Currency::HUF, '123456', 500.0); +it('sends refund request to /rtp/refund with the refund total and the original total', function () { + $response = $this->rtpService->refund(Currency::HUF, '123456', 500.0, originalTotal: 1000.0); expect($response)->toBeArray() ->and($response['refundStatus'])->toBe('REFUNDED'); @@ -165,7 +165,8 @@ return str_contains($httpRequest->url(), '/rtp/refund') && $httpRequest['merchant'] === 'TEST_HUF_MERCHANT' && $httpRequest['transactionId'] === '123456' - && (float) $httpRequest['refundTotal'] === 500.0; + && (float) $httpRequest['refundTotal'] === 500.0 + && (float) $httpRequest['originalTotal'] === 1000.0; }); });