Integrating with Stripe (iOS)
If you haven't already, follow the "Importing DyScan" and "Interfacing DyScan" steps in the General Integration Guide.
Stripe 16.0.3 and higher
Stripe 16.0.2 and lower
The DyScan output can then be converted into an
STPPaymentMethodCardParams
object that can be passed to a STPPaymentCardTextField
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)
}
}
The DyScan output can then be converted into an
STPCardParams
object that can be passed to a STPPaymentCardTextField
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 = 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)
}
}