# Payment form integration

1. Get a token to open the form&#x20;
2. Open form&#x20;
3. Make a deposit/payment&#x20;
4. Receive a callback with invoice status

### Request address to receive a token

`https://cactusgino.com/api/jsapi/obtain_token/`

{% tabs %}
{% tab title="shell" %}

```sh
curl -X POST -H "Content-Type: application/json" \
     -d '
    {
    "site_id": 1,
    "site_login": "551d0ad9072b30f3b71b989e",
    "merchant_id": "merch_id",
    "request_id":"jnvdjd094vnd",
    "amount":900000,
    "method":"card",
    "customer_type":"trust",
    "signature": "mnasdkansda09sdjaslkdnalkd",
    "currency": "KZT"
    }'
 https://cactusgino.com/api/jsapi/obtain_token/
```

#### <mark style="color:red;">Failed response</mark>

```sh
{
  "success": false,
  "message": "Invalid ContentType or json format",
  "signature": "jnfndssfdjkfndsnf09jf"
}
```

#### <mark style="color:green;">Successful response</mark>

```javascript
{
  "success": true,
  "key": "u48fbalfjf904903nb7s830fnaoa0jnfkoddijfkjf9442jijex",
  "redirect_url": "https://pp.ohboo0ie.com/api/jsapi/open/3d6f4a7992bbc19d95e4951cc4387e1dabe04c4bf086cd675009030e75b6a5cd/",
  "signature": "jd93jdslkajldkjskldjskald0"
}
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = 'https://cactusgino.com/api/jsapi/obtain_token/'

json = dict(
    site_id=1,
    site_login="551d0ad9072b30f3b71b989e",
    merchant_id="merch_id",
    request_id="jnvdjd094vnd",
    amount=90000,
    signature="eve84knnfdjnknfsdjfsdfjs0d9jf",
    currency="KZT",
    method="card"
    customer_type="trust",
)
response = requests.post(url, json=json)
data = response.json()
```

#### <mark style="color:red;">Failed response</mark>

```python
{
  "success": false,
  "message": "Invalid ContentType or json format",
  "signature": "jnfndssfdjkfndsnf09jf"
}
```

#### <mark style="color:green;">Successful response</mark>

```python
{
  "success": true,
  "key": "u48fbalfjf904903nb7s830fnaoa0jnfkoddijfkjf9442jijex",
  "signature": "jd93jdslkajldkjskldjskald0"
}
```

{% endtab %}
{% endtabs %}

Take the `key` value from the response to receive a token and open the form to the user.

Depending on your website’s settings, the response parameters may include the `redirect_url` parameter. In this case, the user should be redirected to the specified URL to complete the payment.

### Opening a form

<table data-full-width="true"><thead><tr><th width="209">Parameter</th><th>Required</th><th>Format</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>merchant_id</td><td>Yes</td><td>string</td><td>Merchant ID, to be determined in the system</td><td>superkey</td></tr><tr><td>site_login</td><td>Yes</td><td>string</td><td>Login of the user making the payment</td><td>jnsdf093jfsdklfndf09</td></tr><tr><td>site_id</td><td>Yes</td><td>integer</td><td>Your site_id</td><td>1</td></tr><tr><td>request_id</td><td>Yes</td><td>string</td><td>Order ID in the seller's system</td><td>uib64bc9494n9v</td></tr><tr><td>amount</td><td>Yes</td><td>integer</td><td>Amount to be paid in minor units (numbers after ".")</td><td>9000</td></tr><tr><td>signature</td><td>Yes</td><td>string</td><td>See request signature. <a href="signature">Rules for forming a request signature</a></td><td></td></tr><tr><td>currency</td><td>Yes</td><td>string</td><td>Currency</td><td>KZT</td></tr><tr><td>method</td><td>No</td><td>string</td><td>Open the interface, with a pre-selected method, possible values are sbp, card, qiwi, cash, mobile, binance, MTSPay, WalletM10, Emanat, wise, skrill, cis_transfer, cis_transfer_card, localbanks, papara, Tbank_card, PIX, phone_topup, havale, ELQR</td><td>card</td></tr><tr><td>customer_type</td><td>No</td><td>string</td><td>A parameter that sets the customers type (Trust or Not Trust). Available values: <strong>"trust" -</strong> trust customer, <strong>"regular"</strong> - not trust. For any other parameter values, the default value will be <strong>"regular"</strong></td><td>trust</td></tr><tr><td>language</td><td>No</td><td>string</td><td>A parameter that sets the language of the payment page interface. Available values: EN - English, DE - German, UA - Ukrainian, RU - Russian, KZ - Kazakh, AZ - Azerbaijani, IN - Indonisian, ID - Hindi. EN - default parameter, it’s determined when “language” is not recognized.</td><td>EN</td></tr><tr><td>success_url</td><td>No</td><td>string</td><td>Redirect link upon successful deposit</td><td>https://google.com</td></tr><tr><td>fail_url</td><td>No</td><td>string</td><td>Redirection link in case of unsuccessful deposit</td><td>https://google.com</td></tr><tr><td>additional_fields</td><td>No</td><td>object</td><td><a href="#additional_fields">Additional options for certain payment methods.</a></td><td></td></tr></tbody></table>

#### **`additional_fields`:**

* `cis_transfer, cis_transfer_card`:
  * `bank_app`(required): The parameter that determines which bank the transfer will originate from. The user interface instructions for making a transfer depend on this parameter. Available values: `sberbank` ,  `tbank` and `kapital`&#x20;
* Other payment methods do not require additional fields.

<details>

<summary>Example of a <code>cis_transfer</code> payment method request</summary>

{% code title="Request" %}

```shell
curl -X POST -H "Content-Type: application/json" \
     -d '
    {
    "site_id": 1,
    "site_login": "551d0ad9072b30f3b71b989e",
    "merchant_id": "merch_id",
    "request_id":"jnvdjd094vnd",
    "amount":900000,
    "method":"cis_transfer",
    "customer_type":"trust",
    "signature": "mnasdkansda09sdjaslkdnalkd",
    "currency": "RUB"
    "additional_fields": {
        "bank_app": "tbank"
        }
    }'
 https://cactusgino.com/api/jsapi/obtain_token/
```

{% endcode %}

</details>

### Request address for opening iframe

`https://cactusgino.com/api/jsapi/open/{key}/`
