All Projects → verygoodsecurity → vgs-collect-ios

verygoodsecurity / vgs-collect-ios

Licence: MIT License
VGS Collect iOS SDK

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to vgs-collect-ios

aks-baseline-regulated
This is the Azure Kubernetes Service (AKS) baseline cluster for regulated workloads reference implementation as produced by the Microsoft Azure Architecture Center.
Stars: ✭ 73 (+329.41%)
Mutual labels:  pci-dss, pci
lunasec
LunaSec - Dependency Security Scanner that automatically notifies you about vulnerabilities like Log4Shell or node-ipc in your Pull Requests and Builds. Protect yourself in 30 seconds with the LunaTrace GitHub App: https://github.com/marketplace/lunatrace-by-lunasec/
Stars: ✭ 1,261 (+7317.65%)
Mutual labels:  pci-dss, tokenization
polycash
The ultimate open source betting protocol. PolyCash is a P2P blockchain platform for wallets, asset issuance, bonds & gaming.
Stars: ✭ 24 (+41.18%)
Mutual labels:  tokenization
youtokentome-ruby
High performance unsupervised text tokenization for Ruby
Stars: ✭ 17 (+0%)
Mutual labels:  tokenization
credit-card-example
An example of credit card made by using Rivets Js
Stars: ✭ 23 (+35.29%)
Mutual labels:  credit-card
BlockEditText
Block EditText is a library provide an input view present in multiple block style that common use in TAC or credit card field.
Stars: ✭ 113 (+564.71%)
Mutual labels:  credit-card
card-validator
Card validation helpers for payment forms.
Stars: ✭ 22 (+29.41%)
Mutual labels:  credit-card
react-payment-request-api
High order component to drive Payment Request widget
Stars: ✭ 58 (+241.18%)
Mutual labels:  credit-card
uax29
A tokenizer based on Unicode text segmentation (UAX 29), for Go
Stars: ✭ 26 (+52.94%)
Mutual labels:  tokenization
frames-android
Checkout API Client, Payment Form UI and Utilities
Stars: ✭ 26 (+52.94%)
Mutual labels:  credit-card
symmetric-encryption
Symmetric Encryption for Ruby Projects using OpenSSL
Stars: ✭ 454 (+2570.59%)
Mutual labels:  pci
simplemma
Simple multilingual lemmatizer for Python, especially useful for speed and efficiency
Stars: ✭ 32 (+88.24%)
Mutual labels:  tokenization
pci-paas-webapp-ase-sqldb-appgateway-keyvault-oms
Azure Security and Compliance Blueprint - automation pci-paas-webapp-ase-sqldb-appgateway-keyvault-oms
Stars: ✭ 31 (+82.35%)
Mutual labels:  pci-dss
auto-data-tokenize
Identify and tokenize sensitive data automatically using Cloud DLP and Dataflow
Stars: ✭ 21 (+23.53%)
Mutual labels:  tokenization
com.iatspayments.civicrm
CiviCRM Extension supporting iATS Payments services
Stars: ✭ 13 (-23.53%)
Mutual labels:  credit-card
Credit
An example project that predicts risk of credit card default using a Logistic Regression classifier and a 30,000 sample dataset.
Stars: ✭ 18 (+5.88%)
Mutual labels:  credit-card
spacy russian tokenizer
Custom Russian tokenizer for spaCy
Stars: ✭ 35 (+105.88%)
Mutual labels:  tokenization
wazuh-puppet
Wazuh - Puppet module
Stars: ✭ 25 (+47.06%)
Mutual labels:  pci-dss
PaymentForm
A form that takes credit card and address information. Uses a ported version of jessie pollack's card component.
Stars: ✭ 40 (+135.29%)
Mutual labels:  credit-card
pyamex
Python library for accessing American Express account data
Stars: ✭ 15 (-11.76%)
Mutual labels:  credit-card

CircleCI UT license Platform swift 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 State VGS 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 <vaultId> 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

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Xcode with Swift tools version of 5.3 is required for VGSCollectSDK. Earlier Xcode versions don't support Swift packages with resources. To check your current Swift tools version run in your terminal:

xcrun swift -version

NOTE: In some cases you can have multiple Swift tools versions installed.

Follow the official Apple SPM guide instructions for more details.
To use Swift Package Manager, in Xcode add the https://github.com/verygoodsecurity/vgs-collect-ios.git dependency and choose the Exact version.

Select VGSCollectSDK and optionally other packages provided with VGSCollectSDK:

Usage

Import SDK into your file

