Payments

Create a payment

Changed on

Create 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.

post/v1/payments

Request

Headers

X-Idempotency-Keystring required

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.

X-Split-Platform-Keystring

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

productIdstring uuid

Link this payment to an existing product. If set, amount is optional and defaults to the product price.

customerIdstring uuid

Link this payment to an existing customer. For CARD and BOLETO, the linked customer must have name and CPF/CNPJ.

amountnumber

Payment amount. Required unless productId or items is provided. With items it can be omitted; when sent, it must equal the sum of unitAmount x quantity exactly (400 AMOUNT_ITEMS_MISMATCH).

methodsPaymentMethod[]

Accepted payment methods. Headless payments must use exactly one method, PIX or BOLETO. CARD requires mode: hosted; headless CARD is rejected with 400 CARD_PAYMENTS_NOT_AVAILABLE_VIA_API.

currency'BRL'

Supported currencies.

mode'hosted' | 'headless'

hosted redirects the payer to a YuvexPay checkout page. headless returns method data directly for a single payment method, PIX or BOLETO. CARD is available in hosted mode only: the YuvexPay checkout collects the card, accepts credit cards in a single installment and debit cards, and runs 3D Secure itself.

returnUrlstring uri

Hosted mode: the back link the checkout shows while the payment is unpaid, for a payer who leaves without paying. Only an http or https URL of up to 2048 characters is used; metadata.cancelUrl takes precedence. Use completionUrl for the redirect after payment.

completionUrlstring uri

Hosted mode: where the checkout sends the payer, after a 5-second countdown, once the payment is PAID, CONFIRMED or FREE. The checkout adds yvx_payment_id, yvx_status, yvx_amount_cents, yvx_reference, yvx_ts and yvx_signature, a lowercase hex HMAC-SHA256 of payment_id.status.amount_cents.reference.ts keyed with the account's redirect secret; see the payments guide to verify it. While a post-purchase upsell is offered, the checkout shows a button to this URL instead of the countdown. Only an http or https URL of up to 2048 characters is used. The redirect is not proof of payment: confirm with GET /v1/payments/{paymentId} or the webhook before fulfilling.

descriptionstring

Payment description shown to the payer.

externalIdstring

Your own reference ID (e.g., order number).

expiresInMinutesinteger

Minutes until the payment expires (5-10080, i.e. up to 7 days).

enforcePayerDocumentboolean

PIX only. Opt-in request that the charge be paid from an account whose CPF/CNPJ matches the customer's document (same-document payment). Best-effort: when it cannot be enforced, the charge is still created and paid normally.

metadataobject

Arbitrary key-value pairs attached to the payment. cancelUrl, an http or https URL of up to 2048 characters, shows a back link to that URL on the hosted checkout while the payment is unpaid; any other value under that key is ignored.

passFeeToPayerboolean

Whether the YuvexPay fee should be added on top of amount and charged to the payer instead of being deducted from the merchant's net. When omitted, the company-level passFeeToPayerDefault setting applies. Note: payments with a resolved amount below R$1,00 are always charged to the payer regardless of this value (forced passthrough to keep merchant net positive). The final decision is reflected back as feePassedToPayer on the Payment object. On a hosted payment the fee is computed again, at the rate of the method the payer picks, card included; the checkout shows each method with its own total. A payment that completes as FREE never passes a fee.

recoveryKitboolean

Turn the recovery kit on (true) or off (false) for this payment. When omitted, the account default applies (Ativar por padrão on the Kit de recuperação card in the dashboard, off until turned on). The kit e-mails a payer who filled in the hosted checkout and did not pay: up to 5 e-mails at the delays set for the account, 15 minutes, 1 hour and 24 hours unless changed, plus one about 10 minutes before a PIX code expires, sent only while the payment can still be paid. It starts when the hosted checkout saves the payer's details, or when the checkout is first opened for a payment whose customer already has them, so it does nothing on a headless payment. The kit price, shown in the dashboard, is debited once, when the first e-mail is sent, even if the balance goes negative. Sandbox payments never get a kit: recoveryKit.enabled is false on them. The result is returned as recoveryKit on the Payment object.

itemsQuantityEditableboolean

Let the payer change the quantity of each line on the hosted checkout before picking a method; the amount, the coupon discount, the fee and percentage splits are computed again. Ignored without items and on a payment with a FIXED split.

couponCodestring

Coupon to apply, case-insensitive. A code that does not exist, is inactive, outside its validity window, out of uses, over the per-payer limit for customer.email, gives no discount on this order, or is sent with a FIXED split returns 400 COUPON_INVALID, one answer for every reason. A discount of the whole amount completes the payment as FREE: at once for a headless payment, when the payer confirms on the hosted checkout.

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 from string to no type for status

    • warning

      added the new FREE enum 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 property allOf list for the response status

    • info

      removed the CANCELLED enum value from the ///// response property for the response status

    • info

      removed the CHARGEBACK enum value from the ///// response property for the response status

    • info

      removed the CONFIRMED enum value from the ///// response property for the response status

    • info

      removed the EXPIRED enum value from the ///// response property for the response status

    • info

      removed the MED_FROZEN enum value from the ///// response property for the response status

    • info

      removed the NEW enum value from the ///// response property for the response status

    • info

      removed the PAID enum value from the ///// response property for the response status

    • info

      removed the PARTIAL_REFUND enum value from the ///// response property for the response status

    • info

      removed the PENDING_METHOD_SELECTION enum value from the ///// response property for the response status

    • info

      removed the PROCESSING enum value from the ///// response property for the response status

    • info

      removed the REFUNDED enum value from the ///// response property for the response status

    • info

      added the new optional request property