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:

- (void)voucherCreationShowPaymentOnViewController:(UIViewController *)viewController forVoucher:(Voucher *)voucher isEditing:(BOOL)isEditing onCompletion:(void(^)(NSDictionary *paymentInfo, NSError *error))completion;

- (void)showLoginOnViewController:(UIViewController *)viewController onCompletion:(void(^)(NSError *error))completion;

Example Implementation

- (void)voucherCreationShowPaymentOnViewController:(UIViewController *)viewController
                                        forVoucher:(Voucher *)voucher
                                      onCompletion:(void(^)(NSDictionary *paymentInfo, NSError *error))completion {
    // optionally present a view controller here that collects payment information                                      
    NSDictionary *fakeCreditCardInfo = @{@"paymentType": @"CREDIT_CARD",
                                         @"billingCardNumber": [self encryptString:@"4111111111111111"],
                                         @"billingCVV": [self encryptString:@"111"],
                                         @"billingCardHolderName": @"Test test",
                                         @"billingAddress1": @"123 anywhere street",
                                         @"billingCity": @"San Fransisco",
                                         @"billingRegion": @"CA",
                                         @"billingCountry": @"US"};
    if (completion) {
        completion(fakeCreditCardInfo, nil);
    }
}

- (void)showLoginOnViewController:(UIViewController *)viewController onCompletion:(void(^)(NSError *error))completion {
    [self.facebookManager loginFromViewController:viewController 
                                        onSuccess:^{
                                            if (completion) {
                                                completion(nil);
                                            }
                                        } onError:^(NSError *error) {
                                            if (completion) {
                                                completion(error);
                                            }
                                        }];
}

Optional Methods

Example Implementation

- (NSArray <id<SectionDataSourceProtocol>> *)summaryScreenDataSourcesForVoucher:(Voucher *)voucher {
    // You can mix default and custom sections

    // default data source
    SummaryScreenClaimerInfoDataSource *claimerInfoDataSource = [[SummaryScreenClaimerInfoDataSource alloc] initWithClaimer:voucher.claimer
                                                                                                                  claimDate:voucher.claimDate
                                                                                                                vouchrTheme:self.vouchrTheme];

    // custom data source
    CustomSummaryScreenClaimerInfoDataSource *customDataSource = [CustomSummaryScreenClaimerInfoDataSource dataSourceWithVoucher:voucher];

    return @[claimerInfoDataSource, customDataSource];
}

- (void)showDisclaimerForPaymentMerchantInfo:(PaymentMerchantInfo *)paymentMerchantInfo
                            onViewController:(UIViewController *)viewController
                              withCompletion:(void(^)(void))onCompletion {
    // some merchants require accepting a disclaimer / UELA before choosing this payment option
    if (paymentMerchantInfo.type == PaymentMerchantInfoVanillaVisa) {
        [self showDisclaimerForVanillaVisaWithCompletion:onCompletion];
    } else {
        onCompletion();
    }
}