Step 4: Capture the Callback

Merchants must create a callback function that the JS Library references in the callback field (e.g., callback: mycallbackfunction). Use the console.log() function when creating your callback to record events and capture alert messages in real-time. This callback function should be placed before PNM.init on your checkout page and should provide guidance on how to handle errors, timeouts, and/or specific alert messages. The following is a sample of what your callback script may look like:

<script>
      function mycallbackfunction(data){
        console.log('mycallbackfunction',data);
        
        if( !data.status ){
          // status should always be present 
          // for any messages posted by the PNM iFrame.
          console.log('[mycallbackfunction] Missing expected field');
          return;
        } 
 
        if( data.status == 'error' ){
          // Merchants may want to branch off depending on the error.
        }
 
        if( data.status == ‘exit’ ){
          // The user exited the PNM UI flow before completion.
          // Add code to guide the user as needed by your system.
          PNM.close_modal();
        }
 
        if( data.status == 'complete' ){
          PNM.close_modal();
          // Add code to save off the response information to your system
        }
 
        msg = "Status: "+data.status + "\n";
        if( data.message ){
          msg += data.message.join("\n");
        }
        alert( msg );
      }
    </script>

PNM Response Data

ParameterDescriptionTypeAlways Included?
statusThe status of the payment, disbursement, or tokenization attempt. The following options are supported:
  • complete - The process completed successfully, and no further action is required.
  • info - An informational update on the progress of the process. No further action from the merchant is required. For example, this status can occur when a payment method has been added during the process of completing a payment.
  • exit - The consumer exited the flow without completing the desired action. A last_response object will be provided if the consumer attempted an action like adding a payment method or attempting a payment or disbursement.
  • error - The consumer encountered a non-recoverable error and cannot continue with the transaction.
enumY
messageAn array of user-friendly, localized (English or Spanish) strings that describe the event. Multiple lines are broken into separate rows of the array and can be joined together using your preferred line-break method.
Lines that have key-value pairs are listed in a single string separated by two pipe characters. For example, "Payment Amount||$101.23".
arrayY
paymentThe Payment ObjectJSON objN
payment.payment_madeThe date and time when the transaction occurred in Epoch time.stringN
payment.payment_amountThe decimal value of the payment amount (e.g., 104.99)decN
payment.payment_currencyThe currency code of the payment amount. Currently, only USD is accepted.enumN
payment.payment_statusThe status of the transaction. The following values are supported:
  • approved - The transaction was approved by the processor.
  • authorized - The merchant has approved the retail location to accept the cash payment. The payment is considered pending until the payment confirmation callback is created and sent.
  • rejected - The transaction was not-approved by the processor. This can be caused by malformed data or incorrect data submission. Retries may be possible.
  • canceled - The consumer exited the client before completing the transaction.
stringN
payment.payment_typeThe type of payment method. Supported values include the following:
  • ach
  • ach_push
  • cash
  • cash_app
  • credit
  • debit
  • paypal
  • paypal_push
  • push_debit
  • venmo
  • venmo_push
enumN
payment.payment_accountA short description of the payment method.stringN
payment.net_payment_amountThe payment amount that is settled to the consumer after all merchant, retailer (if applicable), and PayNearMe fees have been taken out.decN
payment.net_payment_currencyThe currency code of the net payment amount. Currently, only USD is accepted.enumN
payment.payment_processing_feeThe fee amount that PayNearMe charges for processing the transaction.decN
payment.due_to_parentThe amount settled to the parent site when set up in a parent/child site relationship. NOTE: This field applies only to ISV integrations.stringN
payment.due_to_parent_currencyThe currency code of the amount due to the parent site. Currently, only USD is accepted. NOTE: This field applies only to ISV integrations.enumN
payment.due_to_childThe amount settled to the child site when set up in a parent/child site relationship. NOTE: This field applies only to ISV integrations.stringN
payment.due_to_child_currencyThe currency code of the amount due to the child site. Currently, only USD is accepted. NOTE: This field applies only to ISV integrations.enumN
payment.settled_to_siteIndicates whether the transaction funds have been settled to the merchant site.boolN
payment.date_settled_to_merchantThe date and time when the transaction was settled to the merchant in Epoch time.stringN
payment.pnm_payment_identifierA unique ID generated for each transaction.stringN
payment.retailer_identifierA unique PayNearMe-assigned ID for the retailer.stringN
payment.merchant_settlementsAn array of merchant settlementsarrayN
payment.merchant_settlements.settlement_ method_identifierA unique ID that identifies a settlementstringN
payment.merchant_settlements.settlement_ typeIdentifies whether the settlement is a net settlement or a gross settlementstringN
payment.merchant_settlements.settlement_ amountThe amount to be settledstringN
payment.merchant_settlements.settlement_ currencyThe currency code of the settlement amount. Currently, only USD is accepted.enumN
payment_methodThe Payment Method objectJSON objN
payment_method.typeThe type of payment method. Supported values include the following:
  • ach
  • credit
  • debit
