AlmondTill/G3N API

cancelPayment

mutation · in the family Payment

What it does

Cancel a payment on an order.

Cancel an authorized Payment: the order-cancel path's first step (cancelOrder refuses CONFLICT/TENDERED while deposit money is held — release here, then cancel). The processor release fires first; the ACK commits the flip + a negative reversal Tender row + the Order rollup stamp in ONE transaction. A captured payment refuses CONFLICT/IN_PROGRESS. Requires the unrestricted capability + the current revision.

Before you call

A bearer session from an API key (see Authentication and key hygiene) or a signed-in user.

Capability area: Refunds and payment corrections — Refunds, corrective notes and voiding invoices.

Roles that may call it:

Careful

Cancellation is usually permanent — check what the record has already caused (reservations, payments) before cancelling.

Arguments

NameTypeRequiredNotes
idID ID!yesThe id of the record.
revisionID ID!yesThe revision id you read on the record; the change is refused if an edit landed in the meantime.
reasonStringno

Concurrency

Send the record’s current revision from your last read as revision. A stale revision is refused as CONFLICT/REVISION_STALE — read the record again and retry with the new value.

Returns

Payment Payment! — A Payment — a processor-backed payment (the integrated processing mode), spawned by a card Tender. Aligned to the deposit→recognition model: authorize = the hold = deposit at tender; capture = recognized at delivery — POS carry-out collapses authorize+capture by arriving at delivery in the same request, never by skipping states. Record-first/processor-after: minted created before any processor call; the StripePort attempt fires post-commit; state flips ride the ACK/webhook path; 32 attempts bound each order (the Order.paymentIds cap). PCI-min: the PAN never touches AT/stack — the record holds the opaque tokenized methodRef + processor refs + at most brand/last4. The StripePort is faked at 7.7a (deterministic, keyless); the live adapter + webhook ingress are 7.7b.

Example request

graphql
mutation ExampleCancelPayment($id: ID!, $revision: ID!, $reason: String) {
  cancelPayment(id: $id, revision: $revision, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    organizationId
    amountMinor
    tipMinor
    currency
    methodRef
    tenderId
    stripeAccountRef
    sagaId
    intentRef
    chargeRef
    brand
    last4
    declineReason
  }
}

Variables:

json
{
  "id": "01900000-0000-7000-8000-20f641110000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "reason": "Correcting a miscount."
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

json
{
  "data": {
    "cancelPayment": {
      "id": "01900000-0000-7000-8000-20f641110000",
      "sysId": "PY-EXMP-0000-000F",
      "type": "Payment",
      "caption": "Blue jeans",
      "status": "cancelled",
      "parentId": "01900000-0000-7000-8000-18e782370000",
      "rootId": "01900000-0000-7000-8000-a1295a650000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-53c6eea90000",
      "organizationId": "01900000-0000-7000-8000-1971e30a0000",
      "amountMinor": 1250,
      "tipMinor": 0,
      "currency": "USD",
      "methodRef": "<method ref>",
      "tenderId": "01900000-0000-7000-8000-337e28070000",
      "stripeAccountRef": "<stripe account ref>",
      "sagaId": "01900000-0000-7000-8000-4d522e410000",
      "intentRef": "01900000-0000-7000-8000-0cb528b40000",
      "chargeRef": "01900000-0000-7000-8000-ae314a160000",
      "brand": "<brand>",
      "last4": "<last4>",
      "declineReason": "<decline reason>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer