Create a payment
Changed onCreate a new payment. Supports PIX and boleto, in headless or hosted mode, and card through the hosted checkout only. Requires an idempotency key.
Card payments are not accepted through the API. A card object, CARD in methods in headless mode (mode omitted or headless), or any of these fields at the top level of the body: deviceInfo, remoteIp, holderInfo, authorizeOnly, creditCard, creditCardHolderInfo, creditCardToken, installmentCount, installmentValue, totalValue, is rejected with 400 CARD_PAYMENTS_NOT_AVAILABLE_VIA_API, even without a valid API key, and the card data is not stored or logged.
To charge a card, create the payment with mode: hosted and CARD in methods (["CARD"], or ["PIX", "CARD"] to let the payer choose), with an amount of at least R$ 5.00, and redirect the payer to the returned checkoutUrl. The checkout collects the card, accepts credit cards in a single installment and debit cards, and runs 3D Secure itself. The result arrives as PAYMENT_CONFIRMED, PAYMENT_PAID, PAYMENT_EXPIRED or PAYMENT_CANCELLED; you can also poll GET /v1/payments/{paymentId}.
Send items to sell several lines in one payment, couponCode to apply a coupon, and, on a hosted payment, itemsQuantityEditable, orderBump and upsell. The response carries items, subtotal, discount and coupon. A coupon that discounts the whole amount completes the payment as FREE, with no charge.
Request
- Base URLhttps://api.yuvexpay.com
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Headers
A unique string to ensure the request is processed only once. Must be unique per request. Valid for 24 hours. Successful (2xx) responses are stored and replayed for the key. On POST /v1/payments, a 502 PROVIDER_TEMPORARILY_UNAVAILABLE for a boleto payment is stored and replayed too: to recover that payment, repeat the request once with the same externalId and a new key. A retry of an earlier card payment request now returns 400 CARD_PAYMENTS_NOT_AVAILABLE_VIA_API instead of the stored response (201 or 502): recover that payment with GET /v1/payments/txid/{txId}, or with a create request with the same externalId, mode: "hosted" and methods: ["CARD"], no card object or card fields, and a new key.
API key of an approved split platform, sent as the key itself, without Bearer, in the environment of the key in Authorization: ypk_live_ in production, ypk_test_ in sandbox. It lets the platform named in splits[] connect the seller on this call, with no dashboard invitation: the relationship is recorded as ACCEPTED with the platform's fee cap and the payment is created. The connection works in production and in sandbox under the same fee cap, and only a production connection notifies the seller. The header is read only when exactly one recipient in splits[] has no accepted relationship with your company, and ignored otherwise. A key that is unknown, revoked or expired, is from the other environment, lacks the payments:write scope, is used from outside its IP allowlist or belongs to your own company returns 403 SPLIT_PLATFORM_KEY_INVALID. A valid key whose company is not that recipient, or is not an approved platform, connects nobody: the request follows the regular flow and returns SPLIT_RELATIONSHIP_PENDING. Send it from a server only. See the Split platforms guide.
Request body
Response
Payment created.
Example response
{
"payment": {
"coupon": {
"code": "BLACK10"
},
"methodData": {
"type": "PIX",
"pixCopyPaste": "00020126...",
"qrCodeBase64": "data:image/png;base64,...",
"qrCodeUrl": null
}
}
}Changes
- breaking
the
/////response's property type changed fromstringto no type for status - warning
added the new
FREEenum value to the/////response property for the response status - info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added the optional property
/////to the response with the status - info
added to the
/////response propertyallOflist for the response status - info
removed the
CANCELLEDenum value from the/////response property for the response status - info
removed the
CHARGEBACKenum value from the/////response property for the response status - info
removed the
CONFIRMEDenum value from the/////response property for the response status - info
removed the
EXPIREDenum value from the/////response property for the response status - info
removed the
MED_FROZENenum value from the/////response property for the response status - info
removed the
NEWenum value from the/////response property for the response status - info
removed the
PAIDenum value from the/////response property for the response status - info
removed the
PARTIAL_REFUNDenum value from the/////response property for the response status - info
removed the
PENDING_METHOD_SELECTIONenum value from the/////response property for the response status - info
removed the
PROCESSINGenum value from the/////response property for the response status - info
removed the
REFUNDEDenum value from the/////response property for the response status
- breaking
- info
added the new optional request property
- info