Menu

Integrating with Stripe (iOS)


First, follow the steps in Parts I and II of our General Integration Guide.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 userDidCancel(_ paymentViewController: DyScanViewController!) {
        paymentViewController.dismiss(animated: true){
        
        let viewController = CardFieldViewController()
        let navigationController = UINavigationController(rootViewController: viewController)
        self.present(navigationController, animated: true, completion: nil)
        }
    }
    
    func userDidProvide(_ cardInfo: DyScanCreditCardInfo!, in paymentViewController: DyScanViewController!) {
        
        let viewController = CardFieldViewController()
        let navigationController = UINavigationController(rootViewController: viewController)

        paymentViewController.dismiss(animated: true){
        
        if let info = cardInfo {
            let card: STPCardParams = 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)
    }
}

        

Here, CardFieldViewController is a UIViewController containing an STPPaymentCardTextField object called cardField, which can be set to the DyScan results.

Get Started