{"__v":15,"_id":"573476ae6dd7ba0e00402805","category":{"__v":0,"_id":"573243608b55962900f063c2","project":"573243608b55962900f063c0","version":"573243608b55962900f063c1","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-04-26T16:11:59.957Z","from_sync":false,"order":3,"slug":"express","title":"Payment Notification"},"parentDoc":null,"project":"573243608b55962900f063c0","user":"573372a75bf1bb0e00e40708","version":{"__v":9,"_id":"573243608b55962900f063c1","project":"573243608b55962900f063c0","createdAt":"2016-04-19T15:51:35.494Z","releaseDate":"2016-04-19T15:51:35.494Z","categories":["573243608b55962900f063c3","573243608b55962900f063c2","573255b9ee92510e00087821","573255c0384fc70e0050ea42","573255ce9ef0fa0e0083f0d4","57334604b90dba1900b3d90c","5733474f45fc0c0e00c154da","57348e6e6a42521700a246fb","57348e79a210200e005f99e2","5734efd57e13fd17002f1129","5746204e04f2410e00a5a2e4"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-12T12:27:26.548Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Payment Notification\"\n}\n[/block]\nThe merchant must provide SafetyPay with a URL page that accepts parameters using HTTP POST standards.  This page can be coded in any language but should respond using a standard format. The Merchant must configure the POST URL from the MMS application, section: Profile > Notifications in the MMS. \n\nSafetyPay will POST the following information to the URL:\n\n**REQUEST**\n\n**Request Fields**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"ApiKey\",\n    \"1-0\": \"RequestDateTime\",\n    \"9-0\": \"Signature\",\n    \"0-1\": \"String (32)\",\n    \"1-1\": \"Datetime\",\n    \"9-1\": \"String (64)\",\n    \"0-2\": \"Merchant Api Key generated by using the MMS.\",\n    \"1-2\": \"ISO 8601: \\nyyyy-MM-ddThh:mm:ss\\n\\nExample: \\n2007-01-31T14:24:59\",\n    \"9-2\": \"Hash SHA256 :\\nRequestDateTime  +\\nMerchantSalesID + ReferenceNo+ CreationDateTime+ Amount+ CurrencyID+ PaymentReferenceNo+ Status + SignatureKey\",\n    \"2-0\": \"MerchantSalesId\",\n    \"2-1\": \"String (20)\",\n    \"3-0\": \"ReferenceNo\",\n    \"3-1\": \"String (16)\",\n    \"2-2\": \"Merchant’s reference number ( the same used in the purchase process or call to CreateTokenExpress)\",\n    \"3-2\": \"SafetyPay Operation Identifier \\nChar(16) \\nExample: 0149929001929301\",\n    \"4-0\": \"CreationDateTime\",\n    \"4-1\": \"Date/Time(GMT). \\nUsed to Compose Signature\",\n    \"4-2\": \"ISO 8601: yyyy-MM-ddThh:mm:ss\\nEjemplo: 2007-01-31T14:24:59\",\n    \"5-0\": \"Amount\",\n    \"5-1\": \"Decimal\\nTwo decimal places\",\n    \"5-2\": \"Transaction amount in the merchant’s currency \\nExample: 100.00\",\n    \"6-0\": \"CurrencyId\",\n    \"6-1\": \"String (3)\",\n    \"6-2\": \"Currency code of transaction\\nISO-4217, Example: USD, EUR, MXN, etc.\",\n    \"7-2\": \"Reference number of the payment operation\\nMax. 20 characters\",\n    \"8-2\": \"Status of SafetyPay operation\\nExample: “102”, “201”, etc.\",\n    \"7-0\": \"PaymentReferenceNo\",\n    \"7-1\": \"String (20)\",\n    \"8-0\": \"Status\",\n    \"8-1\": \"String (3)\"\n  },\n  \"cols\": 3,\n  \"rows\": 10\n}\n[/block]\n**Request - Example**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\nini_set('display_errors', 0);\\n\\n// SafetyPay Proxy Class\\nrequire_once(\\\"Proxy.php\\\");\\n\\n$proxy = new Proxy();\\n\\n// IMPORTANT!\\n// Debug enabled only Sandbox environment.\\n// For reason of security, delete the function \\\"write_log\\\"\\n$logg = $proxy->conf['Environment'];\\n\\n// Confirm New Paid Orders\\nfunction ConfirmNewPaidOrders( $pRequest )\\n{\\n    global $proxy;\\n    \\n    $iError = 0;\\n    \\n    // HERE YOUR CODE TO UPGRADE YOUR ORDER NUMBER FROM A PENDING STATUS TO \\n    // COMPLETED OR PAID STATUS.\\n    // OPTIONALLY CAN SEND A CONFIRMATION EMAIL AT SHOPPER.\\n    // USE $pRequest['MerchantSalesID'] TO SELECT YOUR REFERENCE ORDER.\\n    // \\n    // IF YOUR \\\"ORDER NUMBER\\\" IS EQUAL TO \\\"MERCHANT SALES ID\\\"\\n    $sMerchantOrderNo = $pRequest['MerchantSalesID'];\\n    // ELSE\\n    //\\t$sMerchantOrderNo = 'SET YOUR FINAL ORDER NUMBER';\\n    \\n    $respItems = array(\\n        'ErrorNumber' => $iError,\\n        'RequestDateTime' => $proxy->conf['RequestDateTime'],\\n        'MerchantSalesID' => $pRequest['MerchantSalesID'],\\n        'ReferenceNo' => $pRequest['ReferenceNo'],\\n        'CreationDateTime' => $pRequest['CreationDateTime'],\\n        'Amount' => $pRequest['Amount'],\\n        'CurrencyID' => $pRequest['CurrencyID'],\\n        'PaymentReferenceNo' => $pRequest['PaymentReferenceNo'],\\n        'Status' => $pRequest['Status'],\\n        'MerchantOrderNo' => $sMerchantOrderNo\\n    );\\n    \\n    $respItems['Signature'] = $proxy->GetSignature( $respItems, \\n                                'MerchantSalesID, ReferenceNo, CreationDateTime, '\\n                                . 'Amount, CurrencyID, PaymentReferenceNo, '\\n                                . 'Status, MerchantOrderNo');\\n    \\n    write_log('2. Response to SafetyPay:' . implode('|', $respItems), $logg);\\n    $pDataResponse = implode(',', $respItems);\\n    \\n    return $pDataResponse;\\n}\\n\\nfunction write_log($message, $logger_active = '0')\\n{\\n    global $proxy;\\n    \\n    $lfile = 'log/' . $proxy->GetSignature(array('service' => STP_SERVICE, \\n                                                 'sdk' => STP_SDK, \\n                                                 '_date' => date(\\\"Ymd\\\", time())), \\n                                                 'module, version, _date', true\\n                                            );\\n    \\n    if( ($time = $_SERVER['REQUEST_TIME']) == '')\\n    $time = time();\\n    \\n    if( ($remote_addr = $_SERVER['REMOTE_ADDR']) == '')\\n    $remote_addr = \\\"REMOTE_ADDR_UNKNOWN\\\";\\n    \\n    if( ($request_uri = $_SERVER['REQUEST_URI']) == '')\\n    $request_uri = \\\"REQUEST_URI_UNKNOWN\\\";\\n    \\n    $datet = date(\\\"Y-m-d H:i:s\\\", $time);\\n    $fd = :::at:::fopen($lfile, \\\"a\\\");\\n    if ($fd)\\n    {\\n        $toFile = \\\"$datet,$remote_addr,$message \\\\n\\\";\\n        $result = @fwrite($fd, \\\"$toFile\\\");\\n    }\\n    fclose($fd);\\n}\\n\\n// ***************************************************************************\\n// 1. Start getting information POST from SafetyPay **************************\\n// ***************************************************************************\\n$reqItems = array(\\n    'ApiKey' => strip_tags($_POST['ApiKey']),\\n    'RequestDateTime' => strip_tags($_POST['RequestDateTime']),\\n    'MerchantSalesID' => strip_tags($_POST['MerchantSalesID']),\\n    'ReferenceNo' => strip_tags($_POST['ReferenceNo']),\\n    'CreationDateTime' => strip_tags($_POST['CreationDateTime']),\\n    'Amount' => strip_tags($_POST['Amount']),\\n    'CurrencyID' => strip_tags($_POST['CurrencyID']),\\n    'PaymentReferenceNo' => strip_tags($_POST['PaymentReferenceNo']),\\n    'Status' => strip_tags($_POST['Status']),\\n    'Signature' => strip_tags($_POST['Signature'])\\n);\\n\\nwrite_log('*********************************************************', $logg);\\nwrite_log('0. Configuration Parameters:' . implode('|', $proxy->conf), $logg);\\nwrite_log('1. SafetyPay Elements      :' . implode('|', $reqItems), $logg);\\n\\n$iError = 0;\\n$Signature = $proxy->GetSignature(  $reqItems, \\n                                    'RequestDateTime, MerchantSalesID, '\\n                                    . 'ReferenceNo, CreationDateTime, Amount, '\\n                                    . 'CurrencyID, PaymentReferenceNo, Status');\\n\\n// ***************************************************************************\\n// 2. Comparing Signature received with local calculated *********************\\n// ***************************************************************************\\nif (strtoupper($reqItems['ApiKey']) != strtoupper($proxy->conf['ApiKey']))\\n    $sDataResponse = 'Error (1) in ApiKey.';\\nelseif (strtoupper($reqItems['Signature']) != strtoupper($Signature))\\n    $sDataResponse = 'Error (2) in Signature';\\nelse\\n    $sDataResponse = ConfirmNewPaidOrders( $reqItems );\\n\\nwrite_log('3. Response End: ' . $sDataResponse, $logg);\\n\\n// Write response to SafetyPay\\necho $sDataResponse;\\n?>\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n**RESPONSE**\n\n**Response Fields**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"ErrorNumber\",\n    \"9-0\": \"OrderNo\",\n    \"10-0\": \"Signature (*)\",\n    \"0-1\": \"String (1)\",\n    \"9-1\": \"String (20)\",\n    \"10-1\": \"String (64)\",\n    \"0-2\": \"Error associated to the call: ErrorNumber = 0, which means that call was successful.\\n0 : No error\\n1 : API Key not recognized\\n2 : Signature not valid\\n3 : Other errors\",\n    \"9-2\": \"Merchant’s order number\",\n    \"10-2\": \"Hash SHA256:\\nResponseDateTime + \\nMerchantSalesID + ReferenceNo+ CreationDateTime+ Amount+ CurrencyID+ PaymentReferenceNo+ Status+ OrderNo + SignatureKey\",\n    \"1-0\": \"ResponseDateTime\",\n    \"1-1\": \"Datetime\",\n    \"1-2\": \"ISO 8601: \\nyyyy-MM-ddThh:mm:ss\\n \\nExample: \\n2007-01-31T14:24:59\",\n    \"2-0\": \"MerchantSalesID\",\n    \"2-1\": \"Sting (20)\",\n    \"2-2\": \"Merchant’s reference number ( the same used in the purchase process or call to CreateTokenExpress)\",\n    \"3-0\": \"ReferenceNo\",\n    \"3-1\": \"String (16)\",\n    \"3-2\": \"SafetyPay Operation ID\\n0149929001929301\",\n    \"4-0\": \"CreationDateTime\",\n    \"4-1\": \"Datetime\",\n    \"4-2\": \"ISO 8601: \\nyyyy-MM-ddThh:mm:ss\\n \\nExample: \\n2007-01-31T14:24:59\",\n    \"5-0\": \"Amount\",\n    \"5-1\": \"Two decimal places\",\n    \"5-2\": \"Transaction amount in the merchant’s currency \\nExample: 100.00\",\n    \"6-0\": \"CurrencyId\",\n    \"6-1\": \"String (3)\",\n    \"6-2\": \"Currency code of transaction\\nISO-4217\\nUSD, EUR, MXN, PEN, etc.\",\n    \"7-0\": \"PaymentReferenceNo\",\n    \"7-1\": \"String (20)\",\n    \"7-2\": \"Reference number of payment operation\\nMax. 20 characters\",\n    \"8-0\": \"Status\",\n    \"8-1\": \"String (3)\",\n    \"8-2\": \"Status of SafetyPay operation \\nExample: “102”, “201”\"\n  },\n  \"cols\": 3,\n  \"rows\": 11\n}\n[/block]\nThe response should be in the following CSV structure:\n\nErrorNumber, ResponseDateTime, MerchantSalesID,  ReferenceNo, CreationDateTime, Amount, CurrencyID, PaymentReferenceNo, Status, OrderNo, Signature\n\n**Response - Example**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"0,2009-09-11T15:43:44,12322, 0112206126443651, 2009-09-11T15:43:44,50.00,USD,20120712,102,001-2001212,9ECDACAB25B20D50A6926E460B769C0A69BBEBCA6E41AD9008476DBA30622A68\",\n      \"language\": \"text\",\n      \"name\": \"CSV\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"nvp-3","type":"basic","title":"Payment Notification with NVP"}

Payment Notification with NVP


[block:api-header] { "type": "post", "title": "Payment Notification" } [/block] The merchant must provide SafetyPay with a URL page that accepts parameters using HTTP POST standards. This page can be coded in any language but should respond using a standard format. The Merchant must configure the POST URL from the MMS application, section: Profile > Notifications in the MMS. SafetyPay will POST the following information to the URL: **REQUEST** **Request Fields** [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "ApiKey", "1-0": "RequestDateTime", "9-0": "Signature", "0-1": "String (32)", "1-1": "Datetime", "9-1": "String (64)", "0-2": "Merchant Api Key generated by using the MMS.", "1-2": "ISO 8601: \nyyyy-MM-ddThh:mm:ss\n\nExample: \n2007-01-31T14:24:59", "9-2": "Hash SHA256 :\nRequestDateTime +\nMerchantSalesID + ReferenceNo+ CreationDateTime+ Amount+ CurrencyID+ PaymentReferenceNo+ Status + SignatureKey", "2-0": "MerchantSalesId", "2-1": "String (20)", "3-0": "ReferenceNo", "3-1": "String (16)", "2-2": "Merchant’s reference number ( the same used in the purchase process or call to CreateTokenExpress)", "3-2": "SafetyPay Operation Identifier \nChar(16) \nExample: 0149929001929301", "4-0": "CreationDateTime", "4-1": "Date/Time(GMT). \nUsed to Compose Signature", "4-2": "ISO 8601: yyyy-MM-ddThh:mm:ss\nEjemplo: 2007-01-31T14:24:59", "5-0": "Amount", "5-1": "Decimal\nTwo decimal places", "5-2": "Transaction amount in the merchant’s currency \nExample: 100.00", "6-0": "CurrencyId", "6-1": "String (3)", "6-2": "Currency code of transaction\nISO-4217, Example: USD, EUR, MXN, etc.", "7-2": "Reference number of the payment operation\nMax. 20 characters", "8-2": "Status of SafetyPay operation\nExample: “102”, “201”, etc.", "7-0": "PaymentReferenceNo", "7-1": "String (20)", "8-0": "Status", "8-1": "String (3)" }, "cols": 3, "rows": 10 } [/block] **Request - Example** [block:code] { "codes": [ { "code": "<?php\nini_set('display_errors', 0);\n\n// SafetyPay Proxy Class\nrequire_once(\"Proxy.php\");\n\n$proxy = new Proxy();\n\n// IMPORTANT!\n// Debug enabled only Sandbox environment.\n// For reason of security, delete the function \"write_log\"\n$logg = $proxy->conf['Environment'];\n\n// Confirm New Paid Orders\nfunction ConfirmNewPaidOrders( $pRequest )\n{\n global $proxy;\n \n $iError = 0;\n \n // HERE YOUR CODE TO UPGRADE YOUR ORDER NUMBER FROM A PENDING STATUS TO \n // COMPLETED OR PAID STATUS.\n // OPTIONALLY CAN SEND A CONFIRMATION EMAIL AT SHOPPER.\n // USE $pRequest['MerchantSalesID'] TO SELECT YOUR REFERENCE ORDER.\n // \n // IF YOUR \"ORDER NUMBER\" IS EQUAL TO \"MERCHANT SALES ID\"\n $sMerchantOrderNo = $pRequest['MerchantSalesID'];\n // ELSE\n //\t$sMerchantOrderNo = 'SET YOUR FINAL ORDER NUMBER';\n \n $respItems = array(\n 'ErrorNumber' => $iError,\n 'RequestDateTime' => $proxy->conf['RequestDateTime'],\n 'MerchantSalesID' => $pRequest['MerchantSalesID'],\n 'ReferenceNo' => $pRequest['ReferenceNo'],\n 'CreationDateTime' => $pRequest['CreationDateTime'],\n 'Amount' => $pRequest['Amount'],\n 'CurrencyID' => $pRequest['CurrencyID'],\n 'PaymentReferenceNo' => $pRequest['PaymentReferenceNo'],\n 'Status' => $pRequest['Status'],\n 'MerchantOrderNo' => $sMerchantOrderNo\n );\n \n $respItems['Signature'] = $proxy->GetSignature( $respItems, \n 'MerchantSalesID, ReferenceNo, CreationDateTime, '\n . 'Amount, CurrencyID, PaymentReferenceNo, '\n . 'Status, MerchantOrderNo');\n \n write_log('2. Response to SafetyPay:' . implode('|', $respItems), $logg);\n $pDataResponse = implode(',', $respItems);\n \n return $pDataResponse;\n}\n\nfunction write_log($message, $logger_active = '0')\n{\n global $proxy;\n \n $lfile = 'log/' . $proxy->GetSignature(array('service' => STP_SERVICE, \n 'sdk' => STP_SDK, \n '_date' => date(\"Ymd\", time())), \n 'module, version, _date', true\n );\n \n if( ($time = $_SERVER['REQUEST_TIME']) == '')\n $time = time();\n \n if( ($remote_addr = $_SERVER['REMOTE_ADDR']) == '')\n $remote_addr = \"REMOTE_ADDR_UNKNOWN\";\n \n if( ($request_uri = $_SERVER['REQUEST_URI']) == '')\n $request_uri = \"REQUEST_URI_UNKNOWN\";\n \n $datet = date(\"Y-m-d H:i:s\", $time);\n $fd = @fopen($lfile, \"a\");\n if ($fd)\n {\n $toFile = \"$datet,$remote_addr,$message \\n\";\n $result = @fwrite($fd, \"$toFile\");\n }\n fclose($fd);\n}\n\n// ***************************************************************************\n// 1. Start getting information POST from SafetyPay **************************\n// ***************************************************************************\n$reqItems = array(\n 'ApiKey' => strip_tags($_POST['ApiKey']),\n 'RequestDateTime' => strip_tags($_POST['RequestDateTime']),\n 'MerchantSalesID' => strip_tags($_POST['MerchantSalesID']),\n 'ReferenceNo' => strip_tags($_POST['ReferenceNo']),\n 'CreationDateTime' => strip_tags($_POST['CreationDateTime']),\n 'Amount' => strip_tags($_POST['Amount']),\n 'CurrencyID' => strip_tags($_POST['CurrencyID']),\n 'PaymentReferenceNo' => strip_tags($_POST['PaymentReferenceNo']),\n 'Status' => strip_tags($_POST['Status']),\n 'Signature' => strip_tags($_POST['Signature'])\n);\n\nwrite_log('*********************************************************', $logg);\nwrite_log('0. Configuration Parameters:' . implode('|', $proxy->conf), $logg);\nwrite_log('1. SafetyPay Elements :' . implode('|', $reqItems), $logg);\n\n$iError = 0;\n$Signature = $proxy->GetSignature( $reqItems, \n 'RequestDateTime, MerchantSalesID, '\n . 'ReferenceNo, CreationDateTime, Amount, '\n . 'CurrencyID, PaymentReferenceNo, Status');\n\n// ***************************************************************************\n// 2. Comparing Signature received with local calculated *********************\n// ***************************************************************************\nif (strtoupper($reqItems['ApiKey']) != strtoupper($proxy->conf['ApiKey']))\n $sDataResponse = 'Error (1) in ApiKey.';\nelseif (strtoupper($reqItems['Signature']) != strtoupper($Signature))\n $sDataResponse = 'Error (2) in Signature';\nelse\n $sDataResponse = ConfirmNewPaidOrders( $reqItems );\n\nwrite_log('3. Response End: ' . $sDataResponse, $logg);\n\n// Write response to SafetyPay\necho $sDataResponse;\n?>", "language": "php" } ] } [/block] **RESPONSE** **Response Fields** [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "ErrorNumber", "9-0": "OrderNo", "10-0": "Signature (*)", "0-1": "String (1)", "9-1": "String (20)", "10-1": "String (64)", "0-2": "Error associated to the call: ErrorNumber = 0, which means that call was successful.\n0 : No error\n1 : API Key not recognized\n2 : Signature not valid\n3 : Other errors", "9-2": "Merchant’s order number", "10-2": "Hash SHA256:\nResponseDateTime + \nMerchantSalesID + ReferenceNo+ CreationDateTime+ Amount+ CurrencyID+ PaymentReferenceNo+ Status+ OrderNo + SignatureKey", "1-0": "ResponseDateTime", "1-1": "Datetime", "1-2": "ISO 8601: \nyyyy-MM-ddThh:mm:ss\n \nExample: \n2007-01-31T14:24:59", "2-0": "MerchantSalesID", "2-1": "Sting (20)", "2-2": "Merchant’s reference number ( the same used in the purchase process or call to CreateTokenExpress)", "3-0": "ReferenceNo", "3-1": "String (16)", "3-2": "SafetyPay Operation ID\n0149929001929301", "4-0": "CreationDateTime", "4-1": "Datetime", "4-2": "ISO 8601: \nyyyy-MM-ddThh:mm:ss\n \nExample: \n2007-01-31T14:24:59", "5-0": "Amount", "5-1": "Two decimal places", "5-2": "Transaction amount in the merchant’s currency \nExample: 100.00", "6-0": "CurrencyId", "6-1": "String (3)", "6-2": "Currency code of transaction\nISO-4217\nUSD, EUR, MXN, PEN, etc.", "7-0": "PaymentReferenceNo", "7-1": "String (20)", "7-2": "Reference number of payment operation\nMax. 20 characters", "8-0": "Status", "8-1": "String (3)", "8-2": "Status of SafetyPay operation \nExample: “102”, “201”" }, "cols": 3, "rows": 11 } [/block] The response should be in the following CSV structure: ErrorNumber, ResponseDateTime, MerchantSalesID, ReferenceNo, CreationDateTime, Amount, CurrencyID, PaymentReferenceNo, Status, OrderNo, Signature **Response - Example** [block:code] { "codes": [ { "code": "0,2009-09-11T15:43:44,12322, 0112206126443651, 2009-09-11T15:43:44,50.00,USD,20120712,102,001-2001212,9ECDACAB25B20D50A6926E460B769C0A69BBEBCA6E41AD9008476DBA30622A68", "language": "text", "name": "CSV" } ] } [/block]