Pay Bill

Pay a bill on a site with a Wire action — how to request the action, dry-run it, run it, stop it, and what every stop code means

A Pay Bill action signs in to a site with your identity, opens the pay page, checks the account and the amount, and pays with the payment method you name. Every site's pay action takes the same inputs and answers with the same codes.

Note: a pay action only moves money on your own identity for that site. It never runs on a shared or pooled login.


1. Request the action

A pay action is built for a site already in your catalog. Send a build request with kind: "payment":

curl -X POST https://api.anakin.io/v1/wire/build-request \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{
    "kind": "payment",
    "catalog_id": "<catalog id>",
    "website_url": "https://myaccount.example.com",
    "pay_inputs": []
  }'
FieldNotes
kind"payment"
catalog_idRequired. The site's catalog.
website_urlMust be on the catalog's site.
pay_inputsOptional extra inputs the site asks for on its pay page. Any of invoice_number, bill_id, subscription_id, email, phone, service_location.

The action is named <catalog_slug>_pay_bill. It is private to you and stays a draft until a person at Anakin has reviewed it. A draft only ever does dry runs. If the site has no browser sign-in yet, one is drafted with it (<catalog_slug>_browser_login).

A site that already has a pay action answers 409 ACTION_EXISTS. Where payments are not enabled, the request answers 503 PAYMENTS_DISABLED.


2. Sign in and pick a payment method

  1. Sign in to the site with the browser sign-in (Login). Keep the credential_id.
  2. Create a payment method with POST /v1/wire/payment-methods and keep its id. A payment method is either a card saved on the site for that login, or a card your own Card API hands out for one payment. Wire stores no card number and no CVV, and never saves a card on a site.

3. Run it

curl -X POST https://api.anakin.io/v1/wire/task \
  -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
  -d '{
    "action_id": "<catalog_slug>_pay_bill",
    "credential_id": "<credential id>",
    "params": {
      "payment_method_id": "<payment method id>",
      "payment_amount": "113.00",
      "account_number": "<account on the site>",
      "idempotency_key": "<a new key for each payment>",
      "dry_run": true
    }
  }'
ParamRequiredNotes
payment_method_idYesFrom step 2.
payment_amountYesA positive amount as text, like "47.95".
idempotency_keyYesOne key per payment. Sending the same key again returns the same payment and never pays twice.
account_numberNoThe account to pay when the login has more than one. Required when the card comes from your Card API.
max_amountNoThe most the page may charge. Defaults to payment_amount.
dry_runNotrue or false (a boolean, not text). See below.
expected_balanceNoStop with balance_mismatch when the site shows another balance.
due_date, require_dueNoWith require_due: true, stop with not_due_yet when the bill is not due.

The answer is 202 with job_id, poll_url and payment_id. Poll Get job until it is done. GET /v1/wire/payments/{payment_id} returns the payment's own record.

Dry run

A dry run does everything except the last click: it signs in, opens the pay page, checks the account, the amount and the card, and stops before paying. Nothing is charged. The job result has status: "dry_run", ready (true when the run reached the pay button with every check passed) and, when not ready, reason and failure_code.

A run is always a dry run when you send dry_run: true, when the action is still a draft, or when payments are in dry-run-only mode on the environment.

Stop a payment

curl -X POST https://api.anakin.io/v1/wire/payments/<payment_id>/stop -H "X-API-Key: $KEY"

A stopped payment ends with stopped_by_owner. A stop that arrives after the pay click cannot undo it.


Stop codes

Every pay job that does not pay carries one failure_code from this fixed list, in the job result and on the payment.

CodeWhat happenedWhat to do
card_declinedThe site refused the card.Use another card.
card_not_on_siteThe site lists saved cards and the card for this payment is not one of them.Save the card on the site yourself, or use a payment method the site accepts.
amount_mismatchThe page would charge another amount than payment_amount.Check the amount.
balance_mismatchThe site's balance is not expected_balance.Check the bill.
account_mismatchThe page is not on the account you named.Check account_number.
not_due_yetrequire_due is on and the bill is not due.Run it later.
duplicate_warningThe site warns that this bill was paid recently.Check before paying again.
autopay_enrolledThe account pays itself.Nothing to pay.
payment_scheduledA payment is already scheduled on the site.Nothing to pay.
captcha_blockedThe site blocked the browser with a bot check.Sign in again and retry later.
two_factor_requiredThe site asked for a code that could not be answered.Sign in again.
account_lockedThe site locked the login.Unlock it on the site.
password_reset_requiredThe site demands a new password.Reset it on the site, then update the login.
session_expiredSigned out, or no usable sign-in for the identity.Sign in again.
biller_transientThe site failed in a way that usually passes.Retry later.
stopped_by_ownerYou stopped the payment.—
paid_unknownThe pay click was made and the result could not be read.Do not retry. Check the site by hand.
otherAnything else. Nothing was paid.Contact support with the payment_id.

Only paid_unknown can mean money moved. With every other code, nothing was charged.


Refusals before the job starts

These come back straight from POST /task, with no job and no charge.

StatusCodeMeaning
400INVALID_PAY_PARAMSA param is missing or malformed, or credential_id is missing. The message says which.
400INVALID_PAYMENT_METHODThe payment method cannot pay for this identity: not found, not active, saved on another login, or expired.
409CARD_CHANGEDThe card behind the payment method is no longer the one you connected. Connect it again.
422PAYMENT_LIMITThe amount is over the per-payment limit or the 24-hour limit.
401AUTH_REQUIREDThe credential was not found.
403FORBIDDENThe credential is not yours or is for another site.
503PAYMENTS_DISABLEDPayments are not enabled on this environment.
503ACTION_UNAVAILABLEThe pay action is not configured.