Example

CURL

curl -X POST https://api.excoinz.com/payment/ready \
     -H "EXCOINZ_SECRET: Bearer ${SECRET_KEY}" \
     -H "Content-Type: application/json" \
     -d '{
         "client_id": "YOUR_CLIENT_ID",
         "item_name": "YOUR_ITEM_NAME",
         "item_img_url": "YOUR_ITEM_IMAGE_URL",
         "partner_order_id": "YOUR_PARTNER_ORDER_ID",
         "partner_user_id": "YOUR_PARTNER_USER_ID",
         "amount": "YOUR_AMOUNT",
         "locale": "YOUR_LOCALE"
     }'

NodeJS

const axios = require('axios');

const REQUEST_PATH = 'payment/ready';

const headers = {
  'EXCOINZ_SECRET': `Bearer ${process.env.SECRET_KEY}`,
  'Content-Type': 'application/json'
};

const data = {
     "client_id": "YOUR_CLIENT_ID",
     "item_name": "YOUR_ITEM_NAME",
     "item_img_url": "YOUR_ITEM_IMAGE_URL",
     "partner_order_id": "YOUR_PARTNER_ORDER_ID",
     "partner_user_id": "YOUR_PARTNER_USER_ID",
     "amount": "YOUR_AMOUNT",
     "locale": "YOUR_LOCALE"
};

axios.post(`https://api.excoinz.com/${REQUEST_PATH}`, data, { headers: headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error('Error:', error.response.data);
  });

JAVA

import okhttp3.*;
import java.io.IOException;

public static void main(String[] args) {
        RestTemplate restTemplate = new RestTemplate();

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.set("EXCOINZ_SECRET", "Bearer " + SECRET_KEY);

        Map<String, Object> body = new HashMap<>();
        body.put("client_id", "YOUR_CLIENT_ID");
        body.put("item_name", "YOUR_ITEM_NAME");
        body.put("item_img_url", "YOUR_ITEM_IMAGE_URL");
        body.put("partner_order_id", "YOUR_PARTNER_ORDER_ID");
        body.put("partner_user_id", "YOUR_PARTNER_USER_ID");
        body.put("amount", "YOUR_AMOUNT");
        body.put("locale", "YOUR_LOCALE");

        HttpEntity<Map<String, Object>> entity = new HttpEntity<>(body, headers);

        ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_URL, HttpMethod.POST, entity, String.class);

        return response;
}

PHP

<?php

$url = 'https://api.excoinz.com/payment/ready';

$SECRET_KEY = 'YOUR_SECRET_KEY';

$headers = array(
    "EXCOINZ_SECRET: Bearer $SECRET_KEY",
    "Content-Type: application/json"
);

$data = array(
    "client_id" => "YOUR_CLIENT_ID",
    "item_name" => "YOUR_ITEM_NAME",
    "item_img_url" => "YOUR_ITEM_IMAGE_URL"
    "partner_order_id" => "YOUR_PARTNER_ORDER_ID",
    "partner_user_id" => "YOUR_PARTNER_USER_ID",
    "amount" => "YOUR_AMOUNT",
    "locale" => "YOUR_LOCALE"
);

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if ($error = curl_error($ch)) {
    die('cURL error: ' . $error);
}

curl_close($ch);

echo $response;

?>

Last updated