> 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/mon-cash/createmoncashpayment.md).

# CreateMonCashPayment

## Create mon cash payment

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

#### Request Body

| Name                                     | Type   | Description                                                                                                                                                                                          |
| ---------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| gdes<mark style="color:red;">\*</mark>   | Number | Amount in gdes that convert in USD to your account                                                                                                                                                   |
| userID<mark style="color:red;">\*</mark> | String | Your userID on PG Rewards so you can receive the funds                                                                                                                                               |
| referenceId                              | String | Your internal reference ID for your own tracking                                                                                                                                                     |
| successUrl                               | String | Where you want us to redirect the user once we have completed the transaction                                                                                                                        |
| errorUrl                                 | String | Where you want us to redirect the user once in case any error happens                                                                                                                                |
| metadata                                 | String | Pass additional data you need to be retrieve when fetching order                                                                                                                                     |
| customerFirstName                        | String | Customer first name                                                                                                                                                                                  |
| customerLastName                         | String | Customer last name                                                                                                                                                                                   |
| customerEmail                            | String | Customer email                                                                                                                                                                                       |
| phone                                    | String | MonCash phone number                                                                                                                                                                                 |
| currency                                 | String | Currency that you want to receive the funds to your account - default usd                                                                                                                            |
| webhookUrl                               | String | <p>We send a post a request with the following data to this endpoint once the deposit has finalized</p><ul><li>orderId</li><li>status</li><li>transactionId</li><li>currency</li><li>token</li></ul> |
|                                          |        |                                                                                                                                                                                                      |

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

```json
{
    "sender": "info@pgecom.com",
    "id": "7a8d8d40-3c38-4de8-a0a0-a7df1617cf12",
    "orderId": "7a8d8d40-3c38-4de8-a0a0-a7df1617cf12",
    "gourdes": 500.886767,
    "amount": 3.37,
    "platform": "pgrewards",
    "successUrl": "http://google.com",
    "receiver": "info@pgecom.com",
    "errorUrl": "",
    "metadata": {},
    "operatorId": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "customerId": "87ee04dd-41e8-42e8-b5b9-16c0e4a04c17",
    "currency": "usd",
    "status": "pending",
    "transactionType": "moncash_deposit",
    "redirectUrl": "http://sandbox.moncashbutton.digicelgroup.com/Moncash-middleware/Payment/Redirect?token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjExMDgyNSIsInJlZiI6IjdhOGQ4ZDQwLTNjMzgtNGRlOC1hMGEwLWE3ZGYxNjE3Y2YxMiIsImNydCI6MTcwNDE1MDU0MTQ4MiwiZXh0IjoxNzA0MTUxMTQxNDgyLCJhcGkiOnRydWV9.Yuj9msvDcrlElKzd8yWFw0k28rt8AUNoCMlfKEtFASYqf0haLCspJRQNz7lm6UEy67VXmtgTJFN7PW6jYoOm2BQpT95Ezdn7QIzyNPAFOOt9Zd8Dk2sGJ74HwuOfsTLIYkTvBGaBCH2pMaqL1ZJ2GY-U-SwrzCpiokGbXaoIYIzpH9QAvkYg_XWTh6RIHjN3sPdKBfAYAT6ziFBbt5ivzSnkTbYaf0VjpWU_LDNwxsh7jOsE71zQqcmhheFpbTLydk3Thy_96Cqa4Yx2O55Qhi9rdm7TriIEoby0B0bKC3VsOT4r6vQsNvLJfXjEd8KTs7QADVi3f7fmHFNKpflTmg",
    "payment": {
        "mode": "sandbox",
        "path": "/Api/v1/CreatePayment",
        "payment_token": {
            "expired": "2024-01-01 06:19:01:482",
            "created": "2024-01-01 06:09:01:482",
            "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjExMDgyNSIsInJlZiI6IjdhOGQ4ZDQwLTNjMzgtNGRlOC1hMGEwLWE3ZGYxNjE3Y2YxMiIsImNydCI6MTcwNDE1MDU0MTQ4MiwiZXh0IjoxNzA0MTUxMTQxNDgyLCJhcGkiOnRydWV9.Yuj9msvDcrlElKzd8yWFw0k28rt8AUNoCMlfKEtFASYqf0haLCspJRQNz7lm6UEy67VXmtgTJFN7PW6jYoOm2BQpT95Ezdn7QIzyNPAFOOt9Zd8Dk2sGJ74HwuOfsTLIYkTvBGaBCH2pMaqL1ZJ2GY-U-SwrzCpiokGbXaoIYIzpH9QAvkYg_XWTh6RIHjN3sPdKBfAYAT6ziFBbt5ivzSnkTbYaf0VjpWU_LDNwxsh7jOsE71zQqcmhheFpbTLydk3Thy_96Cqa4Yx2O55Qhi9rdm7TriIEoby0B0bKC3VsOT4r6vQsNvLJfXjEd8KTs7QADVi3f7fmHFNKpflTmg"
        },
        "timestamp": 1704150541499,
        "status": 202,
        "httpStatusCode": 202
    },
    "referenceId": ""
}
```

{% endtab %}

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

```json
{
    "message": "Amount should be less than 75000 gdes",
    "status": 400
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const axios = require('axios');
let data = {
    "gdes": 500.88,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "successUrl": "http://google.com",
    "description": "",
    "referenceId": "",
    "errorUrl": "",
    "customerFirstName": "",
    "customerLastName": "",
    "customerEmail": "",
    "metadata": {}
}
let config = {
  method: 'post',
  url: 'https://sandbox.pgecom.com/api/v1/moncash/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/v1/moncash/token"

payload = {
    "gdes": 500.88,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "successUrl": "http://google.com",
    "description": "",
    "referenceId": "",
    "errorUrl": "",
    "customerFirstName": "",
    "customerLastName": "",
    "customerEmail": "",
    "metadata": {}
}
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/v1/moncash/token")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request.body = {
    "gdes": 500.88,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "successUrl": "http://google.com",
    "description": "",
    "referenceId": "",
    "errorUrl": "",
    "customerFirstName": "",
    "customerLastName": "",
    "customerEmail": "",
    "metadata": {}
}
response = http.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/v1/moncash/token');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody({
    "gdes": 500.88,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "successUrl": "http://google.com",
    "description": "",
    "referenceId": "",
    "errorUrl": "",
    "customerFirstName": "",
    "customerLastName": "",
    "customerEmail": "",
    "metadata": {}
})
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/v1/moncash/token' \
--data '{
    "gdes": 500.886767,
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
    "successUrl": "http://google.com",
    "description": "",
    "referenceId": "",
    "errorUrl": "",
    "customerFirstName": "",
    "customerLastName": "",
    "customerEmail": "",
    "metadata": {}
}'
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If transaction successful or failed, we'll include the following to the errorUrl or `successUrl:`

* `${successUrl}?transactionId=${order.id}`
* ${errorUrl}?transactionId=${order.id}\&errorMessage=${errorMessage}
  {% endhint %}
