Summary of issues encountered in developing Apple Pay

Source: Internet
Author: User

Originally wanted to briefly summarize the Apple Pay development process of a few problems, the results are the following this article all met, simply reproduced, the author of the relevant resources collated more detailed, comparative reference value

In general, we have done APNs push, the application merchant ID and associated to the Apple ID, request a certificate, generate provisioning profile and other steps are similar

And then my real machine debugging has two places failed, the following also summarizes, I carry out alone to say:

1, Payment request is invalid:check your entitlements. Connection to Remote Alert view service failed

Reason: Careless, put merchant ID wrong.

The reason for the carelessness is also listed, because, I have a problem is careless, but because the integration of Apple payment process, it is necessary to configure the interface in the capabilities with a drop-down list to select a merchant ID, and the code is also written once, if you have multiple merchant ID, or switch over during development, the value of the drop-down list and the value of the handwriting in the code to remember synchronization, no synchronization, the same can be the above error

2, not into the Didauthorizepayment method.

Cause, payrequest.merchantcapabilities = pkmerchantcapability3ds| Pkmerchantcapabilityemv. See, the EMV in the back has to be added.

Most of the students who meet the same problem are expected to see WWDC video, the inside of the small brother said 3DS is necessary, obviously in our big celestial, EMV is also necessary, the following is more detailed description.

Okay, here's the full text of the reprint.

Source: Http://www.lilongcnc.cc/2016/02/28/9-applepay Payment interface Call and get payment parameters UnionPay Debit process/#comment-4

Apple Pay seems to be hot these two days, and Apple Pay is integrated into the app you've downloaded, ' Enjoy ' and ' Us '. I've also recently looked at the integration of Apple Pay, and the customer service is really simple, but I need to remind you a few of my own lie down and where I'm having problems. Then I will give you some of my reference posts.

Previous words

Apple Pay功能支持的是iPhone6以上,iOS9.2以上. 且目前企业级证书是不支持的,只有个人开发者证书才支持So all the things we mentioned below are in the context of satisfying this premise.

The main structure of the article is as follows:

    • Client Apple Pay payment Interface code flow

    • Real UnionPay debit and payment process

In addition, the two mines I encountered were:

    • After registering the merchant ID, the Xcode configuration is complete, but the runtime appears "Payment request is invalid:check your entitlements. Connection to Remote Alert view service failed "case

    • Enter the fingerprint (enter pin), after the payment is completed, does not enter the Didauthorizepayment method

One of the problems encountered:

    • A profile created from the app ID that opens Apple Pay will change to "invalid" in the state you just created, or the state automatically changes from "activity" to "invalid."
Client Apple Pay payment Interface code flow

Here I am divided into three parts, as follows:

    1. Register Merchant ID, configure payment certificate, create payment app ID, create profile.
    2. Local judgment is whether Apple Pay is supported, and then create a sheet that shows the payment
    3. After payment is completed, the callback method getsPayment相关加密数据
Register Merchant ID, configure payment certificate, create payment app ID, create profile.

This step is simple, recommended by the author of the book Yasin的简书 "Apple Pay preparation-application Merchantid and corresponding certificate detailed graphic tutorial", Link Address: http://www.jianshu.com/p/2e5e45afc246

Local judgment is whether Apple Pay is supported, and then create a sheet that shows the payment

This step is specific code, not too much technical content. Related articles are also written very well, directly read these articles and the corresponding demo can be. It's important to mention that Apple pay has the option of receiving and filling in the shipping address, but this is not a good way to do it in our current app.

Recommended Demo:

    1. This demo is more comprehensive, including model judgment, the first push. Address: Https://github.com/SummertimSadness/ApplePayDemo
    2. This article seems to be written by the Indian sister, divided into part1 and part2 two parts, and with a demo address. The two demos have the code to choose the receiving method and fill in the delivery address. 苹果中,用户选择收货地址和收货方式,是通过回调代理方法的方式来获取的article address: https://itechroof.wordpress.com/2016/01/15/apple-pay-part-1/
    3. The demo address was simple, but there was no judgment on whether or not the device supported Apple Pay, but at the very beginning, I communicated with the author many times, as 回调不进入**didAuthorizePayment**方法 discussed with the author. Demo Address: https://github.com/lintide/ Applepaydemo
After payment is completed, the callback method gets Payment相关加密数据

