Skip to content

Frisbii

Everything specific to Frisbii (formerly Reepay): how it models a payment, which endpoints we call, what its webhooks mean, and the quirks that have cost us bugs. General behaviour that happens to be exercised by Frisbii lives with the layer it belongs to — see Checkout attempts and Gateway integration.

FrisbiiGateway implements PaymentGatewayInterface, RecurringPaymentGatewayInterface, PaymentSessionGatewayInterface, AgreementSessionGatewayInterface and AgreementImportGatewayInterface — every interface the package defines.

One invoice, many transactions

Frisbii keeps one invoice per handle and many transactions on it. Our table is per attempt, so several rows can point at the same ext_payment_id. Only ext_transaction_id tells them apart, and it is set by the webhook — an attempt that was never carried through never gets one.

That is the whole difficulty behind the checkout work: two pending rows on the same invoice, neither naming a transaction, look identical to FrisbiiWebhookHandler.

transactions[] is listed in ascending order, so the first entry is the earliest attempt. That is what isFirstAttemptOnInvoice() reads.

The handle is the order id, and only one invoice can ever hold it. It is not released when the invoice is deleted, so an order whose invoice is gone can never be paid again.

Endpoints, and what each one touches

Endpoint Level States Effect
DELETE /v1/charge/{handle} invoice only created deletes the invoice — we never call this
POST /v1/charge/{handle}/cancel invoice authorized voids the reservation
POST /v1/invoice/{handle}/transaction/{tx}/cancel transaction pending, authorized, processing cancels one attempt — not used yet
DELETE checkout-api/v1/session/{id} session — closes the checkout session

Cancel, never delete

The charge path is always POST /v1/charge/{handle}/cancel. A pending payment used to go to DELETE /v1/charge/{handle}, on the reasoning that an invoice with nothing authorized cannot be cancelled. It cannot — but deleting it is not the harmless alternative it looks like, because of the handle rule above. That path is reachable from POST /wc/v3/orders/{id}/payments/{id}/cancel, where the order is still live.

Cancelling takes nothing away:

At Frisbii POST …/cancel answers
a reservation to void it is voided
nothing authorized 106 Invoice must be authorized
an authorization the row has not caught up with it is voided — which the delete never could

Closing one attempt without touching the shared invoice is done at session level. Transaction level would be the answer for an attempt that already has a transaction, but that endpoint is addressed through the handle and so is caught by the prefix issue below.

Error codes

ApiException::getErrorCode() carries Frisbii's numeric code, because the HTTP status cannot tell two of its errors apart — 106 and 108 are both 400. The authoritative list is https://api.frisbii.com/v1/error_codes.

Code Meaning What we do
106 Invoice must be authorized FrisbiiGateway::cancelPayment() answers 204 — there was nothing to void, which is the outcome the caller asked for
108 Transaction cancel failed rethrown, like every other code
31 Invoice not found rethrown — on a prefixed environment this is usually the prefix issue, not a missing invoice

Codes are read and acted on inside the gateway, never above it — see Provider error codes stay in the gateway.

Webhook events

Event Action
customer_payment_method_added Stores the payment method on the agreement and activates it
customer_payment_method_failed Disables the agreement (FAILED)
customer_payment_method_deleted Disables the agreement (CANCELED)
invoice_created Persists the payment if we do not know it yet
invoice_authorized Persists the payment if needed, then marks it AUTHORIZED
invoice_settled Marks the payment CAPTURED
invoice_failed Marks the payment FAILED and stores the failure reason as payment meta
invoice_refund Marks the payment REFUNDED
invoice_refund_failed Routed to PaymentStateService::paymentRefundFailed()

An event outside this list is stored with status SKIPPED. invoice_cancelled is one of them, so a voided authorization currently leaves the row AUTHORIZED.

The event only states that something happened — the current state is always read back from the API before acting, since an event can arrive late or more than once for the same invoice.

For invoice_failed the charge endpoint (GET /v1/charge/{handle}) is used rather than the invoice endpoint, because only the charge carries error and error_state. These are stored as failure_code, failure_description and failure_state. A failure_state of hard_declined prevents PaymentRetryHandler from scheduling a retry.

A declined charge is answered with HTTP 200 and state: failed, so the same failure handling runs synchronously in AgreementService::createRecurringPayment() — the webhook is a confirmation, not the only signal.

Which row an event lands on

Only invoice_authorized, invoice_settled, invoice_failed and invoice_refund carry a transaction. An event naming one matches the row that already holds it; otherwise findAdoptablePaymentForHandle() looks for a row with no transaction yet:

Row Adoptable
PENDING, no transaction by any event
FAILED, no transaction by invoice_failed only
CANCELED, or any other status never
Already names a transaction never here — it is matched by its own transaction id instead

Adoption is further gated by isFirstAttemptOnInvoice(): a waiting row is only taken when the event's transaction is the earliest on the invoice. Where more than one row is adoptable, the oldest wins.

Customer handles

The natural handle is the WooCommerce customer ID prefixed with PAYMENTHUB_HANDLE_PREFIX — see Configuration. It is only where the search starts.

Frisbii soft-deletes customers, and its documentation for DELETE /v1/customer/{handle} states that the customer handle is not changed so it cannot be re-used. There is no endpoint to restore one. A deleted customer therefore keeps its handle forever while being unusable, and GET /v1/customer/{handle} answers 200 for it — so the status code alone proves nothing. A customer counts as usable only when the handle it returns is the one that was asked for and it carries no deleted timestamp.

When the natural handle is unusable, the next candidate is tried:

47      ← normally
47-2    ← if 47 belongs to a deleted customer
47-3    ← if 47-2 does too

Nothing is stored. Because the order is fixed, the same handle is found again on every later call, in every flow — which is what keeps a customer reachable after their Frisbii record has been deleted. The search is capped at ten candidates: a silent endless loop would be worse than a loud failure.

The prefix must stay stable per environment; changing it makes every existing Frisbii customer unreachable.

Guest handles

A guest order names its customer after the order:

"customer": { "handle": "<prefix>guest-<order id>" }

Two properties matter. It says plainly that this is not a shop customer — a real one is <prefix><customer id>, so the two can never be confused — and it is the same handle every time for the same order. That stability is deliberate: a new handle per attempt would leave a trail of customers per order and risk error 99, since the existing invoice already belongs to the first one.

We never call POST /v1/customer for a guest — the session's inline customer object is what creates it — and we never refer to that customer again.

Frisbii's own generate_handle is deliberately not used: it names the customer cust-<sequence>, which sits in Frisbii's namespace, reads like a reference to a customer of ours, and discloses volume.

What the code used to do was worse than either: the handle came from prefixHandle( null ), the bare prefix, so with PAYMENTHUB_HANDLE_PREFIX set every guest order in the shop shared one customer.

Only the handle is sent, so a Frisbii customer record looks the same no matter which flow created it. Customer details are deliberately not synced.

The prefix issue

A payment created from a checkout session stores the bare order id in ext_payment_id, because FrisbiiGateway::createPayment() has no invoice yet. On an environment where PAYMENTHUB_HANDLE_PREFIX is set, the real handle carries the prefix — so every handle-addressed call on such a row answers 404. Tracked separately; it is why capture fails on session-created rows and why transaction-level cancellation is not in use.

  • Checkout attempts — the attempt lifecycle this model sits under
  • Webhooks — delivery, signature verification and idempotency
  • Migrations — importing QuickPay cards into Frisbii