Skip to content

bati668/omise-ios-swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Omise-iOS-Swift

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.

Setup

Please copy all files in {repo root}/Omise-iOS/Omise-iOS/OmiseLib into your project.

Installation

Omise-iOS-Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Omise-iOS-Swift', '~> 1.0'

Primary classes

Card

A class representing a card information.

TokenRequest

A class encapsulating parameters for requesting token. You will have to set card information as a parameter for this class.

Token

A class representing token. This class is what will be passed to the delegate if the request is successful.

Omise

A class for requesting token. See also sample code below.

Test app

By opening Omise-iOS_Test.xcodeproj and building it on Xcode, the sample application will launch and create a charge token to test.

Request a token

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
        }
    }
}

About

Omise SDK for iOS/Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.9%
  • Ruby 2.1%