> ## Documentation Index
> Fetch the complete documentation index at: https://developers.paychoice.com.au/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment methods

> Attach stored cards and bank accounts to a customer, set a default, and remove them.

A customer can hold any number of cards and bank accounts, each referenced by the token you got from [Tokens](https://developers.paychoice.com.au/storing-payment-methods/tokens.md) or the [Create Token page](https://developers.paychoice.com.au/storing-payment-methods/create-token-page.md). Attaching a token to a customer is what makes it persistent; one of them is the **default**, which [Pay customer invoice](https://developers.paychoice.com.au/billing/invoices.md) and scheduled charges use when no token is specified.

| Action | Card | Bank account |
| - | - | - |
| Attach | `POST /customer/{customer}/card` with `card_token` | `POST /customer/{customer}/bank` with `bank_token` |
| Retrieve | `GET /customer/{customer}/card/{card_token}` | `GET /customer/{customer}/bank/{bank_token}` |
| Set as default | `PATCH /customer/{customer}/card/{card_token}` | `PATCH /customer/{customer}/bank/{bank_token}` |
| Remove | `DELETE /customer/{customer}/card/{card_token}` | `DELETE /customer/{customer}/bank/{bank_token}` |

## Attach a card

```bash theme={null}
curl https://api-sandbox.paychoice.com.au/api/v4/customer/8c34513b-61e0-4f8a-b007-af4fe9479bf4/card \
  -u "$PAYCHOICE_USERNAME:$PAYCHOICE_PASSWORD" \
  -H "Accept: application/json" \
  -d card_token=c629ac3b-682b-41e4-9a81-9445960843cf
```

```json theme={null}
{
  "status": "Success",
  "code": 201,
  "messages": [ { "message_text": "Data created", "message_type": "success" } ],
  "card": {
    "id": 11175,
    "card_name": "John Doe",
    "masked_number": "411111XXXXXX1111",
    "card_token": "c629ac3b-682b-41e4-9a81-9445960843cf",
    "card_type": "visa",
    "expiry_month": "12",
    "expiry_year": "27",
    "customer_id": 10332,
    "customer_guid": "8c34513b-61e0-4f8a-b007-af4fe9479bf4",
    "link": { "href": "/api/v4/customer/8c34513b-61e0-4f8a-b007-af4fe9479bf4/card/c629ac3b-682b-41e4-9a81-9445960843cf", "rel": "self" }
  },
  "object_type": "card",
  "link": { "href": "/api/v4/customer/8c34513b-61e0-4f8a-b007-af4fe9479bf4/card", "rel": "self" }
}
```

The `bank` object has `id`, `bank_token`, `name`, `bsb`, `number`, `customer_id`, `customer_guid` and `link`. Attaching a bank account that is already attached to this or another customer returns `403`.

> [!NOTE]
>
> These objects are the customer-scoped shape and differ from the token objects returned by `/token` and `/bank_token`: the token field is `card_token` / `bank_token`, `card_type` is lowercase, and `customer_id` / `customer_guid` are included.

## Set the default

`PATCH` with no body. The response has `object_type: "default_payment_method"` with the card or bank object under that key.

## Remove

`DELETE` returns the envelope with an empty `card` or `bank` object and `message_text` "The selected payment method has been deleted".


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.