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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ narrative.

## [Unreleased]

### Added

- `Operation::$callbackSuccess`, `$callbackResponseCode`, `$callbackAt` and `$callbackDuration`: how
Quickpay's callback about the operation was answered, all `null` until it was sent. Before, only
`$callbackUrl` was typed and the rest had to be read from the payment's `$raw['operations']`.
The new constructor parameters come last, so positional calls are unaffected
([#33](https://github.com/Setono/quickpay-php-sdk/pull/33)).

## [1.3.0] — 2026-11-16

A fix for an answer whose body breaks off mid-read, which escaped `catch (QuickpayException $e)` as a
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ $payment->hasPendingOperation(OperationType::Refund); // is a refund in fli
$op->hasOutcome(); // no longer pending — the status codes mean something now
$op->isApproved(); // qp_status_code 20000
$op->isDeclined(); // completed but NOT approved: rejected (4xxxx), error (5xxxx), auth required (3xxxx)

// How Quickpay's callback about the operation was answered (all null until it was sent):
$op->callbackUrl; // where it went
$op->callbackSuccess; // ?bool — Quickpay's judgment of the answer
$op->callbackResponseCode; // ?string — the status code your endpoint answered with, e.g. "204"; null when no answer came
$op->callbackAt; // ?DateTimeImmutable — when it was sent
$op->callbackDuration; // ?int — how long it took, in milliseconds
```

Only **approved** operations count towards the amounts — pending or rejected ones don't. When an
Expand Down
12 changes: 12 additions & 0 deletions src/Response/Payment/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
* status codes say nothing yet. Once it has completed, {@see self::isApproved()} tells you whether
* it succeeded; any other completed outcome (rejected by the acquirer, 3-D Secure required, gateway
* error, …) is described by `qpStatusCode` / `qpStatusMsg` — see the Quickpay status-code appendix.
*
* Reading the callback: Quickpay records how its callback about the operation (sent to
* `callbackUrl`) was answered. The callback fields are `null` until it was sent (e.g. while the
* operation is pending). Once sent, `callbackSuccess` is Quickpay's judgment of the answer and
* `callbackAt` when it was sent. `callbackResponseCode` is the HTTP status code the receiver
* answered with, as a string (e.g. `"204"`), and `null` when no answer came (`callbackSuccess` is
* then `false`). `callbackDuration` is how long the callback took, in milliseconds: a timed-out one
* reports about 30000, and it is `null` when the receiver couldn't be reached at all.
*/
final class Operation
{
Expand All @@ -37,6 +45,10 @@ public function __construct(
public readonly ?string $aqStatusMsg = null,
public readonly ?string $callbackUrl = null,
public readonly ?\DateTimeImmutable $createdAt = null,
public readonly ?bool $callbackSuccess = null,
public readonly ?string $callbackResponseCode = null,
public readonly ?\DateTimeImmutable $callbackAt = null,
public readonly ?int $callbackDuration = null,
) {
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Client/Endpoint/PaymentsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public function it_maps_nested_link_operations_and_metadata(): void
self::assertSame(1000, $payment->operations[0]->amount);
self::assertSame('20000', $payment->operations[0]->qpStatusCode);

// How Quickpay's callback about each operation was answered: the shop answered 200 ...
self::assertTrue($payment->operations[0]->callbackSuccess);
self::assertSame('200', $payment->operations[0]->callbackResponseCode);
self::assertEquals(new \DateTimeImmutable('2026-06-22T10:00:02Z'), $payment->operations[0]->callbackAt);
self::assertSame(804, $payment->operations[0]->callbackDuration);

// ... and never answered the second one
self::assertFalse($payment->operations[1]->callbackSuccess);
self::assertNull($payment->operations[1]->callbackResponseCode);
self::assertEquals(new \DateTimeImmutable('2026-06-22T10:05:01Z'), $payment->operations[1]->callbackAt);
self::assertNull($payment->operations[1]->callbackDuration);

self::assertNotNull($payment->metadata);
self::assertSame('visa', $payment->metadata->brand);
self::assertSame('0000', $payment->metadata->last4);
Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/payment.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"callback_url": "https://shop.example/callback",
"callback_success": true,
"callback_response_code": "200",
"callback_at": "2026-06-22T10:00:02Z",
"callback_duration": 804,
"acquirer": "clearhaus",
"created_at": "2026-06-22T10:00:00Z"
},
Expand All @@ -69,6 +71,10 @@
"aq_status_msg": "Approved",
"data": {},
"callback_url": "https://shop.example/callback",
"callback_success": false,
"callback_response_code": null,
"callback_at": "2026-06-22T10:05:01Z",
"callback_duration": null,
"acquirer": "clearhaus",
"created_at": "2026-06-22T10:05:00Z"
}
Expand Down
Loading