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
Parameter | Description | Type | Always Included? |
---|---|---|---|
status | The status of the payment, disbursement, or tokenization attempt. The following options are supported:
| enum | Y |
message | An 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". | array | Y |
payment | The Payment Object | JSON obj | N |
payment.payment_made | The date and time when the transaction occurred in Epoch time. | string | N |
payment.payment_amount | The decimal value of the payment amount (e.g., 104.99) | dec | N |
payment.payment_currency | The currency code of the payment amount. Currently, only USD is accepted. | enum | N |
payment.payment_status | The status of the transaction. The following values are supported:
| string | N |
payment.payment_type | The type of payment method. Supported values include the following:
| enum | N |
payment.payment_account | A short description of the payment method. | string | N |
payment.net_payment_amount | The payment amount that is settled to the consumer after all merchant, retailer (if applicable), and PayNearMe fees have been taken out. | dec | N |
payment.net_payment_currency | The currency code of the net payment amount. Currently, only USD is accepted. | enum | N |
payment.payment_processing_fee | The fee amount that PayNearMe charges for processing the transaction. | dec | N |
payment.due_to_parent | The amount settled to the parent site when set up in a parent/child site relationship. NOTE: This field applies only to ISV integrations. | string | N |
payment.due_to_parent_currency | The currency code of the amount due to the parent site. Currently, only USD is accepted. NOTE: This field applies only to ISV integrations. | enum | N |
payment.due_to_child | The amount settled to the child site when set up in a parent/child site relationship. NOTE: This field applies only to ISV integrations. | string | N |
payment.due_to_child_currency | The currency code of the amount due to the child site. Currently, only USD is accepted. NOTE: This field applies only to ISV integrations. | enum | N |
payment.settled_to_site | Indicates whether the transaction funds have been settled to the merchant site. | bool | N |
payment.date_settled_to_merchant | The date and time when the transaction was settled to the merchant in Epoch time. | string | N |
payment.pnm_payment_identifier | A unique ID generated for each transaction. | string | N |
payment.retailer_identifier | A unique PayNearMe-assigned ID for the retailer. | string | N |
payment.merchant_settlements | An array of merchant settlements | array | N |
payment.merchant_settlements.settlement_ method_identifier | A unique ID that identifies a settlement | string | N |
payment.merchant_settlements.settlement_ type | Identifies whether the settlement is a net settlement or a gross settlement | string | N |
payment.merchant_settlements.settlement_ amount | The amount to be settled | string | N |
payment.merchant_settlements.settlement_ currency | The currency code of the settlement amount. Currently, only USD is accepted. | enum | N |
payment_method | The Payment Method object | JSON obj | N |
payment_method.type | The type of payment method. Supported values include the following:
| enum | N |
payment_method.fee_amount | The service/convenience fee associated with this payment method type. | dec | N |
payment_method.fee_currency | The currency code of the service/convenience fee amount. Currently, only USD is accepted. | enum | N |
payment_method.accounts | An array of payment method accounts. | array | N |
payment_method.accounts.payment_method_ identifier | The unique ID for this payment method | string | N |
payment_method.accounts.status | The status of this payment method. The following values are supported:
| enum | N |
payment_method.accounts.name | The given name of this payment account. | string | N |
payment_method.accounts.description | A short description of this payment account (e.g., “Debit Card” or “Berkshire Ltd Bank”) | string | N |
payment_method.accounts.number | The last four digits of the card or bank account number | num | N |
payment_method.accounts.fee_amount | The service/convenience fee associated with this payment account. | dec | N |
payment_method.accounts.fee_currency | The currency code of the service/convenience fee amount. Currently, only USD is accepted. | enum | N |
last_response | The 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 obj | N |
last_response.status | The status of the action when the consumer exited the PayNearMe flow. Supported values include the following:
| enum | N |
last_response.response_code | The API Response Code | num | N |
last_response.message | A description of the events displayed in an array of strings | array | N |
auto_pay | The Autopay object. A future-scheduled payment (one-time or recurring) will have an auto_pay object instead of a payment object. | JSON obj | N |
auto_pay.schedule | A human-friendly description of the payment schedule. Displays for all schedules except those where frequency=once . | string | N |
auto_pay.frequency | Indicates how often a payment occurs in this autopay schedule. Supported values include the following:
| enum | N |
auto_pay.amount | The amount of each scheduled payment without the service/convenience fees included. | dec | N |
auto_pay.start_date | The date when the autopay schedule begins in YYYY-MM-DD format. | string | N |
auto_pay.duration_type | Defines how long this autopay schedule will run. Supported options include the following:
| enum | N |
auto_pay.end_date | The date when the autopay schedule ends in YYYY-MM-DD format. | string | N |
auto_pay.scheduled_payments | The total number of payments that will be made for this schedule. This parameter is only used if duration_type=number_of_recurrences . | num | N |
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"
}
Updated 6 months ago