> For the complete documentation index, see [llms.txt](https://docs.pgecom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pgecom.com/api-endpoint/payment/pg-pay/createpgpaypayment.md).

# CreatePGPayPayment

## Create a pg pay payment request

<mark style="color:green;">`POST`</mark> `https://sandbox.pgecom.com/api/pgpay/token`

#### Request Body

| Name                                     | Type           | Description                                                                                                                                                                                                                                                                                  |
| ---------------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| userID<mark style="color:red;">\*</mark> | String         | The receiver that's going to receive the funds                                                                                                                                                                                                                                               |
| amount<mark style="color:red;">\*</mark> | Number         | Amount to charge the customer. Learn more about our fees via this [link](https://help.pgecom.com/ht/article/fees-1irhphn/)                                                                                                                                                                   |
| currency                                 | String         | We currently only accept **htg** or **usd** as currency                                                                                                                                                                                                                                      |
| orderId                                  | String         | Your orderId for internal reference, if not provided, one is creating for you                                                                                                                                                                                                                |
| phone                                    | String         | Customer's phone number to autocomplete in the form                                                                                                                                                                                                                                          |
| description                              | String         | Description of the transaction                                                                                                                                                                                                                                                               |
| successUrl                               | String         | Success url to redirect to when payment is complete                                                                                                                                                                                                                                          |
| errorUrl                                 | String         | Error url to redirect to if payment fails                                                                                                                                                                                                                                                    |
| customerEmail                            | String         | Customer email                                                                                                                                                                                                                                                                               |
| customerFirstName                        | String         | Customer first name                                                                                                                                                                                                                                                                          |
| customerLastName                         | String         | Customer last name                                                                                                                                                                                                                                                                           |
| metadata                                 | Object         | Additional data to retrieve when fetching order                                                                                                                                                                                                                                              |
| isChatEnabled                            | Boolean        | Will disable the pgecom live chat support on the pgpay checkout flow                                                                                                                                                                                                                         |
| paymentMethods                           | Array\[String] | You can pass a list of payment methods that you want to enable (ex. pgpay, moncash, crypto)                                                                                                                                                                                                  |
| webhookUrl                               | string         | <p>This can be sent inside the metadata data as <code>metadata.webhookUrl</code> or directly in the payload. This will receive post a request with the following values when the transaction is complete<br>- orderId<br>- status<br>- transactionId<br>- currency<br>- token</p><p><br></p> |
|                                          |                |                                                                                                                                                                                                                                                                                              |

{% tabs %}
{% tab title="200: OK success" %}

```json
{
    "amount": 0.91,
    "userID": "f725076f-ade0-4912-bc86-db1681700d91",
    "id": "41412be3-01fd-488a-a279-cadbe171b5e5",
    "orderId": "41412be3-01fd-488a-a279-cadbe171b5e5",
    "paymentMethod": "pgpay",
    "paymentStatus": "pending",
    "status": "pending",
    "deliveryMethod": "instant",
    "transactionType": "pgpay_deposit",
    "quantity": 1,
    "phone": "+50934748112",
    "gourdes": 55,
    "customerId": "e66d2dac-e514-42b7-8490-de3972709d7e",
    "successUrl": "https://pgecom.com",
    "currency": "htg",
    "sender": "info@pgecom.com",
    "metadata": {
        "is_matched": false,
        "gender": "female",
        "app_name": "Match.com",
        "webhookUrl": "https://webhook.site/40adf10b-9352-4d20-b23a-17d4f1a32a9f",
        "customerEmail": "info@pgecom.com",
        "isProd": false,
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU",
        "paymentMethods": [
            "moncash",
            "pgpay"
        ],
        "isChatEnabled": false,
        "pgPayMerchantName": "PGecom",
        "customerFirstName": "",
        "customerLastName": "",
        "returnUrl": "https://sandbox.pgecom.com/payment/pgpay/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU?merchantName=PGecom&amount=55"
    },
    "platform": "pgrewards",
    "redirectUrl": "http://localhost:3002/payment/pgpay/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU?merchantName=PGecom&amount=55",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlcklkIjoiNDE0MTJiZTMtMDFmZC00ODhhLWEyNzktY2FkYmUxNzFiNWU1IiwiaWF0IjoxNzEzNDU5MjE2LCJleHAiOjE3MTM0NjI4MTZ9.-LqeTBDi1vOT1giyOLfnQ5hrpmrtrKbWxB_SqvZD5mU"
}
```

{% endtab %}

{% tab title="400: Bad Request bad request" %}

```
{
    "message": "Order ID 8db0fd57-5494-45d2-8ede-f045ffbd85b9 already exist, please create a new order id",
    "status": 400
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const axios = require('axios');
let data = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}

let config = {
  method: 'post',
  url: 'https://sandbox.pgecom.com/api/pgpay/token',
  headers: { },
  data : data
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://sandbox.pgecom.com/api/pgpay/token"

payload = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}
headers = {}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://sandbox.pgecom.com/api/pgpay/token")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request.body = {
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}
response = https.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.pgecom.com/api/pgpay/token');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody({
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
});
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

{% endtab %}

{% tab title="Curl" %}

```sh
curl --location 'https://sandbox.pgecom.com/api/pgpay/token' \
--data-raw '{
    "amount": 25,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerEmail": "info@pgecom.com",
    "customerFirstName": "Esterling",
    "customerLastName": "Accime",
    "successUrl": "/success",
    "errorUrl": "/error"
}'
```

{% endtab %}
{% endtabs %}
