Skip to content

ffl_integrations.payments.api

Source: apps/ffl_integrations/ffl_integrations/payments/api.py · 15 endpoint(s)

Generated by make api-docs — do not edit by hand.

cancel_gb_order_charge

POST /api/method/ffl_integrations.payments.api.cancel_gb_order_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Cancel an in-flight keyed card charge on a GunBroker order (race-safe).

A cancel that races an approval records the approval instead.

arg type required default description
gunbroker_order string yes — The GunBroker Order being charged.
instruction_id string yes — The handle to cancel.

Returns: {ok: True, status: "CANCELED"} — or the settled approval with reconciled=True.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1479

cancel_pos_charge

POST /api/method/ffl_integrations.payments.api.cancel_pos_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Cancel an in-flight card charge (race-safe).

If the cancel RACES an approval (card just captured), the capture is reconciled instead of stranding it / letting a retry double-charge.

arg type required default description
invoice_name string yes — POS Invoice being tendered.
instruction_id string yes — The charge handle to cancel.

Returns: {ok: True, status: "CANCELED"} — or the reconciled settle result when the approval won the race.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:905

cancel_sales_invoice_charge

POST /api/method/ffl_integrations.payments.api.cancel_sales_invoice_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Cancel an in-flight terminal charge on a Sales Invoice (race-safe).

A cancel that races an approval settles the approval instead — the card was charged, so it is recorded and booked, never stranded.

arg type required default description
sales_invoice string yes — The Sales Invoice being charged.
instruction_id string yes — The instruction to cancel.

Returns: {ok: True, status: "CANCELED"} — or the settled approval with reconciled=True when the approval won the race.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1278

card_tender_mode

POST /api/method/ffl_integrations.payments.api.card_tender_mode

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Whether a Credit Card tender must go through the counter terminal.

Read-only. With a card processor switched on, configured and holding a device, a card is charged on the terminal (charge_pos_invoice); otherwise a Credit Card row is a plain tender typed from a standalone terminal.

