概述
Merchant ID
在苹果开发网站上,添加Merchant ID
为Merchant ID 配置Apple Pay证书
CSR文件:
指定秘钥对信息 算法:ECC key size:256bits
说明:中国区接入ApplePay使用的算法时RSA方式
Xcode配置
Xcode 6.1+
Xcode Capabilities 设置 Apple Pay 开关on
选中添加的Merchant ID
头文件引用
#import <PassKit/PassKit.h>
PKPaymentAuthorizationViewController
指定初始化方法:
- (instancetype)initWithPaymentRequest:(PKPaymentRequest *)request;
展现方式:
presentViewController
是否支持ApplePay
- iOS版本 8.1+
- 调用PKPaymentAuthorizationViewController判断:
-
+ (BOOL)canMakePayments; + (BOOL)canMakePaymentsUsingNetworks:(NSArray *)supportedNetworks;
-
- 目前支持Apple Pay的应用内支付的设备有:iPhone 6、iPhone 6 Plus、iPad Air 2、iPad mini3
- Apple watch 不支持应用内支付
PKPaymentRequest
属性说明:
- countryCode (字符串)例:US(ISO国家编码)
- currencyCode (字符串)例:USD(ISO货币编码)
- merchantCapabilities(枚举,支持或运算)例:PKMerchantCapabilityEMV, PKMerchantCapability3DS
- merchantIdentifier(字符串)例:merchant.merchant3.ggg.com
- supportedNetworks(数组)例:PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard
- paymentSummaryItems (数组,最后的对象必须是总价格)存放类型:PKPaymentSummaryItem
- requiredBillingAddressFields(枚举,支持或运算)例:PKAddressFieldNone
- requiredShippingAddressFields(枚举,支持或运算)例:PKAddressFieldNone
- shippingMethods(数组)存放类型:PKShippingMethod
- applicationData(NSData)
PKPaymentRequest 的 paymentSummaryItems
PKPaymentSummaryItem
初始化:
+ (instancetype)summaryItemWithLabel:(NSString *)label amount:(NSDecimalNumber *)amount;
属性
- label
- amount
补充:NSDecimalNumber
一个以10为底数的数值。可以使用指定尾数和指数的方式来创建这个类的实例,也可以通过指定字符串和locale来实例化。
例: 12.75
NSDecimalNumber *subtotalAmount = [NSDecimalNumber decimalNumberWithMantissa:1275 exponent:-2 isNegative:NO];
像float或者Double这样的IEEE浮点数类型是不适合作财务计算的,这些数据类型使用的是以2为底数的数值表示方法,有一些十进制数值不能准确得被表示--例如0.42必须以0.41999这样的循环小数来近似表示,而这种近似表示常常会造成财务计算的错误结果。
PKShippingMethod
label 例:空运
amount
identifier
detail(字符串)例:快速送货,2天必到
PKPaymentAuthorizationViewControllerDelegate
required:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus status))completion;
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller;
PKPaymentAuthorizationStatus :
PKPaymentAuthorizationStatusSuccess
PKPaymentAuthorizationStatusFailure
Optional:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didSelectShippingMethod:(PKShippingMethod *)shippingMethod
completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *summaryItems))completion;
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didSelectShippingAddress:(ABRecordRef)address
completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *shippingMethods, NSArray *summaryItems))completion;
流程
验证流程
服务端处理
- 把支付信息,以及支付流程+所需的其他信息,一起发送给服务器。
- 验证支付数据的哈希表和签名
- 为加密过的支付数据解码
- 向支付处理系统提交支付数据
- 向订单追踪系统提交订单
PaymentToken内容
例如:
解token的方法
https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
Demo
TODO:待补充
参考网站
http://www.cocoachina.com/ios/20150126/11019.html
https://developer.apple.com/library/ios/documentation/PassKit/Reference/PKPaymentRequest_Ref/#//apple_ref/c/tdef/PKMerchantCapability
http://www.cocoachina.com/ios/20140911/9589.html
http://www.cocoachina.com/ios/20140910/9573.html
http://www.cocoachina.com/ios/20141024/10026.html
转载于:https://my.oschina.net/u/859523/blog/752190
最后
以上就是安静雪糕为你收集整理的Apple Pay 应用内支付Merchant IDXcode配置头文件引用PKPaymentAuthorizationViewController 是否支持ApplePayPKPaymentRequestPKPaymentRequest 的 paymentSummaryItems PKPaymentSummaryItem 补充:NSDecimalNumber PKShippingMethodPKPaymentAuthorizationViewControllerDelegate流程验证流程服务的全部内容,希望文章能够帮你解决Apple Pay 应用内支付Merchant IDXcode配置头文件引用PKPaymentAuthorizationViewController 是否支持ApplePayPKPaymentRequestPKPaymentRequest 的 paymentSummaryItems PKPaymentSummaryItem 补充:NSDecimalNumber PKShippingMethodPKPaymentAuthorizationViewControllerDelegate流程验证流程服务所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复