English
API ReferenceSign In

How to Install iOS SDK

Last updated 01/24/2020

You have two ways to install our SDK, They are with:

  • Cocoapods
  • Manual installation

Install iOS SDK with Cocoapods

To install our iOS SDK through Maven, you need to add this to your Podfile

pod 'Xendit', '~> 2.0'

Install iOS SDK Manually

How to install iOS SDK v3

You can install our SDK using Cocoapods.

Install iOS SDK with Cocoapods

To install our iOS SDK through Maven, you need to add this to your Podfile

pod 'Xendit', '~> 3.0.0-beta'

Run `pod install --repo-update` to update your dependencies with Xendit’s SDK.

How to use iOS SDK for EMV 3DS

Two additional fields are recommended when performing EMV 3DS. They are:

  • Billing address of the card holder
  • Shipping address of the order

Creating the tokenization request for single use tokens

let billingDetails: XenditBillingDetails = XenditBillingDetails()
billingDetails.givenNames = "John"
billingDetails.surname = "Smith"
billingDetails.mobileNumber = "123123123"
billingDetails.phoneNumber = "123123123"
billingDetails.email = "john@smith.com"

let billingAddress = XenditAddress()
billingAddress.country = "ID"
billingAddress.streetLine1 = "Panglima Polim IV"
billingAddress.streetLine2 = "Ruko Grand Panglima Polim, Blok E"
billingAddress.city = "Jakarta Selatan"
billingAddress.provinceState = "DKI Jakarta"
billingAddress.postalCode = "12345"
billingAddress.category = "WORK"
billingDetails.address = billingAddress

// If shipping address is different from billing address, create another address object for shipping address to be used in the customer object
let shippingAddress = billingAddress

let customer: XenditCustomer = XenditCustomer()
customer.phoneNumber = "+6208123123123"
customer.mobileNumber = "+6208123123123"
customer.givenNames = "John"
customer.surname = "Hudson"
customer.nationality = "ID"
customer.addresses = [shippingAddress]
customer.dateOfBirth = "1990-03-13"
customer.description = "Customer using promo"
customer.email = "john@xendit.co"

// Single use tokens
let cardData = CardData()
cardData.cardNumber = "4000000000000002"
cardData.cardExpMonth = "12"
cardData.cardExpYear = "2017"
cardData.cardCvn = "123"
cardData.amount = 5000
cardData.isMultipleUse = false

let tokenizationRequest = XenditTokenizationRequest(cardData: cardData, shouldAuthenticate: true)
tokenizationRequest.billingDetails = billingDetails
tokenizationRequest.customer = customer

Creating the tokenization request for multiple use tokens

let billingDetails: XenditBillingDetails = XenditBillingDetails()
billingDetails.givenNames = "John"
billingDetails.surname = "Smith"
billingDetails.mobileNumber = "123123123"
billingDetails.phoneNumber = "123123123"
billingDetails.email = "john@smith.com"

let billingAddress = XenditAddress()
billingAddress.country = "ID"
billingAddress.streetLine1 = "Panglima Polim IV"
billingAddress.streetLine2 = "Ruko Grand Panglima Polim, Blok E"
billingAddress.city = "Jakarta Selatan"
billingAddress.provinceState = "DKI Jakarta"
billingAddress.postalCode = "12345"
billingAddress.category = "WORK"
billingDetails.address = billingAddress

// If shipping address is the same, else create another address object for shipping address to be used in the customer object

let shippingAddress = billingAddress
let customer: XenditCustomer = XenditCustomer()
customer.phoneNumber = "+6208123123123"
customer.mobileNumber = "+6208123123123"
customer.givenNames = "John"
customer.surname = "Hudson"
customer.nationality = "ID"
customer.addresses = [shippingAddress]
customer.dateOfBirth = "1990-03-13"
customer.description = "Customer using promo"
customer.email = "john@xendit.co"

// Multiple use tokens
let cardData = CardData()
cardData.cardNumber = "4000000000000002"
cardData.cardExpMonth = "12"
cardData.cardExpYear = "2017"
cardData.cardCvn = "123"
cardData.isMultipleUse = true

let tokenizationRequest = XenditTokenizationRequest(cardData: cardData, shouldAuthenticate: true)
tokenizationRequest.billingDetails = billingDetails
tokenizationRequest.customer = customer

Xendit.createToken(fromViewController: self, tokenizationRequest: tokenizationRequest, onBehalfOf: "") { (token, error) in
    if (error != nil){
       // Handle error. Error is of type XenditError
       return
    }
    // Handle successful tokenization. Token is of type XenditCCToken
}

Sending and handling the tokenization request

Xendit.createToken(fromViewController: self, tokenizationRequest: tokenizationRequest, onBehalfOf: "") { (token, error) in
    if (error != nil){
       // Handle error. Error is of type XenditError
       return
    }
    // Handle successful tokenization. Token is of type XenditCCToken
}

If EMV 3DS is working, the following 3DS page will be rendered