WorldPay Apple Pay SDK无法识别的选择器发送到实例

时间:2017-03-30 19:59:08

标签: ios swift applepay worldpay

我正在尝试通过Apple pay使用全球付款及​​其SDK https://github.com/Worldpay/worldpay-lib-ios进行付款。在我的应用程序中,此付款通过通知完成,用户点击通知,我的应用程序打开,并显示苹果付款视图。

当我尝试使用此行付款请求(请参阅下面的代码)时

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'

我不确定是什么导致这种情况或如何进行调试?

我在app delegate中运行的完整方法:

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"

1 个答案:

答案 0 :(得分:0)

我想我可能已经找到了这个问题。您是否在Objective-C桥接标题中包含以下导入?

import "Worldpay+ApplePay.h"

此类别使用与Apple Pay相关的方法扩展WorldPay类,并且可能包含相关方法。

编辑:

确保在-ObjC项目的Other Linker Flags媒体资源中添加Build Settings个链接标记。