Gerar link de checkout (Stripe)
Cria uma página de checkout hospedada do Stripe e retorna a url para o usuário abrir no navegador — nada é cobrado até ele concluir lá. purpose:“wallet_topup” (exige amount > 0, na moeda da conta) gera um pagamento único que credita a carteira pré-paga; purpose:“add_card” gera uma página para salvar um cartão. Ação de conta: requer key escopada a TENANT (403 NUMBER_SCOPE_NOT_ALLOWED para key de número). Só Stripe.
Requer uma chave com escopo de tenant.
curl --request POST \
--url https://pilotstatus.com.br/v1/billing/checkout \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"purpose": "wallet_topup",
"amount": 50
}
'import requests
url = "https://pilotstatus.com.br/v1/billing/checkout"
payload = {
"purpose": "wallet_topup",
"amount": 50
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({purpose: 'wallet_topup', amount: 50})
};
fetch('https://pilotstatus.com.br/v1/billing/checkout', 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://pilotstatus.com.br/v1/billing/checkout",
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([
'purpose' => 'wallet_topup',
'amount' => 50
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://pilotstatus.com.br/v1/billing/checkout"
payload := strings.NewReader("{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://pilotstatus.com.br/v1/billing/checkout")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/billing/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}"
response = http.request(request)
puts response.read_body{
"url": "https://checkout.stripe.com/c/pay/cs_test_...",
"purpose": "wallet_topup",
"orderId": "cto_01HZX...",
"amount": 50,
"currency": "BRL"
}{
"error": "Validation error"
}{
"error": "Unauthorized"
}{
"error": "Number-scoped keys cannot call tenant endpoints",
"code": "NUMBER_SCOPE_NOT_ALLOWED"
}{
"error": "Too many requests"
}Autorizações
Sua chave de API ps_
Corpo
Finalidade da página de checkout.
"wallet_topup"
Valor a creditar na carteira, na moeda da conta (obrigatório para wallet_topup).
"50"
URL de redirecionamento após o sucesso.
"https://app.acme.com/billing/ok"
URL de redirecionamento se cancelar.
"https://app.acme.com/billing"
Resposta
Recarregar carteira
Esta página foi útil?
curl --request POST \
--url https://pilotstatus.com.br/v1/billing/checkout \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"purpose": "wallet_topup",
"amount": 50
}
'import requests
url = "https://pilotstatus.com.br/v1/billing/checkout"
payload = {
"purpose": "wallet_topup",
"amount": 50
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({purpose: 'wallet_topup', amount: 50})
};
fetch('https://pilotstatus.com.br/v1/billing/checkout', 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://pilotstatus.com.br/v1/billing/checkout",
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([
'purpose' => 'wallet_topup',
'amount' => 50
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://pilotstatus.com.br/v1/billing/checkout"
payload := strings.NewReader("{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://pilotstatus.com.br/v1/billing/checkout")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/billing/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"purpose\": \"wallet_topup\",\n \"amount\": 50\n}"
response = http.request(request)
puts response.read_body{
"url": "https://checkout.stripe.com/c/pay/cs_test_...",
"purpose": "wallet_topup",
"orderId": "cto_01HZX...",
"amount": 50,
"currency": "BRL"
}{
"error": "Validation error"
}{
"error": "Unauthorized"
}{
"error": "Number-scoped keys cannot call tenant endpoints",
"code": "NUMBER_SCOPE_NOT_ALLOWED"
}{
"error": "Too many requests"
}