4.0.0 - full API coverage, single request() method
Completes coverage of OnPay's documented API, and replaces the per-verb client methods with one.
Seven endpoints that had no implementation
GET /v1/transaction/events/ |
$api->transaction()->getEvents($cursor) |
GET /v1/gateway/window/v3/language/ |
$api->gateway()->getPaymentWindowLanguages() |
GET /v1/acquirer |
$api->acquirer()->getAcquirers() |
GET /v1/acquirer/{name} |
$api->acquirer()->getAcquirer($name) |
PATCH /v1/acquirer/{name} |
$api->acquirer()->updateAcquirer($name, $settings) |
GET /v1/provider |
$api->acquirer()->getProviders() |
GET /v1/wallet |
$api->acquirer()->getWallets() |
Transaction events page by cursor rather than page number, which nothing else in this API does, so the collection carries the cursor instead of a Pagination:
do {
$events = $api->transaction()->getEvents($cursor);
foreach ($events->events as $event) { /* ... */ }
$cursor = $events->nextCursor;
} while ($events->hasMore());That implementation began as a branch Dennis Væversted pushed in July 2020 and nobody merged. It is preserved unmodified at archive/events-endpoint and brought up to date here.
Acquirer fields differ per acquirer — Nets carries card BINs, Clearhaus an API key — so only name, active and links are typed, and the rest is kept as returned and reached through getSetting(). Flattening them would give you a class whose properties are mostly null for any given acquirer.
Breaking: one request() instead of a method per verb
ApiClientInterface had get() and post(), which meant a verb OnPay uses and the SDK does not was simply unreachable — PATCH is what brought this to a head. Widening the interface for each new verb is not a contract worth keeping.
-public function get(string $url): mixed;
-public function post(string $url, mixed $body = null): mixed;
+public function request(string $method, string $url, mixed $body = null): mixed;This only affects code calling $api->getApiClient() directly, or implementing ApiClientInterface for a test double. The service classes are unchanged from the outside.
The wire format is deliberately unchanged. A GET carries no body and every other verb carries one, even when that body is null. OnPay has accepted a literal null from the cancel and capture calls for years, and this was not the release to find out whether it still would if the body vanished entirely.
177 tests, up from 164.