我正在研究Stripe付款集成,并且正在使用“标准”集成在iOS(Swift)中实现Stripe。为此,我指的是本文档“ https://stripe.com/docs/mobile/ios”和演示代码:“ https://github.com/stripe/stripe-ios”,并指的是“标准”集成演示。
我已经成功地在应用程序中实现了信用卡支付,并且可以在沙盒和实时环境中完美运行。
现在,我必须使用Stripe集成Apple Pay。但是我无法做到这一点。
这些是我正在使用的代码:
CheckoutViewController.swift
@objc func didTapApplePay() {
self.paymentInProgressApplePay = true
let merchantIdentifier = "merchant.com.companyName.appName"
let paymentRequest = Stripe.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD")
// Configure the line items on the payment request
paymentRequest.paymentSummaryItems = [
PKPaymentSummaryItem(label: "Fancy Hat", amount: 50.00),
// The final line should represent your company;
// it'll be prepended with the word "Pay" (i.e. "Pay iHats, Inc $50")
PKPaymentSummaryItem(label: "iHats, Inc", amount: 50.00),
]
if Stripe.canSubmitPaymentRequest(paymentRequest) {
// Setup payment authorization view controller
let paymentAuthorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest)
paymentAuthorizationViewController?.delegate = self as! PKPaymentAuthorizationViewControllerDelegate
// Present payment authorization view controller
present(paymentAuthorizationViewController!, animated: true)
}
else {
// There is a problem with your Apple Pay configuration
print("There is a problem with your Apple Pay configuration")
}
// self.paymentContext.requestPayment()
}
在上面的代码中,我在控制台中得到的响应是“您的Apple Pay配置存在问题”
在应用程序中完成以下操作:
if Stripe.deviceSupportsApplePay(){
print("Device support apple pay")
}
else{
print("Device does not support apple pay")
}
在上面的代码中,我在控制台中得到的响应是“ 设备不支持苹果付款”
我真的无法弄清楚到底是什么问题?我在做什么错了?