Create Promotion Quote
Promotions is enabled per organization
Until WHITELABEL enables Promotions for your organization, this endpoint answers 204 (nothing applies). Ask your Technical Account Manager or Key Account Manager. See Promotions.
Using the WHITELABEL checkout? You don’t call this endpoint
The checkout asks for the quote by itself when the customer enters a card, and updates the price and the discount in the order summary. Call this endpoint only from a direct API integration: from your server with your secret key, or from the browser with your public key inside an embedded sdk-web integration.
Two ways to call it
- Secret key, from your server. Send
amount. This is the flow described below. - Public key, from the browser (embedded sdk-web). Send
checkout_sessioninstead ofamount; the amount comes from the session. WHITELABEL validatesaccount_idandcountryagainst that session.
payment_method is required on both. A quote is valid for 30 minutes after it is issued, on both. Add code on either path to quote a promotion that requires one; omit it for automatic promotions.
{
"account_id": "493e9374-510a-4201-9e09-de669d75f256",
"amount": { "currency": "USD", "value": 250.00 },
"country": "AR",
"payment_method": { "type": "CARD", "bin": "457896", "card_type": "CREDIT" }
}{
"account_id": "493e9374-510a-4201-9e09-de669d75f256",
"checkout_session": "chks_8f1c2e6a9b3d",
"country": "AR",
"payment_method": { "type": "CARD", "bin": "457896", "card_type": "CREDIT" }
}{
"account_id": "493e9374-510a-4201-9e09-de669d75f256",
"amount": { "currency": "USD", "value": 250.00 },
"country": "AR",
"payment_method": { "type": "CARD", "bin": "457896", "card_type": "CREDIT" },
"code": "WELCOME10"
}How to use the quote
- Send the context of the payment you’re about to create.
amountis the original amount, before any promotion. For a card, identify it in one of two ways insidepayment_method:bin(the first 6 to 8 digits), ortokenorvaulted_token. Addcodewhen the promotion requires one; omit it for automatic promotions. - On
200, showcharge_amountto your customer. That’s what they’ll pay. The answer includesquote_id,promotions(one entry today:id,name,description,discount,discount_amount), and the three totals outside the list (original_amount,discount_amount,charge_amount). - Create the payment with the same original
amountandadditional_data.order.discounts: [{ "type": "YUNO_PROMOTION", "quote_id": "<quote_id>" }]. See Create Payment and Promotions.
A promotion applies only when the payment carries that quote_id on a discount line. A payment without one is charged in full.
Rules
- Biggest saving wins. When two or more promotions match, the quote is for the one that saves the customer the most, then the oldest, then the smallest
id. One promotion per payment; no stacking. - 30 minutes. A quote is valid until
expires_at, 30 minutes after it is issued. Inside that time the payment charges the quoted price, even if the promotion’s end date passed after the quote was issued, or you disabled the promotion after the quote was issued. - Every condition must already be true. A quote exists only when the promotion’s conditions all hold for the context you send.
- Quoted price or no payment. If the quote expired, or the payment’s amount, currency, card or account differs from what you quoted, WHITELABEL rejects the payment with
422and one of thePROMOTION_*codes listed in Promotions. It never re-prices. Get a new quote and try again. - Nothing is consumed. A quote is a read. Asking twice returns the same answer while it is valid, and a quote you never use needs no cleanup.
- No match isn’t an error. The answer is
204when nothing applies. Create the payment as usual, with noquote_idon a discount line. - BIN or token, never both, inside
payment_method. A server that holds the card number sendspayment_method.bin, the first 6 to 8 digits. A server that holds a token sendspayment_method.tokenorpayment_method.vaulted_token, and WHITELABEL resolves the BIN and the card type from the card, exactly as it does on the payment. Sending both is rejected with400 INVALID_PARAMETERS. Without a BIN, a promotion with abinsorcard_typescondition doesn’t apply. A wallet (Apple Pay, Google Pay) has no BIN; quote it withoutbin. - Never send a full card number.
payment_method.binis 6 to 8 digits, digits only. More than 8 digits, fewer than 6, or anything but digits is rejected with400 INVALID_PARAMETERS. - Promotion codes are not available yet. Today every promotion is
AUTOMATIC; codes are coming in a later release. - A wrong or unusable code doesn’t fall back to automatic. Send
codeonly for a promotion that requires one. No promotion with that code on the account answers404 PROMOTION_NOT_FOUND. A code that exists but can’t apply right now (disabled, not started yet, ended, its conditions don’t match, no discount for this currency, or the discount would be zero) answers422 PROMOTION_NOT_APPLICABLE, with the reason inmessages[]. Both use the standard error body (codeandmessages[]), with noreasonfield. Automatic promotions never return these two; nothing applying is still204.
/promotions/quotePrices a payment before you create it. Returns a signed quote when a promotion applies, or 204 when nothing applies. Nothing is consumed: the same request returns the same answer while the quote is valid. A quote lives 30 minutes after it is issued, on both credentials. Every condition of the promotion must already be true for a quote to exist. Promotions must be enabled for your organization by WHITELABEL before you can use this endpoint. See Promotions.
Response
200
Opaque, about 400 characters, up to 500. Send it unchanged on the payment as quote_id on an additional_data.order.discounts line with type: YUNO_PROMOTION. Never parse it.
The promotions that apply. One entry in this release; a later release may return more than one. The outer discount_amount is the sum of each entry’s discount_amount.
The amount you sent, before the discount.
Total discount (sum of promotions[].discount_amount). Always positive.
What the customer pays: original minus discount.
The quote is valid until this instant: 30 minutes after it was issued.
No promotion applies to this payment context, or Promotions is not enabled for your organization.
400
codeonly: no promotion with that code exists on this account.
codeonly: the promotion exists but cannot apply.