Popularity
2.2
Growing
Activity
8.1
-
31
12
20

Programming language: Swift
License: MIT License
Tags: Payments    
Latest version: v3.4.4

FramesIos alternatives and similar libraries

Based on the "Payments" category.
Alternatively, view FramesIos alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of FramesIos or a related project?

Add another 'Payments' Library

README

FramesIos

Build Status CocoaPods Compatible Carthage Compatible Platform codecov codebeat badge license

Requirements

  • iOS 10.0+
  • Xcode 9.0+
  • Swift 5.0+

Documentation

You can find the FramesIos documentation on this website.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1+ is required to build FramesIos 1.0+.

To integrate FramesIos into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Frames', '~> 3.0'
end

Then, run the following command:

$ pod install

We do not support i386 builds. Cocoapods should configure this for you, but if not, see Architecture Support for setup.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Frames into your Xcode project using Carthage, specify it in your Cartfile:

github "checkout/frames-ios" ~> 3.0

Run carthage update --use-xcframeworks to build the framework and drag the built Frames into your Xcode project.

If you are planning to run release builds for simulator, make sure to exclude the i386 architecture from your builds. See Architecture Support for setup.

Swift Package Manager

Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Frames as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/checkout/frames-ios.git", .upToNextMajor(from: "3.0.0"))
]

If you are planning to run release builds for simulator, make sure to exclude the i386 architecture from your builds. See Architecture Support for setup.

Usage

Import the SDK:

import Frames

Using the CardViewController UI

class ViewController: UIViewController, CardViewControllerDelegate {

    let checkoutAPIClient = CheckoutAPIClient(publicKey: "pk_test_03728582-062b-419c-91b5-63ac2a481e07",
                                              environment: .sandbox)
    lazy var cardViewController: CardViewController = {
        return CardViewController(checkoutApiClient: checkoutAPIClient, cardHolderNameState: .hidden, billingDetailsState: .hidden)
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        // set the card view controller delegate
        cardViewController.delegate = self
        // replace the bar button by Pay
        cardViewController.rightBarButtonItem = UIBarButtonItem(title: "Pay", style: .done, target: nil, action: nil)
        // specified which schemes are allowed
        cardViewController.availableSchemes = [.visa, .mastercard]

        navigationController?.pushViewController(cardViewController, animated: false)
    }

    func onTapDone(controller: CardViewController, card: CkoCardTokenRequest) {
        print(card)
    }

    func onSubmit(controller: CardViewController) {
        // Called just before a create card token request is made.
    }
}

Headless Mode

let checkoutAPIClient = CheckoutAPIClient(publicKey: "pk_test_03728582-062b-419c-91b5-63ac2a481e07",
                                          environment: .sandbox)

// create the phone number
let phoneNumber = CkoPhoneNumber(countryCode: "44", number: "7777777777")
// create the address
let address = CkoAddress(addressLine1: "test1", addressLine2: "test2", city: "London", state: "London", zip: "N12345", country: "GB")
// create the card token request
let cardTokenRequest = CkoCardTokenRequest(number: "123456789101", expiryMonth: "07", expiryYear: "22", cvv: "100", name: "Test Customer", billingAddress: address, phone: phoneNumber)

checkoutAPIClient.createCardToken(card: cardTokenRequest) { result in
    switch result {
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

Using Methods available in FramesIos

You can find more examples on the usage guide.

Create the API Client CheckoutAPIClient:

// replace "pk_test_6ff46046-30af-41d9-bf58-929022d2cd14" by your own public key
let checkoutAPIClient = CheckoutAPIClient(publicKey: "pk_test_6ff46046-30af-41d9-bf58-929022d2cd14",
                                          environment: .sandbox)

Create the CardUtils instance:

let cardUtils = CardUtils()

Use CardUtils to verify card number:

/// verify card number
let cardNumber = "4242424242424242"
let isCardValid = cardUtils.isValid(cardNumber: cardNumber)

Create the card token request CkoCardTokenRequest:

// create the phone number
let phoneNumber = CkoPhoneNumber(countryCode: "44", number: "7777777777")
// create the address
let address = CkoAddress(addressLine1: "test1", addressLine2: "test2", city: "London", state: "London", zip: "N12345", country: "GB")
// create the card token request
let cardTokenRequest = CkoCardTokenRequest(number: cardNumber, expiryMonth: "07", expiryYear: "22", cvv: "100", name: "Test Customer", billingAddress: address, phone: phoneNumber)

Create a card token:

let checkoutAPIClient = CheckoutAPIClient(publicKey: "pk_test_03728582-062b-419c-91b5-63ac2a481e07",
                                          environment: .sandbox)

// create the phone number
let phoneNumber = CkoPhoneNumber(countryCode: "44", number: "7777777777")
// create the address
let address = CkoAddress(addressLine1: "test1", addressLine2: "test2", city: "London", state: "London", zip: "N12345", country: "GB")
// create the card token request
let cardTokenRequest = CkoCardTokenRequest(number: "123456789101", expiryMonth: "07", expiryYear: "22", cvv: "100", name: "Test Customer", billingAddress: address, phone: phoneNumber)

checkoutAPIClient.createCardToken(card: cardTokenRequest) { result in
    switch result {
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

The success handler takes an array of CkoCardTokenResponse as a parameter. The error handler takes an ErrorResponse as a parameter.

Customize with CheckoutTheme

    CheckoutTheme.primaryBackgroundColor = .blue
    CheckoutTheme.secondaryBackgroundColor = .purple
    CheckoutTheme.errorColor = .yellow
    CheckoutTheme.color = .green
    CheckoutTheme.chevronColor = .pink

Architecture Support

We support all available architectures in Xcode except i386. Cocoapods should handle this for you, but if this is not working or if you're using SPM or Carthage you will need to configure your excluded architectures in your build settings as below:

[excluded architectures](screenshots/excludedArchitectures.png)

License

FramesIos is released under the MIT license. See LICENSE for details.


*Note that all licence references and agreements mentioned in the FramesIos README section above are relevant to that project's source code only.