# Tabby for Payment Setup API
To accept Tabby payments, you must:
1. Create a payment setup.
2. Confirm the payment.
3. Redirect the customer to Tabby.
---
## Create a payment setup
Call the [Create a payment setup](https://api-reference.checkout.com/tag/Payment-Setups/#operation/createAPaymentSetup) endpoint.
> **Information**
>
> Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md).
**Production**
`POST` `https://{prefix}.api.checkout.com/payments/setups`
**Sandbox**
`POST` `https://{prefix}.api.sandbox.checkout.com/payments/setups`
### Request example
```json
{
"amount": 10000,
"currency": "AED",
"reference": "ORDER_01234",
"customer": {
"name": "Hannah Bret",
"email": {
"address": "hannah.bret@example.com"
},
"phone": {
"country_code": "971",
"number": "500000001"
}
},
"settings": {
"success_url": "https://example.com/payments/success",
"failure_url": "https://example.com/payments/failure"
}
}
```
In the request body, provide the following:
| Field | Description |
| --- | --- |
| `amount`
`number` | The payment amount, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 1
**Required** |
| `currency`
`string` | The three-letter ISO 4217 [currency code](https://www.checkout.com/docs/developer-resources/codes/currency-codes.md).
Supported values: `AED`, `SAR`, `KWD`, `BHD`, `QAR`
**Required** |
| `reference`
`string` | A reference you can use to identify the payment.
Max length: 80
**Required** |
| `settings.failure_url`
`string` | The URL to redirect the customer to if the payment fails.
Format: URI
**Required** |
| `settings.success_url`
`string` | The URL to redirect the customer to if the payment is successful.
Format: URI
**Required** |
| `customer`
`object` | The customer's details. Provide as many fields as possible to support Tabby's credit assessment and improve the acceptance rate. |
| `customer.device.locale`
`string` | The locale of the customer's device.
Pattern: `^(?i)(ar\|en)(-[A-Za-z0-9]+)?$`
For example, `en-UK`. |
| `customer.email.address`
`string` | The customer's email address.
Format: email |
| `customer.merchant_account.first_transaction_date`
`string` | The date of the customer's first transaction with you.
Format: date-time |
| `customer.merchant_account.id`
`string` | The customer's identifier in your account.
Max length: 255 |
| `customer.merchant_account.last_payment_date`
`string` | The date of the customer's last payment with you.
Format: date-time |
| `customer.merchant_account.registration_date`
`string` | The date the customer registered an account with you.
Format: date-time |
| `customer.name`
`string` | The customer's full name. |
| `customer.phone.number`
`string` | The customer's phone number.
Pattern: `^\d+$` |
| `description`
`string` | A description of the payment.
Max length: 100 |
| `industry.accommodation`
`array` | Accommodation industry data, for travel sector merchants. |
| `industry.accommodation[].check_in_date`
`string` | The check-in date.
Format: date |
| `industry.accommodation[].check_out_date`
`string` | The check-out date.
Format: date |
| `industry.accommodation[].guest[].date_of_birth`
`string` | The guest's date of birth.
Format: date |
| `industry.accommodation[].number_of_rooms`
`integer` | The number of rooms booked.
Minimum: 1 |
| `industry.airline`
`array` | Airline industry data, for travel sector merchants. |
| `industry.airline[].flight_leg_details[].departure_date`
`string` | The flight's departure date.
Format: date |
| `industry.airline[].passenger[].date_of_birth`
`string` | The passenger's date of birth.
Format: date |
| `order.discount_amount`
`number` | The total discount amount applied to the order, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 0 |
| `order.items`
`array` | An array of items in the order.
Minimum items: 1 |
| `order.items[].discount_amount`
`number` | The discount amount applied to the item, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 0 |
| `order.items[].image_url`
`string` | The URL of an image of the item.
Format: URI
Max length: 1024 |
| `order.items[].quantity`
`integer` | The quantity of the item.
Minimum: 1 |
| `order.items[].unit_price`
`number` | The unit price of the item, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 1 |
| `order.items[].url`
`string` | A URL with more information about the item.
Format: URI
Max length: 1024 |
| `order.shipping_amount`
`number` | The total shipping amount for the order, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 0 |
| `order.tax_amount`
`number` | The total tax amount applied to the order, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value.md).
Minimum: 0 |
### Response example
```json
{
"id": "set_rcmepwrchqab2wsergcafvijfy",
"processing_channel_id": "pc_wzjki6hw5puepb5fnvqlizj2e4",
"amount": 10000,
"currency": "AED",
"payment_type": "Regular",
"reference": "ORDER_01234",
"description": "Tabby payment",
"payment_methods": {
"tabby": {
"status": "ready",
"flags": []
}
},
"available_payment_methods": [
"tabby"
],
"settings": {
"success_url": "https://example.com/payments/success",
"failure_url": "https://example.com/payments/failure"
}
}
```
The response returns a `payment_methods` object, which contains the payment methods enabled on your account.
When all required fields are present, the `payment_methods.tabby` object shows a `ready` [status](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-using-the-payment-setup-api.md#Payment_method_status).
---
## Confirm the payment
Confirm the payment by calling the [Confirm a payment setup](https://api-reference.checkout.com/tag/Payment-Setups/#operation/confirmAPaymentSetup) endpoint and provide:
- The payment setup `id` as the `{id}` path parameter.
- `tabby` as the `{payment_method_name}` path parameter.
### Request example
**Production**
`POST` `https://{prefix}.api.checkout.com/payments/setups/{id}/confirm/tabby`
**Sandbox**
`POST` `https://{prefix}.api.sandbox.checkout.com/payments/setups/{id}/confirm/tabby`
### Response example
```json
{
"id": "pay_mbabizu24mvu3mela5njyhpit4",
"status": "Pending",
"reference": "ORDER_01234",
"customer": {
"id": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
"email": "hannah.bret@example.com",
"name": "Hannah Bret",
"phone": {
"country_code": "971",
"number": "500000001"
}
},
"_links": {
"self": {
"href": "https://{prefix}.api.checkout.com/payments/pay_mbabizu24mvu3mela5njyhpit4"
},
"redirect": {
"href": "https://checkout.tabby.ai/?sessionId=ad76fb0e-3b52-4c8f-85d3-5171d84e5b6b&apiKey=pk_test_e7522500-ea7b-44d4-9f76-22b3ef8167b7&product=installments&merchantCode=CKOAED"
}
}
}
```
---
## Redirect the customer
Redirect the customer to the `_links.redirect.href` URL from the response. The customer completes the payment on the Tabby page and is then redirected back to your `settings.success_url` or `settings.failure_url`.
If the customer has a Tabby account, they receive a one-time password (OTP) to authenticate. If the customer does not have an account, they are redirected to sign up for an account with Tabby.
> **Information**
>
> The sign-up option is only available in the production environment.