If you haven't already, follow the "Importing DyScan" and "Interfacing DyScan" steps in the .
The DyScan output can then be converted into an object that can be passed to a or a custom Stripe class by editing the extension functions in the following manner.
extension ExampleViewController: DyScanViewControllerDelegate{
func onFailure(_ paymentViewController: DyScanViewController!, reason: DyScanExitReason) {
paymentViewController.dismiss(animated: true){
// CardFieldViewController is a view controller containing an
// STPPaymentCardTextField called cardField
let viewController = CardFieldViewController()
let navigationController = UINavigationController(rootViewController: viewController)
self.present(navigationController, animated: true, completion: nil)
}
}
func onSuccess(_ cardInfo: DyScanCreditCardInfo!, in paymentViewController: DyScanViewController!) {
// CardFieldViewController is a view controller containing an
// STPPaymentCardTextField called cardField
let viewController = CardFieldViewController()
let navigationController = UINavigationController(rootViewController: viewController)
paymentViewController.dismiss(animated: true){
if let info = cardInfo {
let card = STPPaymentMethodCardParams()
card.number = info.cardNumber
if(info.expiryMonth > 0){
card.expMonth = NSNumber(value: info.expiryMonth)
card.expYear = NSNumber(value: info.expiryYear)
}
viewController.cardField.cardParams = card
}
self.present(navigationController, animated: true, completion: nil)
}
}
extension ExampleViewController: DyScanViewControllerDelegate{
func onFailure(_ paymentViewController: DyScanViewController!, reason: DyScanExitReason) {
paymentViewController.dismiss(animated: true){
// CardFieldViewController is a view controller containing an
// STPPaymentCardTextField called cardField
let viewController = CardFieldViewController()
let navigationController = UINavigationController(rootViewController: viewController)
self.present(navigationController, animated: true, completion: nil)
}
}
func onSuccess(_ cardInfo: DyScanCreditCardInfo!, in paymentViewController: DyScanViewController!) {
// CardFieldViewController is a view controller containing an
// STPPaymentCardTextField called cardField
let viewController = CardFieldViewController()
let navigationController = UINavigationController(rootViewController: viewController)
paymentViewController.dismiss(animated: true){
if let info = cardInfo {
let card = STPCardParams()
card.number = info.cardNumber
if(info.expiryMonth > 0){
card.expMonth = info.expiryMonth
card.expYear = info.expiryYear
}
viewController.cardField.cardParams = card
}
self.present(navigationController, animated: true, completion: nil)
}
}
The DyScan output can then be converted into an object that can be passed to a or a custom Stripe class by editing the extension functions in the following manner.