Skip to content

Commit

Permalink
Public Release 1.7.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrokhl committed Oct 20, 2020
2 parents da3f130 + 8bf7fec commit c0a126c
Show file tree
Hide file tree
Showing 155 changed files with 1,743 additions and 5,372 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build
Podfile.lock
demoapp/Podfile.lock
Carthage
Cartfile.resolved
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "verygoodsecurity/card.io-iOS-source"
github "getbouncer/cardscan-ios" "1.0.5048"
github "verygoodsecurity/card.io-iOS-source" "b43a202acd7c7a258930b675348f8c4086f32e5d"
27 changes: 27 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
## Migration Guides

### Migrating from versions < v1.7.0
#### Carthage build modules changed for CardIO
If you use CardIO and integrate with Carthage, from now it's required to import `VGSCardIOCollector.framework` build in your application Target `Build Phases` and `Linkend Frameworks` settings.

Before:

Input Files
```
$(SRCROOT)/Carthage/Build/iOS/VGSCollectSDK.framework
$(SRCROOT)/Carthage/Build/iOS/CardIO.framework
```

Now:
```
$(SRCROOT)/Carthage/Build/iOS/VGSCollectSDK.framework
$(SRCROOT)/Carthage/Build/iOS/CardIO.framework
$(SRCROOT)/Carthage/Build/iOS/VGSCardIOCollector.framework
```

Same updates should be made for `Output Files`

Also in you project file where you use CardIO, you should import `VGSCardIOCollector` module:
```
import VGSCollectSDK
import VGSCardIOCollector
```

### Migrating from versions < v1.6.0
#### Updated namings

Expand Down
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "VGSCollectSDK",
platforms: [
.iOS(.v11),
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "VGSCollectSDK",
targets: ["VGSCollectSDK"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "VGSCollectSDK",
dependencies: []),
.testTarget(
name: "FrameworkTests",
dependencies: ["VGSCollectSDK"]),
]
)
62 changes: 54 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ You should have your organization registered at <a href="https://dashboard.veryg

# Integration

