Step 1: Generate a Smart Token

A secure_smart_token is a unique string of encrypted data values that authenticate PayNearMe orders within your app or website. The button used to invoke the PayNearMe JS Library requires a Smart Token to initialize the timed session within the iframe. Smart Tokens can be configured at the site level to expire after a set amount of time or can remain the same for the duration of the order’s lifetime.

🚧

Smart Token Expiration

For security, PayNearMe recommends setting an expiration time for Smart Tokens

How you generate Smart Tokens will depend on how you configure orders. If consumers will be making payments at the time of order generation, use the /create_order call. If payments will be made after order generation, use the /get_smart_token call to regenerate an expired token for an existing order. A typical implementation uses the /get_smart_token call after creating orders via bulk upload.

The following code sample displays an example /get_smart_token call.

curl -X POST https://www.paynearme-sandbox.com/json-api/get_smart_token -L \
  -d site_customer_identifier=760390000 \
  -d site_identifier=S2411573363 \
  -d timestamp=1694036217 \
  -d version=3.0 \
  -d signature=492a62960fa336f34a0130ec377950210b08c7132004af70d66cc375fbd5ca43
{
  "status": "ok",
  "orders": [
    {
      "pnm_order_identifier": "84879088413",
      "site_order_identifier": "760390000",
      "secure_smart_token": "5mk8Jpr7UYCKDqR6zRn0bN1asLb48YGIWtnAv6WFdj2g4hGdJTJTQHb9EFdnVcuP",
      "secure_smart_link": "https://www.paynearme-sandbox.com/ssl/5mk8Jpr7UYCKDqR6zRn0bN1asLb48YGIWtnAv6WFdj2g4hGdJTJTQHb9EFdnVcuP",
      "order_tracking_url": "https://www.paynearme-sandbox.com/84879088413"
    }
  ]
}

Adding Fixed Amounts

Clients, such as gaming operators, may want to optionally encode the token to force a fixed amount for the payment or disbursement (e.g., deposits and withdrawals can only be made in $50.00 increments). To do this, pass in the payment_amount and payment_field_fixed parameters. The following sample displays the code.

curl -X POST https://www.paynearme-sandbox.com/json-api/get_smart_token -L \
  -d payment_amount=50 \
  -d payment_field_fixed=true \
  -d pnm_order_identifier=88569878166 \
  -d site_identifier=S2411573363 \
  -d timestamp=1694118324 \
  -d version=3.0 \
  -d signature=2fb59d80d6218b6bbb237b7758eca1f193604274bff9b0588e97dcc96f8056d2
{
  "status": "ok",
  "orders": [
    {
      "pnm_order_identifier": "88569878166",
      "site_order_identifier": "412410000",
      "secure_smart_token": "ynfmvb3jgd8rZj1lRvMELjQQ27CMeP80MYgrcnmEWz0eQJoCYfL!8DUpXJk6EkQ8j6AIPsIuFgb8q4Pb$lESCCDB7WsSXWU4P9Mh$Lss9Cr0nYq!YKiJvYd7m2auKIbE",
      "secure_smart_link": "https://www.paynearme-sandbox.com/ssl/ynfmvb3jgd8rZj1lRvMELjQQ27CMeP80MYgrcnmEWz0eQJoCYfL!8DUpXJk6EkQ8j6AIPsIuFgb8q4Pb$lESCCDB7WsSXWU4P9Mh$Lss9Cr0nYq!YKiJvYd7m2auKIbE",
      "order_tracking_url": "https://www.paynearme-sandbox.com/88569878166"
    }
  ]
}

When the consumer accesses the Embedded Client to pay, the fixed amount displays on the payment submission screen.