After we have entered the fingerprint, and enter the correct PIN code, the following two methods are returned:

 -(void) Paymentauthorizationviewcontroller: ( Pkpaymentauthorizationviewcontroller *) Controller didauthorizepayment: (pkpayment *) Payment completion: (void (^) (pkpaymentauthorizationstatus)) Completion {NSLog (@ "Verify fingerprint success, Apple back to UnionPay card related encrypted data did authorize payment token:%@,%@", Payment.token, Payment.token.transactionidentifier); completion ( pkpaymentauthorizationstatussuccess);} -(void) Paymentauthorizationviewcontrollerdidfinish: ( Pkpaymentauthorizationviewcontroller *) Controller {nslog (@ "Payment Complete or user clicks Cancel"); [Controller Dismissviewcontrolleranimated:controller Completion:null];}    

The first method didAuthorizePayment , as written in log, is returned after success. We have to payment the data, whether we are dealing with encrypted data with a third-party SDK or our own company backend servers. In addition, the actual debit process is mentioned in the following section.

The second way, after we present the Apple Pay-related sheet, we click on the "Cancel" button and verify the fingerprint success, the system will call back this method, we mainly in this method, the bounce up the payment sheet to diss down.

As for the other methods, I do not mention here (in addition to the above and in the payment sheet the user fill in the delivery address and choose the way of receiving goods), we can click to see the file.

Real UnionPay debit and payment process

When we didAuthorizePayment get to the method, Payment相关加密数据 it's not 真正的完成了扣款的交易 . Here we need to mention Aplle Pay他只是一种代为扣款的方式 , just like you directly to the merchant cash, to cash is a way, but the real deduction of money, or to wait for the merchant to find you change back to be a real completion. In the mainland, UnionPay is like this big business.

When you officially access the Apple Pay feature, you also need to register: https://open.unionpay.com/ajweb/product/detail?id=80

We also need to use Payment相关加密数据 and UnionPay backstage to do the docking business. There are also two forms:
The first is the use of a third-party SDK, the advantage is that we do not have to deal with encrypted data, the disadvantage is that the payment interface we can not customize. Refer to UnionPay related documents. Address: https://open.unionpay.com/ajweb/help/file/ Techfile?productid=80

The second is to decrypt the encrypted data in the background of the company and call the UnionPay interface. The advantage of this approach is that you can control the payment interface, the drawback is that the decryption process is particularly hard.

Next

About the actual demo example, we recommend that you follow the following three address, of which two authors are applying for UnionPay's access eligibility, presumably after the relevant article will be updated. There is also a "Enjoy" of the developers committed to a period of time will be 后台解析Payment相关加密数据和银联支付相关 , the need for students can continue to pay attention.

Address One: Https://github.com/lintide/ApplePayDemo

Address two: http://www.cocoachina.com/ios/20160219/15345.html

Address three: http://blog.nswebfrog.com/2016/02/20/apple-pay-analysis/

Tell me about the Thunder and the problem.

In addition, the two mines I encountered were:

? After registering the merchant ID, the Xcode configuration is complete, but the runtime appears "Payment request is invalid:check your entitlements. Connection to Remote Alert view service failed "case

这个问题Troubled me one day, the problem appeared to me to be too negligent. Carelessness kills people. We should note that after capability in Xcode has chosen the merchant ID, we also need to modify the merchant ID in this line of code.

payment.merchantIdentifier = @"merchant.com.lauren.nihao11";

? Enter the fingerprint (enter pin), after the payment is completed, does not enter the Didauthorizepayment method

这个问题It was also a bit depressing, because it was going to be in the simulator. Later found that we in the designation of Merchantcapabilities, must have PKMerchantCapability3DS and PKMerchantCapabilityEMV . Otherwise only the callback will be entered paymentAuthorizationViewControllerDidFinish . Other two ' pkmerchantcapabilitycredit ' and ' pkmerchantcapabilitydebit ' can also be added as appropriate.

payment.merchantCapabilities = PKMerchantCapability3DS | PKMerchantCapabilityEMV | PKMerchantCapabilityCredit | PKMerchantCapabilityDebit;

One of the problems encountered:

? A profile created from the app ID that opens Apple Pay will change to "invalid" in the state you just created, or the state automatically changes from "activity" to "invalid."

这个问题It doesn't seem like it's just the time to create a profile with an app ID that opens Apple Pay. The solution is to click on the corresponding description file, then click ' Edit ' and then ' Generate ' again.

End

Apple Pay Programming Guide: Http://www.jianshu.com/p/a5342940afa3

Apple Pay Development Document: Https://developer.apple.com/apple-pay/Getting-Started-with-Apple-Pay.pdf

Swift Related: http://nshipster.com/apple-pay/

Others: http://www.cocoachina.com/ios/20140910/9573.html

Summary of issues encountered in developing Apple Pay

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.