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

# Customer actions

> What your customer must do to authorize a mobile money collection, and how your integration should guide them.

A mobile money collection is not complete until your customer approves it. How they approve depends on the operator: some send a prompt to the phone, some need a code or a USSD dial, and some need the customer to open a link. Bumxpress describes all of these with one model, **customer actions**, so you handle every operator the same way.

> [!NOTE]
>
> Customer actions apply to **payins** and to the **collection leg of transfers**. Payouts need nothing from the recipient.

## The two moments

| Moment | What you get | Where |
| - | - | - |
| **Before you create the payin** | A *requirement*: what the customer must do on this route | `customer_action` on [`GET /coverage`](https://developers.bumxpress.com/api-reference/coverage/list-coverage) (inside `payin`) and on payin [quotes](https://developers.bumxpress.com/guides/quotes.md) |
| **After the provider accepted the request** | An *action*: the concrete thing to show the customer (a link, a USSD code, a field for a code) | `provider_action` on the payin, `payin_action` on transfers, and in [webhooks](https://developers.bumxpress.com/guides/webhooks.md) |

When a route has no `customer_action`, the customer just approves a prompt on their phone and you have nothing to show.

## Requirement types

The requirement tells you what to ask for **before** you call `POST /payins`.

| `type` | What happens | What you do |
| - | - | - |
| `approve_on_phone` | A prompt or SMS reaches the customer, who approves it with their PIN. | Tell the customer to check their phone. |
| `dial_ussd` | After submission the customer dials a USSD code to approve. | Show the `ussd_code` once it is returned in `provider_action`. |
| `redirect` | After submission the customer opens a link to pay. | Redirect the customer to `provider_action.redirect_url`. |
| `otp_before` | The customer generates a one-time code **first** (for example by dialing a USSD code). | Collect the code and send it as `otp_code` on `POST /payins`. |
| `otp_after` | The operator sends the customer a code **after** submission. | Collect the code and send it to [`POST /payins/{payin_id}/authorize`](https://developers.bumxpress.com/api-reference/payins/authorize-payin) (or [`POST /transfers/{transfer_id}/authorize`](https://developers.bumxpress.com/api-reference/transfers/authorize-transfer)). |

A requirement can also carry `ussd_code` and bilingual `instructions` (`en`, `fr`) you can show as they are:

```json theme={null}
{
  "customer_action": {
    "type": "otp_before",
    "ussd_code": "#144*82#",
    "instructions": {
      "en": "Dial #144*82#, choose option 2 to generate a payment code, then enter it.",
      "fr": "Composez le #144*82#, choisissez l'option 2 pour générer un code de paiement, puis saisissez-le."
    }
  }
}
```

## Action types

Once the provider accepted the request, the payin carries a `provider_action` while it waits for the customer.

| `type` | Fields | What you do |
| - | - | - |
| `redirect` | `redirect_url`, sometimes `app_links` (for example `orange_money`) | Open the URL, or the matching app link on mobile. |
| `dial_ussd` | `ussd_code`, `message` | Show the code and the message. |
| `submit_otp` | `message` | Show a field for the code the customer received, then call `/authorize`. |

```json theme={null}
{
  "id": "44444444-4444-4444-4444-444444444444",
  "status": "pending",
  "provider_action": {
    "type": "redirect",
    "redirect_url": "https://pay.example.com/checkout/abc",
    "app_links": { "orange_money": "orangemoney://pay/abc" },
    "message": "Scan the QR code or open the link to pay."
  }
}
```

> [!WARNING]
>
> The action is created **after** `POST /payins` returns. The `201` response can still show no `provider_action`, because the provider call runs in the background and usually finishes within seconds. Wait for the [`payin.action_required`](https://developers.bumxpress.com/guides/webhooks#customer-action-events) webhook, or poll `GET /payins/{payin_id}` until `provider_action` appears. Do not treat a missing action as a failure.

Older fields (`next_action`, `redirect_url`, `otp_required`, `ussd_code`) can still appear inside `provider_action`. They keep working for existing integrations; new code should read `provider_action.type`.

## The flow

**1. Read the requirement**

Call `GET /coverage` or create the payin quote. If the route has a `customer_action`, prepare your screen for it.

**2. Collect what is needed up front**

For `otp_before`, ask the customer for the code **before** creating the payin and send it as `otp_code`. Without it the request fails with `400` and reason `otp_required`.

**3. Create the payin**

`POST /payins` returns `pending`. Keep the payin `id`.

**4. Show the action**

When `payin.action_required` arrives (or `provider_action` shows up when you poll), show the link, the USSD code, or the code field.

**5. Send the code, if asked**

For `submit_otp`, call `POST /payins/{payin_id}/authorize` with the customer's code.

**6. Wait for the final status**

The payin stays `pending` until the provider confirms. Use `payin.completed` or `payin.failed`, or poll.

## Sending a code before: `otp_before`

```bash theme={null}
curl -X POST "https://api.business.bumxpress.com/payins" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: bmx_pk_xxx" \
  -H "X-Api-Secret: bmx_sk_xxx" \
  -H "Idempotency-Key: payin_001" \
  -d '{
    "quote_id": "33333333-3333-3333-3333-333333333333",
    "source": { "phone": "+2250700000000" },
    "otp_code": "123456"
  }'
```

The code is single-use and short-lived. Bumxpress keeps it only until the provider call is made, then removes it. It is never returned by the API, written to logs, or sent in webhooks. Ask for the code as late as you can, right before you create the payin.

## Sending a code after: `otp_after`

When `provider_action.type` is `submit_otp`, the customer has received a code. Send it:

```bash theme={null}
curl -X POST "https://api.business.bumxpress.com/payins/44444444-4444-4444-4444-444444444444/authorize" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: bmx_pk_xxx" \
  -H "X-Api-Secret: bmx_sk_xxx" \
  -d '{ "otp_code": "654321" }'
```

A successful call returns the payin, still `pending`, with `provider_action` removed. The final status arrives like any other payin. A wrong code returns `422` with reason `otp_invalid` and leaves the payin waiting, so the customer can try again. See [`POST /payins/{payin_id}/authorize`](https://developers.bumxpress.com/api-reference/payins/authorize-payin) for every response.

## Transfers

The collection leg of a [transfer](https://developers.bumxpress.com/guides/transfers.md) follows the same rules, with these differences:

* Transfer quotes return `customer_action` for the payer leg, so you can collect an `otp_before` code before creating the transfer.
* Send `otp_code` on `POST /transfers` for an `otp_before` route.
* While the collection waits for the customer, the transfer carries `payin_action` (same shape as `provider_action`), and you receive `transfer.payin.action_required`.
* For `otp_after` (`payin_action.type` is `submit_otp`), send the customer's code to [`POST /transfers/{transfer_id}/authorize`](https://developers.bumxpress.com/api-reference/transfers/authorize-transfer). The transfer stays `collecting` until the provider confirms; a wrong code returns `422` with reason `otp_invalid` and can be retried.

```bash theme={null}
curl -X POST "https://api.business.bumxpress.com/transfers/55555555-5555-5555-5555-555555555555/authorize" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: bmx_pk_xxx" \
  -H "X-Api-Secret: bmx_sk_xxx" \
  -d '{ "otp_code": "654321" }'
```

* Always wait for `transfer.payin.completed` or `transfer.payin.failed` before treating the collection as done.

## Show the right screen

| Requirement | Before creating | After `action_required` |
| - | - | - |
| none or `approve_on_phone` | "Approve the request on your phone." | Nothing to show. |
| `dial_ussd` | Explain that a USSD dial will follow. | Show `ussd_code` and `message`. |
| `redirect` | Explain that you will open a payment page. | Open `redirect_url`. |
| `otp_before` | Show `instructions` and a code field. | Nothing more to show. |
| `otp_after` | Explain that a code will arrive by SMS. | Show a code field, then call `/authorize` on the payin or transfer. |

## Checkout checklist

* Read `customer_action` from the quote. For `otp_before`, show the instructions and collect the code **before** you create the payin. Codes are short-lived, so create the payin as soon as the customer enters one.
* After creating the payin, show a waiting screen. Listen for `payin.action_required`, or poll `GET /payins/{payin_id}` every few seconds for up to a minute.
* `redirect`: open the link in a new tab or the operator's app. Do not embed it in an iframe. On a phone, prefer an entry from `app_links` when there is one.
* `dial_ussd`: show the code large enough to read, with a copy button.
* `message` is the operator's own text and is often in French. Prefer your own wording based on `type`.
* Always wait for `payin.completed` or `payin.failed`. Coming back from a redirect, or a successful `/authorize`, does not mean the money has arrived.

> [!TIP]
>
> Read the requirement from `GET /coverage` instead of hard-coding it per operator. Routes can change, and the response always reflects what is enabled for your account.


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