{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"71253c73-1691-4421-84e2-09d874eafc10","name":"GATEWAY - MERCHANT API","description":"Sparco Gateway - collect and disburse payment through various channels(Cards & Mobile Money).\n\n*** Currently only MTN Mobile Money, Zamtel Kwacha, Airtel Money and Cards are live on Sparco.\n\n\n\n## Response Status Description\nThe following response statuses are returned in webhook and transaction query payloads:\n\n| Status               | Description                                                                                | \n|----------------------|--------------------------------------------------------------------------------------------|\n| TXN_AUTH_PENDING     | Transaction awaiting authorization.         \n| TXN_PENDING          | Transaction still processing.                                                         |\n| TXN_AUTH_SUCCESSFUL  | Transaction successfully processed. Successful authorization                                                      |\n| TXN_AUTH_UNSUCCESSFUL| Transaction failed. Unsuccessful authorization                                                                           |\n| TXN_SUCCESSFUL       | Transaction successfully processed.                                                    |\n| TXN_FAILED           | Transaction failed.                                                                        |\n| TXN_PROCESSING       | Transaction was successfully submitted for processing.                                                                        |\n\n\n\n## [Webhook](#webhook)\n\n### Webhook Payload Response Fields\n\n| Key                  | Description                                                                                | \n|----------------------|--------------------------------------------------------------------------------------------|\n| amount               | for collection, `amount` are the funds credited to merchants account and for payout `amount` are the funds credited to customer recipients wallet.         |\n| feeAmount            | Transaction fee                                                                            |\n| transactionAmount    | This is the `amount`+`fees`. For collection, `transactionAmount` are the funds debited from customers wallet and for payout `transactionAmount` are the funds debited from merchants account.                                               |\n| currency             | Transaction Currency                                                                       |\n| customerFirstName    | Customer's First Name                                                                      |\n| customerLastName     | Customer's Last Name                                                                       |\n| customerMobileWallet | Customer's Mobile Wallet Number                                                            |\n| feePercentage        | Transaction fee percentage                                                                 |\n| merchantReference    | Unique Merchant's Reference                                                                |\n| reference            | Transaction Reference                                                                      |\n| message              | Transaction status message                                                                 |\n| status               | Transaction status response message                                                        |\n| signedFields         | payload fields hashed                                                                      |\n| signature            | Base64 encoded HMAC SHA265 hash of payload                                                 |\n| isError              | Boolean Indicating whether request's an error or not                                       |\n\nWebhook Payload Response Example\n```JSON\n{\n    \"amount\": 1,\n    \"feeAmount\": 0.035,\n    \"transactionAmount\": 1.035,\n    \"currency\": \"ZMW\",\n    \"customerFirstName\": \"Michelle\",\n    \"customerLastName\": \"Oliver\",\n    \"customerMobileWallet\": \"0961453688\",\n    \"feePercentage\": 3.4,\n    \"merchantReference\": \"7b6ba00ce7bb4911996defd5d1d13170\",\n    \"reference\": \"eyJ0aWQiOiAyMTksICJlbnYiOiAicCJ9\",\n    \"message\": \"Transaction was successful\",\n    \"status\": \"TXN_AUTH_SUCCESSFUL\",\n    \"signedFields\": \"merchantReference,reference,amount,currency,feeAmount,feePercentage,transactionAmount,customerMobileWallet,customerFirstName,customerLastName,message,status,signedFields\",\n    \"signature\": \"6wf7B0GHyZFDZX9e7AKam+dlTAgws5RV0TjF35CGGbc=\",\n    \"isError\": false\n}\n```\n\n\nTo verify the webhook payload, generate an HMAC-SHA256 digest using the merchant's `secret_key` and a comma separated string of the payload keys and values present under `signedFields`  in the format: `key1=value1,key2=value2,..` .\n\n### [Node JS Webhook Payload Verification Example](#verify-webhook-nodejs)\n``` JS\nconst crypto = require(\"crypto\");\n\nfunction SparcoSignature(secKey) {\n  this.secKey = secKey;\n}\n\nSparcoSignature.prototype.generate = function (payload) {\n  let signedFields = payload[\"signedFields\"];\n  signedFields = signedFields.split(\",\");\n  const msg = signedFields.map((key) => `${key}=${payload[key]}`).join(\",\");\n  const hmac = crypto.createHmac(\"sha256\", this.secKey);\n  hmac.update(msg);\n  sig = hmac.digest(\"base64\");\n  return sig;\n};\n\nSparcoSignature.prototype.verify = function (payload) {\n  const payloadSig = payload.signature;\n  const generatedSig = this.generate(payload);\n  return {\n    isVerified: crypto.timingSafeEqual(\n      Buffer.from(payloadSig, \"base64\"),\n      Buffer.from(generatedSig, \"base64\")\n    ),\n  };\n};\n\nconst SEC_KEY = \"<Merchant Secret Key>\";\n\nconst signature = new SparcoSignature(SEC_KEY);\n\nconst webhookPayload = {\n    \"merchantReference\": \"cd3d3275991a48588c4d9205644a333f\",\n    \"reference\": \"eyJ0aWQiOiAyNzMsICJlbnYiOiAibCJ9\",\n    \"amount\": 0.966,\n    \"currency\": \"ZMW\",\n    \"feeAmount\": 0.034,\n    \"feePercentage\": 3.4,\n    \"transactionAmount\": 1,\n    \"customerMobileWallet\": \"0961453688\",\n    \"customerFirstName\": \"Mundia\",\n    \"customerLastName\": \"Mwala\",\n    \"message\": \"Transaction was successful\",\n    \"status\": \"TXN_AUTH_SUCCESSFUL\",\n    \"signedFields\": \"merchantReference,reference,amount,currency,feeAmount,feePercentage,transactionAmount,customerMobileWallet,customerFirstName,customerLastName,message,status,signedFields\",\n    \"signature\": \"vcxpHlQf16+nVnSceVoYCreOSeZdsD/oKyxzKr8zEfs=\",\n    \"isError\": false\n}\n\nconst verificationResponse = signature.verify(webhookPayload);\nconsole.log(verificationResponse);\n//{ isVerified: true }\n```","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":false,"owner":"688123","team":357214,"collectionId":"71253c73-1691-4421-84e2-09d874eafc10","publishedId":"T17M6k2j","public":true,"publicUrl":"https://documenter-api.postman.tech/view/688123/T17M6k2j","privateUrl":"https://go.postman.co/documentation/688123-71253c73-1691-4421-84e2-09d874eafc10","customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"documentationLayout":"classic-double-column","customisation":null,"version":"8.10.1","publishDate":"2020-07-10T10:32:20.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{},"logos":{}},"statusCode":200},"environments":[{"name":"GATEWAY - MERCHANT API","id":"5b7260c0-5ee9-4b0e-bff0-eef63888f879","owner":"688123","values":[{"key":"CHECKOUT_BASE_URL","value":"","enabled":false},{"key":"CHECKOUT_BASE_URL","value":"https://checkout.sparco.io","enabled":true},{"key":"REST_API_BASE_URL","value":"https://live.sparco.io","enabled":true},{"key":"MERCHANT_PUBLIC_KEY","value":"","enabled":true},{"key":"MOMO_DEBIT_PAYLOAD","value":"","enabled":true},{"key":"MOMO_CREDIT_PAYLOAD","value":"","enabled":true},{"key":"TXN_REF","value":"","enabled":true},{"key":"JWT_TOKEN","value":"","enabled":true},{"key":"ADMIN_TOKEN","value":"","enabled":true}],"published":true}],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/e10ca25c213f7dc57c216a783018c458d53510a59dedf9cc1b8c52d92cf52f7a","favicon":""},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"},{"label":"GATEWAY - MERCHANT API","value":"688123-5b7260c0-5ee9-4b0e-bff0-eef63888f879"}],"canonicalUrl":"https://documenter.gw.postman.com/view/metadata/T17M6k2j"}