Understanding the Data Flow

Create the Order

Typically, clients use the SFTP bulk upload option to create an Order for their consumers. This can be once a month, once a week, or once a day, depending on the client's individual payment and business requirements. Clients can also create or "stage" an order using the /create_order API endpoint. To create an order via the /create_order API call, use the following parameters in your request call.

ParameterDescriptionTypeRequired?
order_amountThe decimal amount of the order.decR
order_currencyUSDenumR
site_customer_identifierA unique, merchant-defined string that identifies the customer.stringR
site_order_identifierAn arbitrary, merchant-defined string used to refer to this order.stringO
site_order_descriptionThe merchant's description of the order. This does not appear on the payment slip (for cash payments) but is useful for support issues.stringO
order_typeThe order's type. Supported values include the following:
  • exact = Consumer must pay the exact order amount.
  • up-to = Consumer any amount up to the order amount.
  • any = Consumer can pay any amount.
enumR
order_is_standingIf the order can be repeatedly paid for, enter true.boolR
site_customer_phoneThe consumer’s mobile phone number.stringO
site_customer_emailThe consumer’s email address.stringO
site_customer_nameThe first and last name of the consumer. You can also send the consumer’s first and last names in separate parameters using site_customer_first_name and site_customer_last_name.stringO
site_customer_year_of_birthThe consumer's four-digit year of birth (i.e., YYYY)stringO
site_customer_languageSpecifies whether the consumer’s preferred language is
  • en = English
  • sp = Spanish
enumO
site_customer_streetThe consumer’s street address from his/her billing address.stringO
site_customer_stateThe consumer’s two-character state abbreviation from his/her billing address (e.g., TX, AK, NY, etc).stringO
site_customer_postal_codeThe consumer’s ZIP code from his/her billing address.stringO
site_identifierThe merchant’s unique Site ID.stringR
timestampThe Unix Epoch time of the call.stringR
versionThe version of the API you’re using. This version must match the version associated with your API key pair.stringR
signatureThe HMAC signature that is calculated by running your API Secret Key and the alphabetized, concatenated parameters of the request’s payload through the SHA256 message digest algorithm.stringR
curl --location --request POST 'https://api.paynearme-sandbox.com/json-api/create_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json; charset=utf-8' \
--data-raw '{
  "order_amount": "30000.0",
  "order_currency": "USD",
  "order_type": "any",
  "signature": " bded9807eae0d20f906df49d1790f98e8a57009218d832c691412a0d6dc64209",
  "site_customer_identifier": "171090000",
  "site_identifier": "S2155373459",
  "timestamp": "1668203922",
  "version": "3.0",
  "order_is_standing": true,
  "site_order_identifier": "171090000",
  "site_order_key": "85647985321",
  "site_order_description": "Loan85647985321",
  "site_customer_phone": "2144485393",
  "site_customer_email": "[email protected]",
  "site_customer_name": "Peppa Pig",
  "site_customer_year_of_birth": "1980",
  "site_customer_language": "en",
  "site_customer_street": "123%20Fake%20Street",
  "site_customer_state": "TX",
  "site_customer_postal_code": "75013"
}'
{
  "status": "ok",
  "order": {
    "site_name": "Freehold Financial VII",
    "site_logo_url": "https://www.paynearme-sandbox.com/photos/emit_image/H3NopCqX5n",
    "site_order_identifier": "171090000",
    "type": "order",
    "site_identifier": "S2155373459",
    "require_auth_tracker": "false",
    "pnm_order_crid": "v5hz8B",
    "pnm_customer_language": "en",
    "pnm_order_identifier": "83733025337",
    "pnm_order_short_identifier": "0K93DZ",
    "site_order_key": "85647985321",
    "order_created": "2022-11-11 13:58:44 -0800",
    "order_status": "open",
    "order_amount": "30000.00",
    "order_currency": "USD",
    "minimum_payment_amount": "0.00",
    "minimum_payment_currency": "USD",
    "order_type": "any",
    "order_is_standing": "true",
    "site_order_description": "Loan85647985321",
    "secure_smart_token": "p869ZdcFtxrNbyl$eHt2yBnexhDN8a2qMoJpM1HReyDIjTRsaoR7v8vewle0YkXa",
    "secure_smart_link": "https://www.paynearme-sandbox.com/ssl/p869ZdcFtxrNbyl$eHt2yBnexhDN8a2qMoJpM1HReyDIjTRsaoR7v8vewle0YkXa",
    "order_tracking_url": "https://www.paynearme-sandbox.com/83733025337",
    "auto_pay": null,
    "electronic_payments": {
      "embedded_js_url": "https://www.paynearme-sandbox.com/api/embedded/tZgpGtb_GKHsW_ng8nnJsQ/script.js",
      "payment_methods": [
        {
          "type": "debit",
          "fee_amount": "4.99",
          "fee_currency": "USD",
          "accounts": [

          ]
        },
        {
          "type": "ach",
          "fee_amount": "0.00",
          "fee_currency": "USD",
          "accounts": [

          ]
        }
      ]
    },
    "cards": null,
    "customer": {
      "pnm_customer_identifier": "U7726318287",
      "site_customer_identifier": "171090000",
      "pnm_customer_name": "Peppa Pig",
      "pnm_customer_email": "[email protected]",
      "pnm_customer_phone": "2144485393",
      "pnm_customer_addressee": "Peppa Pig",
      "pnm_customer_street": "123 Fake Street",
      "pnm_customer_city": "Allen",
      "pnm_customer_state": "TX",
      "pnm_customer_postal_code": "75013",
      "pnm_customer_language": "en"
    }
  }
}

