DyScan
  • DyScan Integration Guide
  • iOS Integration Guide
  • Android Integration Guide
  • React Native Integration Guide
  • Cordova Integration Guide
  • Integrity Verification
  • Migrating from card.io
    • Migrating from card.io (iOS)
    • Migrating from card.io (Android)
  • Integrating with Stripe
    • Integrating with Stripe (iOS)
    • Integrating with Stripe (Android)
  • Alternate Ways to Integrate iOS
    • Integrating with Swift Package Manager
    • Integrating with Carthage
    • Integrating as a Framework
  • Alternate Ways To Integrate Android
    • Manually Importing the Library
    • Using DyScanView
  • MIGRATING FROM 1.0.X TO 1.1.X
    • Migrating from 1.0.x to 1.1.x (iOS)
    • Migrating from 1.0.x to 1.1.x (Android)
    • Migrating from 1.0.x to 1.1.x (React Native)
Powered by GitBook
On this page

Was this helpful?

  1. Integrating with Stripe

Integrating with Stripe (iOS)

PreviousMigrating from card.io (Android)NextIntegrating with Stripe (Android)

Last updated 5 years ago

Was this helpful?

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.

STPCardParams
STPPaymentCardTextField
STPPaymentMethodCardParams
STPPaymentCardTextField
General Integration Guide