iOS integration guide
The Bouncer Insight iOS SDK integration guide.

Installing the CardVerify module

Please follow the general instructions for installing, setting up permissions, and configuring CardVerify.

Using Bouncer Scan to verify cards when users add them

Our VerifyCardAddViewController proactively verifies any cards that users add to your platform. To support this flow, you should use the VerifyCardAddViewController but you don't need to implement the optional fraudModelResultsVerifyCardAdd protocol method in the VerifyCardAddResult protocol:
1
import CardVerify
2
import UIKit
3
4
class VerifyAddFlowViewController: UIViewController, VerifyCardExplanationResult, VerifyCardAddResult {
5
@IBAction func buttonPressed() {
6
let vc = VerifyCardAddViewController(userId: self.currentUser.userId)
7
vc.cardAddDelegate = self
8
9
// only use this if you're using a "default to scan" flow
10
vc.enableManualEntry = true
11
12
viewController.present(vc, animated: true, completion: nil)
13
}
14
15
// MARK: -VerifyCardAddResult protocol implementation
16
func userDidCancelCardAdd(_ viewController: UIViewController) {
17
dismiss(animated: true)
18
}
19
20
func userDidScanCardAdd(_ viewController: UIViewController, creditCard: CreditCard) {
21
// Add the card details in `creditCard` to your card entry form
22
}
23
24
func userDidPressManualCardAdd(_ viewController: UIViewController) {
25
// The user pressed the "enter details manually" button
26
// navigate to your card entry form without filling in details
27
}
28
}
Copied!

Instrumenting credit card forms

To instrument credit card forms, add the following code to your card entry ViewController:
Stripe Form
Custom Form
1
import CardVerify
2
import Stripe
3
import UIKit
4
5
class PaymentFormViewController: UIViewController {
6
7
@IBOutlet weak var paymentCardTextField: STPPaymentCardTextField!
8
@IBOutlet weak var addCardButton: UIButton!
9
10
var creditCardFormListener: BouncerFormInstrumentation?
11
12
override func viewDidLoad() {
13
super.viewDidLoad()
14
15
guard let viewWithForm = paymentCardTextField.subviews.first else { return }
16
creditCardFormListener = BouncerFormInstrumentation(userId: self.currentUser.userId, viewWithForm: viewWithForm, fieldOrder: [.cardNumber, .expiry, .cvv, .postalCode], advanceButton: addCardButton)
17
}
18
}
Copied!
1
import CardVerify
2
import UIKit
3
4
class PaymentFormViewController: UIViewController {
5
6
@IBOutlet weak var cardNumberTextField: UITextField!
7
@IBOutlet weak var expiryTextField: UITextField!
8
@IBOutlet weak var cvvTextField: UITextField!
9
@IBOutlet weak var postalCodeTextField: UITextField!
10
@IBOutlet weak var addCardButton: UIButton!
11
12
var creditCardFormListener: BouncerFormInstrumentation?
13
14
override func viewDidLoad() {
15
super.viewDidLoad()
16
17
guard let viewWithForm = paymentCardTextField.subviews.first else { return }
18
creditCardFormListener = BouncerFormInstrumentation(userId: self.currentUser.userId, cardNumberTextField: cardNumberTextField, expiryTextField: expiryTextField, advanceButton: addCardButton, cvvTextField: cvvTextField, postalCodeTextField: postalCodeTextField)
19
}
20
}
Copied!

Logging signup and login events

To provide signals for our risk engine, we also log events around signup and login actions.

Signup events

In your user signup flow, create an UserCreateEvent object and invoke the recordSuccess method after creating a user successfully:
1
import CardVerify
2
3
class SignupViewController: UIViewController {
4
5
private let userCreateEvent = UserCreateEvent()
6
7
private func createUser(userName: String, password: String) -> Bool {
8
// create a user
9
val user = MyApi.createUser(userName, password)
10
if (user != null) {
11
userCreateEvent.recordSuccess(userId: user.id, loginIdentifier: userName)
12
}
13
14
return user != null
15
}
16
}
Copied!

Login events

In your login flow, create an UserLoginEvent object and invoke the recordSuccess method after a successful login attempt, and invoke the recordFailure method after an unsuccessful login attempt:
1
class UserLoginViewController: UIViewController {
2
3
private let userLoginEvent = UserLoginEvent()
4
private func userLogin(userName: String, password: String) {
5
// log the user in
6
guard let user = MyApi.getUserFromUserName(userName) else {
7
showLoginFailed()
8
return
9
}
10
user.login(password) { authToken in
11
if (authToken != null) {
12
userLoginEvent.recordSuccess(userId: user.id, loginIdentifier: userName)
13
} else {
14
userLoginEvent.recordFailure(loginIdentifier: userName)
15
showLoginFailed()
16
}
17
}
18
}
19
}
Copied!
Last modified 9mo ago