Skip to main content

Change API Key

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

Card Utilities

Fetch Card Network

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.
Get Card Network
Possible values are:
  • visa
  • mastercard
  • maestro16
  • amex
  • rupay
  • maestro and
  • diners
If the method cannot identify the network, it returns unknown.

Card Number Validation

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

Fetch Card Number Length for Card Network

Use the below method to fetch the card number’s length for a card network:
Fetch Card Number Length for Card Network

Save Card Details

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:

Step 1: Create a Customer

Create a customer, whose card details should be saved, from the Dashboard or Customers API. /customers
Request

Step 2: Create a Token

Use the following code to create a token.
Swift
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 previous step. 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.
Watch Out!
  • CVV is not required by default for tokenised cards across all networks.
  • CVV is optional for tokenised card payments. Do not pass dummy CVV values.
  • To implement this change, skip passing the cvv parameter entirely, or pass a null or empty value in the CVV field.
  • We recommend removing the CVV field from your checkout UI/UX for tokenised cards.
  • If CVV is still collected for tokenised cards and the customer enters a CVV, pass the entered CVV value to Razorpay.
We save the card details entered by the customer as tokens in Razorpay.

Step 3: Fetch Card Tokens

You can fetch all tokens generated for a customer by sending a request to the Fetch Tokens API./customers/:customer_id/tokens
Request
All the tokens (saved card details) returned in the response can be shown to the customer when payment creation.

Step 4: Create a Payment using the Token

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:
Swift

Fetch Logos

Fetch Bank Logo URL

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.
Fetch Bank Logo URL

Fetch Wallet Logo URL

Use the below method to fetch the wallet logo URL:
Fetch Wallet Logo URL

Fetch Wallet Square Logo URL

Use the below method to fetch the wallet square image logo URL:
Fetch Wallet Square Logo URL