Ready-to-Use Code Snippets
1. C# / ASP.NET HttpClient Example
var payload = new {
app_id = "cashsetu",
txnid = "ORD_" + DateTime.UtcNow.Ticks,
amount = "100.00",
productinfo = "Wallet Recharge",
firstname = "Customer",
email = "customer@example.com",
phone = "9876543210",
return_url = "https://your-domain.com/Wallet/Callback",
udf1 = "1054",
signature = ComputeSha512($"{secretKey}|cashsetu|{txnid}|100.00|{returnUrl}")
};
var client = new HttpClient();
var response = await client.PostAsJsonAsync("https://shop.sanjivanimt.com/Gateway/Api/Initiate.ashx", payload);
var json = await response.Content.ReadAsStringAsync();
// Redirect customer to json.payment_url
2. JavaScript / Fetch API Example
const res = await fetch("https://shop.sanjivanimt.com/Gateway/Api/Initiate.ashx", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(orderData)
});
const data = await res.json();
if (data.success) {
window.location.href = data.payment_url;
}
3. Inbound Callback Verification Formula
string expectedSig = ComputeSha512($"{secretKey}|{status}|{txnid}|{amount}|{mihpayid}|{udf1}");
if (expectedSig.Equals(receivedSignature, StringComparison.OrdinalIgnoreCase) && status == "success") {
// Credit local wallet table
}