Skip to content

Add opt-in transport retries following PayWay retry guidance - #6

Merged
napper1 merged 3 commits into
masterfrom
feature/transport-retries
Aug 10, 2026
Merged

Add opt-in transport retries following PayWay retry guidance#6
napper1 merged 3 commits into
masterfrom
feature/transport-retries

Conversation

@napper1

@napper1 napper1 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

Adds opt-in transport retries to Client, following PayWay's retry guidance:

  • New keyword-only constructor kwargs: Client(..., max_retries=0, retry_delay=1.0). Default max_retries=0 keeps existing single-attempt behaviour — fully backwards compatible.
  • Retries on requests.ConnectionError, requests.Timeout, and HTTP 429/503, with linear backoff (retry_delay × attempt), honouring a numeric Retry-After header when present. retry_delay is configurable since synchronous checkout flows can't afford PayWay's suggested 20s wait.
  • Never retries other status codes (including 500/502/504, per PayWay's advice) or declined transactions.
  • POSTs are only retried when an idempotency_key was supplied, and the same Idempotency-Key header is resent on every attempt so PayWay replays the original response instead of double-charging. PUTs never carry a key, so they never retry. GETs always retry.
  • After retries are exhausted, behaviour is identical to a single failed attempt today — the (response, errors) contract is unchanged.

Also documents the new params in the README, adds a CHANGELOG, and bumps the version to 0.0.8.

Test plan

  • New TestClientRetries unit tests (HTTP layer mocked): connection error then success (same key on both attempts), 429 then success (waits, honours Retry-After), 503 exhausting retries, 500 not retried, POST without key not retried, default max_retries=0 single attempt, GET retried.
  • Full suite: 27 passed. ruff check payway and mypy payway clean.

🤖 Generated with Claude Code

napper1 and others added 3 commits August 10, 2026 16:04
Retry on connection errors, timeouts and HTTP 429/503 (honouring
Retry-After), never on other status codes, and never for a POST
without an Idempotency-Key. Off by default (max_retries=0).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@napper1
napper1 merged commit cd45769 into master Aug 10, 2026
1 check passed
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