PAYCOW / DOCUMENTATION

Code examples

Endpoints, error handling and executable examples.

Code Examples

Create payment sessions in your preferred language

const response = await fetch('https://paycow.net/api/payment/create', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.PAYCOW_API_KEY,
    'x-api-secret': process.env.PAYCOW_API_SECRET,
    'Idempotency-Key': `order_${order.id}`,
  },
  body: JSON.stringify({
    amount: 50.00,
    userId: 'user_123456',
    network: 'TRC20',
  }),
});

const data = await response.json();
res.redirect(data.paymentUrl);
import requests, os

response = requests.post("https://paycow.net/api/payment/create",
    json={"amount": 50.00, "userId": "user_123456", "network": "TRC20"},
    headers={
        "Content-Type": "application/json",
        "x-api-key": os.getenv("PAYCOW_API_KEY"),
        "x-api-secret": os.getenv("PAYCOW_API_SECRET"),
        "Idempotency-Key": "order_847291"
    })
payment_url = response.json().get("paymentUrl")
data := map[string]interface{}{
    "amount": 50.00, "userId": "user_123456", "network": "TRC20",
}
jsonData, _ := json.Marshal(data)

req, _ := http.NewRequest("POST", "https://paycow.net/api/payment/create",
    bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", os.Getenv("PAYCOW_API_KEY"))
req.Header.Set("x-api-secret", os.Getenv("PAYCOW_API_SECRET"))

resp, _ := (&http.Client{}).Do(req)
$ch = curl_init('https://paycow.net/api/payment/create');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'amount' => 50.00, 'userId' => $user_id, 'network' => 'TRC20'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'x-api-key: ' . getenv('PAYCOW_API_KEY'),
    'x-api-secret: ' . getenv('PAYCOW_API_SECRET'),
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch), true);
header('Location: ' . $result['paymentUrl']);
var client = new HttpClient();
var data = new { amount = 50.00, userId = "user_123456", network = "TRC20" };
var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");

client.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("PAYCOW_API_KEY"));
client.DefaultRequestHeaders.Add("x-api-secret", Environment.GetEnvironmentVariable("PAYCOW_API_SECRET"));

var response = await client.PostAsync("https://paycow.net/api/payment/create", content);
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("x-api-key", HeaderValue::from_str(&std::env::var("PAYCOW_API_KEY")?)?);
headers.insert("x-api-secret", HeaderValue::from_str(&std::env::var("PAYCOW_API_SECRET")?)?);

let res = client.post("https://paycow.net/api/payment/create")
    .headers(headers)
    .json(&json!({"amount": 50.0, "userId": "user_1", "network": "TRC20"}))
    .send().await?.json::<serde_json::Value>().await?;

println!("URL: {}", res["paymentUrl"]);