Developer ZoneRecipesAPI ReferenceChangelog
Developer Zone
These docs are for v3.2.6. Click to read the latest docs for v4.3.0.

Retrieve payment option details (Optional)

The Payment Option Details API is for retrieve bank bins or installment plans information based on merchant account’s configuration.

 
Here are 3 steps to retrieve payment option details:


Step 1: Get payment token.

📘

Payment Token API

Please refer: Full sample code

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
let paymentToken:String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";

Step 2: Construct payment option details request.

PaymentOptionDetailRequest paymentOptionDetailRequest = new PaymentOptionDetailRequest();
   paymentOptionDetailRequest.setPaymentToken(paymentToken);
   paymentOptionDetailRequest.setPaymentChannel(PaymentChannel.CREDIT_CARD);
let paymentOptionDetailRequest:PaymentOptionDetailRequest = PaymentOptionDetailRequest()
   paymentOptionDetailRequest.paymentToken = paymentToken
   paymentOptionDetailRequest.paymentChannel = PaymentChannel.CREDIT_CARD
PaymentOptionDetailRequest *paymentOptionDetailRequest = [[PaymentOptionDetailRequest alloc] init];
   paymentOptionDetailRequest.paymentToken = paymentToken;
   paymentOptionDetailRequest.paymentChannel = PaymentChannel.CREDIT_CARD;

Step 3: Retrieve payment option details.

Based on these information merchant can verify customer input or show option list to customer.
e.g.: allowed card bins or installment plans.

PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, 
                                            new PaymentOptionDetailCallback() { 
    
      @Override
      public void onResponse(PaymentOptionDetailResponse response) {
      
         if(response.getResponseCode().equals(APIResponseCode.API_SUCCESS)) {
               
            CreditCardOptionDetail creditCardOptionDetail = response.getCreditCardOptionDetail();
            validateCreditCard(creditCardOptionDetail);
         } else {
            //Get error response and display error
         }
      }
    
      @Override
      public void onFailure(Throwable error) {
         //Get error response and display error
      }
   });
PGWSDK.shared.paymentOptionDetail(paymentOptionDetailRequest: paymentOptionDetailRequest, 
                                     success: { (response:PaymentOptionDetailResponse) in
                                     
      if response.responseCode == APIResponseCode.API_SUCCESS {
      
         let creditCardOptionDetail:CreditCardOptionDetail = response.creditCardOptionDetails!
         self.validateCreditCard(creditCardOptionDetail)
      } else {
         //Get error response and display error
      }
   }) { (error:NSError) in
      //Get error response and display error
   }
[[PGWSDK shared] paymentOptionDetailWithPaymentOptionDetailRequest:paymentOptionDetailRequest 
                    success:^(PaymentOptionDetailResponse * _Nonnull response) {
                      
      if ([response.responseCode isEqualToString:APIResponseCode.API_SUCCESS]) {
        
         CreditCardOptionDetail *creditCardOptionDetail = response.creditCardOptionDetails;
         [self validateCreditCard:creditCardOptionDetail];
      } else {
         //Get error response and display error
      }
   } failure:^(NSError * _Nonnull error) {
        //Get error response and display error
   }];
Data TypeDescription
CreditCardOptionDetailPayment option details for credit card payment.

Credit Card Option Detail
InstallmentOptionDetailPayment option details for installment payment.

Installment Option Detail

Complete Code:

Copy & Paste below source code into your application.

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";

   //Construct payment option details request
   PaymentOptionDetailRequest paymentOptionDetailRequest = new PaymentOptionDetailRequest();
   paymentOptionDetailRequest.setPaymentToken(paymentToken);
   paymentOptionDetailRequest.setPaymentChannel(PaymentChannel.CREDIT_CARD);

   //Retrieve payment option details
   PGWSDK.getInstance().paymentOptionDetail(paymentOptionDetailRequest, 
                                            new PaymentOptionDetailCallback() { 
    
      @Override
      public void onResponse(PaymentOptionDetailResponse response) {
      
         if(response.getResponseCode().equals(APIResponseCode.API_SUCCESS)) {
               
            CreditCardOptionDetail creditCardOptionDetail = response.getCreditCardOptionDetail();
            validateCreditCard(creditCardOptionDetail);
         } else {
            //Get error response and display error
         }
      }
    
      @Override
      public void onFailure(Throwable error) {
         //Get error response and display error
      }
   });

   private void validateCreditCard(CreditCardOptionDetail creditCardOptionDetail) {

      String userInputCardNumber = "4111111111111111";

      stopLoop:
      for(String bin : creditCardOptionDetail.getBins()) {

         //Do validate for supported card number
         if(userInputCardNumber.startsWith(bin)) {

            for(CardType cardType : creditCardOptionDetail.getCardTypes()) {

               //Validate for card number length
               if(cardType.getPrefixes().contains(bin)) {

                  if(userInputCardNumber.length() < cardType.getMinLength() 
                     || userInputCardNumber.length() > cardType.getMaxLength()) {
                    
                     //Invalid card number length
                  } else {
                     //Valid credit card number
                  }
                 
                  break stopLoop;
               }
            }
         }
      }
   }
