Bin detection
Starting from version 3.5.0 you can use new Bin detection feature for your own UI.
iOS
Android
iOS Android
Follow steps below for a successful request to get payment brands for provides card Bin:
Request Checkout ID
Request ChechoutInfo
Request Brands for provided Bin
Request Checkout ID
See detailed instruction in our guide: SDK Integration
Your app should request a checkout ID from your server . This example uses our sample integration server; please adapt it to use your own backend API.
Objective-C
Swift
NSURLRequest *merchantServerRequest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://YOUR_URL/?amount=100¤cy=EUR&paymentType=DB" ]];
[[[NSURLSession sharedSession] dataTaskWithRequest:merchantServerRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil ];
self .checkoutID = JSON[@"checkoutId" ];
}] resume];
let merchantServerRequest = NSURLRequest (url: URL (string: "https://YOUR_URL/?amount=100¤cy=EUR&paymentType=DB" )! )
URLSession .shared.dataTask(with: merchantServerRequest as URLRequest ) { (data, response, error) in
if let data = data, let json = try? JSONSerialization .jsonObject(with: data, options: []) as? [String : Any ] {
let checkoutID = json? ["checkoutId" ] as? String
}
}.resume()
Java
Kotlin
public String requestCheckoutId () {
URL url;
String urlString;
HttpURLConnection connection = null ;
String checkoutId = null ;
urlString = YOUR_URL + "?amount=48.99¤cy=EUR&paymentType=DB" ;
try {
url = new URL(urlString);
connection = (HttpURLConnection) url.openConnection();
JsonReader reader = new JsonReader(
new InputStreamReader(connection.getInputStream(), "UTF-8" ));
reader.beginObject();
while (reader.hasNext()) {
if (reader.nextName().equals("checkoutId" )) {
checkoutId = reader.nextString();
break ;
}
}
reader.endObject();
reader.close();
} catch (Exception e) {
} finally {
if (connection != null ) {
connection.disconnect();
}
}
return checkoutId;
}
fun requestCheckoutId () : String? {
val url: URL
var connection: HttpURLConnection? = null
var checkoutId: String? = null
val urlString = YOUR_URL.toString() + "?amount=48.99¤cy=EUR&paymentType=DB"
try {
url = URL(urlString)
connection = url.openConnection() as HttpURLConnection
val reader = JsonReader(InputStreamReader(connection.inputStream, "UTF-8" ))
reader.beginObject()
while (reader.hasNext()) {
if (reader.nextName() == "checkoutId" ) {
checkoutId = reader.nextString()
break
}
}
reader.endObject()
reader.close()
} catch (e: Exception) {
} finally {
connection?.disconnect()
}
return checkoutId
}
Create an instance of OPPPaymentProvider
Objective-C
Swift
self .provider = [OPPPaymentProvider paymentProviderWithMode:OPPProviderModeTest ];
self .provider = OPPPaymentProvider (mode: .test)
Java
Kotlin
OppPaymentProvider paymentProvider = new OppPaymentProvider(context, Connnect.ProviderMode.TEST);
val paymentProvider = OppPaymentProvider(context, Connnect.ProviderMode.TEST)
Now, let the class implement the ITransactionListener
interface.
Request CheckoutInfo
Use CheckoutId from step above to make a CheckoutInfo request call:
Objective-C
Swift
[self .provider requestCheckoutInfoWithCheckoutID:checkoutId completionHandler:^(OPPCheckoutInfo * _Nullable checkoutInfo, NSError * _Nullable error) {
if (error) {
} else {
}
}];
self .provider.requestCheckoutInfo(withCheckoutID: checkoutId, completionHandler: { (checkoutInfo, error) in
if error != nil {
return
}
})
Java
Kotlin
try {
paymentProvider.requestCheckoutInfo(CHECKOUT_ID, transactionListener);
} catch (PaymentException e) {
}
@Override
public void paymentConfigRequestSucceeded (CheckoutInfo checkoutInfo) {
}
try {
paymentProvider.requestCheckoutInfo(CHECKOUT_ID, transactionListener)
} catch (e: PaymentException) {
}
override fun paymentConfigRequestSucceeded (checkoutInfo: CheckoutInfo ) {
}
Request Bin detection service
Objective-C
Swift
[self .provider requestPaymentBrandsForBin:bin checkoutID:checkoutID completionHandler:^(NSArray * _Nullable paymentBrands, NSError * _Nullable error) {
if (error) {
} else {
}
}];
self .provider.requestPaymentBrands(forBin: bin, checkoutID: checkoutID! , completionHandler: { (brands, error) in
if error != nil {
return
}
})
Java
Kotlin
public void requestBinInfo () {
paymentProvider.requestBinInfo(checkoutId, bin, this ::onBinInfo);
}
public void onBinInfo (@Nullable BinInfo binInfo,
@Nullable PaymentError error) {
if (binInfo != null ) {
String[] detectedBrands = binInfo.getBrands();
}
}
open fun requestBinInfo () {
paymentProvider.requestBinInfo(checkoutId, bin) {
binInfo: BinInfo?, error: PaymentError? -> onBinInfo(binInfo, error)
}
}
open fun onBinInfo (binInfo: BinInfo ?,
error: PaymentError ?) {
if (binInfo != null ) {
val detectedBrands = binInfo.brands
}
}
Final notes
Bin detection request is asynchronous.
Yous can make multiple Bin detection calls after CheckoutId and CheckoutInfo calls.
Bin length must be at least 1 digit.
Please do not create Bin detection request for each entered Bin digit
Take a look at this page Advanced options for a good example of Bin detection service usage - look for Card brand detection paragraph.
You can find a good example of Bin detection service usage at Advanced options page for a good example of Bin detection service usage - look for Card brand detection paragraph.