enumN
payment_method.fee_amountThe service/convenience fee associated with this payment method type.decN
payment_method.fee_currencyThe currency code of the service/convenience fee amount. Currently, only USD is accepted.enumN
payment_method.accountsAn array of payment method accounts.arrayN
payment_method.accounts.payment_method_ identifierThe unique ID for this payment methodstringN
payment_method.accounts.statusThe status of this payment method. The following values are supported:
  • active
  • inactive
  • expired
enumN
payment_method.accounts.nameThe given name of this payment account.stringN
payment_method.accounts.descriptionA short description of this payment account (e.g., “Debit Card” or “Berkshire Ltd Bank”)stringN
payment_method.accounts.numberThe last four digits of the card or bank account numbernumN
payment_method.accounts.fee_amountThe service/convenience fee associated with this payment account.decN
payment_method.accounts.fee_currencyThe currency code of the service/convenience fee amount. Currently, only USD is accepted.enumN
last_responseThe Last Response object. If the consumer exits the PayNearMe flow without completing the desired action, a last_response object will be included in the callback when the consumer exits. The object will contain information about the last significant action the consumer took before exiting.JSON objN
last_response.statusThe status of the action when the consumer exited the PayNearMe flow. Supported values include the following:
  • complete
  • error
  • exit
  • info
  • warning
enumN
last_response.response_codeThe API Response CodenumN
last_response.messageA description of the events displayed in an array of stringsarrayN
auto_payThe Autopay object. A future-scheduled payment (one-time or recurring) will have an auto_pay object instead of a payment object.JSON objN
auto_pay.scheduleA human-friendly description of the payment schedule. Displays for all schedules except those where frequency=once.stringN
auto_pay.frequencyIndicates how often a payment occurs in this autopay schedule. Supported values include the following:
  • biweekly
  • end_of_month
  • monthly
  • once
  • twice_monthly
  • weekly
enumN
auto_pay.amountThe amount of each scheduled payment without the service/convenience fees included.decN
auto_pay.start_dateThe date when the autopay schedule begins in YYYY-MM-DD format.stringN
auto_pay.duration_typeDefines how long this autopay schedule will run. Supported options include the following:
  • end_date
  • indefinite
  • number_of_recurrences
  • once
enumN
auto_pay.end_dateThe date when the autopay schedule ends in YYYY-MM-DD format.stringN
auto_pay.scheduled_paymentsThe total number of payments that will be made for this schedule. This parameter is only used if duration_type=number_of_recurrences.numN

Payment Success Callback

{
"status": "complete",
"code": 0,
"message": [
  "Payment Complete",
  "Payment Date||10/14/21",
  "Account||198640000",
  "Customer||Raymond Stantz",
  "Confirmation number||234478391623",
  "Payment Method||Credit Card 9999",
  "Payment Amount||$100.00",
  "Service Fee||$4.99",
  "Total Payment||$104.99"
],
"payment_method":{
  "payment_method_identifier":"8eb1948964b7b",
  "type": "credit",
  "status": "active",
  "name": "Dr. Raymond Stantz",
  "description": "Credit Card",
  "account_type": "Credit",
  "number": "9999",
  "fee_amount": "4.99",
  "fee_currency": "USD"
},
"payment": {
    "payment_identifier": "786715791256",
    "total_amount": "102.32",
    "total_currency": "USD",
    "payment_amount": "100.33",
    "payment_currency": "USD"
  }
}

