2014-10-05 89 views

回答

2

這是它的代碼片段。調用此方法將調用Apple Pay的控制器表格

-(void)handlesApplePay 
{ 

    @try { 

     PKPaymentSummaryItem *paymentSummary = [PKPaymentSummaryItem summaryItemWithLabel:@"Credit Card" amount:[NSDecimalNumber decimalNumberWithString:@"20.00"]]; 

     NSArray *summaryItem = [[NSArray alloc] initWithObjects:paymentSummary, nil]; 

     //Creates the type of credit card it wil support 
     NSArray *supportPaymentType = [[NSArray alloc] initWithObjects:PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, nil]; 

     PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc]init]; 

     //This is the merchant id you create from the provisioing profile page 
     //developer.apple.com 
     paymentRequest.merchantIdentifier = @"merchant.com.ApplePay"; 
     paymentRequest.paymentSummaryItems = summaryItem; 
     paymentRequest.countryCode = @"EN"; 
     paymentRequest.currencyCode = @"USD"; 
     paymentRequest.supportedNetworks = supportPaymentType; 
     paymentRequest.merchantCapabilities = PKMerchantCapabilityEMV; 

     PKPaymentAuthorizationViewController *paymentAuthController = [[PKPaymentAuthorizationViewController alloc]initWithPaymentRequest:paymentRequest]; 
     paymentAuthController.delegate = self; 

     [self presentViewController:paymentAuthController animated:YES completion:nil]; 
    } 
    @catch (NSException *exception) { 

    } 


} 
相關問題