> For the complete documentation index, see [llms.txt](https://docs.payvalida.com/api-recaudo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payvalida.com/api-recaudo/api-recaudo-en/purchase-orders/register.md).

# Register

In order to enable payment for the customer, you must register an order first.

<figure><img src="https://2646475391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ly_b6lZywQ5rYRHAN2H-1525464909%2Fuploads%2Fw0xdWct8Pxvl4p3mjLoE%2Fimage.png?alt=media&amp;token=31d47f34-e069-403b-b92f-da4b8206f9cd" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Production:** <https://api.payvalida.com/api/v3/porders>
{% endhint %}

{% hint style="success" %}
**Sandbox:** <https://api-test.payvalida.com/api/v3/porders>
{% endhint %}

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

| Field                       | Type   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| merchant                    | string | yes      | Name assigned to the merchant in Payvalida. Delivered with your credentials.                                                                                                                                                                                                                                                                                                                                                                                |
| email                       | string | yes      | Buyer's email address. Must be a valid email format.                                                                                                                                                                                                                                                                                                                                                                                                        |
| country                     | number | yes      | Country code.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| order                       | string | yes      | Merchant's order code. **This code must be unique across all orders registered by the merchant.** It is used for the notification. It must not contain underscores or special characters.                                                                                                                                                                                                                                                                   |
| reference                   | string | no       | <p>Reference number the customer will use to make the payment. Alphanumeric references or references with special characters cannot be generated. This number is <strong>unique</strong> in Payvalida. If not sent, an available one is assigned. If sent, collisions may occur and the order creation will be rejected.<br><br>Maximum length:<br>Colombia 🇨🇴: 15<br>Ecuador 🇪🇨: 16<br>El Salvador 🇸🇻: 16<br>Guatemala 🇬🇹: 16<br>Peru 🇵🇪: 11</p> |
| money                       | string | yes      | Payment currency code.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| amount                      | string | yes      | <p>Order amount to be collected. If this field is sent as zero ("0"), the order is an open-amount order: the customer can pay any amount and the amount paid will be notified.<br><br>For decimals, use a period (.) as the separator, with no more than 2 decimal places. Example: <code>"amount": "10.95"</code></p>                                                                                                                                      |
| description                 | string | yes      | Short description of the order. Do not include special characters.                                                                                                                                                                                                                                                                                                                                                                                          |
| method                      | string | no       | Payment method for the order. If not sent, the order can be paid with any of the payment methods enabled for the merchant.                                                                                                                                                                                                                                                                                                                                  |
| language                    | string | no       | Language of the request: `es` or `en`. Default: `es`.                                                                                                                                                                                                                                                                                                                                                                                                       |
| recurrent                   | bool   | yes      | Indicates whether the order is recurrent. A recurrent order does not expire and can be paid multiple times by the user. Notifications for recurrent orders use a sequence number (`order` + `_` + sequence) that increases with each payment. (Recurrence only applies to cash payments.)                                                                                                                                                                   |
| expiration                  | string | yes      | Order expiration date in `DD/MM/YYYY` format. It cannot be more than 30 calendar days away and cannot be earlier than the current date.                                                                                                                                                                                                                                                                                                                     |
| iva                         | string | yes      | Percentage amount corresponding to the order's VAT (IVA). If your payment method is credit card, you must send this value so the reteIVA can be calculated.                                                                                                                                                                                                                                                                                                 |
| checksum                    | string | yes      | Verification string using SHA512 (`email + country + order + money + amount + FIXED_HASH`).                                                                                                                                                                                                                                                                                                                                                                 |
| user\_di                    | string | no       | Buyer's identity document number.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| user\_type\_di              | string | no       | Type of the customer's identity document.                                                                                                                                                                                                                                                                                                                                                                                                                   |
| user\_name                  | string | no       | Customer's full name as it appears on their identity document. Special characters and accents are not allowed. Maximum length: 130 characters.                                                                                                                                                                                                                                                                                                              |
| redirect\_timeout           | string | no       | Wait time before automatically redirecting to the merchant's site once the payment is completed. Applies to credit card and PSE in Colombia. (Default: 15000 ms.)                                                                                                                                                                                                                                                                                           |
| shortener                   | bool   | no       | Indicates whether the URL received in `checkout` is shortened.                                                                                                                                                                                                                                                                                                                                                                                              |
| get\_deposit\_url           | bool   | no       | `false` by default. Set to `true` if you want the deposit registration form in the response.                                                                                                                                                                                                                                                                                                                                                                |
| additional\_information     | object | no       | Allows you to pre-fill the user's information in our checkout and define whether it is editable. The additional information this field can contain is described in Register additional information.                                                                                                                                                                                                                                                         |
| beneficiary\_merchant\_data | object | no       | Additional information about the beneficiary merchant, for merchants that operate as payment gateways. The information this field can contain is described in Register beneficiary merchant information.                                                                                                                                                                                                                                                    |
| {% endtab %}                |        |          |                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

{% tab title="Request (example)" %}
{% code overflow="wrap" %}

```bash
curl --location --request POST 'https://api-test.payvalida.com/api/v3/porders' \
--header 'Content-Type: application/json' \
--data-raw '{
    "merchant": "kuanto",
    "email": "someone@example.com",
    "country": 343,
    "order": "999999991",
    "reference": "46534512",
    "money": "COP",
    "amount": "10500",
    "description": "Test order",
    "method": "",
    "language": "en",
    "recurrent": true,
    "expiration": "27/12/2020",
    "iva": "0",
    "checksum": "96C79878E0CDC0C525090281141874D7494E0194B33E0E373DC412DD31AAD32B5DB2C681441C8007B2FCAF0873BBF2C8BFDB4A6E7D04DB8E52A843A30D6CFF08",
    "user_di": "94320444",
    "user_type_di": "CC",
    "user_name": "UserName",
    "redirect_timeout": "300000"
}'
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

| Field        | Structure | Type   | Description                                                                                                                                 |
| ------------ | --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| CODE         | -         | string | Response code. **0000** means **OK**.                                                                                                       |
| DESC         | -         | string | Response description.                                                                                                                       |
| DATA         | -         | object | Registration data.                                                                                                                          |
| Monto        | DATA      | string | Operation amount.                                                                                                                           |
| Operacion    | DATA      | string | Result of the order creation.                                                                                                               |
| OrdenID      | DATA      | string | Unique order ID associated with the merchant.                                                                                               |
| PVordenID    | DATA      | string | Unique order ID in Payvalida.                                                                                                               |
| Referencia   | DATA      | string | Reference number the customer will use to make the payment.                                                                                 |
| checkout     | DATA      | string | Link generated by Payvalida where the customer can make the payment through electronic collection networks and get the payment information. |
| deposit\_url | DATA      | string | Deposit registration link.                                                                                                                  |
| {% endtab %} |           |        |                                                                                                                                             |

{% tab title="Response (example)" %}
{% code overflow="wrap" %}

```json
{
    "CODE": "0000",
    "DATA": {
        "Monto": "10500.0",
        "Operacion": "CREADA",
        "OrdenID": "999999991",
        "PVordenID": "1934480",
        "Referencia": "46534512",
        "checkout": "sandbox-short.payv.co/H4P1KTDr9"
    },
    "DESC": "OK"
}
```

{% endcode %}
{% endtab %}

{% tab title="Headers" %}

| Header        | Value            |
| ------------- | ---------------- |
| Content-Type  | application/json |
| {% endtab %}  |                  |
| {% endtabs %} |                  |

{% hint style="info" %}
The merchant identifier (`merchant`) and the `FIXED_HASH` are generated when you [create an account](https://registro.payvalida.com/) on our platform and are sent by email.
{% endhint %}

{% hint style="warning" %}
For PSE payments from payment gateways, the `beneficiary_merchant_data` object is mandatory.
{% endhint %}

{% hint style="warning" %}
For Ecuador, the following data must be sent: `user_di`, `user_type_di`, and `user_name`.
{% endhint %}

### Code examples

#### Go

{% code overflow="wrap" %}

```go
package main

import (
	"bytes"
	"crypto/sha512"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"math/rand"
	"net/http"
	"time"
)

type Request struct {
	Country         int    `json:"country,omitempty"`
	Email           string `json:"email,omitempty"`
	Merchant        string `json:"merchant,omitempty"`
	Order           string `json:"order,omitempty"`
	Reference       string `json:"reference,omitempty"`
	Money           string `json:"money,omitempty"`
	Amount          string `json:"amount,omitempty"`
	Description     string `json:"description,omitempty"`
	Language        string `json:"language,omitempty"`
	Recurrent       bool   `json:"recurrent,omitempty"`
	Expiration      string `json:"expiration,omitempty"`
	Method          string `json:"method,omitempty"`
	Iva             string `json:"iva,omitempty"`
	Checksum        string `json:"checksum,omitempty"`
	UserDI          string `json:"user_di,omitempty"`
	UserTypeDI      string `json:"user_type_di,omitempty"`
	RedirectTimeout string `json:"redirect_timeout,omitempty"`
	UserName        string `json:"user_name,omitempty"`
}

func main() {
	url := "https://api-test.payvalida.com/api/v3/porders"
	method := "POST"
	email := "someone@example.com"
	country := "343"
	order := "test" + fmt.Sprint(rand.Intn(999999999))
	money := "COP"
	amount := "20000"
	fixedHash := "YOUR_FIXED_HASH"
	Paysha512 := sha512.Sum512([]byte(email + country + order + money + amount + fixedHash))
	checksum := hex.EncodeToString(Paysha512[:])
	date := time.Now()
	expiration := date.AddDate(0, 0, 2)
	request := Request{
		Country:         343,
		Email:           email,
		Merchant:        "kuanto",
		Order:           order,
		Reference:       "",
		Money:           money,
		Amount:          amount,
		Description:     "Unit test",
		Language:        "en",
		Recurrent:       false,
		Expiration:      expiration.Format("02/01/2006"),
		Method:          "",
		Iva:             "0",
		Checksum:        checksum,
		UserDI:          "90000000",
		UserTypeDI:      "CC",
		RedirectTimeout: "150000",
		UserName:        "devPayvalida",
	}
	json, err := json.Marshal(request)
	if err != nil {
		fmt.Println(err)
		return
	}
	client := &http.Client{}
	req, err := http.NewRequest(method, url, bytes.NewBuffer(json))
	if err != nil {
		fmt.Println(err)
		return
	}
	req.Header.Add("Content-Type", "application/json")
	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()
	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(body))
}
```

{% endcode %}

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api-test.payvalida.com/api/v3/porders",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"merchant\": \"kuanto\",\n    \"email\": \"someone@example.com\",\n    \"country\": 343,\n    \"order\": \"999999991\",\n    \"reference\": \"46534512\",\n    \"money\": \"COP\",\n    \"amount\": \"10500\",\n    \"description\": \"Test order\",\n    \"method\": \"\",\n    \"language\": \"en\",\n    \"recurrent\": true,\n    \"expiration\": \"27/12/2020\",\n    \"iva\": \"0\",\n    \"checksum\": \"96C79878E0CDC0C525090281141874D7494E0194B33E0E373DC412DD31AAD32B5DB2C681441C8007B2FCAF0873BBF2C8BFDB4A6E7D04DB8E52A843A30D6CFF08\",\n    \"user_di\": \"94320444\",\n    \"user_type_di\": \"CC\",\n    \"user_name\": \"UserName\",\n    \"redirect_timeout\": \"300000\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Java

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"merchant\": \"kuanto\",\n    \"email\": \"someone@example.com\",\n    \"country\": 343,\n    \"order\": \"999999991\",\n    \"reference\": \"46534512\",\n    \"money\": \"COP\",\n    \"amount\": \"10500\",\n    \"description\": \"Orden de prueba\",\n    \"method\": \"\",\n    \"language\": \"es\",\n    \"recurrent\": true,\n    \"expiration\": \"27/12/2020\",\n    \"iva\": \"0\",\n    \"checksum\": \"96C79878E0CDC0C525090281141874D7494E0194B33E0E373DC412DD31AAD32B5DB2C681441C8007B2FCAF0873BBF2C8BFDB4A6E7D04DB8E52A843A30D6CFF08\",\n    \"user_di\": \"94320444\",\n    \"user_type_di\": \"CC\",\n    \"user_name\": \"NombreUsuario\",\n    \"redirect_timeout\": \"300000\"\n}");
Request request = new Request.Builder()
  .url("https://api-test.payvalida.com/api/v3/porders")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

#### Python

```python
import http.client
import mimetypes
conn = http.client.HTTPSConnection("api-test.payvalida.com")
payload = "{\n    \"merchant\": \"kuanto\",\n    \"email\": \"someone@example.com\",\n    \"country\": 343,\n    \"order\": \"999999991\",\n    \"reference\": \"46534512\",\n    \"money\": \"COP\",\n    \"amount\": \"10500\",\n    \"description\": \"Orden de prueba\",\n    \"method\": \"\",\n    \"language\": \"es\",\n    \"recurrent\": true,\n    \"expiration\": \"27/12/2020\",\n    \"iva\": \"0\",\n    \"checksum\": \"96C79878E0CDC0C525090281141874D7494E0194B33E0E373DC412DD31AAD32B5DB2C681441C8007B2FCAF0873BBF2C8BFDB4A6E7D04DB8E52A843A30D6CFF08\",\n    \"user_di\": \"94320444\",\n    \"user_type_di\": \"CC\",\n    \"user_name\": \"NombreUsuario\",\n    \"redirect_timeout\": \"300000\"\n}"
headers = {
  'Content-Type': 'application/json'
}
conn.request("POST", "/api/v3/porders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

**JavaScript**

```javascript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"merchant":"kuanto","email":"someone@example.com","country":343,"order":"999999991","reference":"46534512","money":"COP","amount":"10500","description":"Orden de prueba","method":"","language":"es","recurrent":true,"expiration":"27/12/2020","iva":"0","checksum":"96C79878E0CDC0C525090281141874D7494E0194B33E0E373DC412DD31AAD32B5DB2C681441C8007B2FCAF0873BBF2C8BFDB4A6E7D04DB8E52A843A30D6CFF08","user_di":"94320444","user_type_di":"CC","user_name":"NombreUsuario","redirect_timeout":"300000"});
var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};
fetch("https://api-test.payvalida.com/api/v3/porders", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```
