Welcome‎ > ‎Version 3‎ > ‎Publisher Api‎ > ‎Methods‎ > ‎1 - Offer Related‎ > ‎

Validate Promo Codes

Will return discount information for valid promo codes.  Returns errors for invalid promo codes.

Method: POST /api/v3/publisher/promocodes

Authentication: oauth
 
Post
Required Form Name
Explanation
Yes PromoCodes A list of promo codes to validate.  The first promo code in the list is applied first, etc...
Yes OfferOptionIds The ids of the offer options that the promo codes are being applied to.
No PurchaseTotal 
The cost of goods for the purchase.  I.e. the sum of (price * quantity) over all items being purchased.  This should be passed if available.
NoUserKeyThe user key of the consumer making the purchase.

Returns
base response fields
promoCodeValidationResults - a list of promo code validation results (see below) - one for each promo code in the request.

PromoCodeValidationResult
Fields:
Field Data Type Nulls Description
offerOptionId
int
Y
The offer option id that this promo code applies to among the offer option ids that were passed in on the validate promo code request.  Null if it applies to more than one.
discountPercentage
decimal

The value (price * discountPercentage / 100) should be subtracted from the total price of the applicable offer options.
discountAmount decimal

The fixed value that should be subtracted from the total price of the order.
errorMessage string
Y
The error message associated with this promo code (null if promo code is valid)
isValid bool

Whether or not the promo code is valid.
promoCode string

The promo code being validated.
 

Sample Request:

POST http://api.groupcommerce.com/api/v3/publisher/promocodes

Form: OfferOptionIds%5b0%5d=8318&OfferOptionIds%5b1%5d=9909&PromoCodes%5b0%5d=democode&PromoCodes%5b1%5d=test&PromoCodes%5b2%5d=badcode&userkey=3c651ac9e6054d72b9b938f782790c8c&purchasetotal=30

Authorization: OAuth oauth_signature="%2bE0S9eax5ebzqn5cETk3DVTP0xs%3d", oauth_nonce="5699801", oauth_timestamp="1328131944", oauth_consumer_key="eeb6b959-b854-4ad1-b563-e801c83cf81d", oauth_signature_method="HMAC-SHA1", oauth_version="1.0"

Sample JSON Response:

{
    "errors": [],
    "lastPublished": "/Date(1328131614624)/",
    "success": true,
    "version": "3",
    "promoCodeValidationResults": [
        {
            "discountAmount": 0,
            "discountPercentage": 45,
            "errorMessage": null,
            "isValid": true,
            "offerOptionId": 8318,
            "promoCode": "democode"
        },
       
{
            "discountAmount": 0,
            "discountPercentage": 25,
            "errorMessage": null,
            "isValid": true,
            "offerOptionId": null,
            "promoCode": "test"
        }
,
       
{
            "discountAmount": 0,
            "discountPercentage": 0,
            "errorMessage": "Sorry, that promo code (or an equivalent promo code) was already applied to the order.",
            "isValid": false,
            "offerOptionId": null,
            "promoCode": "badcode"
        }

    ]
}


Sample XML Response:

<validatePromoCodesResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <errors />
      <lastPublished>2012-02-01T21:32:23.9041816Z</lastPublished>
      <success>true</success>
      <version>3</version>
      <promoCodeValidationResults>
             <validatePromoCodeResult>
                <discountAmount>0</discountAmount>
                <discountPercentage>45</discountPercentage>
                <errorMessage i:nil="true" />
                <isValid>true</isValid>
                <offerOptionId>8318</offerOptionId>
                <promoCode>democode</promoCode>
             </validatePromoCodeResult>
            
<validatePromoCodeResult>
                <discountAmount>0</discountAmount>
                <discountPercentage>25</discountPercentage>
                <errorMessage i:nil="true" />
                <isValid>true</isValid>
                <offerOptionId i:nil="true" />
                <promoCode>test</promoCode>
             </validatePromoCodeResult>
             <validatePromoCodeResult>
                <discountAmount>0</discountAmount>
                <discountPercentage>0</discountPercentage>
                <errorMessage>
Sorry, that promo code (or an equivalent promo code) was already applied to the order.</errorMessage>
                <isValid>false</isValid>
                <offerOptionId i:nil="true" />
                <promoCode>badcode</promoCode>
             </validatePromoCodeResult>

      </promoCodeValidationResults>
</validatePromoCodesResponse>
Comments