async function assessRisk(cardBin, payerInfo, apiKey) {
const response = await fetch(
`https://api.orchestrasolutions.com/Tools/validate?iin=${cardBin}`,
{
method: 'POST',
headers: {
'X-Api-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
clientIPAddress: payerInfo.ip,
countryCode: payerInfo.country,
city: payerInfo.city,
stateProvince: payerInfo.state
})
}
);
const result = await response.json();
if (result.riskLevel === 'VeryHigh' || result.riskLevel === 'High') {
console.warn(`High risk: ${result.description}`);
console.warn(`Card from ${result.issuerCountry}, IP from ${result.countryByIP}, billing from ${result.countryFromBillingAddress}`);
if (result.anonymousProxyUsed) {
console.warn('Anonymous proxy detected');
}
return { approved: false, reason: result.description };
}
return { approved: true, riskLevel: result.riskLevel };
}
const risk = await assessRisk('411111', {
ip: '203.0.113.42',
country: 'US',
city: 'New York',
state: 'NY'
}, 'YOUR_API_KEY');