Swiftpack.co - Package - verygoodsecurity/vgs-collect-ios

CircleCI UT license Platform swift SwiftPM compatible Cocoapods Compatible

VGS Collect iOS SDK

VGS Collect - is a product suite that allows customers to collect information securely without possession of it. VGSCollect iOS SDK allows you to securely collect data from your users via forms without having to have that data pass through your systems. The form fields behave like traditional input fields while securing access to the unsecured data.

Table of contents

VGS Collect iOS SDK StateVGS Collect iOS SDK Response

Before you start

You should have your organization registered at VGS Dashboard. Sandbox vault will be pre-created for you. You should use your <vault-id> to start collecting data. Follow integration guide below.

Integration

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate VGSCollectSDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'VGSCollectSDK'

Swift Package Manager(Xcode 11+)

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To add VGSCollectSDK package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency. Enter package repository URL and press Next:

https://github.com/verygoodsecurity/vgs-collect-ios

Now you need to choose which part of the code you want to look at, you can choose the dependency type(tagged version, branch or commit). Then Xcode will setup all the stuff for you. We recommend to choose master branch to get latest stable SDK version.

On Final screen check that you project target is correct and press Finish.

Usage

Create VGSCollect instance and VGS UI Elements

Use your <vault-id> to initialize VGSCollect instance. You can get it in your organisation dashboard.

import UIKit
import VGSCollectSDK

class ViewController: UIViewController {

  var vgsForm = VGSCollect(id: "<vault-id>", environment: .sandbox)

  // VGS UI Elements
  var cardNumber = VGSTextField()

  override func viewDidLoad() {
		super.viewDidLoad()

		// Configure Elements UI
		let cardConfig = VGSConfiguration(collector: vgsForm, fieldName: "cardNumber")
		cardConfig.placeholder = "card number"
		cardConfig.isRequired = true
		cardConfig.type = .cardNumber

		cardNumber.configuration = cardConfig

		cardNumber.frame = CGRect(x: 10, y: 55, width: 310, height: 35)
		view.addSubview(cardNumber)
    }
}

Customize UI Elements

You can use general properties for styling your UI elements.

	// UI Elements styling
	cardNumber.borderWidth = 1
	cardNumber.borderColor = .lightGray
	cardNumber.padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
	cardNumber.textColor = .magenta
	cardNumber.font = UIFont(name: "Arial", size: 22)

Observe Fields State

	// Observing text fields
	vgsForm.observeStates = { textFields in
	    textFields.forEach({ textField in
	           print(textField.state.description)
	    })
	}

Collect and Send Your Data

func sendData() {
    // extra information will be sent together with all sensitive card information
    var extraData = [String: Any]()
    extraData["cardHolderName"] = "Joe Business"

    // send data
    vgsForm.submit(path: "/post", extraData: extraData, completion: { (json, error) in
        if error == nil, let json = json {
            // parse response data
        } else {
            // handle error
        }
    })
}

For more details check our documentation

https://www.verygoodsecurity.com/docs/vgs-collect/ios-sdk

Dependencies

  • iOS 10+
  • Swift 5
  • 3rd party libraries:
    • Alamofire

License

VGSCollect iOS SDK is released under the MIT license. See LICENSE for details.

Github

link
Stars: 3
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.0 - Nov 28, 2019

  • Possibility to collect data from VGSTextfield.
  • Pre-defined fields validation(card number, cvc, expDate).
  • Demo app, examples of fields configuration and data collecting at Vault

0.0.4 - Nov 26, 2019

Possibility to collect data from VGSTextfield. Pre-defined fields validation(card number, cvc, expDate).

0.0.3 - Nov 25, 2019

0.0.2 - Oct 10, 2019

0.0.1 - Oct 8, 2019