This SDK allows mobile developers to provide credit card payment functionality within their iOS applications, without having to pass sensitive card data back to their application backend servers. For more information on including payments in your mobile application see our InApp Payments Guide
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions,
visit their website. To integrate Cybersource Flex iOS SDK into your Xcode project using CocoaPods,
specify it in your Podfile:
pod 'flex-api-ios-sdk'
Select flex-client-sdk
from target list. Keep only flex-client-sdk
and CybersourceFlexSDK
, remove any other schemes from Manage Schemes option.
Once selected, run the application.
val merchantId = "<MerchantID>"
val merchantSecret = "<MerchantSecret>"
val merchantKey = "<MerchantKey>"
Please refer sample application which demonstrates creation of Capture context
Sample App
let captureContext = createCaptureContext()
let service = FlexService()
service.createTransientToken(from: captureContext, data: getPayload()) { (result) in
DispatchQueue.main.async { [weak self] in
switch result {
case .success:
//handle success case
case let .failure(error):
//handle error case
}
}
}
private func getPayload() -> [String: String] {
var payload = [String: String]()
payload["paymentInformation.card.number"] = "4111111111111111"
payload["paymentInformation.card.securityCode"] = "123"
payload["paymentInformation.card.expirationMonth"] = 12
payload["paymentInformation.card.expirationYear"] = 29
return payload
}
Your server constructs a transaction request using the Cybersource API, placing the encrypted payment information that it received in previous step in the opaqueData element.
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "YOUR_API_LOGIN_ID",
"transactionKey": "YOUR_TRANSACTION_KEY"
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "5",
"payment": {
"opaqueData": {
"dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
"dataValue": "PAYMENT_NONCE_GOES_HERE"
}
}
}
}
}