Skip to content

Getting Started with Card BIN SDK

Card BIN SDK refers to a Software Development Kit (SDK) related to Card Bank Identification Numbers (BIN) thus an SDK making it possible to find card BINs.

A Bank Identification Number (BIN) is the initial four to six numbers that appear on a credit card. The BIN uniquely identifies the institution issuing the card. It is critical in the process of matching transactions to the issuer of the charge card.

In essence, Card BIN SDK is a set of tools designed to help developers create applications that work with Card Bank Identification Numbers. These applications could be used for payment processing systems to fraud detection services.

In order to get started, do the following activities

Install-Package Hubtel.CardBin.Sdk

The provided code below is a command to install a package named Hubtel.CardBin.Sdk in a .NET project. This command is used in the Package Manager Console of Visual Studio.

C#
    Install-Package Hubtel.CardBin.Sdk

Add to IServiceCollection in Program.cs or Startup.cs

This is typically done in the Program.cs or Startup.cs file, which are responsible for setting up the application's services and configuration.

The services.AddHubtelCardBinData is a method call that adds the HubtelCardBinData service to the IServiceCollection. IServiceCollection is an interface in .NET Core that is used for dependency injection. It maintains a collection of service descriptors, which are used to build a service container that provides requested services.

AddHubtelCardBinData is an extension method provided by the Hubtel.CardBin.Sdk package. This method would register the services and configurations necessary for the HubtelCardBinData service to function correctly in the application.

By adding this line in the Program.cs or Startup.cs file, you're telling .NET to include HubtelCardBinData in the set of services that can be injected into your controllers, views, and other classes that support dependency injection. This is a common practice when you want to use a service provided by a third-party library throughout your application.

c#
       services.AddHubtelCardBinData();

Inject and consume service methods

The code snippet beneath shows the usage of an instance of IBinDataCollection to find card bin information.

private readonly IBinDataCollection _binCollection is a field declaration. The field _binCollection is of type IBinDataCollection, which is an interface defining a collection of bin data. The private keyword means this field can only be accessed within the same class. The readonly keyword means that the value of this field can only be assigned at the time of declaration or in the constructor of the class.

The line var cardBin = _binCollection.Find("<bin_number>") is calling the Find method on the _binCollection instance . The Find method takes a bin number as a parameter and returns the corresponding card bin information. The returned information is being assigned to the cardBin variable. The <bin_number> is a placeholder and should be replaced with an actual bin number when using this code.

c#
    private readonly IBinDataCollection _binCollection;    
 
 //call methods on the SDK instance
   var cardBin = _binCollection.Find("<bin_number>");

Was this page helpful?

Happy React is loading...