Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/en/rtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions examples/hu/rtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions resources/boost/skills/simplepay-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
```
Expand Down
2 changes: 1 addition & 1 deletion src/Services/RtpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
*
* @throws RandomException|ConnectionException
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/RtpServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
});
});

Expand Down