Sincronizar uma recarga com cartão
Chame depois que o stripe.confirmPayment() resolver. Lê o PaymentIntent no Stripe e, quando está succeeded, credita a carteira — uma única vez: uma repetição, ou uma chamada depois que o nosso webhook do Stripe já creditou, responde credited: false. Nunca cobra (não é o /confirm do Stripe). canceled marca o pedido como FAILED. Não lê corpo. Só Proprietário.
Requer uma chave com escopo de tenant — uma chave de workspace, ou uma chave de conta com x-workspace-id.
curl --request POST \
--url https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync \
--header 'x-api-key: <api-key>'import requests
url = "https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync', 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/payment-intents/{id}/sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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/payment-intents/{id}/sync")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"paymentIntentId": "pi_3QabcDEF",
"status": "succeeded",
"amount": 150,
"currency": "BRL",
"orderId": "cmh2b7q4s0003to8example8t",
"orderStatus": "COMPLETED",
"credited": true,
"balance": 212.4,
"cardSaved": true
}{
"error": "The id must be a Stripe PaymentIntent id (pi_…). | O id deve ser o id de um PaymentIntent do Stripe (pi_…).",
"code": "INVALID_PAYMENT_INTENT_ID"
}{
"error": "Invalid API key"
}{
"error": "This endpoint requires a tenant-scoped API key",
"code": "NUMBER_SCOPE_NOT_ALLOWED"
}{
"error": "Payment intent not found for this workspace. | Payment intent não encontrado neste workspace.",
"code": "PAYMENT_INTENT_NOT_FOUND"
}Autorizações
Sua chave de API ps_
Cabeçalhos
Só com chave de conta (ps_account_): o workspace em que agir, obtido em GET /v1/workspaces. Sem ele, uma chave de conta recebe 400 WORKSPACE_ID_REQUIRED.
Parâmetros de caminho
O paymentIntentId (pi_…).
Resposta
Resultado
Status no Stripe.
COMPLETED, PENDING, FAILED, UNCHANGED true só na chamada que creditou a carteira.
Saldo da carteira logo depois deste crédito, ou null.
Esta página foi útil?
curl --request POST \
--url https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync \
--header 'x-api-key: <api-key>'import requests
url = "https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync', 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/payment-intents/{id}/sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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/payment-intents/{id}/sync")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/billing/payment-intents/{id}/sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"paymentIntentId": "pi_3QabcDEF",
"status": "succeeded",
"amount": 150,
"currency": "BRL",
"orderId": "cmh2b7q4s0003to8example8t",
"orderStatus": "COMPLETED",
"credited": true,
"balance": 212.4,
"cardSaved": true
}{
"error": "The id must be a Stripe PaymentIntent id (pi_…). | O id deve ser o id de um PaymentIntent do Stripe (pi_…).",
"code": "INVALID_PAYMENT_INTENT_ID"
}{
"error": "Invalid API key"
}{
"error": "This endpoint requires a tenant-scoped API key",
"code": "NUMBER_SCOPE_NOT_ALLOWED"
}{
"error": "Payment intent not found for this workspace. | Payment intent não encontrado neste workspace.",
"code": "PAYMENT_INTENT_NOT_FOUND"
}