You'll need the following parameters contained in the response above when integrating with the Embedded Form:

  • pnm_order_identifier - A unique identifier for the order within the PayNearMe system, you will want to store this with your customer record in your system as it will be used for additional API calls.
  • embedded_js_url​ - The dynamic JavaScript that can be used to invoke the PayNearMe Embedded Form. This URL is only active for 30 minutes after it is returned in the response to the /create_order API call. When triggered within that 30-minute window, it invokes the Embedded Form modal hosted by PayNearMe to collect and tokenize card or bank data and, if configured, to complete a payment.
🚧

Storing the JavaScript URL

Do not store the embedded_js_url as it will expire after 30 minutes. Make a /refresh_embedded_js_urls API call to get a fresh URL if that 30-minute window has passed.

Regenerate the JavaScript URL

Since the embedded_js_url expires 30 minutes after order creation, clients must recreate it before invoking the Embedded Form and proceeding with tokenization and/or payment. This script can be recreated using the /refresh_embedded_js_urls API call. When making the /refresh_embedded_js_urls call, use the following parameters in the request:

ParameterDescriptionTypeRequired?
pnm_order_identifierThe unique, PayNearMe-created identifier for this order. Use this parameter to regenerate the embedded_js_url for a specific order.stringC*
site_order_identifierAn arbitrary, merchant-defined string used to refer to the order. Use this parameter to regenerate the embedded_js_url for a specific order.stringC*
pnm_customer_identifierA unique, merchant-defined string that identifies the customer. Use this parameter to regenerate the embedded_js_url for all orders belonging to a customer.stringC*
site_customer_identifierAn arbitrary, merchant-defined string used to refer to this order. Use this parameter to regenerate the embedded_js_url for all orders belonging to a customer.stringC*
forceUse true to regenerate all embedded_js_url for an order regardless of expiration status. If force is set to false or is not provided, the embedded_js_url is regenerated only for orders where the existing URL has expired.boolO
limitUsed for pagination, this parameter specifies the maximum number of orders to return (maximum is 5; default is 2)intO
offsetUsed for pagination, this parameter specifies the number of orders to skip before starting to return results in the response (default is 0).intO
site_identifierThe merchant’s unique Site ID.stringR
timestampThe Unix Epoch time of the call.stringR
versionThe version of the API you’re using. This version must match the version associated with your API key pair.stringR
signatureThe HMAC signature that is calculated by running your API Secret Key and the alphabetized, concatenated parameters of the request’s payload through the SHA256 message digest algorithm.stringR

*When using these calls, only one of the following parameters is required:

  • pnm_order_identifier
  • site_order_identifier
  • pnm_customer_identifier
  • site_customer_identifier

