🇦🇷Argentina
Check the requirements and validations made over the cashouts on Argentina
Last updated
Was this helpful?
Was this helpful?
public class Validations {
static Integer CBU_LENGTH = 22;
public static Boolean verifyCBU(String cbu) {
return cbuLengthValidation(cbu) && bankCodeValidation(cbu) && accountValidation(cbu);
}
public static Boolean cbuLengthValidation(String cbu) {
return cbu.length() == 22 && ValidationsUtils.validateOnlyNumbers(cbu);
}
public static Boolean bankCodeValidation(String cbu) {
if (cbu.length() == CBU_LENGTH && ValidationsUtils.validateOnlyNumbers(cbu)) {
String shortCbu = StringUtils.left(cbu, 8);
String bankCode = shortCbu.substring(0, 3);
String branchCode = shortCbu.substring(4, 7);
int firstCheckDigit = charToInt(shortCbu.toCharArray()[3]);
int secondCheckDigit = charToInt(shortCbu.toCharArray()[7]);
int sum = charToInt(bankCode.charAt(0)) * 7 + charToInt(bankCode.charAt(1)) * 1 + charToInt(bankCode.charAt(2)) * 3 + firstCheckDigit * 9 + charToInt(branchCode.charAt(0)) * 7 + charToInt(branchCode.charAt(1)) * 1 + charToInt(branchCode.charAt(2)) * 3;
int diference = (10 - sum % 10) % 10;
return diference == secondCheckDigit;
} else {
return false;
}
}
public static Boolean accountValidation(String cbu) {
String account = cbu.substring(8, 22);
int sum = 0;
int j = 0;
int[] weighter = new int[]{3, 9, 7, 1};
char[] arrayAccount = account.toCharArray();
int checkDigit = charToInt(account.toCharArray()[13]);
for(int i = 0; i < 13; ++i) {
sum += charToInt(arrayAccount[i]) * weighter[j % 4];
++j;
}
int diference = (10 - sum % 10) % 10;
return diference == checkDigit;
}
private static int charToInt(char ch) {
return Integer.parseInt(String.valueOf(ch));
}
}{
"login": "xxxxxxxx",
"pass": "xxxxxxxx",
"external_id": "30000000001",
"country": "AR",
"currency": "ARS",
"amount": 10000,
"document_id": "5676586998",
"bank_account": "0000003100000098476521",
"email": "[email protected]",
"beneficiary_name": "John",
"beneficiary_lastname": "Smith",
"notification_url": "https://webhook.site/url",
"type": "json"
}