Getting Transaction Status by Querying the WebService
This service URL can be used to get the status of a transaction. Below are the HTTP request method and parameters to be used.
GetTransactionData
GET https://sandbox.interswitchng.com/webpay/api/v1/gettransaction.json
GET https://sandbox.interswitchng.com/webpay/api/v1/gettransaction.xml
Request Parameters
Request Body Parameter | Description | Format |
---|---|---|
productid | Merchant Product Identifier on WebPAY. Same used in Payment leg | Numeric |
amount | Original transaction reference sent in the original request (transaction reference you generated for this | Numeric |
transactionreference | Original amount sent in the transaction, in lower denomination i.e kobo value. Same value sent in 2.4 above | Alphanumeric |
Security Parameters
Request Body Parameter | Description | Format |
---|---|---|
hash | SHA512 hash of productid, transactionreference and your MAC key . same way you computed your hash in 2.3 above but different parameters this time . | This should be sent in the header of the request as Hash |
NOTE: – The value of the hash is passed in the header of the GET request as Hash
Request Submission
The amount, transaction reference and product id are sent in a HTTP GET request to the service URL with the calculated hash in the header of the request.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php $parameters = array( "productid"=>$subpdtid, "transactionreference"=>$submittedref, "amount"=>$submittedamt ); $ponmo = http_build_query($parameters) . "\n"; $url = urlencode("https://sandbox.interswitchng.com/test_paydirect/api/v1/gettransaction.json " . $ponmo); // json //note the variables appended to the url as get values for these parameters $headers = array( "GET /HTTP/1.1", "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: en-us,en;q=0.5", "Keep-Alive: 300", "Connection: keep-alive", "Hash: " . $thash ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POST, false ); curl_exec($ch); ?> |
Request String:-
GET: https://sandbox.interswitchng.com/webpay/api/v1/gettransaction.json?productId=6207&transactionreference=001211343476456&amount=304500
Headers:-
Connection: Keep-Alive
Host: sandbox.interswitchng.com
Hash:
2F398AF4D166F7F80225C127F47BDEEB8A4509DCD420F3E04197E7ADA3B29ACD34A11FD966F6F26E741108A86A4BB89D9357BD71F54093599FEB415F8CAC9C76
Find below a sample POSTMan screen grab showing request and response structure. (click image to expand)