Implementing the VoucherCreationFlowDelegate

VoucherCreationFlowDelegate is used to delegate out of the VouchrSDK throughout the create process for input and additional customization.

Required Methods

At a minimum, the following methods must be implemented:

func voucherCreationShowPayment(on viewController: UIViewController!, for voucher: Voucher!, isEditing: Bool, onCompletion completion:(([AnyHashable : Any]?, Error?) -> Void)!)

func showLogin(on viewController: UIViewController!, onCompletion completion: ((Error?) -> Void)!)

Example Implementation

func voucherCreationShowPayment(on viewController: UIViewController!, for voucher: Voucher!, isEditing: Bool, onCompletion completion:(([AnyHashable : Any]?, Error?) -> Void)!) {
    // optionally present a view controller here that collects payment information 
    let fakeCreditCardInfo = [
        "paymentType": "CREDIT_CARD",
        "billingCardNumber": self.encryptString(string:"4111111111111111"),
        "billingCVV": self.encryptString(string:"111"),
        "billingCardHolderName": "Test test",
        "billingAddress1": "123 anywhere street",
        "billingCity": "San Fransisco",
        "billingRegion": "CA",
        "billingCountry": "US"
    ]

    if (completion != nil) {
        completion(fakeCreditCardInfo, nil);
    }
}

func showLogin(on viewController: UIViewController!, onCompletion completion: ((Error?) -> Void)!) {
    self.facebookManager?.login(from:viewController, handler: {[weak self] (result: Any?, error: Error?) in
        if (completion != nil) {
            completion(error)
        }
    })
}