Hello. This is T.K. from Navitime Japan Travel Development.
Recently, many cashless payment apps have appeared. Therefore, in order to aim for a site that is easy for users to use We are increasing payments on the Web other than credit cards.
Among the additional payments, I would like to talk about the difficult introduction of Apple Pay.
First of all, the first thing I struggled with was the communication method leading to payment. Like a credit company, I thought it would be complete by communicating with one company. However, with payment methods such as Apple Pay, it is necessary to run communication between the Apple Pay company and the payment agency.
Next is the SandBox settings. Apple Pay is used by linking a credit card to the iPhone. However, it is dangerous to tie your credit card at the time of development.
That's why Apple has a credit card for verification. Please refer to here when developing.
Points to worry about
Authentication between Apple and the payment agent is required to access the Apple Pay server. The registration method may differ slightly depending on the payment agent. Please note.
With the renewal of the Apple site, this is the most annoying part. This registration can be divided into the following five.
Create a merchant ID at Apple Developer (https://developer.apple.com/account/). If the merchant ID is provided by the payment agent, please register it. By registering this, you can determine the company information that Apple has settled.
Points to worry about
Register the CSR file of the payment agency in Apple Developer to link the payment agency with Apple.
Points to worry about
Register the site domain where you want to deploy Apple Pay payments. If you have multiple domains, you need to register for each domain.
RewriteRule ^/.well-known/apple-developer-merchantid-domain-association.txt /hoge/apple-developer-merchantid-domain-association.txt [L]
point
This is the last registration on the Apple site.
The P12 file is used for client authentication during development. Create "ApplePayMerchantIdentity.p12" from "merchant_id.cer" with key chain access (Reference)
The development was done with reference to GitHub of here. You can get a Token using Apple Pay.js provided by Apple.
In development, I was worried about client authentication with java. "Apple_pay_conf.php, apple_pay_comm.php" described on the GitHub site is described in php, and I could not find many reference sites for introducing Apple Pay in java.
The pem used in php cannot be used for client authentication in Java. So, use the p12 file you created earlier.
If you create Java by referring to the here site, authentication will pass and you can use the token of Apple Pay.
You will be able to make payments with Apple Pay by using the API of the payment agency for this token.
I can get the response information at the time of Java client authentication. For some reason, the phenomenon that only a certain environment is not displayed has occurred.
When I checked the difference, it was because of the difference in the JDK. If it doesn't work, try increasing the JDK version.
This time, Apple Pay has been introduced on the SP page of LCC and hotels. I hope you can refer to it. https://travel.navitime.co.jp/ja/booking/?reserveType=lcc&cid=qiita.article https://travel.navitime.co.jp/ja/booking/hotel?cid=qiita.article
Thank you for reading the long text to the end. The introduction of Apple Pay took a lot of time around registration and authentication. I hope that many people will be able to smoothly introduce payment in this article.
Recommended Posts