import VGSCollectSDK

Create VGSCollect instance and VGS UI Elements

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

Code example

Here's an example In Action
Customize VGSTextFields...
/// Initialize VGSCollect instance
var vgsCollect = VGSCollect(id: "vauiltId", environment: .sandbox)

/// VGS UI Elements
var cardNumberField = VGSCardTextField()
var cardHolderNameField = VGSTextField()
var expCardDateField = VGSTextField()
var cvcField = VGSTextField()

/// Native UI Elements
@IBOutlet weak var stackView: UIStackView!

override func viewDidLoad() {
    super.viewDidLoad()

    /// Create card number field configuration
    let cardConfiguration = VGSConfiguration(collector: vgsCollect,
                                         fieldName: "card_number")
    cardConfiguration.type = .cardNumber
    cardConfiguration.isRequiredValidOnly = true

    /// Setup configuration to card number field
    cardNumberField.configuration = cardConfiguration
    cardNumberField.placeholder = "Card Number"
    stackView.addArrangedSubview(cardNumberField)

    /// Setup next textfields...
}
...
... observe filed states
override func viewDidLoad() {
    super.viewDidLoad()
	
    ...  
	
    /// Observing text fields
    vgsCollect.observeStates = { textFields in

        textFields.forEach({ textField in
            print(textdField.state.description)
            if textdField.state.isValid {
                textField.borderColor = .grey
            } else {
                textField.borderColor = .red
            }

            /// CardState is available for VGSCardTextField
            if let cardState = textField.state as? CardState {
                print(cardState.bin)
                print(cardState.last4)
                print(cardState.brand.stringValue)
            }
        })
    }
}
... send data to your Vault
// ...

// MARK: - Send data    
func sendData() {

    /// handle fields validation before send data
    guard cardNumberField.state.isValid else {
	print("cardNumberField input is not valid")
    }

    /// extra information will be sent together with all sensitive card information
    var extraData = [String: Any]()
    extraData["customKey"] = "Custom Value"

    /// send data to your Vault
    vgsCollect.sendData(path: "/post", extraData: extraData) { [weak self](response) in
      switch response {
        case .success(let code, let data, let response):
          // parse data
        case .failure(let code, let data, let response, let error):
          // handle failed request
          switch code {
            // handle error codes
          }
      }
    }
}

VGSCardTextField automatically detects card provider and display card brand icon in the input field.

Scan Credit Card Data

VGS Collect SDK provides several card scan solutions for the Payment Card Industry to help protect your businesses and the sensitive information of your consumers. It's required to use only Scan modules provided by VGS, which are audited by VGS PCI requirements.

Integrate with Cocoapods

Add 'VGSCollectSDK' alongside with one of scan modules pod:

pod 'VGSCollectSDK'

# Add CardIO module to use Card.io as scan provider
pod 'VGSCollectSDK/CardIO' 

# Add CardScan module to use CardScan(Bouncer) as scan provider
pod 'VGSCollectSDK/CardScan' 

Integrate with Swift Package Manager

Starting with the 1.7.4 release, VGSCollectSDK also supports CardScan integration via Swift PM.

To use CardScan add VGSCollectSDK, VGSCardScanCollector packages to your target.

Starting with the 1.7.11 release, VGSCollectSDK supports CardIO integration via Swift PM.

To use CardIO add VGSCollectSDK, VGSCardIOCollector packages to your target.

Integrate with Carthage

Carthage users should point to VGSCollectSDK repository and use next generated framework:

  • To use Card.io: VGSCollectSDK, VGSCardIOCollector, and CardIO. In your file add import VGSCardIOCollector.
  • To use Card Scan: VGSCollectSDK, VGSCardScanCollector, and CardScan. In your file add import VGSCardScanCollector.

Other submodules can safely be deleted from Carthage Build folder.

NOTE: At this time, Carthage does not provide a way to build only specific repository submodules. All submodules and their dependencies will be built by default. However you can include into your project only submodules that you need.

NOTE: For Carthage users CardScan available only with version 1.0.5048. Use CocoaPods or Swift Package Manager integration for the latest CardScan version. CardScan supports only CocoaPods or Swift Package Manager now.

Code Example

Here's an example In Action
Setup VGSCardIOScanController...
class ViewController: UIViewController {
	 
    var vgsCollect = VGSCollect(id: "vauiltId", environment: .sandbox)

    /// Init VGSCardIOScanController
    var scanController = VGSCardIOScanController()

    /// Init VGSTextFields...

