Create an invoice

All requests must be sent via POST method in JSON format.


    ENDPOINT https://app.paycrypto24.com/api/gateway/request/gate
    

Parameters

the following parameters are required to properly generate and configure the invoice details

NAMETYPESUPPORTED PARAMS
currency`String`"IRR" | "USD"
amount`Integer`-
orderId`Integer`-

Examples

Here are some examples of how to communicate with the API:

Javascript

Example of making request in Javascript:

fetch('https://app.paycrypto24.com/api/gateway/request/gate', {
      method: "POST",
      headers: {
        "Authorization": "Bearer 3|fy5JH4a8 ********** 1C9958f1f1",
        "Accept": "application/json",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({currency: 'USD',amount: 150, orderId: 90666})
    })

PHP Laravel Client::HTTP

Example of making request in Laravel client:http package:

use Illuminate\Support\Facades\Http;

$url = "https://app.paycrypto24.com/api/gateway/request/gate";
$token = "your_bearer_token_here"; // Replace with your actual token

$response = Http::withToken($token)
    ->acceptJson()
    ->post($url, [
        'currency' => 'USD',
        'amount' => 150,
        'orderId' => 90666,
    ]);

if ($response->successful()) {
    return $response->json(); // Return or process the response data
} else {
    return response()->json([
        'error' => 'Request failed',
        'status' => $response->status(),
        'message' => $response->body(),
    ], $response->status());
}

CURL

Example of making request with CURL:

curl -X POST https://app.paycrypto24.com/api/gateway/request/gate -H "Authorization: Bearer your_bearer_token_here" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"currency": "USD", "amount": 150, "orderId": 90666}'

Responses

Here are some examples of endpoint response types:

DATASTATUSCODE
`Invoice unique ID`true200
`Order already paid !`false500
`sth_wrong`false500
`invalid_parameters`false500
`Unauthenticated.`-401

Examples

Example of responses with json format:

{
  "status": true,
  "data": {
    "hash": "invoice_unique_id" // example: https://pay.paycrypto24.com/door/invoice_unique_id
  }
}
  
{
  "status": false,
  "data": "Order already paid !" // the invoice with the orderId is already paid
}

{
  "status": false,
  "data": "sth_wrong" // something prevent creating invoice
}

{
  "status": false,
  "data": "invalid_parameters" // the parameters does not pass the validation
}

{
  "message": "Unauthenticated." // invalid API key
}

NEXT :

In this section, you can learn about to set callback URL in your merchant settings.

Setting callback URL

Basic information on how to set a callback URL