Skip to content

Commit

Permalink
Public Release 1.12.0
Browse files Browse the repository at this point in the history
Public Release 1.12.0
  • Loading branch information
dmytrokhl committed Jan 18, 2023
1 parent e1ec3a3 commit a05fa24
Show file tree
Hide file tree
Showing 46 changed files with 853 additions and 1,091 deletions.
4 changes: 4 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Migration Guides

### Migrating from versions < v1.12.0
#### `VGSCollectSDK/CardScan` scan module deprecated.
Use `VGSCollectSDK/CardIO` or `VGSCollectSDK/BlinkCard` as card scan solution instead.

### Migrating from versions < v1.11.3
#### Rename enum
`HTTPMethod` -> `VGSCollectHTTPMethod`
Expand Down
16 changes: 8 additions & 8 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"object": {
"pins": [
{
"package": "CardIOSDK",
"repositoryURL": "https://github.com/verygoodsecurity/CardIOSDK-iOS.git",
"package": "BlinkCard",
"repositoryURL": "https://github.com/blinkcard/blinkcard-swift-package",
"state": {
"branch": null,
"revision": "9f21bec2d2f12d14ffbe8305c44ceff9b60e35af",
"version": "5.5.7"
"revision": "e74689f8e0df9c4fbebf46b87c4ab716325516a8",
"version": "2.7.0"
}
},
{
"package": "CardScan",
"repositoryURL": "https://github.com/getbouncer/cardscan-ios.git",
"package": "CardIOSDK",
"repositoryURL": "https://github.com/verygoodsecurity/CardIOSDK-iOS.git",
"state": {
"branch": null,
"revision": "84e7d1e7805675274edd85bc786b2dd1e4d864e0",
"version": "2.0.9"
"revision": "9f21bec2d2f12d14ffbe8305c44ceff9b60e35af",
"version": "5.5.7"
}
}
]
Expand Down
49 changes: 23 additions & 26 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,24 @@ let package = Package(
.library(
name: "VGSCollectSDK",
targets: ["VGSCollectSDK"]),
.library(
name: "VGSCardScanCollector",
targets: ["VGSCardScanCollector"]
),
.library(
name: "VGSCardIOCollector",
targets: ["VGSCardIOCollector"])
.library(
name: "VGSCardIOCollector",
targets: ["VGSCardIOCollector"]),
.library(
name: "VGSBlinkCardCollector",
targets: ["VGSBlinkCardCollector"])
],
dependencies: [
.package(
name: "CardScan",
url: "https://github.com/getbouncer/cardscan-ios.git",
.exact("2.0.9")
),
.package(
name: "CardIOSDK",
url: "https://github.com/verygoodsecurity/CardIOSDK-iOS.git",
.exact("5.5.7")
)
),
.package(
name: "BlinkCard",
url: "https://github.com/blinkcard/blinkcard-swift-package",
.exact("2.7.0")
)
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -49,18 +48,16 @@ let package = Package(
"Info.plist",
"FrameworkTests.xctestplan"
],
resources: [.process("Resources")]
),
.target(
name: "VGSCardScanCollector",
dependencies: ["VGSCollectSDK",
.product(name: "CardScan", package: "CardScan")],
path: "Sources/VGSCardScanCollector/"
),
.target(
name: "VGSCardIOCollector",
dependencies: ["VGSCollectSDK",
.product(name: "CardIOSDK", package: "CardIOSDK")],
path: "Sources/VGSCardIOCollector/")
resources: [.process("Resources")]),
.target(
name: "VGSCardIOCollector",
dependencies: ["VGSCollectSDK",
.product(name: "CardIOSDK", package: "CardIOSDK")],
path: "Sources/VGSCardIOCollector/"),
.target(
name: "VGSBlinkCardCollector",
dependencies: ["VGSCollectSDK",
.product(name: "BlinkCard", package: "BlinkCard")],
path: "Sources/VGSBlinkCardCollector/")
]
)
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Platform](https://img.shields.io/cocoapods/p/VGSCollectSDK.svg?style=flat)](https://github.com/verygoodsecurity/vgs-collect-ios)
[![swift](https://img.shields.io/badge/swift-5-orange)]()
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/VGSCollectSDK.svg?style=flat)](https://cocoapods.org/pods/VGSCollectSDK)
<img src="./VGSZeroData.png" height="20">
<img src="./images/VGSZeroData.png" height="20">

# VGS Collect iOS SDK

Expand All @@ -30,8 +30,8 @@ Table of contents
<!--te-->

<p align="center">
<img src="https://raw.githubusercontent.com/verygoodsecurity/vgs-collect-ios/canary/vgs-collect-ios-state.png" width="200" alt="VGS Collect iOS SDK State" hspace="20">
<img src="https://raw.githubusercontent.com/verygoodsecurity/vgs-collect-ios/canary/vgs-collect-ios-response.png" width="200" alt="VGS Collect iOS SDK Response" hspace="20">
<img src="images/vgs-collect-ios-state.png" width="200" alt="VGS Collect iOS SDK State" hspace="20">
<img src="images/vgs-collect-ios-response.png" width="200" alt="VGS Collect iOS SDK Response" hspace="20">
</p>


Expand Down Expand Up @@ -93,7 +93,7 @@ Use your `<vaultId>` to initialize VGSCollect instance. You can get it in your [
</tr>
<tr>
<td>Customize VGSTextFields...</td>
<th rowspan="2"><img src="add-card.gif"></th>
<th rowspan="2"><img src="images/add-card.gif"></th>
</tr>
<tr>
<td>
Expand Down Expand Up @@ -131,7 +131,7 @@ Use your `<vaultId>` to initialize VGSCollect instance. You can get it in your [
</tr>
<tr>
<td>... observe filed states </td>
<th rowspan="2"><img src="state.gif"></th>
<th rowspan="2"><img src="images/state.gif"></th>
</tr>
<tr>
<td>
Expand Down Expand Up @@ -213,14 +213,16 @@ Add 'VGSCollectSDK' alongside with one of scan modules pod:
```ruby
pod 'VGSCollectSDK'

# Add CardIO module to use Card.io as scan provider
pod 'VGSCollectSDK/CardIO'
# Add one of available scan providers
pod 'VGSCollectSDK/CardIO'
pod 'VGSCollectSDK/BlinkCard'
```
#### Integrate with Swift Package Manager

Starting with the 1.7.11 release, `VGSCollectSDK` supports [CardIO](https://github.com/verygoodsecurity/card.io-iOS-source) integration via Swift PM.

To use **CardIO** add `VGSCollectSDK`, `VGSCardIOCollector` packages to your target.
To use **BlinkCard** add `VGSCollectSDK`, `VGSBlinkCardCollector` packages to your target.

#### Code Example

Expand All @@ -231,7 +233,7 @@ To use **CardIO** add `VGSCollectSDK`, `VGSCardIOCollector` packages to your tar
</tr>
<tr>
<td>Setup VGSCardIOScanController...</td>
<th rowspan="2"><img src="card-scan.gif"></th>
<th rowspan="2"><img src="images/card-scan.gif"></th>
</tr>
<tr>
<td>
Expand Down Expand Up @@ -392,7 +394,7 @@ You can add a file uploading functionality to your application with **VGSFilePic
}

</td>
<td><img src="file-picker.gif"></td>
<td><img src="images/file-picker.gif"></td>
</tr>
<tr>
<td colspan="2">... send file to your Vault</td>
Expand Down Expand Up @@ -453,6 +455,7 @@ VGSAnalyticsClient.shared.shouldCollectAnalytics = false
- Swift 5
- Optional 3rd party libraries:
- [CardIO](https://github.com/card-io/card.io-iOS-SDK)
- [BlinkCard](https://github.com/blinkcard/blinkcard-ios)

## License

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

import Foundation
#if !COCOAPODS
import VGSCollectSDK
#endif

/// Holds scanned expiration date data.
/// BlinkCard holds scanned data expiration date with two separate Ints.
internal struct VGSBlinkCardExpirationDate {
/// Scanned month.
let month: Int
/// Month converted to String: "01"
let monthString: String
/// Scanned year: YYYY
let year: Int
/// Scanned year short: YY
let shortYear: Int

init(_ month: Int, year: Int) {
self.month = month
// Normalize month to format "01"
self.monthString = Self.formatMonthString(from: month)
self.year = year
self.shortYear = year - 2000
}

// MARK: - Helpers

/// Maps scanned exp month and year to valid format (MM/YY).
/// - Returns: `String`, composed text or nil if scanned info is invalid.
func mapDefaultExpirationDate() -> String {
return "\(monthString)\(shortYear)"
}

/// Maps scanned exp month and year to long expiration date format (MM/YYYY).
/// - Returns: `String`, composed text or nil if scanned info is invalid.
func mapLongExpirationDate() -> String {
return "\(monthString)\(year)"
}

/// Maps scanned exp month and year to valid format starting with year (YY/MM).
/// - Returns: `String`, composed text or nil if scanned info is invalid.
func mapExpirationDateWithShortYearFirst() -> String {
return "\(shortYear)\(monthString)"
}

/// Maps scanned exp month and year to long expiration date format starting with year (YYYY/MM).
/// - Returns: `String`, composed text or nil if scanned info is invalid.
func mapLongExpirationDateWithLongYearFirst() -> String {
return "\(year)\(monthString)"
}

/// Formats month int.
/// - Parameter monthInt: `Int`, should be month.
/// - Returns: `String` object, formatted month.
private static func formatMonthString(from monthInt: Int) -> String {
// Add `0` for month less than 10.
let monthString = monthInt < 10 ? "0\(monthInt)" : "\(monthInt)"
return monthString
}
}
70 changes: 70 additions & 0 deletions Sources/VGSBlinkCardCollector/VGSBlinkCardController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// VGSBlinkCardController.swift
// VGSBlinkCardCollector
//

import Foundation
#if !COCOAPODS
import VGSCollectSDK
#endif
#if os(iOS)
import UIKit
#endif

/// Controller responsible for managing `BlinkCard` scanner.
@available(iOS 13.0, *)
public class VGSBlinkCardController {

// MARK: - Attributes

/// Handle card scanner events.
internal var scanHandler: VGSBlinkCardHandler?

/// `VGSBlinkCardControllerDelegate` - handle user interaction with `BlinkCard` scanner.
public var delegate: VGSBlinkCardControllerDelegate? {
set {
scanHandler?.delegate = newValue
}
get {
return scanHandler?.delegate
}
}

// MARK: - Initialization

/// Initialization
/// - Parameters:
/// - licenseKey: key required for BlinkCard SDK usage.
/// - delegate: `VGSBlinkCardControllerDelegate`. Default is `nil`.
/// - errorCallback: Error callback with Int error code(represents `MBCLicenseError` enum), triggered only when error occured.
public required init(licenseKey: String, delegate: VGSBlinkCardControllerDelegate? = nil, onError errorCallback: @escaping ((NSInteger) -> Void)) {
self.scanHandler = VGSBlinkCardHandler(licenseKey: licenseKey, errorCallback: errorCallback)
self.delegate = delegate

}

// MARK: - Methods

/// Present `BlinkCard` scanner.
/// - Parameters:
/// - viewController: `UIViewController` that will present card scanner.
/// - animated: pass `true` to animate the presentation; otherwise, pass `false`.
/// - modalPresentationStyle: `UIModalPresentationStyle` object, modal presentation style. Default is `.overCurrentContext`.
/// - completion: the block to execute after the presentation finishes.
public func presentCardScanner(on viewController: UIViewController, animated: Bool, modalPresentationStyle: UIModalPresentationStyle = .overCurrentContext, completion: (() -> Void)?) {
scanHandler?.presentScanVC(on: viewController, animated: animated, modalPresentationStyle: modalPresentationStyle, completion: completion)
}

/// Dismiss `BlinkCard` scanner.
/// - Parameters:
/// - animated: pass `true` to animate the dismiss of presented viewcontroller; otherwise, pass `false`.
/// - completion: the block to execute after the dismiss finishes.
public func dismissCardScanner(animated: Bool, completion: (() -> Void)?) {
scanHandler?.dismissScanVC(animated: animated, completion: completion)
}

/// Set custom localization fileName.
public static func setCustomLocalization(fileName: String) {
VGSBlinkCardHandler.setCustomLocalization(fileName: fileName)
}
}
65 changes: 65 additions & 0 deletions Sources/VGSBlinkCardCollector/VGSBlinkCardControllerDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// VGSBlinkCardControllerDelegate.swift
// VGSBlinkCardCollector
//

import Foundation
#if !COCOAPODS
import VGSCollectSDK
#endif
#if os(iOS)
import UIKit
#endif

/// Supported scan data fields by BlinkCard.
@objc
public enum VGSBlinkCardDataType: Int {

/// Credit Card Number. Digits string.
case cardNumber

/// Card holder name displayed on card.
case name

/// Card cvc.
case cvc

/// Credit Card Expiration Date. String in format "mm/yy", e.g: "01/21".
case expirationDate

/// Credit Card Expiration Month. String in format "mm", e.g:"01".
case expirationMonth

/// Credit Card Expiration Year. String in format "yy", e.g: "21".
case expirationYear

/// Credit Card Expiration Year. String in format "yyyy", e.g:"2021".
case expirationYearLong

/// Credit Card Expiration Date. String in format "mm/yyyy", e.g:"01/2021".
case expirationDateLong

/// Credit Card Expiration Date. String in format "yy/mm", e.g:"21/01".
case expirationDateShortYearThenMonth

/// Credit Card Expiration Date. String in format "yyyy/mm", e.g:"2021/01".
case expirationDateLongYearThenMonth
}

/// Delegates produced by `VGSBlinkCardController` instance.
@objc
public protocol VGSBlinkCardControllerDelegate {

// MARK: - Handle user ineraction with `BlinkCard`

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

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

// MARK: - Manage scanned data

/// Asks `VGSTextField` where scanned data with `VGSConfiguration.FieldType` need to be set. Called after user select Done button, just before userDidFinishScan() delegate.
@objc func textFieldForScannedData(type: VGSBlinkCardDataType) -> VGSTextField?
}
Loading

0 comments on commit a05fa24

Please sign in to comment.