# Octopus for Payment Setup API To accept Octopus payments, you must: 1. Create a payment setup. 2. Confirm the payment. 3. Redirect the customer to Octopus. --- ## 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": 1000, "currency": "HKD", "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).

Minimum: 1

**Required**

For Octopus, payment and refund amounts must end in a `0`. | | `currency`
`string` | Three-letter ISO 4217 [currency code](https://www.checkout.com/docs/developer-resources/codes/currency-codes.md).

Supported value: `HKD`

**Required** | | `settings.failure_url`
`string` | The URL to redirect the customer to if the payment fails.

Format: URI

Max length: 1024

**Required** | | `settings.success_url`
`string` | The URL to redirect the customer to if the payment is successful.

Format: URI

Max length: 1024

**Required** | | `description`
`string` | A description of the payment.

Max length: 100 | | `reference`
`string` | A reference you can use to identify the payment.

Max length: 80 | ### Response example ```json { "id": "set_rcmepwrchqab2wsergcafvijfy", "processing_channel_id": "pc_wzjki6hw5puepb5fnvqlizj2e4", "amount": 1000, "currency": "HKD", "payment_type": "Regular", "reference": "ORD-5023-4E89", "description": "Octopus payment", "payment_methods": { "octopus": { "status": "ready", "flags": [] } }, "available_payment_methods": [ "octopus" ], "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.octopus` 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. - `octopus` as the `{payment_method_name}` path parameter. ### Request example **Production** `POST` `https://{prefix}.api.checkout.com/payments/setups/{id}/confirm/octopus` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/payments/setups/{id}/confirm/octopus` ### Response example ```json { "id": "pay_dinkmi3v4vgutixpcw6mcdzt44", "status": "Pending", "reference": "ORD-5023-4E89", "customer": { "id": "cus_2g4ehcpm6phexgkzahlwxvbgne" }, "processing": { "landing_url": "https://web-test.online.octopus.com.hk/oos/payment/?token=zjsdhd3", "octopus_uri": "octopus://payment?token=zjsdhd3", "token": "zjsdhd3" }, "_links": { "self": { "href": "https://{prefix}.api.checkout.com/payments/pay_dinkmi3v4vgutixpcw6mcdzt44" } } } ``` --- ## Redirect the customer The redirect step varies depending on where you're requesting the payment from. ### Desktop To redirect a customer from a desktop browser: 1. Ensure that the Octopus App is installed on your customer's phone. 2. Redirect your customer to the `processing.landing_url` value from the response.
The URL displays a QR code. 3. Your customer must scan the code using their Octopus App and authorize the payment on their device. 4. After authorizing the payment, they're redirected to either your `settings.success_url` or `settings.failure_url`. ### Mobile To redirect a customer from a mobile application: 1. Ensure that the Octopus App is installed on your customer's phone.
If the application is not installed, instruct your customers to install it. 2. Obtain the necessary token from the `processing` object in the response: - For Android – Pass the `processing.octopus_uri` value to the Octopus App. - For iOS – Use the `processing.token` value to construct a URL using a custom URL scheme to invoke the Octopus App. 3. The Octopus App launches on your customer's phone so they can authorize the payment.