Migrating from card.io (iOS)
View Controller
View
import DyScan
in the file with the view controller that will instantiate DyScan. Unlike card.io, a bridging header is not necessary as DyScan is written in Swift.Implement two functions,
onFailure(_ paymentViewController: DyScanViewController!, reason: DyScanExitReason)
, and onSuccess(_ cardInfo:DyScanCreditCardInfo!, in paymentViewController: DyScanViewController!)
. These should be analogous to the corresponding functions with Card.io, except that the names have been modified and the failure case provides a reason that you may choose to use to give a more robust experience.Make your view controller conform to
DyScanViewControllerDelegate
instead of CardIOPaymentViewControllerDelegate
.Replacing the instantiation and presentation of the
CardIOPaymentViewController
with let scanVC = DyScanViewController()
let navigationController = UINavigationController(rootViewController: scanVC)
scanVC.paymentDelegate = self
scanVC.apiKey = "{YOUR API KEY}"
present(navigationController, animated: true, completion: nil)
DyScanCreditCardInfo
is analogous to card.io's, but contains fewer methods. You can access the relevant fields by indexing cardNumber
, expiryMonth
, and expiryYear
.import DyScan
in the file with the view controller that will instantiate DyScan. Unlike card.io, a bridging header is not necessary as DyScan is written in Swift.Implement two functions,
onSuccess(_ dyScanIOView: DyScanView!, didScanCard cardInfo: DyScanCreditCardInfo?)
, and onFailure(_ dyScanIOView: DyScanView!, reason: DyScanExitReason)
. These should be analogous to the corresponding functions with Card.io, except that the names have been modified and the failure case provides a reason that you may choose to use to give a more robust experience.Make your view controller conform to
DyScanViewDelegate
instead of CardIOViewControllerDelegate
.Replacing the instantiation and presentation of the
CardIOViewController
with dyScanView = DyScanView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width , height: self.view.frame.width))
dyScanView?.apiKey = "{YOUR API KEY}"
dyScanView?.delegate = self
dyScanView?.prepare()
self.view.addSubview(dyScanView!)
DyScanCreditCardInfo
is analogous to card.io's, but contains fewer methods. You can access the relevant fields by indexing cardNumber
, expiryMonth
, and expiryYear
.