Create Purchase URL
curl --request POST \
--url https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url \
--header 'Content-Type: application/json' \
--data '
{
"customer_type": "user",
"customer_id": "user_1234567890abcdef",
"product_id": "prod_premium_monthly",
"return_url": "https://myapp.com/purchase-success"
}
'import requests
url = "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url"
payload = {
"customer_type": "user",
"customer_id": "user_1234567890abcdef",
"product_id": "prod_premium_monthly",
"return_url": "https://myapp.com/purchase-success"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
customer_type: 'user',
customer_id: 'user_1234567890abcdef',
product_id: 'prod_premium_monthly',
return_url: 'https://myapp.com/purchase-success'
})
};
fetch('https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_type' => 'user',
'customer_id' => 'user_1234567890abcdef',
'product_id' => 'prod_premium_monthly',
'return_url' => 'https://myapp.com/purchase-success'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url"
payload := strings.NewReader("{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url")
.header("Content-Type", "application/json")
.body("{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>"
}Payments
Create Purchase URL
Creates a secure checkout URL for purchasing a product.
POST
/
payments
/
purchases
/
create-purchase-url
Create Purchase URL
curl --request POST \
--url https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url \
--header 'Content-Type: application/json' \
--data '
{
"customer_type": "user",
"customer_id": "user_1234567890abcdef",
"product_id": "prod_premium_monthly",
"return_url": "https://myapp.com/purchase-success"
}
'import requests
url = "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url"
payload = {
"customer_type": "user",
"customer_id": "user_1234567890abcdef",
"product_id": "prod_premium_monthly",
"return_url": "https://myapp.com/purchase-success"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
customer_type: 'user',
customer_id: 'user_1234567890abcdef',
product_id: 'prod_premium_monthly',
return_url: 'https://myapp.com/purchase-success'
})
};
fetch('https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_type' => 'user',
'customer_id' => 'user_1234567890abcdef',
'product_id' => 'prod_premium_monthly',
'return_url' => 'https://myapp.com/purchase-success'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url"
payload := strings.NewReader("{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url")
.header("Content-Type", "application/json")
.body("{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hexclave.com/api/v1/payments/purchases/create-purchase-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_type\": \"user\",\n \"customer_id\": \"user_1234567890abcdef\",\n \"product_id\": \"prod_premium_monthly\",\n \"return_url\": \"https://myapp.com/purchase-success\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>"
}Body
application/json
The type of customer making the purchase
Available options:
user, team, custom Example:
"user"
The ID of the customer (user ID, team ID, or custom customer ID)
Example:
"user_1234567890abcdef"
The ID of the product to purchase. Either this or product_inline should be given.
Example:
"prod_premium_monthly"
Inline product definition. Either this or product_id should be given.
Show child attributes
Show child attributes
URL to redirect to after purchase completion. Must be configured as a trusted domain in the project configuration.
Example:
"https://myapp.com/purchase-success"
Response
200 - application/json
Successful response
The secure checkout URL for completing the purchase
⌘I