Allow selected BINs
Learn how to allow specific card BINs when processing a card payment.
Overview
BIN stands for Bank Identification Number. It is the first six digits of a credit/debit card number and identifies the issuer.
The allow selected BINs feature adjusts the payment intent's behavior when processing card
payments. Suppose your use case is to allow selected BINs whenever your customer completes a card
payment. In that case, you can specify the list of permitted BINs during your integration.
Allow selected card BINs in your integration
When creating a payment intent, you must add a payload attribute called payment_method_options
to specify the allowed card BINs before your customer completes a card payment.
If you don't know yet how to integrate payments, please refer to this guide
- Node
- PHP
- Python
- Ruby
// Protect your PayRex Secret API key at all costs. One common approach
// to store it in an environment variable.
// Add your PayRex test secret API key.
const payrexSecretApiKey = '';
const payrex = require('payrex-node')(payrexSecretApiKey);
// Create a PaymentIntent with amount and currency
const paymentIntent = await payrex.paymentIntents.create({
// Amount is in cents. The sample below is 100.00.
amount: 10000,
currency: 'PHP',
payment_method_options: {
card: {
allowed_bins: ['424242', '411111']
}
},
payment_methods: ['card'],
});
const output = {
clientSecret: paymentIntent.clientSecret,
}
console.log(JSON.stringify(output));
<?php
require_once '../vendor/autoload.php';
// Protect your PayRex Secret API key at all costs. One common approach
// to store it in an environment variable.
// Add your PayRex test secret API key.
$payrexSecretApiKey = '';
$payrex = new \Payrex\PayrexClient($payrexSecretApiKey);
// Create a PaymentIntent with amount and currency
$paymentIntent = $payrex->paymentIntents->create([
// Amount is in cents. The sample below is 100.00.
'amount' => 10000,
'currency' => 'PHP',
'payment_method_options': [
'card': [
'allowed_bins': ['424242', '411111']
]
],
'payment_methods' => [
'card'
],
]);
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
from payrex import Client as PayrexClient
# Protect your PayRex Secret API key at all costs. One common approach
# to store it in an environment variable.
# Add your PayRex test secret API key.
payrex_secret_api_key = ''
payrex = PayrexClient(payrex_secret_api_key)
# Create a PaymentIntent with amount and currency
payment_intent = payrex.payment_intents.create(
{
# Amount is in cents. The sample below is 100.00.
'amount': 10000,
'currency': 'PHP',
'payment_method_options': {
'card': {
'allowed_bins': ['424242', '411111']
}
},
'payment_methods': [
'card',
'gcash'
]
}
)
output = {
'client_secret': payment_intent.client_secret
}
print(output)
require "payrex-ruby"
# Protect your PayRex Secret API key at all costs. One common approach
# to store it in an environment variable.
# Add your PayRex test secret API key.
payrex_secret_api_key = ""
payrex = Payrex::Client.new(payrex_secret_api_key)
# Create a PaymentIntent with amount and currency
payment_intent = payrex.payment_intents.create(
# Amount is in cents. The sample below is 100.00.
amount: 10000,
currency: "PHP",
payment_method_options: {
card: {
allowed_bins: ['424242', '411111']
}
},
payment_methods: [
"card"
]
)
output = {
clientSecret: payment_intent.client_secret
}
puts output.to_json
With the code above, you are instructing that card payment processed by Payment Intent should only allow the 2 card BINs, 424242
and 411111
. The payment form will return an error if the customer uses a card with no BIN in the list.