Disbursement Success Callback

{
"status": "complete",
"code": 0,
"message":[
  "Card load completed successfully from Hard Rock Casino",
  "Amount loaded||$74.01",
  "Processing fee||$0.99",
  "Total amount||$75.00",
  "Confirmation||913963157076"
],
"payment_method":{
  "payment_method_identifier": "b31d6dc606f5e",
  "type": "debit",
  "status": "active",
  "name": "Egon Spengler",
  "description": "Debit Card",
  "account_type": "Debit",
  "number": "9997",
  "fee_amount": "4.99",
  "fee_currency": "USD"
},
"payment":{
  "payment_made": "2021-10-14 14:47:38 -0700",
  "payment_amount": "75.00",
  "payment_currency": "USD",
  "payment_status": "approved"
}
}

Tokenize Success Callback

{
"status": "complete",
"code": 0,
"message": [
"Payment Method added successfully"
],
payment_method: {
  "payment_method_identifier": "ob3e46a4eee9c",
  "type": "ach",
  "status": "active",
  "name": "Dana Bennett",
  "description": "Star City Federal Credit Union",
  "account_type": "Personal Checking",
  "number": "8103",
  "fee_amount": "4.99"
  "fee_currency": "USD"
} 
}

Authorized Success Callback

{
    "status": "authorized",
    "message":
    [
        "Payment Authorized",
        "Payment Date||1/11/22",
        "Account||123456789",
        "Customer||Patsy",
        "Confirmation Number||592104711367",
        "Payment Method||Cash at 7-Eleven",
        "Payment Amount||$250.00",
        "Service Fee||$2.99",
        "Total Payment||$252.99",
        "A confirmation has been sent to (555) 500-0002 and [email protected]" 
    ],
    "payment_method":
    {
        "type": "cash",
        "description": "Cash at 7-Eleven"
    },
    "payment":
    {
        "payment_made": "2022-01-11 08:00:00 -0800",
        "payment_amount": "252.99",
        "payment_currency": "USD",
        "payment_status": "authorized",
        "net_payment_amount": "250.00",
        "net_payment_currency": "USD",
        "payment_processing_fee": "2.99",
        "payment_processing_fee_currency": "USD",
        "pnm_processing_fee": "2.99",
        "pnm_processing_fee_currency": "USD",
        "settled_to_site": "false",
        "date_settled_to_merchant": "",
        "pnm_payment_identifier": "592104711367",
        "retailer_identifier": "7-Eleven",
        "site_channel": "consumer",
        "payment_receipt_text": "Please try again in a minute to get your receipt.\n\n",
        "payment_latitude": "26.3623",
        "payment_longitude": "-80.0901",
        "payment_location_identifier": "14338",
        "payment_location_retailer": "7-Eleven",
        "payment_location_address": "Holly Street, San Carlos, CA",
        "merchant_settlements":
        [
            {
                "settlement_method_identifier": "SM754042196",
                "settlement_type": "net_payment",
                "settlement_amount": "250.00",
                "settlement_currency": "USD"
            }
        ]
    }
}

Exit After Error Callback

{
  "status": "exit",
  "message": [
    "Action cancelled"
  ],
  "last_response": {
    "status": "error",
    "response_code": "5000",
    "message": [
       "Minimum required payment is $20.00. Please retry transaction with this amount. You may contact your merchant or PayNearMe Support at 1-888-714-0004 for assistance."
    ]
  }

Exit Before Payment Completion Callback

{
  "status": "exit",
  "message": [ 
    "Action Canceled"
  ],
  "last_response": {
    "message": [
      "payment_method created"
    ],
  "response_code": "0"
}