Including Promotion Codes

The Embedded Client gives Operators the ability to add promotional (promo) codes to incentivize players. Promo codes are passed in via a custom parameter and are returned in both the client and server callbacks (see below) that you configure. Operators can include promotional codes using the following methods:

  • Add the customer parameter to the data object in the PNM.init script.
  • Encode the custom parameter into the smart token.
  • Append the custom parameter to either the Secure Smart Link or the Order Tracking URL.

Adding Promo Codes via PNM.init

To include the promo code via the PNM.init script, add the custom parameter you created for the promo code (e.g., ext_bonus) and add it to the data object. The following sample displays an initialization script with a promo code parameter:

{
    "data": {
        "min_disbursement_amount": "20.00",
        "max_disbursement_amount": "500.00",
        "disbursement_balance_amount": "4000.00",
        "ext_bonus": "Super7"
    },
    "auto_resize": true,
    "language": "en",
    "header_size": "",
    "header_bkgnd": "",
    "header_color": "",
    "callback": "handlePnmCallback",
    "target": "demo_container",
    "actions": {
        "Disburse": {
            "action": "withdrawal",
            "header": "Disbursement",
            "debit": true
        },
        "Deposit": {
            "action": "pay",
            "header": "Deposit",
            "debit": true,
            "ach": true,
            "cash": true
        }
    },
    "header": "",
    "order_token":"V4UkRQm$uyA$64$$XBdAEhqW2JVQiiGEsmLaxZDYa7vxGL6tHBsp8bnTsuZk47PZ"
}

Encoding the Promo Code in the Smart Token

To encode the promo code directly into the smart token, submit a /get_smart_token request while passing in the custom parameter.

📘

Encoding the Smart Token

If promo codes are both encoded into the smart token and then passed in the PNM.init script, the encoded code will be used.

curl -X POST 
https://api.paynearme.com/json-api/get_smart_token -L \
  -d ext_bonus=Super7  
  -d site_customer_identifier=12345678 \
  -d site_identifier=S7056027885 \
  -d version=3.0 \
  -d timestamp=1643322831 \
  -d signature=1fbd09f646c0d09ebfd7b9b89c34e12a1ee956c7e1671fbd7592a77094fcd38b
{
  "status": "ok",
  "orders": [
    {
      "pnm_order_identifier": "89235062092",
      "type": "order",
      "secure_smart_token": "V4UkRQm$uyA$64$$XBdAEv7dMSfT8NXUAScfp7kCd8idmfwn2B7nSqwhVX4JwO0!",
      "secure_smart_link": "https://api.paynearme.com/json-api/V4UkRQm$uyA$64$$XBdAEv7dMSfT8NXUAScfp7kCd8idmfwn2B7nSqwhVX4JwO0!",
      "order_tracking_url": "https://api.paynearme.com/json-api/89235062092"
    }
  ]
}

Appending the Promo Code to a URL

The simplest solution for adding a promo code to an order is appending the code to either the secure_smart_link or the order_tracking_url. These parameters are returned in both the /create_order and /get_smart_token calls.

To add the promo code to the secure_smart_link URL, you’ll append the custom parameter containing the code to the URL in the data attribute. The parameter must be URL encoded. For example, using the secure_smart_link URL from the call above,

https://api.paynearme.com/json-api/V4UkRQm$uyA$64$$XBdAEv7dMSfT8NXUAScfp7kCd8idmfwn2B7nSqwhVX4JwO0

add the custom parameter {"ext_bonus_code"="Super7"} after URL encoding it. To URL encode it, use the following simple JS script:

encodeURIComponent(JSON.stringify({"ext_bonus_code":"SUPER7"}))

which renders the following string: %7B%22ext_bonus_code%22%3A%22SUPER7%22%7D

Once the parameter is URL encoded, append it to the secure_smart_link URL within the data attribute:

https://api.paynearme.com/json-api/V4UkRQm$uyA$64$$XBdAEv7dMSfT8NXUAScfp7kCd8idmfwn2B7nSqwhVX4JwO0?data=%7B%22ext_bonus_code%22%3A%22SUPER7%22%7D

If you don’t want to go through the process of URL encoding, you can simply append the promo code parameter to the order_tracking_url: https://api.paynearme.com/json-api/89235062092?ext_bonus_code=SUPER7