The following examples show how to create a payment request with the Payget
API
in various programming languages.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.payget.xyz/v1/payment/create',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
"redirect_url" => "https://yourdomain.com/success",
"cancel_url" => "https://yourdomain.com/cancel",
"webhook_url" => "https://yourdomain.com/webhook",
"metadata" => ["phone" => "016****"],
"amount" => "10"
]),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'payget-api-key: YOUR_BRAND_API_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
const res = await fetch('https://api.payget.xyz/v1/payment/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'payget-api-key': 'YOUR_BRAND_API_KEY'
},
body: JSON.stringify({
redirect_url: 'https://yourdomain.com/success',
cancel_url: 'https://yourdomain.com/cancel',
webhook_url: 'https://yourdomain.com/webhook',
metadata: { phone: '016****' },
amount: '10'
})
});
const data = await res.json();
console.log(data);
import requests
import json
url = "https://api.payget.xyz/v1/payment/create"
payload = json.dumps({
"cus_name": "John Doe",
"cus_email": "john@gmail.com",
"amount": "10",
"redirect_url": "yourdomain.com/success",
"cancel_url": "yourdomain.com/cancel",
"webhook_url": "yourdomain.com/webhook",
"metadata": {
"phone": "016****"
},
})
headers = {
'zini-api-key': 'YOUR_BRAND_API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.payget.xyz/v1/payment/create"
method := "POST"
payload := strings.NewReader(`{
"cus_name": "John Doe",
"cus_email": "john@gmail.com",
"amount": "10",
"redirect_url":"yourdomain.com/success",
"cancel_url":"yourdomain.com/cancel",
"webhook_url":"yourdomain.com/webhook",
"metadata":
{"phone":"01511111111"}
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("zini-api-key", "YOUR_BRAND_API_KEY")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
{
"status": true,
"message": "Payment URL generated successfully",
"payment_url": "https://secure.payget.xyz/payment/abc123xyz"
}