标签:
#import "ViewController.h" #import "CardIO.h" @interface ViewController ()<CardIOPaymentViewControllerDelegate> @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(100, 100, 100, 100); btn.backgroundColor =[UIColor cyanColor]; [btn addTarget:self action:@selector(pressBtn) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; } -(void)pressBtn{ CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self]; scanViewController.modalPresentationStyle = UIModalPresentationFormSheet; [self presentViewController:scanViewController animated:YES completion:nil]; } #pragma mark - CardIOPaymentViewControllerDelegate - (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)paymentViewController { NSLog(@"Scan succeeded with info: %@", info); // Do whatever needs to be done to deliver the purchased items. [self dismissViewControllerAnimated:YES completion:nil]; UILabel * label = [[UILabel alloc]init]; label.frame = CGRectMake(100, 250, 100, 100); label.text = [NSString stringWithFormat:@"Received card info. Number: %@, expiry: %02lu/%lu, cvv: %@.", info.redactedCardNumber, (unsigned long)info.expiryMonth, (unsigned long)info.expiryYear, info.cvv]; } - (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)paymentViewController { NSLog(@"User cancelled scan"); [self dismissViewControllerAnimated:YES completion:nil]; } -(void)viewWillAppear:(BOOL)animated{ [CardIOUtilities preload]; }
标签:
原文地址:http://www.cnblogs.com/sayimba/p/5666273.html