AUTH4D-36: Stitch payment links and status lookup
@auth4/provider-stitch exports createStitchPaymentsClient({ api, onWarning? }), built on the
AUTH4D-35 REST transport. The token client needs the client_paymentrequest scope. The package
exposes no HTTP routes.
createPaymentRequest
The input is { paymentId, amount, payerName, redirectUrl, expiresAt? }. The call sends
POST /api/v1/payment-links as operation CreatePaymentLink and returns
{ providerPaymentId, redirectUrl }. providerPaymentId is the Express payment link id.
amountis a contractMoney. Express takes integer South African cents, soamountMinoris sent as is. The currency must be ZAR and the amount at least 100 (R1.00).merchantReferenceis ourpaymentIdwith a hyphen (pay_abc…is sent aspay-abc…), because Express allows only letters, digits, spaces and hyphens there. Status lookups and the payer’s return correlate to our payment record through it.payerNameis shown on the Stitch checkout page. It must be 3 to 40 printable ASCII characters.redirectUrlmust be HTTPS, or HTTP on loopback. It is appended to the Stitch-hostedlinkas theredirect_urlquery parameter, and the result’sredirectUrlis that combined URL. Stitch only honours a registered redirect URL (at most 5 per account), compared without its query string; an unregistered one shows the payer a 404. Register it withinfra/stitch/setup.mjs. On return Stitch appendsreference(the merchant reference) and its ownpayment_id.expiresAt(ISO 8601) is sent when present. Express defaults to 30 days.- A response whose
amountdiffers from the requested amount is anupstreamerror, so a link for a different amount never reaches the payer.
getPaymentStatus
getPaymentStatus(providerPaymentId) sends GET /api/v1/payment-links/{id} as operation
GetPaymentLink. It returns { providerPaymentId, status, providerState?, externalReference? }.
Express link status |
Contract PaymentStatus |
|---|---|
PENDING |
pending |
PAID |
completed |
CANCELLED |
canceled |
EXPIRED |
expired |
| anything else | pending, plus a warning |
The warning is { code: "unknown_payment_state", operationName, providerState? }. providerState
is included only when it is a plain identifier. The warning goes to onWarning, or by default to
console.warn as one JSON line with event provider.stitch.payment.
externalReference is our payment id recovered from the link’s merchantReference, or the raw
reference when it is not one of ours. Callers must check that it equals the payment they expect
before acting on the result.
Errors
All failures are StitchError:
validation: invalid input, which is rejected before any HTTP call; a Stitch field error; an unknown link id (HTTP 404); or a response for a different id.upstream: a malformed response, or a link created for a different amount.- Transport errors are unchanged from AUTH4D-35.
Source: docs/api-spec/auth4d-36.md