Simular pagamento do checkout
curl --request POST \
--url https://api.pagstack.com/v1/checkouts/{id}/simulate-payment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment_method": "pix",
"coupon": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({payment_method: 'pix', coupon: '<string>'})
};
fetch('https://api.pagstack.com/v1/checkouts/{id}/simulate-payment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.pagstack.com/v1/checkouts/{id}/simulate-payment"
payload = {
"payment_method": "pix",
"coupon": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "checkout",
"livemode": true,
"status": "open",
"url": "<string>",
"amount": 0,
"description": "<string>",
"payment_methods": [
"pix"
],
"external_id": "<string>",
"buyer": {
"name": "<string>",
"email": "<string>",
"tax_id": "<string>",
"phone": "<string>"
},
"success_url": "<string>",
"cancel_url": "<string>",
"transaction_id": "<string>",
"plan": "<string>",
"subscription_id": "<string>",
"bucket": {
"id": "<string>",
"name": "<string>",
"slug": "<string>"
},
"tracking": {},
"order_bump": {
"productId": "<string>",
"name": "<string>",
"amount": 0,
"accepted": true
},
"allow_coupons": true,
"coupon": {
"id": "<string>",
"code": "<string>"
},
"metadata": {},
"expires_at": "<string>",
"completed_at": "<string>",
"created_at": "<string>"
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Checkout
Simular pagamento do checkout
Só no modo de teste: paga o checkout como a página faria, com cupom opcional. Gera transaction.paid e checkout.completed. Cupom recusado responde 400 (coupon_invalid, coupon_expired, coupon_exhausted, coupon_below_minimum, coupon_unavailable ou coupons_not_allowed) e nada é pago.
Simular pagamento do checkout
curl --request POST \
--url https://api.pagstack.com/v1/checkouts/{id}/simulate-payment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment_method": "pix",
"coupon": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({payment_method: 'pix', coupon: '<string>'})
};
fetch('https://api.pagstack.com/v1/checkouts/{id}/simulate-payment', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.pagstack.com/v1/checkouts/{id}/simulate-payment"
payload = {
"payment_method": "pix",
"coupon": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "checkout",
"livemode": true,
"status": "open",
"url": "<string>",
"amount": 0,
"description": "<string>",
"payment_methods": [
"pix"
],
"external_id": "<string>",
"buyer": {
"name": "<string>",
"email": "<string>",
"tax_id": "<string>",
"phone": "<string>"
},
"success_url": "<string>",
"cancel_url": "<string>",
"transaction_id": "<string>",
"plan": "<string>",
"subscription_id": "<string>",
"bucket": {
"id": "<string>",
"name": "<string>",
"slug": "<string>"
},
"tracking": {},
"order_bump": {
"productId": "<string>",
"name": "<string>",
"amount": 0,
"accepted": true
},
"allow_coupons": true,
"coupon": {
"id": "<string>",
"code": "<string>"
},
"metadata": {},
"expires_at": "<string>",
"completed_at": "<string>",
"created_at": "<string>"
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Autorizações
Cabeçalhos
Corpo
application/json
Resposta
Sucesso.
Checkout: página de pagamento hospedada pela Pagstack.