let paymentToken:String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
   
   //Construct payment option details request
   let paymentOptionDetailRequest:PaymentOptionDetailRequest = PaymentOptionDetailRequest()
   paymentOptionDetailRequest.paymentToken = paymentToken
   paymentOptionDetailRequest.paymentChannel = PaymentChannel.CREDIT_CARD
   
   //Retrieve payment option details
   PGWSDK.shared.paymentOptionDetail(paymentOptionDetailRequest: paymentOptionDetailRequest, 
                                     success: { (response:PaymentOptionDetailResponse) in
                                     
      if response.responseCode == APIResponseCode.API_SUCCESS {
      
         let creditCardOptionDetail:CreditCardOptionDetail = response.creditCardOptionDetails!
         self.validateCreditCard(creditCardOptionDetail)
      } else {
         //Get error response and display error
      }
   }) { (error:NSError) in
      //Get error response and display error
   }
   
   private func validateCreditCard(_ creditCardOptionDetail:CreditCardOptionDetail) {
   
      let userInputCardNumber:String = "4111111111111111"
        
      stopLoop:
      for bin:String in creditCardOptionDetail.bins {
      
         //Do validate for supported card number
         if userInputCardNumber.starts(with: bin) {
         
            for cardType:CardType in creditCardOptionDetail.cardTypes {
            
               //Validate for card number length
               if cardType.prefixes.contains(bin) {
               
                  if userInputCardNumber.count < cardType.minLength
                     || userInputCardNumber.count > cardType.maxLength {
                     
                     //Invalid card number length
                  } else {
                     //Valid credit card number
                  }
                            
                  break stopLoop
               }
            }
         }
      }
   }
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";

   //Construct payment option details request
   PaymentOptionDetailRequest *paymentOptionDetailRequest = [[PaymentOptionDetailRequest alloc] init];
   paymentOptionDetailRequest.paymentToken = paymentToken;
   paymentOptionDetailRequest.paymentChannel = PaymentChannel.CREDIT_CARD;

   //Retrieve payment option details
   [[PGWSDK shared] paymentOptionDetailWithPaymentOptionDetailRequest:paymentOptionDetailRequest 
                    success:^(PaymentOptionDetailResponse * _Nonnull response) {
                      
      if ([response.responseCode isEqualToString:APIResponseCode.API_SUCCESS]) {
        
         CreditCardOptionDetail *creditCardOptionDetail = response.creditCardOptionDetails;
         [self validateCreditCard:creditCardOptionDetail];
      } else {
         //Get error response and display error
      }
   } failure:^(NSError * _Nonnull error) {
        //Get error response and display error
   }];

   - (void)validateCreditCard:(CreditCardOptionDetail *)creditCardOptionDetail {

      NSString *userInputCardNumber = @"4111111111111111";

      stopLoop: { }
      for (NSString *bin in creditCardOptionDetail.bins) {
        
         //Do validate for supported card number
         if ([userInputCardNumber hasPrefix:bin]) {
          
            for (CardType *cardType in creditCardOptionDetail.cardTypes) {
           
               //Validate for card number length
               if ([cardType.prefixes containsObject:bin]) {
              
                  if (userInputCardNumber.length < cardType.minLength
                      || userInputCardNumber.length > cardType.maxLength) {
                    
                     //Invalid card number length
                  } else {
                     //Valid credit card number
                  }
              
                  goto stopLoop;
               }
            }
         }
      }
   }

Next: Payment options