Skip to content

Add a client-wide default for the synchronized operation flag - #1

Merged
loevgaard merged 1 commit into
1.xfrom
client-synchronized-default
Aug 6, 2026
Merged

Add a client-wide default for the synchronized operation flag#1
loevgaard merged 1 commit into
1.xfrom
client-synchronized-default

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Why

Call sites that always want synchronized operations currently have to repeat the flag on every call:

$client->payments()->refund(
    $paymentId,
    new RefundRequest(amount: $amount),
    synchronized: $this->api->isSynchronized(), // repeated on every operation call
);

Whether to wait for the completed transaction is almost always an integration-wide decision, not a per-call one — so it belongs on the client, not at every call site. (It deliberately does not move into the request DTOs: ?synchronized is a query flag rather than body data, the Payload DTOs map 1:1 to Quickpay's documented request bodies, and cancel() has no body DTO at all.)

What

  • Client constructor gains a bool $synchronized = false parameter (appended last — BC for positional callers), exposed as isSynchronized() on ClientInterface.
  • The operation methods (authorize/capture/refund/cancel) change bool $synchronized = false?bool $synchronized = null; null falls back to the client-wide default, a non-null argument overrides it. Behavior is unchanged for existing code.
  • README + CLAUDE.md updated.
$client = new Client('YOUR_API_KEY', synchronized: true);

$client->payments()->capture($id, new CaptureRequest(1000)); // waits (client default)
$client->payments()->refund($id, new RefundRequest(250), synchronized: false); // override per call

BC note

Adding isSynchronized() to ClientInterface breaks custom implementations/decorators of that interface (if any exist). Consumers using Client directly are unaffected.

Tests

  • Client default is false / constructor flag is exposed via isSynchronized().
  • An operation on a synchronized: true client appends ?synchronized without a per-call flag.
  • A per-call synchronized: false overrides a true client default.
  • Full suite: PHPUnit (92 tests), PHPStan max, ECS, Rector dry-run, Infection all green locally (covered MSI ≈ 76% ≥ 70 gate; the mutant flipping the new constructor default is killed).

The payment operation methods (authorize/capture/refund/cancel) now take
?bool $synchronized = null, falling back to a new 'synchronized' flag on
the Client constructor (exposed as ClientInterface::isSynchronized()).
Integrations that always want to wait for the completed transaction can
set the default once instead of repeating the flag on every call; a
non-null per-call argument still overrides it.
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@loevgaard
loevgaard merged commit 12a4a7e into 1.x Aug 6, 2026
35 checks passed
@loevgaard
loevgaard deleted the client-synchronized-default branch August 6, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant