Apple Pay集成(一)准备工作
1.配置Merchant ID(商业ID)
1.1创建AppID
登录开发者中心,创建App ID。填写描述及Bundle ID后,在App Services里勾选Apple Pay以开启该功能。
![](https://img.haomeiwen.com/i2361081/8615202d523fe5f0.png)
![](http://upload-images.jianshu.io/upload_images/2361081-9015ddec32aa6b1a.png)
注意:由于星号通配符的不能开启一些App 服务(Apple Pay、推送等),所以只能使用明确的通配符
点击Continue后,会发现概览该App ID时,Apple Pay服务是等待配置状态的,接下来点击Register继续2.2操作。
![](http://upload-images.jianshu.io/upload_images/2361081-c35cf4f95f8633a3.png)
1.2创建Merchant ID,并绑定到相关App ID
在Merchant IDs中来创建一个Merchant ID,填写相关信息后Continue
![](http://upload-images.jianshu.io/upload_images/2361081-a7c344e7e9345702.png)
确认信息后,点击Register-->Done。由于加密需要证书,所以还要对刚创建的Merchant ID添加证书(加密根据证书来的)。Merchant ID点Edit
![](http://upload-images.jianshu.io/upload_images/2361081-2ae40c3d6214eb81.png)
这里询问是否支持中国以外的地区处理支付,这里要根据实际需求选择
![](http://upload-images.jianshu.io/upload_images/2361081-da97eb6efcad9abe.png)
Continue后,需要上传一个CSR文件
![](http://upload-images.jianshu.io/upload_images/2361081-275cb0017bb34592.png)
在本机的钥匙串中,从证书颁发机构请求证书
![](http://upload-images.jianshu.io/upload_images/2361081-36298ecea128c13c.png)
存储到本地后,选择刚才生成的证书,点Continue
![](http://upload-images.jianshu.io/upload_images/2361081-14065d130ee5f45b.png)
把生成的cer文件下载到本地,双击安装。这就完成了网页端的创建~
如果有小伙伴没有及时下载更新证书就会遇到下面的问题
到钥匙串中,查看刚才安装的cer,喜闻乐见的事情来了,证书颁发机构未知了???
![](http://upload-images.jianshu.io/upload_images/2361081-0a3a21ad94136e1e.png)
原来是系统跟证书的问题
解决方法:在这里下载安装就好了
http://www.apple.com/certificateauthority/
下载:
![](http://upload-images.jianshu.io/upload_images/2361081-f72cd07a12ffa202.png)
安装完就可以了
![](http://upload-images.jianshu.io/upload_images/2361081-e5cd245567b184e8.png)
===========昏割线==============
上传完证书,安装完之后继续就完成了创建Merchant ID
![](http://upload-images.jianshu.io/upload_images/2361081-3c1f86538165d2ae.png)
由于刚才创建的App ID中Apple Pay服务仍处于待配置状态,在App IDs列表中找到刚才创建的App ID展开,点击Edit对其进行编辑。
![](http://upload-images.jianshu.io/upload_images/2361081-f85223fbd5201a37.png)
在Enable Service中找到Apple Pay,点击Edit对其进行编辑。
![](http://upload-images.jianshu.io/upload_images/2361081-efc23dc64bbc2b07.png)
在弹出的界面中勾选对应的Merchant ID,Continue
![](http://upload-images.jianshu.io/upload_images/2361081-4e6cb6309c351d58.png)
然后Assign,此时就完成了为App ID添加Merchant ID。可以点开该App ID进行确认,可看到Apple Pay服务已可用
![](http://upload-images.jianshu.io/upload_images/2361081-1db7e164ea4d117f.png)
2.创建Xcode工程并为其开启Apple Pay
2.1使用Xcode创建工程,设置相关Bundle ID:
![](http://upload-images.jianshu.io/upload_images/2361081-31a3d46c52e78dd6.png)
注意:Apple Pay最低支持iOS8.0~
2.2开启Apple Pay功能
到Xcode的Capabilities中,找到Apple Pay开关,打开
![](http://upload-images.jianshu.io/upload_images/2361081-39c1babbed49c5f1.png)
会弹出选择机构的选项,选择相关机构Choose,然后在Apple Pay栏目下会显示出当前机构所有的商业ID,选择你的打勾就好了
![](http://upload-images.jianshu.io/upload_images/2361081-0f208269639b5851.png)
可以看到Steps里所有对勾都打上了,这就证明配置无误。
这篇文章介绍了Apple Pay集成的一些准备工作,代码部分看第二篇《Apple Pay集成(二)编码实战》吧。
2016年6月28日
以上~~