# Pay as a known customer

> Charge a customer by its id, and what a known customer changes on the checkout page.

Once you hold an `id`, from the `customer` object of an earlier payment or from
[`POST /customers`](https://docs.wajub.com/payments/customers/manage#create-a-customer-up-front), pass it and skip the
contact fields entirely. The `customer` field accepts the id as a plain string, and `customer_id`
accepts the same value; they are two spellings of one thing.

**Charge an existing customer**

```bash
curl https://api.wajub.com/payments \
  -H "Authorization: sk_test.xxxxxxxxxxxxxxxx…" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "currency": "XAF",
    "customer": "cus_test_sAaim5apjocIgtlhzJY3wQ8s",
    "reference": "order-4173"
  }'
```

```javascript
const payment = await wajub.payments.create({
  amount: 5000,
  currency: 'XAF',
  customer: 'cus_test_sAaim5apjocIgtlhzJY3wQ8s',
  reference: 'order-4173',
});
```

```python
payment = wajub.payments.create({
    "amount": 5000,
    "currency": "XAF",
    "customer": "cus_test_sAaim5apjocIgtlhzJY3wQ8s",
    "reference": "order-4173",
})
```

```php
$payment = $wajub->payments->create([
  'amount' => 5000,
  'currency' => 'XAF',
  'customer' => 'cus_test_sAaim5apjocIgtlhzJY3wQ8s',
  'reference' => 'order-4173',
]);
```

```go
payment, err := client.Payments.Create(context.Background(), map[string]any{
	"amount": 5000,
	"currency": "XAF",
	"customer": "cus_test_sAaim5apjocIgtlhzJY3wQ8s",
	"reference": "order-4173",
}, nil)
```

The identifier does not have to be an id. If the value you pass matches no customer `id`, Wajub
tries it as a phone number, then as an email address. So `"customer": "amina@example.com"` and
`"customer": "+237670000000"` both resolve, which is convenient when your own database stores the
email and not the Wajub id.

> [!CAUTION]
> **An identifier that resolves to nothing is a 422, not a new customer**
>
> This is the one place where the API refuses to create. Pass `customer` or `customer_id` and Wajub
> will find that customer or fail the call with a `422` on the field you used, `Customer not found.`;
> it never falls back to creating one. A stale id, a customer deleted last week, or a live id sent to sandbox all kill the
> payment outright. Send `email` or `phone` instead when you are not certain the record exists.

## What a customer changes on the checkout page

This is the part that pays for the extra call. A payment attached to a known customer renders a
different page.

| What the customer carries           | What the checkout does with it                                         |
| ----------------------------------- | ---------------------------------------------------------------------- |
| Past cards and Mobile Money numbers | Offers them as one-tap saved methods, default first, ten at most       |
| `preferred_language`                | Sets the page locale, unless the team or branding setting overrides it |
| `currency`                          | Becomes the pre-selected currency when auto-convert is enabled         |

Saved methods are the real win for returning payers: the number is already there, masked, and they
confirm on the handset without typing it again.

> [!NOTE]
> **Saving a method is the payer's decision**
>
> A card or Mobile Money number is only kept when the payer ticks the box on the checkout page. It
> is never inferred and never defaulted on, so a customer record with no saved methods is the
> normal state until someone opts in. Only cards and Mobile Money are reusable; wallets and bank
> transfers are not stored.

- [Manage customers](https://docs.wajub.com/payments/customers/manage): Create one up front, so the first payment already has an id to use.
- [Recurring invoices](https://docs.wajub.com/billing/invoice/recurring): Bill a known customer on a schedule.
