我正在尝试使用 world pay 及其 SDK HERE https://github.com/Worldpay/worldpay-lib-ios通过 Apple Pay 付款。在我的应用程序中,此付款是通过通知完成的,用户单击通知,我的应用程序打开并显示苹果支付视图。
当我尝试使用此行提出付款请求时(按照下面的代码)
let request = wp.createPaymentRequest(withMerchantIdentifier: ApplePaySwagMerchantID)
但是我的应用程序崩溃:
2017-03-30 20:38:20.026378 CarGo[757:79619] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Worldpay createPaymentRequestWithMerchantIdentifier:]: unrecognized selector sent to instance 0x1740fea00'
我不确定是什么原因造成的,或者如何调试它?
我在应用程序委托中运行的完整方法:
func makePayment(locationString: String){
let defaults = UserDefaults.standard
let topWindow: UIWindow = UIWindow(frame: UIScreen.main.bounds)
topWindow.rootViewController = UIViewController()
topWindow.windowLevel = UIWindowLevelAlert + 1
topWindow.makeKeyAndVisible()
let wp: Worldpay = Worldpay.sharedInstance();
wp.clientKey = "xxxxxxx";
wp.reusable = true;
let request = wp.createPaymentRequest(withMerchantIdentifier: ApplePaySwagMerchantID)
request?.supportedNetworks = SupportedPaymentNetworks
request?.countryCode = "GB"
request?.currencyCode = "GBP"
request?.merchantCapabilities = PKMerchantCapability.capability3DS
var decimalValue = NSDecimalNumber(string: defaults.string(forKey: locationString))
decimalValue = decimalValue.multiplying(by: 100)
self.transactionsDescription = "Toll Payment: " + locationString
self.transactionCost = decimalValue.intValue
request?.paymentSummaryItems = [
PKPaymentSummaryItem(label: "Toll Payment: " + locationString, amount:NSDecimalNumber(string: defaults.string(forKey: locationString)))
]
let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request!)
applePayController.delegate = self
topWindow.rootViewController?.present(applePayController, animated: true, completion: nil)
}
我的桥头文件:
#import "Worldpay.h"
#import "APMController.h"
#import "WorldpayAPMViewController.h"
#import "ThreeDSController.h"
#import "WorldpayCardViewController.h"
#import "Worldpay+ApplePay.h"