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": []
}'| Field | Notes |
|---|---|
kind | "payment" |
catalog_id | Required. The site's catalog. |
website_url | Must be on the catalog's site. |
pay_inputs | Optional 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
- Sign in to the site with the browser sign-in (Login). Keep the
credential_id. - Create a payment method with
POST /v1/wire/payment-methodsand 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
}
}'| Param | Required | Notes |
|---|---|---|
payment_method_id | Yes | From step 2. |
payment_amount | Yes | A positive amount as text, like "47.95". |
idempotency_key | Yes | One key per payment. Sending the same key again returns the same payment and never pays twice. |
account_number | No | The account to pay when the login has more than one. Required when the card comes from your Card API. |
max_amount | No | The most the page may charge. Defaults to payment_amount. |
dry_run | No | true or false (a boolean, not text). See below. |
expected_balance | No | Stop with balance_mismatch when the site shows another balance. |
due_date, require_due | No | With 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.
| Code | What happened | What to do |
|---|---|---|
card_declined | The site refused the card. | Use another card. |
card_not_on_site | The 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_mismatch | The page would charge another amount than payment_amount. | Check the amount. |
balance_mismatch | The site's balance is not expected_balance. | Check the bill. |
account_mismatch | The page is not on the account you named. | Check account_number. |
not_due_yet | require_due is on and the bill is not due. | Run it later. |
duplicate_warning | The site warns that this bill was paid recently. | Check before paying again. |
autopay_enrolled | The account pays itself. | Nothing to pay. |
payment_scheduled | A payment is already scheduled on the site. | Nothing to pay. |
captcha_blocked | The site blocked the browser with a bot check. | Sign in again and retry later. |
two_factor_required | The site asked for a code that could not be answered. | Sign in again. |
account_locked | The site locked the login. | Unlock it on the site. |
password_reset_required | The site demands a new password. | Reset it on the site, then update the login. |
session_expired | Signed out, or no usable sign-in for the identity. | Sign in again. |
biller_transient | The site failed in a way that usually passes. | Retry later. |
stopped_by_owner | You stopped the payment. | — |
paid_unknown | The pay click was made and the result could not be read. | Do not retry. Check the site by hand. |
other | Anything 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.
| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_PAY_PARAMS | A param is missing or malformed, or credential_id is missing. The message says which. |
| 400 | INVALID_PAYMENT_METHOD | The payment method cannot pay for this identity: not found, not active, saved on another login, or expired. |
| 409 | CARD_CHANGED | The card behind the payment method is no longer the one you connected. Connect it again. |
| 422 | PAYMENT_LIMIT | The amount is over the per-payment limit or the 24-hour limit. |
| 401 | AUTH_REQUIRED | The credential was not found. |
| 403 | FORBIDDEN | The credential is not yours or is for another site. |
| 503 | PAYMENTS_DISABLED | Payments are not enabled on this environment. |
| 503 | ACTION_UNAVAILABLE | The pay action is not configured. |