# Checkout Page (General)

## Payin by using Pagsmile checkout page

<mark style="color:green;">`POST`</mark> `https://gateway-test.pagsmile.com/trade/create`

This endpoint allows you to submit a payin by using Pagsmile checkout page

#### Headers

| Name                                            | Type   | Description                                |
| ----------------------------------------------- | ------ | ------------------------------------------ |
| Content-Type<mark style="color:red;">\*</mark>  | string | application/json; chartset=UTF-8           |
| Authorization<mark style="color:red;">\*</mark> | string | Basic Base($app\_*id:$security\_*&#x6B;ey) |

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                                                                                          |
| ------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| app\_id<mark style="color:red;">\*</mark>         | string | <p>created app's id at dashboard</p><p>- Max. 32 chars -</p>                                                                                                                                                                                                         |
| method                                            | string | Add this object to show only the selected method. For instance, “method”: “PIX” will only show the PIX method. To show all the methods do not add this object in the request body. Check [here](https://docs.pagsmile.com/payin/data/payment-method) for all methods |
| out\_trade\_no<mark style="color:red;">\*</mark>  | string | <p>ID given by the merchant in their system<br>- Max. 64 chars - </p>                                                                                                                                                                                                |
| notify\_url<mark style="color:red;">\*</mark>     | string | Where Pagsmile will send notification to                                                                                                                                                                                                                             |
| timestamp<mark style="color:red;">\*</mark>       | string | <p>yyyy-MM-dd HH:mm:ss<br>- Max. 19 chars -</p>                                                                                                                                                                                                                      |
| subject<mark style="color:red;">\*</mark>         | string | <p>payment reason or item title</p><p>- Max. 128 chars -</p>                                                                                                                                                                                                         |
| order\_amount<mark style="color:red;">\*</mark>   | string | <p>order amount<br>- 0.01 \~ 999999999 -</p><p>(refer to amount limit for different <a href="../data/payment-method">methods</a>)</p>                                                                                                                                |
| order\_currency<mark style="color:red;">\*</mark> | string | <p>order currency<br>- Max. 3 chars -<br>Check <a href="../data/payment-method">here</a> for all methods.</p>                                                                                                                                                        |
| content<mark style="color:red;">\*</mark>         | string | <p>payment reason detail or item detail. This will be shown on the bank bill.</p><p>- Max. 255 chars -</p>                                                                                                                                                           |
| buyer\_id<mark style="color:red;">\*</mark>       | string | merchant user's id                                                                                                                                                                                                                                                   |
| channel                                           | string | only use when method = Wallet                                                                                                                                                                                                                                        |
| trade\_type<mark style="color:red;">\*</mark>     | string | fixed value: WEB                                                                                                                                                                                                                                                     |
| return\_url                                       | sring  | web redirect url when payment is finish                                                                                                                                                                                                                              |
| timeout\_express                                  | string | <p>m(minutes), h(hours), d(days), c(always end in current day). </p><p>Used to control the expiration time of <strong>submitting</strong> an order (from initial to processing).  (90m in default, max 15d)</p>                                                      |
| customer.name                                     | string | <p>User's name</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                                 |
| customer.phone                                    | string | <p>User's phone</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                                |
| customer.email                                    | string | <p>User's email</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                                |
| customer.identify.number                          | string | <p>User's identification number</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                |
| customer.identify.type                            | string | <p>User's identification type</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                  |
| address.zip\_code                                 | string | <p>zip code</p><p>- Will be pre-filled on the checkout page -</p>                                                                                                                                                                                                    |
| regions                                           | array  | <p>regions of the payment. Required if using Global App. The format is ISO 3166-1 alpha-3<br>- ARG, BRA, etc. Check <a href="../data/country-code">here</a> - </p>                                                                                                   |

{% tabs %}
{% tab title="200 submit successfully" %}

```
{
    "code": "10000",
    "msg": "Success",
    "trade_no": "2022010110293900083",
    "out_trade_no": "202201010354003",
    "web_url": "http://checkout-testv2.pagsmile.com?prepay_id=123456",
    "prepay_id":"123456"
}
```

{% endtab %}

{% tab title="400 duplicate out\_trade\_no" %}

```
{
    "code": "40002",
    "msg": "Business Failed",
    "sub_code": "duplicate-out_trade_no",
    "sub_msg": "out_trade_no is duplicate"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Check [here](https://docs.pagsmile.com/payin/data/payment-method) for supported methods.&#x20;

* If not passing the parameter "method" or pass "method": "", all enabled methods will be shown to the user on the checkout page.
* If passing "method": "PIX", only PIX will be shown to the user on the checkout page.
  {% endhint %}

## Example

```
curl --location --request POST 'https://gateway-test.pagsmile.com/trade/create' \
--header 'Authorization: Basic MTYyNTgyOTIxNDUzMTY2Mzg6UGFnc21pbGVfc2tfZDUwMWQ1ZGNkNTI5OGQ5N2MwNmUzYjI4YjA2OWZjZmY3NDU5ZjY2NzNiMjFjMTFlYTY3NDM5MDgzOTZkOTYxNQ==' \
--header 'Content-Type: application/json' \
--data-raw '{
      "charset": "UTF-8",
    * "app_id": "162************38",
    * "out_trade_no": "202201010354002",
    * "order_currency": "BRL",
    * "order_amount": "12.01",
    * "subject": "item name",
    * "content": "item description",
    * "trade_type": "WEB",
      "timeout_express": "1d",
    * "timestamp": "2022-01-01 03:54:01",
    * "notify_url": "http://merchant/callback/success",
    * "buyer_id": "buyer_0101_0001",
      "customer": {
          "identify": {
              "type": "CPF",
              "number": "50284414727"
          },
      "name": "Test User Name",
      "email": "test@pagsmile.com"
      },
      "regions": ["BRA"], //Support multiple regions. For example "regions": ["BRA","COL","MEX"]
      "address": {
          "zip_code": "38082365"
      }
}'
```

{% hint style="danger" %}
Return*url is not required in the request parameters. However if needed, you can overwrite it by appending the return\_*&#x75;rl after the web\_url when redirect.&#x20;

`http://checkout.pagsmile.com?prepay_id={$prepay_id}`

↓↓↓

`http://checkout.pagsmile.com?prepay_id={$prepay_id}&return_url=encodeURIComponent({$return_url})`
{% endhint %}

{% hint style="info" %}
Note:  **162\*\*\*\*\*\*\*\*\*\*\*\*38** is pagsmile's test app id for sandbox, and **MTYyNTgyOTIxNDUzMTY2Mzg6UGFnc21pbGVfc2tfZDUwMWQ1ZGNkNTI5OGQ5N2MwNmUzYjI4YjA2OWZjZmY3NDU5ZjY2NzNiMjFjMTFlYTY3NDM5MDgzOTZkOTYxNQ==** is authorization token associated with the test app id.&#x20;
{% endhint %}

{% hint style="danger" %}
Please use your own **app\_id** and generate your own **authorization token** when testing.
{% endhint %}

<figure><img src="https://4142198059-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgOGd5QxlX-U1mkQpVU%2Fuploads%2FwCxwlfFSl8nJxRoLYxD9%2Fimage.png?alt=media&#x26;token=405d68ad-101b-4c6d-9aca-1597a360d3fb" alt=""><figcaption><p>The Checkout page without specifying "method"</p></figcaption></figure>

<figure><img src="https://4142198059-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgOGd5QxlX-U1mkQpVU%2Fuploads%2FSSBtZS66w0UFztllBjng%2Fimage.png?alt=media&#x26;token=ee75fced-9238-48ad-a9e6-8d0fd86abfbd" alt=""><figcaption><p>The Checkout page with specifying "method":"PIX" (as an exmaple)</p></figcaption></figure>
