iOS PassKit框架(一)—— PKPaymentAuthorizationViewController

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/HDFQQ188816190/article/details/81539325

PKPaymentAuthorizationViewController 此类弹出apple pay视图控制器。

+ (BOOL)canMakePayments;// 设备是否能进行applepay支付
+ (BOOL)canMakePaymentsUsingNetworks:(NSArray<PKPaymentNetwork> *)supportedNetworks;
+ (BOOL)canMakePaymentsUsingNetworks:(NSArray<PKPaymentNetwork> *)supportedNetworks capabilities:(PKMerchantCapability)capabilties;

PKPaymentNetwork // 支付系统
{
    PKPaymentNetworkAmex API_AVAILABLE(ios(8.0), watchos(3.0)); // 美国运通卡
    PKPaymentNetworkCartesBancaires API_AVAILABLE(ios(11.2), watchos(4.2));
    PKPaymentNetworkChinaUnionPay API_AVAILABLE(ios(9.2), watchos(3.0)); // 中国银联卡
    PKPaymentNetworkDiscover API_AVAILABLE(ios(9.0), watchos(3.0)); // 发现卡
    PKPaymentNetworkIDCredit API_AVAILABLE(ios(10.3), watchos(3.2));
    PKPaymentNetworkInterac API_AVAILABLE(ios(9.2), watchos(3.0));
    PKPaymentNetworkJCB API_AVAILABLE(ios(10.1), watchos(3.1));
    PKPaymentNetworkMasterCard API_AVAILABLE(ios(8.0), watchos(3.0)); // 万事达卡
    PKPaymentNetworkPrivateLabel API_AVAILABLE(ios(9.0), watchos(3.0)); // 信用卡和借记卡
    PKPaymentNetworkQuicPay API_AVAILABLE(ios(10.3), watchos(3.2));
    PKPaymentNetworkSuica API_AVAILABLE(ios(10.1), watchos(3.1));
    PKPaymentNetworkVisa // 维萨卡
}

PKMerchantCapability // 商家支付能力
{
    PKMerchantCapability3DS                                  = 1UL << 0,   // 3DS卡
    PKMerchantCapabilityEMV                                  = 1UL << 1,   // EMV卡
    PKMerchantCapabilityCredit NS_ENUM_AVAILABLE_IOS(9_0) = 1UL << 2,   // 信用卡
    PKMerchantCapabilityDebit  NS_ENUM_AVAILABLE_IOS(9_0) = 1UL << 3    // 借记卡
}


- (nullable instancetype)initWithPaymentRequest:(PKPaymentRequest *)request; // 指定初始化方法

- (void)presentWithCompletion:(nullable void(^)(BOOL success))completion; // 弹出

- (void)dismissWithCompletion:(nullable void(^)(void))completion; // dismiss

@property (nonatomic, assign, nullable) id<PKPaymentAuthorizationViewControllerDelegate> delegate;  // 代理

包括以下方法:

@required
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller; // 支付完成回调 负责dismiss控制器

@optional

// 8.3后可用

//  将要去支付
- (void)paymentAuthorizationViewControllerWillAuthorizePayment:(PKPaymentAuthorizationViewController *)controller;


// 11.0后可用

 // 付款成功苹果服务器返回信息回调,做服务器验证
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                       didAuthorizePayment:(PKPayment *)payment
                                   handler:(void (^)(PKPaymentAuthorizationResult *result))completion;
// 送货方式回调
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didSelectShippingMethod:(PKShippingMethod *)shippingMethod
                                   handler:(void (^)(PKPaymentRequestShippingMethodUpdate *update))completion;
// 送货地址回调
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                  didSelectShippingContact:(PKContact *)contact
                                   handler:(void (^)(PKPaymentRequestShippingContactUpdate *update))completion;
// 支付方式回调
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                    didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod
                                   handler:(void (^)(PKPaymentRequestPaymentMethodUpdate *update))completion;

PKPaymentRequestUpdate
{
    PKPaymentAuthorizationResult
    PKPaymentRequestUpdate
    {
        PKPaymentRequestShippingMethodUpdate
        PKPaymentRequestShippingContactUpdate
        PKPaymentRequestPaymentMethodUpdate
    }
}

// 11.0后被废弃的方法 分别对应上面四个方法
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                       didAuthorizePayment:(PKPayment *)payment
                                completion:(void (^)(PKPaymentAuthorizationStatus status))completion;

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didSelectShippingMethod:(PKShippingMethod *)shippingMethod
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKPaymentSummaryItem *> *summaryItems))completion;

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                  didSelectShippingContact:(PKContact *)contact
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods, NSArray<PKPaymentSummaryItem *> *summaryItems))completion;

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                    didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod
                                completion:(void (^)(NSArray<PKPaymentSummaryItem *> *summaryItems))completion;

 

-- NORMAL --

-- NORMAL --
展开阅读全文

没有更多推荐了,返回首页