Use either the pnm_order_identifier or site_order_identifier to recreate the embedded_js_url for a specific order and use either the site_customer_identifier or pnm_customer_identifier to recreate the embedded_js_url for up to five orders associated with a consumer.

curl --request POST \
     --url https://api.paynearme-sandbox.com/json-api/refresh_embedded_js_urls \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "site_identifier": "S3711063247",
  "timestamp": "1769726017",
  "version": "3.0",
  "signature": "e09df48a34fbef0de1033d1198d9da964c182e8d781f70d0138022c6d1d7c4c2",
  "site_order_identifier": "96088234724"
}
'
curl --request POST \
     --url https://api.paynearme-sandbox.com/json-api/refresh_embedded_js_urls \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "site_identifier": "S3711063247",
  "timestamp": "1769726369",
  "version": "3.0",
  "signature": "028523a38554a84e551cd08b71ff79bec3f5f24539e3df5e31c7fb9dda72ba91",
  "site_customer_identifier": "2142455462",
  "limit": 5
}
'
{
  "status": "ok",
  "embedded_js_urls": [
    {
      "pnm_order_identifier": "85977123613",
      "site_order_identifier": "96088234724",
      "pnm_customer_identifier": "U3624027130",
      "site_customer_identifier": "2142455462",
      "url": "https://www.paynearme-sandbox.com/api/embedded/JPZD_RFcyw2yd3tt9Fmfmg/script.js"
    }
  ]
}
{
  "status": "ok",
  "embedded_js_urls": [
    {
      "pnm_order_identifier": "80249634711",
			"site_order_identifier": "91350745822",
      "pnm_customer_identifier": "U3624027130",
      "site_customer_identifier": "2142455462",
      "url": "https://www.paynearme-sandbox.com/api/embedded/zqNAYce-5ykwHQcUlqAl-g/script.js"
    },
    {
      "pnm_order_identifier": "85977123613",
      "site_order_identifier": "96088234724",
      "pnm_customer_identifier": "U3624027130",
      "site_customer_identifier": "2142455462",
      "url": "https://www.paynearme-sandbox.com/api/embedded/JPZD_RFcyw2yd3tt9Fmfmg/script.js"
    },
    {
      "pnm_order_identifier": "87633175415",
			"site_order_identifier": "98744286526",
      "pnm_customer_identifier": "U3624027130",
      "site_customer_identifier": "2142455462",
      "url": "https://www.paynearme-sandbox.com/api/embedded/D34WkXuuXY2pSEWH9JYeyA/script.js"
    },
    {
      "pnm_order_identifier": "80242357673",
			"site_order_identifier": "91353468784",
      "pnm_customer_identifier": "U3624027130",
      "site_customer_identifier": "2142455462",
      "url": "https://www.paynearme-sandbox.com/api/embedded/Hao_Bq1vf0izSVSWsjAABA/script.js"
    }
  ]
}

Embedded Form Flow

The Embedded Form can be used exclusively as a payment method tokenization solution or as a tokenization and payment processing solution. Your Embedded Form configuration depends on how you want to submit payments to PayNearMe.

Tokenization + Payments Flow

The Embedded Form configuration with the lowest compliance burden involves tokenizing the payment method and accepting a payment in the same session. All data added by the agent is transferred securely and directly to PayNearMe servers without the need for token storage by the client. This configuration type only requires one API call, /refresh_embedded_js_urls, to capture both the payment method and the payment details. The following data flow diagram displays how this configuration works:

Tokenization Only Flow

Clients who submit payments with the /make_payment API can use the Embedded Form to quickly tokenize payment methods. These tokens (i.e., payment_method_identifier) can then be collected for storage via a JavaScript callback function or a simple page refresh in the Embedded Form. Once captured and stored, the token can be used for any future payments associated with this order. The following data flow diagram displays the Embedded Form's tokenization process:

To make payments with a previously tokenized payment method, clients can simply look up the order with a /find_orders request, select the desired payment_method_identifier, and then submit a /make_payment call using the payment method token. The following data flow diagram displays this process: