我们正在将Apple Pay集成到我们的应用程序中,并成功完成了设置,并取回了“支付令牌”,但仍显示“支付未完成”错误。
-(IBAction)btnApplePayClicked:(id)sender
{
if([PKPaymentAuthorizationViewController canMakePayments]) {
NSLog(@"Woo! Can make payments!");
PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
PKPaymentSummaryItem *widget1 = [PKPaymentSummaryItem summaryItemWithLabel:@"Widget 1"
amount:[NSDecimalNumber decimalNumberWithString:@"0.99"]];
PKPaymentSummaryItem *widget2 = [PKPaymentSummaryItem summaryItemWithLabel:@"Widget 2"
amount:[NSDecimalNumber decimalNumberWithString:@"1.00"]];
PKPaymentSummaryItem *total = [PKPaymentSummaryItem summaryItemWithLabel:@"Grand Total"
amount:[NSDecimalNumber decimalNumberWithString:@"1.99"]];
request.paymentSummaryItems = @[widget1, widget2, total];
request.countryCode = @"US";
request.currencyCode = @"USD";
request.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
request.merchantIdentifier = @"merchant.com.*******";
request.merchantCapabilities = PKMerchantCapability3DS;
PKPaymentAuthorizationViewController *paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
paymentPane.delegate = self;
[self presentViewController:paymentPane animated:TRUE completion:nil];
} else {
NSLog(@"This device cannot make payments");
}
}
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus status))completion
{
NSLog(@"Payment was authorized: %@", payment); //receiving Payment token
}
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
{
NSLog(@"Finishing payment view controller");
[controller dismissViewControllerAnimated:TRUE completion:nil];
}
沙盒环境中的测试卡
FPAN: 4761 1200 1000 0492
Expiration Date: 11/2022
CVV: 533
收到付款令牌后,我们该怎么办? 任何想法/建议都会有所帮助。谢谢