    override func viewDidLoad() {
        super.viewDidLoad()

        /// set VGSCardIOScanDelegate
        canController.delegate = self
    }

    /// Present scan controller 
    func scanData() {
        scanController.presentCardScanner(on: self,
				animated: true,
			      completion: nil)
    }

    // MARK: - Send data  
    func sendData() {
        /// Send data from VGSTextFields to your Vault
        vgsCollect.sendData{...}
    }
}
...
... handle VGSCardIOScanControllerDelegate
// ...

/// Implement VGSCardIOScanControllerDelegate methods
extension ViewController: VGSCardIOScanControllerDelegate {

    ///Asks VGSTextField where scanned data with type need to be set.
    func textFieldForScannedData(type: CradIODataType) -> VGSTextField? {
	switch type {
	case .expirationDate:
	    return expCardDateField
	case .cvc:
	    return cvcField
	case .cardNumber:
	    return cardNumberField
	default:
	    return nil
	}
    }

    /// When user press Done button on CardIO screen
    func userDidFinishScan() {
	scanController.dismissCardScanner(animated: true, completion: { [weak self] in
	    /// self?.sendData()
	})
    }
}

Handle VGSCardIOScanControllerDelegate functions. To setup scanned data into specific VGSTextField implement textFieldForScannedData: . If scanned data is valid it will be set in your VGSTextField automatically after user confirmation. Check CradIODataType to get available scand data types.

Don't forget to add NSCameraUsageDescription key and description into your App Info.plist.

Upload Files

You can add a file uploading functionality to your application with VGSFilePickerController.

Code Example

Setup VGSFilePickerController...
class FilePickerViewController: UIViewController, VGSFilePickerControllerDelegate {

  var vgsCollect = VGSCollect(id: "vailtId", environment: .sandbox)
  
  /// Create strong referrence of VGSFilePickerController
  var pickerController: VGSFilePickerController?

  override func viewDidLoad() {
      super.viewDidLoad()

      /// create picker configuration
      let filePickerConfig = VGSFilePickerConfiguration(collector: vgsCollect,
      							fieldName: "secret_doc",
						       fileSource: .photoLibrary)

      /// init picket controller with configuration
      pickerController = VGSFilePickerController(configuration: filePickerConfig)

      /// handle picker delegates
      pickerController?.delegate = self
  }

  /// Present picker controller
  func presentFilePicker() {
      pickerController?.presentFilePicker(on: self, animated: true, completion: nil)
  }
}
...
... handle VGSFilePickerControllerDelegate In Action
// ...  

// MARK: - VGSFilePickerControllerDelegate
/// Check file info, selected by user
func userDidPickFileWithInfo(_ info: VGSFileInfo) {
	let fileInfo = """
		    File info:
		    - fileExtension: \(info.fileExtension ?? "unknown")
		    - size: \(info.size)
		    - sizeUnits: \(info.sizeUnits ?? "unknown")
		    """
	print(fileInfo)
	pickerController?.dismissFilePicker(animated: true,
					  completion: { [weak self] in
					  
		self?.sendFile()
	})
}

// Handle cancel file selection
func userDidSCancelFilePicking() {
	pickerController?.dismissFilePicker(animated: true)
}

// Handle errors on picking the file
func filePickingFailedWithError(_ error: VGSError) {
	pickerController?.dismissFilePicker(animated: true)
}
... send file to your Vault
// ...

// MARK: - Send File	
/// Send file and extra data
func sendFile() {

	/// add extra data to send request	
	let extraData = ["document_holder": "Joe B"]

  /// send file to your Vault
  vgsCollect.sendFile(path: "/post", extraData: extraData) { [weak self](response) in
    switch response {
      case .success(let code, let data, let response):
        /// remove file from VGSCollect storage
        self?.vgsCollect.cleanFiles()
      case .failure(let code, let data, let response, let error):
        // handle failed request
        switch code {
          // handle error codes
        }
    }
  }
}

Use vgsCollect.cleanFiles() to unassign file from associated VGSCollect instance whenever you need.

Demo Application

Demo application for collecting card data on iOS is here.

Also you can check our payment optimization demo with Multiplexing.

Documentation

Releases

To follow VGSCollectSDK updates and changes check the releases page.

Metrics

VGSCollectSDK tracks a few key metrics to understand SDK features usage, which helps us know what areas need improvement. No personal information is tracked. You can easily opt-out of metrics collection in VGSAnalyticsClient:

VGSAnalyticsClient.shared.shouldCollectAnalytics = false

Dependencies

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].