//
// CardIOPaymentViewControllerDelegateImpl.m
// Project
//
// Created by haibara on 12/12/17.
//

#import "CardIOPaymentViewControllerDelegateImpl.h"

@implementation CardIOPaymentViewControllerDelegateImpl

+ (instancetype)sharedInstance {
	static dispatch_once_t onceToken;
	static CardIOPaymentViewControllerDelegateImpl *instance;
	dispatch_once(&onceToken, ^{
		instance = [[self alloc] init];
	});
	instance.userDidProvideCreditCardInfoBlock = nil;
	return instance;
}

#pragma mark - <CardIOPaymentViewControllerDelegate>

- (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)cardInfo inPaymentViewController:(CardIOPaymentViewController *)paymentViewController {
	[paymentViewController.presentingViewController dismissViewControllerAnimated:YES completion:self.userDidProvideCreditCardInfoBlock ? ^{
		self.userDidProvideCreditCardInfoBlock(cardInfo);
	} : nil];
}

- (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)paymentViewController {
	[paymentViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

@end