Returns: {"integrated": bool, "readers": [names]} — readers: the card readers switched on now, one of which a terminal charge must name ([] = the processor's one device, name none). The counter reads it again after a charge naming a reader is refused.

apps/ffl_integrations/ffl_integrations/payments/api.py:647

charge_gb_order

POST /api/method/ffl_integrations.payments.api.charge_gb_order

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Start a keyed card charge (the processor's payment page) for a GunBroker order.

Pending Order → Record Payment on a GunBroker order that has not been paid. The frontend polls it with poll_gb_order_charge(); the approval is recorded as the order's payment, which opens Dispose. Reuses an in-flight charge rather than charging twice.

arg type required default description
gunbroker_order string yes — GunBroker Order awaiting payment.
amount — no None Charge amount, at most the order total (blank = the order total).

Returns: {ok, instruction_id, status, amount, keyed_url}; {"skip": True} when no card processor is switched on and configured; an earlier approval found unrecorded comes back settled with already=True.

Permissions: POS charge roles (_check_perm); keying a card in needs a manager.

apps/ffl_integrations/ffl_integrations/payments/api.py:1363

charge_pos_invoice

POST /api/method/ffl_integrations.payments.api.charge_pos_invoice

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Start a card charge on the card processor's terminal for a POS invoice.

Starts the charge on the active processor's card device; the frontend then polls poll_pos_charge() until the terminal returns. Reuses an in-flight charge rather than double-charging.

arg type required default description
invoice_name string yes — POS Invoice being tendered.
terminal string | null no None Optional terminal id; defaults to the configured one.
amount — no None Optional charge amount; defaults to the card-tender target.
description string | null no None Optional statement descriptor.
save_card — no 0 1 to keep the card for later charges (card on file): refused unless saving is switched on, the processor can keep cards and the invoice customer has signed the card-on-file authorization.
keyed — no 0 1 to key the card number in on the processor's payment page instead of the terminal (managers only; not with save_card).
reader string | null no None This computer's card reader (its name). Required when the store lists card readers (refused when it is missing, unknown or switched off); ignored for a keyed charge. Without listed readers, leave it out.

Returns: {ok, instruction_id, reader, status, amount} — reader: the card reader the charge is on (a charge already in flight on this invoice keeps its own; None when no reader is named) — plus keyed_url (the payment page to open) for a keyed charge — or {"skip": True} when no card processor is switched on and configured. The poll that settles an approval then adds card_saved / save_message.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:668

charge_sales_invoice

POST /api/method/ffl_integrations.payments.api.charge_sales_invoice

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Start a card charge on the card processor's terminal against a counter Sales Invoice.

The counter's card tender for an on-account order (Create Order right after the order books; Pending Order → Record Payment for a balance). Starts a charge on the active processor's card device; the frontend polls it with poll_sales_invoice_charge(); the approval books a Payment Entry. Reuses an in-flight instruction rather than double-charging, and never starts one while an earlier approval on this invoice is unrecorded.

arg type required default description
sales_invoice string yes — Submitted Sales Invoice with an outstanding balance.
amount — no None Charge amount, at most the outstanding balance (blank = the whole balance; less = a deposit).
terminal string | null no None Optional terminal id; defaults to the configured one.
save_card — no 0 1 to keep the card for later charges (card on file): refused unless saving is switched on, the processor can keep cards and the invoice customer has signed the card-on-file authorization.
keyed — no 0 1 to key the card number in on the processor's payment page instead of the terminal (managers only; not with save_card).
reader string | null no None This computer's card reader (its name). Required when the store lists card readers (refused when it is missing, unknown or switched off); ignored for a keyed charge. Without listed readers, leave it out.

Returns: {ok, instruction_id, reader, status, amount} — reader: the card reader the charge is on (a charge already in flight on this invoice keeps its own; None when no reader is named) — plus keyed_url (the payment page to open) for a keyed charge — {"skip": True} when no card processor is switched on and configured; an earlier approval found unrecorded comes back settled with already=True. The poll that settles an approval then adds card_saved / save_message.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1115

confirm_out_of_band_refund

POST /api/method/ffl_integrations.payments.api.confirm_out_of_band_refund

Auth (derived from code): Roles: Sales Manager / System Manager

Record that a gateway-charged sale's refund was issued in the card processor's portal.

The manager-level exit for the switched-off refund guard. Deliberately its own field plus a timeline entry — never the tender row's reference_no, which the standalone-terminal flow collects for a different purpose and which therefore cannot double as this guard's evidence (a guard whose evidence another rule force-collects clears itself).

arg type required default description
return_invoice_name string yes — The POS RETURN invoice being confirmed.
portal_reference string yes — The refund's reference from the processor's portal.
reason string yes — Why the refund went out of band (audited, mandatory).

Returns: {ok: True, invoice, portal_reference}.

Raises: ValidationError: Missing reference/reason, a PAN-shaped reference, the charging processor switched on (the live path owns refunds then), unknown or cancelled document, not a return, an original that never took gateway money, or a confirmation that already exists.

Permissions: Manager role (_check_manager).

apps/ffl_integrations/ffl_integrations/payments/api.py:2605

list_terminals

POST /api/method/ffl_integrations.payments.api.list_terminals

Auth (derived from code): Roles: Sales Manager / System Manager

List the terminals the active card processor's credentials may use (connectivity smoke test).

A zero-risk connectivity + pairing check (Payroc: the authenticate response's allowedTerminals).

Returns: The processor's own answer, {"error": } on a refusal, or {"skip": True} when no card processor is switched on and configured.

Permissions: Manager role.

apps/ffl_integrations/ffl_integrations/payments/api.py:1523

poll_gb_order_charge

POST /api/method/ffl_integrations.payments.api.poll_gb_order_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Poll a keyed card charge started by charge_gb_order once.

arg type required default description
gunbroker_order string yes — The GunBroker Order being charged.
instruction_id string yes — The handle returned by charge_gb_order.

Returns: {ok: True, unique_reference, approval_code, amount, paid} on approval (the payment is recorded on the order); {ok: False, status: "IN_PROGRESS"} while pending; {ok: False, status, error} on decline / cancel.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1454

poll_pos_charge

POST /api/method/ffl_integrations.payments.api.poll_pos_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Poll a card charge once, on the processor that started it.

In progress → {ok: False} (frontend loops). Finished → verify full approval, stamp the reference on the invoice.

arg type required default description
invoice_name string yes — POS Invoice being tendered.
instruction_id string yes — The charge handle returned by charge_pos_invoice.
expected_amount — no None Optional approval-amount check.

Returns: {ok: True, ...settled details} on completion; {ok: False, status: "IN_PROGRESS"} while pending; {ok: False, status, error} on terminal failure.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:855

poll_sales_invoice_charge

POST /api/method/ffl_integrations.payments.api.poll_sales_invoice_charge

Auth (derived from code): Roles: Sales User / Sales Manager / System Manager

Poll a terminal charge started by charge_sales_invoice once.

IN_PROGRESS → {ok: False} (frontend loops). On approval the record goes CHARGED and a Payment Entry books against the invoice; the answer carries the new balance.

arg type required default description
sales_invoice string yes — The Sales Invoice being charged.
instruction_id string yes — The instruction returned by charge_sales_invoice.

Returns: {ok: True, unique_reference, approval_code, amount, payment_entry, outstanding, paid} on approval; {ok: False, status: "IN_PROGRESS"} while pending; {ok: False, status, error} on decline / cancel.

Permissions: POS charge roles (_check_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1247

refund_pos_invoice

POST /api/method/ffl_integrations.payments.api.refund_pos_invoice

Auth (derived from code): Roles: Sales Manager / System Manager

Refund a POS return's card portion to the original card(s).

Referenced refund of the Credit Card portion of a POS RETURN invoice, sent to the processor that took each original charge. Firearm returns are blocked (bound-book reversal is a separate project). Multi-card originals refund across rows within per-original-card caps.

arg type required default description
return_invoice_name string yes — The POS RETURN invoice.
reason string | null no None Optional audit reason.

Returns: {ok: True, refund_reference, amount, original}; {"skip": True} when no card processor is switched on and configured, or the original never took gateway money.

Raises: ValidationError: When the processor that charged the ORIGINAL on the terminal is switched off / unconfigured and no manager has confirmed the portal refund yet (confirm_out_of_band_refund is the exit — ops are also emailed). Also: firearm returns (bound-book reversal is a separate project), a repeat refund of an already-refunded return, or a refund whose sibling returns' booked money exceeds their documented card entitlement.

Permissions: Manager-gated refund roles (gate at entry).

apps/ffl_integrations/ffl_integrations/payments/api.py:1860

unlock_refund_lock

POST /api/method/ffl_integrations.payments.api.unlock_refund_lock

Auth (derived from code): Roles: Sales Manager / System Manager

Manager unlock for a return whose automatic card refund armed the

UNKNOWN-OUTCOME re-refund lock (the amplifier: the lock had no product-side unlock, so a locked return died in bench console).

ONLY UNKNOWN-OUTCOME unlocks — zero slices booked, so a full-amount retry is exactly the original entitlement. A PARTIAL:* sentinel is the ONE record of how much this return already pushed back; clearing it re-arms a full-amount retry that the per-ORIGINAL-card caps cannot bound (an original with headroom would refund the booked slices again). Its residue goes to back-office manual processing. A real refund reference means the refund COMPLETED and never unlocks.

The unlock is an attestation, not a reconciliation: the gateway may actually have refunded (rows still show headroom), so the manager must verify in the processor's portal FIRST — the reason is required and the whole action lands in the document timeline (who/when/why/previous lock), mirroring manager_override_4473's audit posture.

arg type required default description
return_invoice_name string yes — The locked POS RETURN invoice.
reason string yes — Required attestation — what the manager verified in the card processor's portal.

Returns: {ok: True, cleared: , invoice}.

Permissions: Manager gate (roles per the derived Auth line) + required reason — the reason must record what was verified in the processor's portal.

apps/ffl_integrations/ffl_integrations/payments/api.py:2243

void_pos_invoice

POST /api/method/ffl_integrations.payments.api.void_pos_invoice

Auth (derived from code): Roles: Sales Manager / System Manager

Reverse an unsettled card charge (back-office; per-card on multi-card).

Books the gateway reversal on the processor that took the charge (Payroc has no /void: it reverses). Multi-card invoices void PER CARD: pass the charge row's unique_reference when more than one live capture exists.

arg type required default description
invoice_name string yes — POS Invoice carrying the charge.
reason string | null no None Optional audit reason.
unique_reference string | null no None The specific charge row to void (required when several live captures exist).

Returns: {ok: True, unique_reference, response}.

Permissions: Refund/void roles (_check_refund_perm).

apps/ffl_integrations/ffl_integrations/payments/api.py:1547