The Save Card BIN API helps you determine whether CVV needs to be collected from your customers and validated or not be collected for saved card transactions.
HTTP Method: POST
Environment
Environment | URL |
---|---|
Test Environment | https://test.payu.in/issuing-bank/v1/bin |
Production Environment | https://info.payu.in/issuing-bank/v1/bin |
Request headers
The request header contains the following fields:
Field | Description | Example |
---|---|---|
Date
| The date and time should be in the GMT time conversion(not the IST). For example, current time in India is 18:00:00 IST, the time in the date header should be 12:30:00 GMT. | Thu, 17 Feb 2022 08:17:59 GMT |
Digest
| Base 64 encode of (sha256 hash of the JSON data (post to server). |
|
Authorization
| This field is in the following format:
|
The following sample Java code contains the logic used to encrypt as described in the above table:
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.apache.commons.codec.binary.Base64;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HmacAuth {
public static String getSha256(String input) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] digest = md.digest(input.getBytes());
return Base64.encodeBase64String(digest);
} catch (NoSuchAlgorithmException ignored) {}
return null;
}
public static JsonObject getRequestBody(){
JsonObject requestJson = new JsonObject();
requestJson.addProperty("firstname","John");
requestJson.addProperty("lastname","Doe");
return requestJson;
}
public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException {
String key = "smsplus";
String secret = "admin";
Gson gson = new Gson();
String date = DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'").withZoneUTC().print(new DateTime());
System.out.println(date);
JsonObject requestJson = getRequestBody();
String digest = getSha256(gson.toJson(requestJson));
System.out.println(digest);
String signingString = new StringBuilder()
.append("date: " + date)
.append("\ndigest: " + digest).toString();
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
String signature = Base64.encodeBase64String(sha256_HMAC.doFinal(signingString.getBytes()));
String authorization = new StringBuilder()
.append("hmac username=\"")
.append(key)
.append("\", algorithm=\"hmac-sha256\", headers=\"date digest\", signature=\"")
.append(signature)
.append("\"").toString();
System.out.println(authorization);
}
}
Request parameters
In addition to the Request Headers listed above, the data parameter is posted with the following fields are posted in an array:
Field | Description |
---|---|
bin |
|
checkCVVRequired |
|
Sample request
curl --location 'https://info.payu.in/issuing-bank/v1/bin' \
--header 'Content-Type: application/json' \
--header 'Date: Thu, 01 Jun 2023 06:59:03 GMT' \
--header 'Digest: sYxiEFksDG+h+sB11nonf9ry31aKynEJ/Hmxwc6M3pM=' \
--header 'Authorization: hmac username="smsplus", algorithm="hmac-sha256", headers="date digest", signature="F8D2PW2/Q2VF7FZKiY3RKJ6+1HU5OH8/HkxvitghvP4="' \
--header 'Cookie: PHPSESSID=lf33il1bio9scn7cars1hqsf05; PHPSESSID=o7bbf6gbociqmroctldtslkc21' \
--header 'mid: 2' \
--data '{
"bin": "512345789",
"checkCVVRequired": true
}'
Response parameters
The response involves the following parameters and the result parameter contains the offer results:
Parameter | Description | Example |
---|---|---|
code | This parameter returns the status of web service call. The status can be any of the following:
| 1 |
result |
| Refer to the result Field JSON Details subsection. |
result parameter JSON details
The result parameter contains the result in a JSON format and the fields in the JSON are described in the following table:
Sample response
Success scenario
{
"message": "Success",
"status": 1,
"result":
{
"status": 0,
"category": "debitcard",
"bin": "401151",
"cvvLessSupported": false,
"is_domestic": true,
"card_type": "VISA",
"issuing_bank": "HDFC",
"otp_on_fly": true,
"is_atmpin_card": 1
}
}