> For the complete documentation index, see [llms.txt](https://6dot50.gitbook.io/6dot50-apis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://6dot50.gitbook.io/6dot50-apis/initiate-payment/post-payments.md).

# POST /payments

This operation will **initiate a new payment** for a user and the response will include a unique PaymentID to track the status of the transaction.

### Request

Initiating a payment is performed by posting to /payments with the following body:

```
{
  "amount": "string",
  "currencyCode": "string",
  "accountId": "string($guid)",
  "reference": "string",
  "returnUrl": "string",
  "countryCode": "string"
}
```

<table><thead><tr><th width="206.33333333333331">Header</th><th width="134">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Yes</td><td>Bearer token from <a href="/pages/cHEoeOTtlWUGg6JiSd31">/authentication/getToken</a></td></tr></tbody></table>

<table><thead><tr><th width="187.33333333333331">Body Field</th><th width="134">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><code>amount</code></td><td>Yes</td><td>The amount to request from the user <strong>in cents</strong>.</td></tr><tr><td><code>currencyCode</code></td><td>Yes</td><td>The payment currency to request from the user, e.g. DZAR</td></tr><tr><td><code>accountId</code></td><td>Yes</td><td><p>The unique ID of the merchant’s account to which to transfer the user’s payment to (if successful).</p><p>See <a href="/pages/5s5ssXL242PSLj7qz7nO">Accounts</a> for obtaining the correct <code>accountId</code>.</p></td></tr><tr><td><code>reference</code></td><td>Yes</td><td>A unique reference generated and supplied by your system. This reference will be displayed to the user should they have any queries for the payment.</td></tr><tr><td><code>returnUrl</code></td><td>No</td><td><p>The URL to redirect the user to once payment has been completed.</p><p> </p><p>An <code>id</code> parameter will be appended to the <code>returnUrl</code> which can be used by the Merchant’s system to query the status of the Payment.</p></td></tr><tr><td><code>countryCode</code></td><td>Yes</td><td>The country code of the user who is requesting the payment. This is the Alpha-2 country code as defined by <a href="https://www.iban.com/country-codes">https://www.iban.com/country-codes</a></td></tr></tbody></table>

{% code title="Sample Request" %}

```
{
  "amount": "10000",
  "currencyCode": "DZAR",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "reference": "ref12345678",
  "returnUrl": "https://redirect.merchant.com",
  "countryCode": "ZA"
}
```

{% endcode %}

### Response

If successful, the operation will return a payment initiation response:

```
{
  "id": "string($guid)",
  "reference": "string",
  "amount": "string",
  "accountId": "string($guid)",
  "currencyCode": "string",
  "statusCode": int,
  "statusMessage": "string",
  "errorCode": int,
  "errorMessage": "string",
  "createdAt": "string($date-time)"
}
```

| Field           | Response Type      | Description                                                                                                                                                      |
| --------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`            | string($guid)      | The unique Payment ID generated by 6DOT50 to be used in subsequent user redirects and method calls.                                                              |
| `reference`     | string             | Same value from Request.                                                                                                                                         |
| `amount`        | string             | Same value from Request.                                                                                                                                         |
| `accountId`     | string($guid)      | Same value from Request.                                                                                                                                         |
| `currencyCode`  | string             | Same value from Request.                                                                                                                                         |
| `statusCode`    | int                | Status code for the transaction. See [Payment Status Codes](/6dot50-apis/redemptions-api/payment-codes.md#status-codes) for more information.                    |
| `statusMessage` | string             | A display message for the status code. See [Payment Status Codes](/6dot50-apis/redemptions-api/payment-codes.md#status-codes) for messages.                      |
| `errorCode`     | int                | Error code for the transaction if it failed to create. See [Payment Error Codes](/6dot50-apis/redemptions-api/payment-codes.md#error-codes) for more information |
| `errorMessage`  | string             | A display message for the error code. See [Payment Error Codes](/6dot50-apis/redemptions-api/payment-codes.md#error-codes) for messages.                         |
| `createdAt`     | string($date-time) | Time in UTC when the payment was created.                                                                                                                        |

{% code title="Sample Response" %}

```
{
  "id": "009c3481-a65c-4afa-a950-1f5bce710493",
  "reference": "ref12345678",
  "amount": "10000",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "currencyCode": "DZAR",
  "statusCode": 0,
  "statusMessage": "Payment is in progress",
  "errorCode": 0,
  "createdAt": "2022-09-26T11:40:47.33"
}
```

{% endcode %}
