Skip to main content
POST
/
payments
/
purchases
/
purchase-session
Create Purchase Session
curl --request POST \
  --url https://api.hexclave.com/api/v1/payments/purchases/purchase-session \
  --header 'Content-Type: application/json' \
  --data '
{
  "full_code": "proj_abc123_def456ghi789",
  "price_id": "price_1234567890abcdef",
  "quantity": 1
}
'
import requests

url = "https://api.hexclave.com/api/v1/payments/purchases/purchase-session"

payload = {
"full_code": "proj_abc123_def456ghi789",
"price_id": "price_1234567890abcdef",
"quantity": 1
}
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({
full_code: 'proj_abc123_def456ghi789',
price_id: 'price_1234567890abcdef',
quantity: 1
})
};

fetch('https://api.hexclave.com/api/v1/payments/purchases/purchase-session', 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/purchase-session",
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([
'full_code' => 'proj_abc123_def456ghi789',
'price_id' => 'price_1234567890abcdef',
'quantity' => 1
]),
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/purchase-session"

payload := strings.NewReader("{\n \"full_code\": \"proj_abc123_def456ghi789\",\n \"price_id\": \"price_1234567890abcdef\",\n \"quantity\": 1\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/purchase-session")
.header("Content-Type", "application/json")
.body("{\n \"full_code\": \"proj_abc123_def456ghi789\",\n \"price_id\": \"price_1234567890abcdef\",\n \"quantity\": 1\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.hexclave.com/api/v1/payments/purchases/purchase-session")

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 \"full_code\": \"proj_abc123_def456ghi789\",\n \"price_id\": \"price_1234567890abcdef\",\n \"quantity\": 1\n}"

response = http.request(request)
puts response.read_body
{
  "client_secret": "1234567890abcdef_secret_xyz123"
}

Body

application/json
full_code
string
required

The verification code, given as a query parameter in the purchase URL

Example:

"proj_abc123_def456ghi789"

price_id
string
required

The Stack auth price ID to purchase

Example:

"price_1234567890abcdef"

quantity
integer
default:1

The quantity to purchase

Example:

1

Response

200 - application/json

Successful response

client_secret
string

Stripe client secret used by the browser to confirm payment via Stripe Elements. Omitted when no payment step is required from the customer; in that case the purchase is being settled without a confirmation step and the caller should skip mounting Stripe Elements.

Example:

"1234567890abcdef_secret_xyz123"