Additional Configurations

Additional configurations available for Razorpay iOS Custom SDK.


This section explains the additional configurations available for Razorpay iOS Custom SDK.

Call the following function after the successful SDK initialization and change the API key:

razorpay.changeApiKey("rzp_new_key")

The SDK provides a method to get the card network of the card. At least six digits of the card number are required to identify the network. The below method fetches the card network for a card. A minimum of 6 digits is required to identify the network.

razorpay.getCardNetwork(fromCardNumber: "cardNumber")

Possible values are:

  • visa
  • mastercard
  • maestro16
  • amex
  • rupay
  • maestro and
  • diners

If the method cannot identify the network, it returns unknown.

The entered card number can be validated using the checksum-based method.

razorpay.isCardValid("cardNumber")

Use the below method to fetch the card number's length for a card network:

razorpay.getCardNetworkLength(ofNetwork: "network")

You can save the card details as tokens with Razorpay. On repeat visits, the customers can complete the payment quicker by just entering the cvv of the card.

To implement the save cards feature in your app:

Create a customer, whose card details should be saved, from the Dashboard or

.

POST
/customers
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/customers \
-H "Content-Type: application/json" \
-d '{
"name": "Gaurav Kumar",
"email": "gaurav.kumar@example.com",
"contact": "9000090000",
"fail_existing": "0",
"notes":{
"landmark": "Razorpay Office Building",
"location": "Bangalore"
}
}'

For saving the card details on the Checkout, send the following parameters in the options dictionary:

customer_id

NSString Unique identifier of the customer. Obtained from the response of the

.

save

NSString Specifies if the card details should be stored as tokens. Possible values are:

  • 1: Saves the card details.
  • 0 (default): Does not save the card details.

internal func showPaymentForm(){
let options: [String:Any] = [
"amount": "100",
"currency": "INR",
"order_id": "order_4xbQrmEoA5WJ0G",
"method": "card",
"card[name]": "Gaurav Kumar",
"card[number]": "4111111111111111",
"card[expiry_month]": "9",
"card[expiry_year]": "20",
"card[cvv]": "123",
"customer_id": "cust_1Aa00000000001",
"save": "1",
// And the remaining fields
]
razorpay.open(options)
}

Watch Out!

  • CVV is not required by default for Visa and Amex tokenised cards.
  • To enable CVV-less flow for Rupay and MasterCard, contact our .
  • CVV is mandatory for Diners tokenised cards.
  • CVV is an optional field. Skip passing the cvv parameter to Razorpay to implement this change.

We save the card details entered by the customer as tokens in Razorpay.

You can fetch all tokens generated for a customer by sending a request to the Fetch Tokens API.

GET
/customers/:customer_id/tokens
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X GET https://api.razorpay.com/v1/customers/:cust_1Aa00000000001/tokens

All the tokens (saved card details) returned in the response can be shown to the customer when payment creation.

On a repeat visit, the customer selects a card from the list of saved cards and completes the payment by entering the cvv of the card. Send the customer_id, and token_id(associated with the saved card) attributes along with cvv in the payment request:

internal func showPaymentForm(){
let options: [String:Any] = [
"amount": "100",
"currency": "INR",
"order_id": "order_4xbXrmEoB5WApy",
"method": "card",
"customer_id": "cust_1Aa00000000001",
"token": "token_4zwefDSCC829ma",
"card[cvv]": "123",
// And the remaining fields
]
razorpay.open(options)
}

Use the below method to fetch the bank logo URL. Here bankCode is the code of the bank. This should be available in the response received in the onPaymentMethodsReceived callback.

Use the below method to fetch the wallet logo URL:

Use the below method to fetch the wallet square image logo URL:


Is this integration guide useful?