//
// PayPalPaymentDelegateImpl.m
// Project
//
// Created by haibara on 12/26/17.
//

#import "PayPalPaymentDelegateImpl.h"

@implementation PayPalPaymentDelegateImpl

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

#pragma mark - <PayPalPaymentDelegate>

- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment {
	[paymentViewController.presentingViewController dismissViewControllerAnimated:YES completion:self.didCompletePaymentBlock ? ^{
		self.didCompletePaymentBlock(completedPayment);
	} : nil];
}

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

@end
