Instalasi

Anda memiliki dua cara untuk menggunakan SDK Xendit, yaitu:

  • Cocoapods
  • Instalasi manual

Instalasi iOS SDK dengan Cocoapods

Melalui Maven anda bisa installasi iOS SDK kami dengan menambahkan parameter berikut pada Podfile:

pod 'Xendit', '~> 3.10.2' 

Instalasi iOS SDK Secara Manual

Cara melakukan instalasi iOS SDK v3

Anda dapat melakukan instalasi menggunakan Cocoapods.

Instalasi iOS SDK menggunakan Cocoapods

Untuk melakukan instalasi iOS SDK kami melalui maven, Anda perlu menambahkan ini pada Podfile Anda

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

Jalankan `pod install --repo-update` untuk memperbarui dependensi Anda dengan SDK Xendit

Cara penggunakan iOS SDK untuk EMV 3DS

Dua kolom tambahan yang direkomendasikan saat menjalankan EMV 3DS. Yaitu:

  • Alamat penagihan pemegang kartu
  • Alamat pengiriman pesanan

Membuat permintaan tokenization** untuk token sekali pakai (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

Membuat permintaan tokenization** untuk token berkali kali (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
}

Mengirim dan menangani permintaan tokenisasi

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
}

Jika EMV 3DS berfungsi, halaman 3DS berikut akan ditampilkan (mode tes)

Last Updated on 2024-11-21