Mswipe Refund API document
OVERVIEW
❖ This document gives the brief about Integration of Void and Refund details.
❖ API call will be done once a day and Transaction data of last 3 days will be available for delta dump.
❖ API client will pass from and to data along with merchant data for get Transaction details.
SCOPE OF WORK
There will be following API call for Transaction Reports integration
Get Transaction details
- Process Void / Refund
Workflow
The user will receive the developer portal credentials via email, use the same to login into the portal and generate the keys for Refund Void, all the required details will be available on the profile section along with the UAT demo customer code.
While invoking the login API, use the credentials available in the profile section of the Developer portal to generate the access token.
Then call the get transaction details API for processing data, pass a unique request id for every request, access token received in the login API response, client key available on developer portal, Authorization is the HMAC created by passing the request body (without spaces) and using the client secret key. In the request body pass the client code, demo customer code, user id and invoice number.
Then use the process refund API by passing the same request id used for getting txn details in the header section along with the access token received in the login API response, client key available on developer portal, Authorization is the HMAC created by passing the request body (without spaces) and using the client secret key.
- HMAC Authorization is used for authorizing the request.
- Key Exchange Process: 32 byte Client Key available on developer portal.
| Parameter | Type(length) | Description | Sample |
| RequestID | String(64) | Used for debugging purposes to track individual requests | 1231231283123123 |
| Content-type | String(128) | Type of message | application/json |
| Authorization | String(1024) | HMAC auth Header | HMAC |
| ClientKey | String | Key shared by Mswipe | PS9TIMKeQ2nEBu0C1ZutdEbJnZQ NjaDB |
| AccessToken | String(350) | This token is generated upon login which needs to be passed in header in rest of the API’s for getting data for authorization. | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX Vtyty9.eyJodHRwOi8vc2NoZW1hc y54bWxzb2FwLm9yZy93cy8yMDA 1LzA1L2lkZW50aXR5L2NsYWltcy9 uYW1lIjoiRkxJUEtBUlRAU09MIiwi UmVxdWVzdFRpbWUiOiJXZWRuZ XNkYXksIEp1bHkgMTcsIDIwMTkiL CJleHAiOjE4Nzg5ODc5NDEsImlzcyI 6Im1zd2lwZXRlY2guY28uaW4iLCJh dWQiOiJtc3dpcGV0ZWNoLmNvLm luIn0.izpMmviuhYZF68FeWgRYCkx HbnYgoA_ZYe4bICj9rks |
API DETAILS
Login
Request URL:
UAT: https://uat.Mswipetech.co.in/MswipeGWGenericApi/login
LIVE: https://www.Mswipetech.com/MswipeGWGenericApi/login
| Parameter | Description | Sample |
| user_id | Provided by Mswipe | test |
| user_pwd | Provided by Mswipe | test |
Request Parameters:
{
"user_name": "test",
"user_pwd": "test"
}
Response: If pass
{
"status":"True",
"response_message":"login successful",
"response_code":"200",
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVtyty9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiRkxJUEtBUlRAU09MIiwiUmVxdWVzdFRpbWUiOiJXZWRuZXNkYXksIEp1bHkgMTcsIDIwMTkiLCJleHAiOjE4Nzg5ODc5NDEsImlzcyI6Im1zd2lwZXRlY2guY28uaW4iLCJhdWQiOiJtc3dpcGV0ZWNoLmNvLmluIn0.izpMmviuhYZF68FeWgRYCkxHbnYgoA_ZYe4bICj9rks"
}
Response: If Failed
{
"status":"False",
"response_message":"invalid username and password",
"response_code":"200",
"token":""
}
Note:
Scenario 1: When the user login, Token 1 is generated which will be valid for 30 days.
Scenario 2: Before 30 days, if the user logs in again, then Token 2 will be generated. Token 1 will get expired and token 2 will be valid for next 30 days.
VOID/Refund PROCESS
If the transaction has been done today, then same day transaction will get void. Else transaction will go for refund process. We will allow refund for 7 days.
GET TRANSACTION DETAILS:
Request Header:
Content-Type: "application/JSON", RequestID: "123", ClientKey: "PS9TIMKeQ2nEBu0C1ZutdEbJnZQNjaDB", Authorization: "5Nfe5QkqLcA6PuDdlIt7VG7ixY8+6F/OgaT6+eQ82hM=", AccessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVtyty9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiRkxJUEtBUlRAU09MIiwiUmVxdWVzdFRpbWUiOiJXZWRuZXNkYXksIEp1bHkgMTcsIDIwMTkiLCJleHAiOjE4Nzg5ODc5NDEsImlzcyI6Im1zd2lwZXRlY2guY28uaW4iLCJhdWQiOiJtc3dpcGV0ZWNoLmNvLmluIn0.izpMmviuhYZF68FeWgRYCkxHbnYgoA_ZYe4bICj9rks"
| Parameter | Description | Sample |
| client_code | Provided by Mswipe for client identification | test@test |
| cust_code | Cust code of Merchant | 2345467867 |
| reference_no | Invoice number | 11112 |
| transaction_type | This will be “Void” or “Refund” | |
| user_id | Provided by Mswipe which will be the one used while login |
Request URL:
UAT: https://uat.Mswipetech.co.in/MswipeGWGenericApi/getTrxData
LIVE: https://www.Mswipetech.com/MswipeGWGenericApi/getTrxData
Request Parameters:
{
"client_code": "test@test",
"cust_code": "2345467867",
"reference_no": "11112",
"user_id": "string"
}
Response: VOID
{
"rsp_code": "00",
"desc": "success",
"trx_date": "2019-12-21T11:48:59.79",
"amount": "66.66",
"card_last_digits": "8697",
"stan_no": "9252805.0",
"voucher_no": "SLS0000000000000000000988792",
"reference_no": "test3",
"auth_id": "000005",
"rrn": "000000288073",
"transaction_type": "REFUND"
}
Response: REFUND
{
"rsp_code": "00",
"desc": "success",
"trx_date": "7/7/2019 1:27:14 PM",
"amount": "1552",
"card_last_digits": "0499",
"stan_no": "9214417",
"voucher_no": "SLS0000000000000000000951924",
"reference_no": "11112",
"auth_id": "000033",
"rrn": "000000241793",
"transaction_type": "REFUND"
}
Response: (After Void If we fetching same transaction again)
{
"rsp_code": "30",
"desc": "transaction is pending for settlement."
}
Response: (If we fetching again transaction more than 7 days)
{
"rsp_code": "30",
"desc": "refund is not allowed after 7 days"
}
PROCESS VOID/REFUND:
Request Header:
| Parameter | Description | Sample |
| client_code | Provided by Mswipe for client identification | test@test |
| cust_code | Cust code of Merchant | 2345467867 |
| voucher_no | This is the voucher number received in get void API response | SLS1234566 |
| reference_no | Invoice number | 11112 |
| user_id | User id of the merchant will be Provided by Mswipe | test |
| user_pwd | Password will be Provided by Mswipe | test |
| Remark | This is the remark field | test void |
| refund_type | This is refund type field | FULL / PARTIAL |
| refund_amount | This is the amount to be refunded. | 2000 |
Request URL:
UAT: https://uat.Mswipetech.co.in/MswipeGWGenericApi/ProcessVoidOrRefund
LIVE: https://www.Mswipetech.com/MswipeGWGenericApi/ProcessVoidOrRefund
Request: For Void
{
"client_code": "test@test",
"reference_no": "11112",
"cust_code": "92345467867",
"voucher_no": "SLS1234566",
"remark": "test void",
"user_id": "test",
"user_pwd": "test",
"refund_type": null,
"refund_amount": null
}
Response: VOID
{
"status": "True",
"transaction_no": "9214494",
"voucher_no": "SLS1234566",
"reference_no": "11112",
"ticket_no": "NA"
}
Request: For Refund
{
"client_code": "test@test",
"reference_no": "11112",
"cust_code": "92345467867",
"voucher_no": "SLS1234566",
"remark": "test void",
"user_id": "test",
"user_pwd": "test",
"refund_type": "Partial",
"refund_amount": "500"
}
Response: REFUND
{
"status": "True",
"transaction_no": "9214417",
"voucher_no": "SLS1234566",
"reference_no": "11112",
"ticket_no": "RFD00762304"
}
Note: • ticket_no: It will be NA in case of void as void will get processed on same day and will give actual ticket number in case of refund. • refund_type : Refund type will be FULL/PARTIAL • refund_amount : If refund_type is “Full”, refund_amount field will contain actual transaction amount. And if refund_type is “partial”, refund_amount field will contain refund amount.
Example: If transaction amount is 2000 In case of “FULL” refund_type, amount will be 2000 If client wants to do partial refund, then he needs to pass value as “PARTIAL”. He will receive amount which is less than the original amount.
UPDATE TRANSACTION REFUND STATUS:
For Refund transaction status, client will need to provide API end point on which Mswipe will be back posting the refund status. Status API will get called only in case of refund not in case of void as it will get processed on same day.
HMAC CALCULATION
Please refer sample code for HMAC Generation
.Net code
Payload is JSON string of transaction request
string payload = JsonConvert.SerializeObject(transactiondumprequest);
private string GenerateMacHeader(string clientSecret, string payload)
{
var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(clientSecret));
hmac.Initialize();
byte[] rawBodyHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(payload));
string bodyHash = Convert.ToBase64String(rawBodyHash);
return bodyHash;
}
Java code sample
//'main' method must be in a class 'Rextester'.
//Compiler version 1.8.0_111
import java.net.URL;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
class Rextester
{
private static final String UTF8_ENCODING = "UTF-8";
private static final String HMAC_SHA256_ALGORITHM = "HmacSHA256";
public static void main(String[] args)
String hmac="";
String payload="{\"Client_Code\":\" test@test\", \"RefNo\":\"11112\",\"custcode\":\"92345467867\",\"Voucher_No\":\" SLS1234566\",\"Remark\":\"test void\",\"UserId\":\"test\",\"UserPwd\":\" test\",\"RefundType\":\"FULL\",\"RefundAmount\":\"100\"}";
String clientsercet="xgAOmaX9UKbAM8lt6YLj4gTsHaMFMVEH";
try{
hmac=generateMacHeader(payload,clientsecret);
}
catch(Exception e){ }
System.out.println("HMAC :"+hmac);
}
final static String generateMacHeader(String payload,String client_secret) throws Exception
{
SecretKeySpec signingKey = new SecretKeySpec(client_secret.getBytes(UTF8_ENCODING), HMAC_SHA256_ALGORITHM);
Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM); mac.init(signingKey);
// create the bodyHash value by hashing the payload and encoding it
byte[] rawBodyHash = mac.doFinal(payload.getBytes(UTF8_ENCODING));
byte[] encodedBytes = Base64.getEncoder().encode(rawBodyHash);
String bodyHash = new String(encodedBytes);
return bodyHash;
}
}