promotions

Stable. Describes behaviour that is built and covered by tests in this repository.

API reference

POST /v1/promotions/quote #

What a code would take off a purchase (claims nothing)

For a checkout page of your own. The answer is the discount or the bonus credits, or an error with a coupon.* key: coupon.expired, coupon.exhausted, coupon.not_applicable, coupon.currency_mismatch, coupon.already_used and the others in the error key list.

Request body

FieldTypeDescription
codestring
customer_external_idstringNeeded by codes that are first-purchase-only or one per customer
target requiredCOUPON_TARGET_CREDIT_PURCHASE | COUPON_TARGET_PAYMENT
amount_minorstringThe price before the discount, format: int64
currency requiredstring
itemstringThe credit pack id, for codes restricted to some packs
creditsstringThe credits sold, for a bonus coupon
prior_purchasesbooleanThe customer has paid for something before
Example
{
  "target": "COUPON_TARGET_CREDIT_PURCHASE",
  "currency": "string"
}

Responses

StatusMeaningBody
200OKPromotionQuote
400Error envelopeError
404Error envelopeError
409Error envelopeError
Example response
{
  "applied": false,
  "coupon_code": "string",
  "coupon_name": "string",
  "promotion_code": "string",
  "discount_minor": "string",
  "bonus_credits": "string",
  "total_minor": "string",
  "currency": "string",
  "redemption_id": "string"
}
curl
curl -X POST https://YOUR-API-ADDRESS/v1/promotions/quote \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"target":"COUPON_TARGET_CREDIT_PURCHASE","currency":"string"}'

Models

Error

FieldTypeDescription
error requiredobject

PromotionQuote

FieldTypeDescription
applied requiredboolean
coupon_code requiredstring
coupon_name requiredstring
promotion_code requiredstring
discount_minor requiredstring · int64
bonus_credits requiredstring · int64
total_minor requiredstring · int64The price after the discount, never below zero
currency requiredstring
redemption_id requiredstring

PromotionQuoteRequest

FieldTypeDescription
codestring
customer_external_idstringNeeded by codes that are first-purchase-only or one per customer
target requiredCOUPON_TARGET_CREDIT_PURCHASE | COUPON_TARGET_PAYMENT
amount_minorstringThe price before the discount, format: int64
currency requiredstring
itemstringThe credit pack id, for codes restricted to some packs
creditsstringThe credits sold, for a bonus coupon
prior_purchasesbooleanThe customer has paid for something before