Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Updates to v4 of CardFlight SDK #687

Merged
merged 8 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Displays CardFlight messages to the user.
  • Loading branch information
ashfurrow committed Mar 6, 2018
commit c8fdf99d0dceb87764be110f3676fe8e85d3a72f
2 changes: 1 addition & 1 deletion Kiosk/App/CardHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CardHandler: NSObject, CFTTransactionDelegate {
var cardStatus: Observable<String> {
return _cardStatus.asObservable()
}
// TODO: Surface these messages to the user in the Kiosk UI.

var userMessages: Observable<String> {
// User messages are things like "Swipe card", "processing", or "Swipe card again". Due to a problem with the
// CardFlight SDK, the user is prompted to accept processing for card tokenization, which is provides a
Expand Down
22 changes: 15 additions & 7 deletions Kiosk/Bid Fulfillment/SwipeCreditCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class SwipeCreditCardViewController: UIViewController, RegistrationSubController
@IBOutlet var cardStatusLabel: ARSerifLabel!
let finished = PublishSubject<Void>()

@IBOutlet weak var titleLabel: ARSerifLabel!
@IBOutlet weak var spinner: Spinner!
@IBOutlet weak var processingLabel: UILabel!
@IBOutlet weak var illustrationImageView: UIImageView!

@IBOutlet weak var titleLabel: ARSerifLabel!

class func instantiateFromStoryboard(_ storyboard: UIStoryboard) -> SwipeCreditCardViewController {
return storyboard.viewController(withID: .RegisterCreditCard) as! SwipeCreditCardViewController
Expand Down Expand Up @@ -44,17 +43,27 @@ class SwipeCreditCardViewController: UIViewController, RegistrationSubController
super.viewDidLoad()
self.setInProgress(false)

let pleaseWaitMessage = "Please wait..."

cardHandler.userMessages
.startWith(pleaseWaitMessage)
.map { message in
if message.isEmpty {
return pleaseWaitMessage
} else {
return message
}
}
.bind(to: titleLabel.rx.text)
.disposed(by: rx.disposeBag)

cardHandler.cardStatus
.takeUntil(self.viewWillDisappear)
.subscribe(onNext: { message in
self.cardStatusLabel.text = "Card Status: \(message)"
if message == "Got Card" {
self.setInProgress(true)
}

if message.hasPrefix("Card Flight Error") {
self.processingLabel.text = "ERROR PROCESSING CARD - SEE ADMIN"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

},
onError: { error in
self.cardStatusLabel.text = "Card Status: Errored"
Expand Down Expand Up @@ -116,7 +125,6 @@ class SwipeCreditCardViewController: UIViewController, RegistrationSubController

func setInProgress(_ show: Bool) {
illustrationImageView.alpha = show ? 0.1 : 1
processingLabel.isHidden = !show
spinner.isHidden = !show
}

Expand Down
Loading