CTL*_*CTL 17 objective-c ios applepay
使用下面的标准UIAlertView代码将在Apple Pay PKPaymentAuthorizationViewController表下方显示警报.
[[[UIAlertView alloc] initWithTitle:@"Payment Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil] show];
Run Code Online (Sandbox Code Playgroud)
如何在付款授权书上方显示?或者是否有不同的方式为Apple Pay显示错误消息?我想在用户输入无效的送货地址时给出特定的错误消息.
你可以不显示UIAlertView在PKPaymentAuthorizationViewController系统的安全性,因为.
整个UI PKPaymentAuthorizationViewController通过远程视图控制器呈现.这意味着在您给出的PKPaymentRequest之外,不可能以其他方式设置或修改此视图的内容.
而对于处理Apple Pay错误,您必须使用PKPaymentAuthorizationViewControllerDelegate委托方法来显示付款已成功完成或有任何错误.
对于show PKPaymentAuthorizationViewController,目前的付款视图控制器为:
PKPaymentAuthorizationViewController *paymentVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
paymentVC.delegate = self;
[self presentViewController:paymentVC animated:true completion:nil];
Run Code Online (Sandbox Code Playgroud)
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus status))completion {
//=========================================
//=========================================
// Call your api here for charge payment and according to that api result show complition as follow
//========================================
//========================================
// Use your payment processor's SDK to finish charging your customer.
// When this is done, call:
completion(PKPaymentAuthorizationStatusSuccess);
// When this is Payment not completed, call:
// completion(PKPaymentAuthorizationStatusFailure);
// When this is Supplied billing address is insufficient or otherwise invalid, call:
// completion(PKPaymentAuthorizationStatusInvalidBillingPostalAddress);
// When this is Supplied postal address is insufficient or otherwise invalid, call:
// completion(PKPaymentAuthorizationStatusInvalidShippingPostalAddress);
// When this is Supplied contact information is insufficient or otherwise invalid, call:
// completion(PKPaymentAuthorizationStatusInvalidShippingContact);
}
// Sent to the delegate when payment authorization is finished. This may occur when
// the user cancels the request, or after the PKPaymentAuthorizationStatus parameter of the
// paymentAuthorizationViewController:didAuthorizePayment:completion: has been shown to the user.
//
// The delegate is responsible for dismissing the view controller in this method.
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller {
[self dismissViewControllerAnimated:true completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
在iOS 11中有一个新的回调
public func paymentAuthorizationController(_ controller: PKPaymentAuthorizationController, didAuthorizePayment payment: PKPayment,
handler completion: (PKPaymentAuthorizationResult) -> Void)
Run Code Online (Sandbox Code Playgroud)
如您所见,处理程序从中更改
completion: (PKPaymentAuthorizationStatus) -> Void)
Run Code Online (Sandbox Code Playgroud)
至
handler completion: (PKPaymentAuthorizationResult) -> Void)
Run Code Online (Sandbox Code Playgroud)
从iOS 11开始,我们将在完成处理程序中获得一个status数组NSErrors.
有关详细信息,请查看今年的会议.
| 归档时间: |
|
| 查看次数: |
811 次 |
| 最近记录: |