Create subscription checkout session
curl --request POST \
--url https://hiimpria.ai/api/user/stripe/subscribe \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"priceId": "price_1234567890",
"trial": "true",
"mode": "subscription",
"institutionId": "<string>",
"plan": "<string>",
"returnTo": "tab"
}
'import requests
url = "https://hiimpria.ai/api/user/stripe/subscribe"
payload = {
"priceId": "price_1234567890",
"trial": "true",
"mode": "subscription",
"institutionId": "<string>",
"plan": "<string>",
"returnTo": "tab"
}
headers = {
"x-access-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
priceId: 'price_1234567890',
trial: 'true',
mode: 'subscription',
institutionId: '<string>',
plan: '<string>',
returnTo: 'tab'
})
};
fetch('https://hiimpria.ai/api/user/stripe/subscribe', 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://hiimpria.ai/api/user/stripe/subscribe",
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([
'priceId' => 'price_1234567890',
'trial' => 'true',
'mode' => 'subscription',
'institutionId' => '<string>',
'plan' => '<string>',
'returnTo' => 'tab'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$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://hiimpria.ai/api/user/stripe/subscribe"
payload := strings.NewReader("{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
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://hiimpria.ai/api/user/stripe/subscribe")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://hiimpria.ai/api/user/stripe/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cs_test_abc123",
"url": "<string>",
"mode": "<string>",
"status": "<string>",
"client_reference_id": "<string>"
}{
"message": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}Billing
Create subscription checkout session
Creates a Stripe checkout session and returns the full session object. The client should redirect the user to the session URL to complete payment.
POST
/
api
/
user
/
stripe
/
subscribe
Create subscription checkout session
curl --request POST \
--url https://hiimpria.ai/api/user/stripe/subscribe \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"priceId": "price_1234567890",
"trial": "true",
"mode": "subscription",
"institutionId": "<string>",
"plan": "<string>",
"returnTo": "tab"
}
'import requests
url = "https://hiimpria.ai/api/user/stripe/subscribe"
payload = {
"priceId": "price_1234567890",
"trial": "true",
"mode": "subscription",
"institutionId": "<string>",
"plan": "<string>",
"returnTo": "tab"
}
headers = {
"x-access-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
priceId: 'price_1234567890',
trial: 'true',
mode: 'subscription',
institutionId: '<string>',
plan: '<string>',
returnTo: 'tab'
})
};
fetch('https://hiimpria.ai/api/user/stripe/subscribe', 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://hiimpria.ai/api/user/stripe/subscribe",
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([
'priceId' => 'price_1234567890',
'trial' => 'true',
'mode' => 'subscription',
'institutionId' => '<string>',
'plan' => '<string>',
'returnTo' => 'tab'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$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://hiimpria.ai/api/user/stripe/subscribe"
payload := strings.NewReader("{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
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://hiimpria.ai/api/user/stripe/subscribe")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://hiimpria.ai/api/user/stripe/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"priceId\": \"price_1234567890\",\n \"trial\": \"true\",\n \"mode\": \"subscription\",\n \"institutionId\": \"<string>\",\n \"plan\": \"<string>\",\n \"returnTo\": \"tab\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cs_test_abc123",
"url": "<string>",
"mode": "<string>",
"status": "<string>",
"client_reference_id": "<string>"
}{
"message": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}Body
application/json
Where Stripe sends the buyer back. tab — the purchase was started inside a course page (an LMS frame) and runs in a new tab with no signed-in session, so Checkout returns to the static pages /payment/complete and /payment/cancelled. Omitted or any other value — the signed-in /signup/success and /signup/failed pages, as before. Never a URL.
Available options:
tab Response
Checkout session created successfully. Returns the full Stripe checkout session object.
Full Stripe Checkout Session object (see Stripe API docs)
Was this page helpful?