This page's content:

Features

  • Create Token
  • Set CVV
  • Get all tokens
  • Get token by masked creditcard number
  • Delete token
  • Delete all tokens
  • Complete Documentation

Requirements

  • Swift 3
  • iOS 8.0+
  • Xcode 8.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To install EBANX with CocoaPods:

  • Make sure CocoaPods is installed.
  • Update your Podfile to include the following:
    Copy
    use_frameworks!
    pod 'EBANX'
  • Run
    Copy
    pod install
  • Use the .xcworkspace file generated by CocoaPods to work on your project!

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To install EBANX with it:

  • Install Carthage via Homebrew
    Copy
    $ brew update
    $ brew install carthage
  • Add github “ebanx/ios-sdk” to your Cartfile.
  • Run carthage update to build the framework.
  • Drag the build EBANX.framework into your Xcode project.

Configuration

How to get a Public Key

The public key and the integration key are generated at the time of the merchant’s account creation.

Click here for more details

Set Public Key

Copy
// import EBANX module in AppDelegate
import EBANX

// Configure public key SDK in application:didFinishLaunchingWithOptions:
func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Configuration for production environment
EBANX.configure(publicKey: "your public key")

// Configuration for development environment
EBANX.configure(publicKey: "your public key", testMode: true)
return true
}

Usage

Create Token

The token operation is used to create a token for a given credit card to be used for recurrent payments.

Copy
//import module
import EBANX

// Create a creditcard
let card = EBANXCreditCard(name: "John Doe", number: "4111111111111111", dueDate: "12/2015", cvv: "123", type: .visa)

EBANX.Token.create(card: card, country: .br) { (result: EBANXTokenResult) in
  switch result {
    case .success(let token):
    // Object EBANXToken
    case .apiError(let apiError):
    // enum EBANXAPIErrors
    // possibles values:
    // publicKeyNotSet - Public key is not set in EBANX.configure()
    // invalidPublicKey - Public key invalid (API response)
    // parseError - Object not found
    // responseError - Object EBANXError
    case .networkError(let error):
    // Object error from NSURLSession case request fail
  }
}

Set CVV

The setCVV operation is used to temporary associate a CVV with an existing token. This CVV will be used by the next request made with the associated token and then discarded.

The setCVV operation is useful for one-click payments, where you already have the customer’s credit card information and cannot send the CVV from your server.

Copy
//import module
import EBANX

// Set CVV from credicard token
EBANX.Token.setCVV(token: EBANXToken(token: "123456......123456", cardNumberMasked: "4111********1111"), cvv: "123") { (result: EBANXTokenResult) in
  switch result {
    case .success(let token):
    // Object EBANXToken
    case .apiError(let apiError):
    // enum EBANXAPIErrors
    // possibles values:
    // PublicKeyNotSet - Public key is not set in EBANX.configure()
    // InvalidPublicKey - Public key invalid (API response)
    // ParseError - Object not found
    // ResponseError - Object EBANXError
    case .networkError(let error):
    // Object error from NSURLSession case request fail
  }
}

Get all tokens

Copy
// return Array
let tokens = EBANX.Token.getTokens()

Get token by masked creditcard number

Copy
// return EBANXToken?
let currentToken = EBANX.Token.getToken(cardNumberMasked: "4111********1111")

Delete token

Copy
let currentToken = .......
EBANX.Token.deleteToken(currentToken)

Delete all tokens

Copy
EBANX.Token.deleteAllTokens()

Credit

EBANX iOS SDK is owned and maintained by EBANX.

If you have any doubts, you can send an email to mobile@ebanx.com