Skip to content

2.2 Saved Card Payments

Mukesh Patil - Sr. iOS Engineer edited this page Dec 7, 2016 · 1 revision

Paying through SimpliPay will enable the user using any of the payment instrument like Cards and Net-Banking.

Before exploring payment feature you should refer specific SDK features consumption on the basis of scope of the user (Full or Limited scope) refer for more details

Update / Store User's Payment Information

Once you have successfully Linked the user you can now store cards/net-banking accounts. There are two types of cards that's can be saved Credit and Debit.

Net-Banking
// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions netBankingOption:@"set your bank name here"
                         issuerCode:@"set your issuer code here"];
Or Credit Card
// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions creditCardOption:@"set your card number here"
                     cardExpiryDate:@"set your expiry date here" // only mm/yyyy format
                                cvv:nil];
Or Debit Card
// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions debitCardOption:@"set your card number here"
                    cardExpiryDate:@"set your expiry date here" // only mm/yyyy format
                               cvv:nil];
Update Payment Information
// Configure your request here.
[proifleLayer updatePaymentInformation:paymentOption
                 withCompletionHandler:^(NSError *error) {
                     if (error) {
                         NSLog(@"error %@", [error localizedDescription]);
                     }
                     else {
                         NSLog(@"succesfully card saved \n%@",paymentOptions.cardNumber);
                     }
                 }];

Get Wallet / Request Payment Information

Use following code to get the saved payment instruments, a Saved payment instruments also will have a token which looks like this 5115669e6129247a1e7a3599ea58e947, this can be used for payment using this instruments. you won't need to collect the card / NB information except CVV from user again.


[proifleLayer requestPaymentInformationWithCompletionHandler:^(CTSConsumerProfile *consumerProfile,
                                                               NSError *error)  {
    if  (error  ==  nil)  {
        // Your code to handle success.
        
        // get saved NetBanking payment options
        NSArray  *netBankingArray = consumerProfile.getSavedNBPaymentOptions;
        NSLog(@"netBankingArray %@", netBankingArray);
        
        // get saved Debit cards payment options
        NSArray  *debitCardArray = consumerProfile.getSavedDCPaymentOptions;
        NSLog(@"debitCardArray %@", debitCardArray);
        
        // get saved Credit cards payment options
        NSArray  *creditCardArray = consumerProfile.getSavedCCPaymentOptions;
        NSLog(@"creditCardArray %@", creditCardArray);
        
        if ([consumerProfile.paymentOptionsList count]) {
            //process the saved accounts here
        }
        else {
            // no saved accounts
        }
    }
    else {
        // Your code to handle error.
    }
}];

This will return the list of payment options for the logged in user. The list includes all the saved payment instruments as well as Prepaid and MVC as payment modes.

You need to present user with the UI to decide to the user using which payment instrument the user wants to make the payment.

Following are the steps to implement simplified payments interface.

Payment Using Saved Payment Instruments (A.K.A. Tokenized payments)

Saved payment instruments like CC, DC and NB Payments (A.K.A. Tokenized payments) Obtain users saved cards / NB and use this method to pay using saved payment instruments, Citrus server returns a token in each of the saved accounts. You only need send this token and CVV (cvv is not saved along with the other card information only in case of card payment) for doing the payment, rest of the information will be fetched by the Citrus server from its database using this token.

Debit Card Tokenized
// Step 1 - Get All the saved instruments.(requestPaymentInformationWithCompletionHandler method of SDK).
// Step 2 - Display List on the UI.
// Step 3 - If option selected by user is CardOption, call set CVV method and set payment option to DebitCardTokenized method.

// Parse the selected paymentOptionsList dictionary to CTSConsumerProfileDetails model object
JSONModelError* jsonError;
CTSConsumerProfileDetails* consumerProfileDetails = [[CTSConsumerProfileDetails alloc]
                                                     initWithDictionary:[consumerProfile.paymentOptionsList
                                                                         objectAtIndex:selectedRow]
                                                     error:&jsonError];

// Set the CVV for cardOption
[consumerProfileDetails setCvv:@"set your cvv here"];

// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions debitCardTokenized:consumerProfileDetails];
Or Credit Card Tokenized
// Step 1 - Get All the saved instruments.(requestPaymentInformationWithCompletionHandler method of SDK).
// Step 2 - Display List on the UI.
// Step 3 - If option selected by user is CardOption, call set CVV method and set payment option to CreditCardTokenized method.

// Parse the selected paymentOptionsList dictionary to CTSConsumerProfileDetails model object
JSONModelError* jsonError;
CTSConsumerProfileDetails* consumerProfileDetails = [[CTSConsumerProfileDetails alloc]
                                                     initWithDictionary:[consumerProfile.paymentOptionsList
                                                                         objectAtIndex:selectedRow]
                                                     error:&jsonError];

// Set the CVV for cardOption
[consumerProfileDetails setCvv:@"set your cvv here"];

// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions creditCardTokenized:consumerProfileDetails];
Or Net-Banking Tokenized
// Step 1 - Get All the saved instruments.(requestPaymentInformationWithCompletionHandler method of SDK).
// Step 2 - Display List on the UI.
// Step 3 - If option selected by user is Netbanking Option, set Netbanking Option to NetBankingTokenized method.

// Parse the selected paymentOptionsList dictionary to CTSConsumerProfileDetails model object
JSONModelError* jsonError;
CTSConsumerProfileDetails* consumerProfileDetails = [[CTSConsumerProfileDetails alloc]
                                                     initWithDictionary:[consumerProfile.paymentOptionsList
                                                                         objectAtIndex:selectedRow]
                                                     error:&jsonError];

// Create instance for CTSPaymentOptions Class & set required payment details.
CTSPaymentOptions *paymentOption =
[CTSPaymentOptions netBankingTokenized:consumerProfileDetails];
// Set your payment type here
PaymentType *paymentType =

// If you wish to use BillURL follow below signature
[PaymentType PGPayment:@"set your total transaction amount here"
               billUrl:@"set your bill generator URL here" // pass BillURL string
         paymentOption:paymentOption
               contact:@"set your contact info here"
               address:@"set your address info here"];
// Optional
// Or if you wish to use CTSBill object follow below signature
[PaymentType PGPayment:@"set your total transaction amount here"
            billObject:@"set your CTSBill object here" // pass CTSBill object
         paymentOption:paymentOption
               contact:@"set your contact info here"
               address:@"set your address info here"];

// Pay using simplified payment interface
[paymentLayer requestSimpliPay:paymentType
       andParentViewController:self
             completionHandler:^(CTSPaymentReceipt *paymentReceipt,
                                 NSError *error) {
                 if (error) {
                     NSLog(@"error %@", [error localizedDescription]);
                 }
                 else {
                     NSLog(@"response %@", paymentReceipt.toDictionary);
                 }
             }];
Clone this wiki locally