VGSCollectSDK is available through [CocoaPods](https://cocoapods.org) and [Carthage](https://github.com/Carthage/Carthage).

### CocoaPods

[CocoaPods](https://cocoapods.org) 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`:
Expand All @@ -64,8 +62,34 @@ then run:
carthage update --platform iOS
```

Note that `VGSCollectSDK` includes [CardIO](https://github.com/verygoodsecurity/card.io-iOS-source) as dependency for scanning card numbers. You should also link it to your project. Follow the [Carthage instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)
If you don't need additional features like card scanning, you should add into your project only `VGSCollectSDK`. Other submodules can safely be deleted from Carthage Build folder.

Check VGSCollecSDK submodules and required frameworks:

| Build Frameworks | Core SDK | CardIO | Card Scan |
| ----- | -------------- |---------------- |--------------- |
| VGSCollectSDK ||||
| CardIO | || |
| VGSCardIOCollector | || |
| CardScan | | ||
| VGSCardScanCollector | | ||

Don't forget to import `VGSCardIOCollector` or `VGSCardScanCollector` in files where you use scan modules.

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

### Swift Package Manager

The [Swift Package Manager](https://swift.org/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, add VGSCollectSDK dependency.

```swift
dependencies: [
.package(url: "https://github.com/verygoodsecurity/vgs-collect-ios", .upToNextMajor(from: "1.7.0"))
]
```

## Usage

Expand Down Expand Up @@ -198,13 +222,34 @@ Use your `<vaultId>` to initialize VGSCollect instance. You can get it in your [


### Scan Credit Card Data
VGSCollect provide secure [card.io](https://github.com/verygoodsecurity/CardIOSDK-iOS) integration for collecting and setting scanned data into ``VGSTextFields``.
To use [card.io](https://github.com/verygoodsecurity/CardIOSDK-iOS) with **VGSCollectSDK** you should add **CardIO** module alongside with core **VGSCollectSDK** module into your App Podfile:
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:

```ruby
pod 'VGSCollectSDK'
pod 'VGSCollectSDK/CardIO'

# 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 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.

#### Code Example

<table>
Expand Down Expand Up @@ -425,8 +470,9 @@ To follow `VGSCollectSDK` updates and changes check the [releases](https://githu
## Dependencies
- iOS 10+
- Swift 5
- 3rd party libraries:
- CardIO(optional)
- Optional 3rd party libraries:
- [CardIO](https://github.com/card-io/card.io-iOS-SDK)
- [Card Scan(Bouncer)](https://github.com/getbouncer/cardscan-ios)

## License

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@
//

import Foundation
#if canImport(UIKit)
import CardIO
import UIKit
import AVFoundation.AVCaptureDevice

#if !COCOAPODS
import VGSCollectSDK
#endif

#if canImport(CardIO)
import CardIO
import AVFoundation.AVCaptureDevice

internal class VGSCardIOHandler: NSObject, VGSScanHandlerProtocol {

weak var delegate: VGSCardIOScanControllerDelegate?
weak var view: UIViewController?
var cameraPosition: AVCaptureDevice.Position?
var suppressScanConfirmation = false

var disableManualEntryButtons = false
var languageOrLocale: String?

func presentScanVC(on viewController: UIViewController, animated: Bool, completion: (() -> Void)?) {
guard let vc = CardIOPaymentViewController(paymentDelegate: self, scanningEnabled: true, preferredDevicePosition: cameraPosition ?? .unspecified) else {
print("This device is not compatible with CardIO")
return
}
vc.hideCardIOLogo = true
vc.suppressScanConfirmation = suppressScanConfirmation
vc.disableManualEntryButtons = disableManualEntryButtons
vc.languageOrLocale = languageOrLocale
vc.modalPresentationStyle = .overCurrentContext
self.view = vc
viewController.present(vc, animated: animated, completion: completion)
Expand All @@ -44,16 +49,20 @@ extension VGSCardIOHandler: CardIOPaymentViewControllerDelegate {

/// :nodoc:
func userDidCancel(_ paymentViewController: CardIOPaymentViewController!) {
delegate?.userDidCancelScan?()
VGSAnalyticsClient.shared.trackEvent(.scan, status: .cancel, extraData: [ "scannerType": "CardIO"])
delegate?.userDidCancelScan()
}

/// :nodoc:
func userDidProvide(_ cardInfo: CardIOCreditCardInfo!, in paymentViewController: CardIOPaymentViewController!) {
guard let cardInfo = cardInfo, let cardIOdelegate = delegate else {
delegate?.userDidFinishScan?()
delegate?.userDidFinishScan()
return
}
if !cardInfo.cardNumber.isEmpty, let textfield = cardIOdelegate.textFieldForScannedData(type: .cardNumber) {
if let form = textfield.configuration?.vgsCollector {
VGSAnalyticsClient.shared.trackFormEvent(form, type: .scan, status: .success, extraData: [ "scannerType": "CardIO"])
}
textfield.setText(cardInfo.cardNumber)
}
if 1...12 ~= Int(cardInfo.expiryMonth), cardInfo.expiryYear >= 2020 {
Expand Down Expand Up @@ -83,7 +92,7 @@ extension VGSCardIOHandler: CardIOPaymentViewControllerDelegate {
if let cvc = cardInfo.cvv, !cvc.isEmpty, let textfield = cardIOdelegate.textFieldForScannedData(type: .cvc) {
textfield.setText(cvc)
}
cardIOdelegate.userDidFinishScan?()
cardIOdelegate.userDidFinishScan()
}
}
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@
//

import Foundation
import AVFoundation.AVCaptureDevice

#if canImport(UIKit)
import UIKit
#if !COCOAPODS
import VGSCollectSDK
#endif

internal protocol VGSScanHandlerProtocol {
var delegate: VGSCardIOScanControllerDelegate? { get set }
var cameraPosition: AVCaptureDevice.Position? { get set }
var suppressScanConfirmation: Bool { get set }

func presentScanVC(on viewController: UIViewController, animated: Bool, completion: (() -> Void)?)
func dismissScanVC(animated: Bool, completion: (() -> Void)?)
}
#if os(iOS)
import UIKit
import AVFoundation.AVCaptureDevice

/// Controller responsible for managing Card.io scanner
public class VGSCardIOScanController {

// MARK: - Attributes

internal var scanHandler: VGSScanHandlerProtocol?
internal var scanHandler: VGSCardIOHandler?

/// `VGSCardIOScanControllerDelegate` - handle user interaction with `Card.io` scanner
public var delegate: VGSCardIOScanControllerDelegate? {
Expand All @@ -53,20 +47,30 @@ public class VGSCardIOScanController {
scanHandler?.suppressScanConfirmation = suppressScanConfirmation
}
}

/// Defines preferred language for all strings appearing in the CardIO user interface.
/// If not set, or if set to nil, defaults to the device's current language setting.
public var languageOrLocale: String? = nil {
didSet {
scanHandler?.languageOrLocale = languageOrLocale
}
}

/// Set to `true` to prevent CardIO from showing its "Enter Manually" button. Defaults to `false`.
public var disableManualEntryButtons: Bool = false {
didSet {
scanHandler?.disableManualEntryButtons = disableManualEntryButtons
}
}

// MARK: - Initialization
/// Initialization
///
/// - Parameters:
/// - delegate: `VGSCardIOScanControllerDelegate`. Default is `nil`.
public required init(_ delegate: VGSCardIOScanControllerDelegate? = nil) {
#if canImport(CardIO)
self.scanHandler = VGSCardIOHandler()
self.delegate = delegate
#else
print("Can't import CardIO. Please check that CardIO submodule is installed")
return
#endif
}

// MARK: - Methods
Expand All @@ -89,3 +93,4 @@ public class VGSCardIOScanController {
scanHandler?.dismissScanVC(animated: animated, completion: completion)
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import Foundation
#if !COCOAPODS
import VGSCollectSDK
#endif

/// Supported scan data fields by Card.io
@objc
Expand Down Expand Up @@ -41,10 +44,10 @@ public protocol VGSCardIOScanControllerDelegate {
// MARK: - Handle user ineraction with `Card.io`

/// On user confirm scanned data by selecting Done button on `Card.io` screen.
@objc optional func userDidFinishScan()
@objc func userDidFinishScan()

/// On user press Cancel buttonn on `Card.io` screen.
@objc optional func userDidCancelScan()
@objc func userDidCancelScan()

// MARK: - Manage scanned data

Expand Down
Loading

0 comments on commit c0a126c

Please sign in to comment.