Omise-iOS-Swift is a Swift 2.0 library for managing token with Omise API.
By using the token produced by this library, you will be able to securely process credit card without letting sensitive information pass through your server. This token can also be used to create customer card data which will allow re-using of card data for the next payment without entering it again.
All data are transmitted via HTTPS to our PCI-DSS certified server.
Please copy all files in {repo root}/Omise-iOS/Omise-iOS/OmiseLib into your project.
Omise-iOS-Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Omise-iOS-Swift', '~> 1.0'
A class representing a card information.
A class encapsulating parameters for requesting token. You will have to set card information as a parameter for this class.
A class representing token. This class is what will be passed to the delegate if the request is successful.
A class for requesting token. See also sample code below.
By opening Omise-iOS_Test.xcodeproj and building it on Xcode, the sample application will launch and create a charge token to test.
AccessOmiseViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
//set parameters
let tokenRequest = TokenRequest()
tokenRequest.publicKey = "pkey_test_4y7dh41kuvvawbhslxw" //required
tokenRequest.card!.name = "JOHN DOE" //required
tokenRequest.card!.city = "Bangkok" // optional
tokenRequest.card!.postalCode = "10320" //optional
tokenRequest.card!.number = "4242424242424242" //required
tokenRequest.card!.expirationMonth = "11" //required
tokenRequest.card!.expirationYear = "2016" //required
tokenRequest.card!.securityCode = "123" //required
//request
let omise = Omise()
omise.delegate = self
omise.requestToken(tokenRequest)
}
// MARK: - OmiseTokenDelegate
extension AccessOmiseViewController: OmiseRequestDelegate {
func omiseOnFailed(error: NSError?) {
//handle error
}
func omiseOnSucceededToken(token: Token?) {
//handle success
if let token = token {
//your code here
}
}
}