A story that struggled with the introduction of Web Apple Pay

A story that struggled with the introduction of Web Apple Pay

Introduction

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.

Target audience

Range not covered

table of contents

Communication method leading to payment

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.

applepay-certificate.png

SandBox settings

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

Register with Apple Developer

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.

  1. Add MerchantId
  2. Register the CSR file
  3. Registration of Merchant Domains
  4. Register for Apple Pay Merchant Identity Certificate
  5. P12 file creation

Add MerchantId

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.

  1. Transition to "Certificates, Identifiers & Profiles / Identifiers / Merchant IDs" in Apple Developer
  2. Press "+" of Identifiers, select "Merchant IDs", and register merchantId in Identifier.

Points to worry about

Register CSR file

Register the CSR file of the payment agency in Apple Developer to link the payment agency with Apple.

  1. Register the CSR file from the MerchantId created by Apple Developer because it was provided by the payment agent in the "Apple Pay Payment Processing Certificate".
  2. Download "apple_pay.cer" from 1 and have it registered with the payment agency.

Points to worry about

Registration of Merchant Domains

Register the site domain where you want to deploy Apple Pay payments. If you have multiple domains, you need to register for each domain.

  1. Register your domain in "Merchant Domains" under Apple Developer (https://developer.apple.com/account/).
  2. After registration, you can download "apple-developer-merchantid-domain-association.txt". Place it on the site of the registered domain. This time, it will be placed under "hoge".
  3. From the apache settings, set the following and hit "/.well-known/apple-developer-merchantid-domain-association.txt", the contents of "apple-developer-merchantid-domain-association.txt" Is displayed.
RewriteRule ^/.well-known/apple-developer-merchantid-domain-association.txt /hoge/apple-developer-merchantid-domain-association.txt [L]
  1. Click Verify to complete the authentication. If you register once, it is valid for 2 years.

point

Apple Pay Merchant Identity Certificate Registration

This is the last registration on the Apple site.

  1. Using the previously created "apple_pay.cer", create a "CertificateSigningRequest.certSigningRequest" file with keychain access. (Reference)
  2. Register the created "CertificateSigningRequest.certSigningRequest" file in the Apple Pay Merchant Identity Certificate of Apple Developer.
  3. After registration, you can download "merchant_id.cer".

P12 file creation

The P12 file is used for client authentication during development. Create "ApplePayMerchantIdentity.p12" from "merchant_id.cer" with key chain access (Reference)

development of

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.

Other points I was worried about

JDK version

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.

Sites that introduced Apple Pay

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

Summary

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

A story that struggled with the introduction of Web Apple Pay
The story of making a reverse proxy with ProxyServlet
A story packed with the basics of Spring Boot (solved)
The story of the first Rails app refactored with a self-made helper
A story that I struggled to challenge a competition professional with Java
A story about hitting the League Of Legends API with JAVA
A story that confirmed the profile of Yasuko Sawaguchi 36 years ago
The story of making a game launcher with automatic loading function [Java]
The story of making it possible to build a project that was built by Maven with Ant
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
A story that I wanted to write a process equivalent to a while statement with the Stream API of Java8
The story that docker had a hard time
The story of tuning android apps with libGDX
A story about making a Builder that inherits the Builder
[Jackson] A story about converting the return value of BigDecimal type with a custom serializer.
Write a test by implementing the story of Mr. Nabeats in the world with ruby
[Spring Boot] The story that the bean of the class with ConfigurationProperties annotation was not found
Graph the sensor information of Raspberry Pi and prepare an environment that can be checked with a web browser
Roughly the flow of web application development with Rails.
A story that stumbled when deploying a web application created with Spring Boot to EC2
The story of making dto, dao-like with java, sqlite
[Java] The problem that true was returned as a result of comparing Integer with ==
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
The story of building a Java version of Minecraft server with GCP (and also set a whitelist)
A story that ended up taking a break when using the Linked List with a light feeling
Determine that the value is a multiple of 〇 in Ruby
The first WEB application with Spring Boot-Making a Pomodoro timer-
Check the operation of two roles with a chat application
A story addicted to toString () of Interface proxied with JdkDynamicAopProxy
Explain the benefits of the State pattern with a movie rating
A program that counts the number of words in a List
Introduction of library ff4j that realizes FeatureToggle with Spring Boot
Find the number of days in a month with Kotlin
[Automatic trading of Bitcoin] A story about operating with Docker on AWS, with 1 TAP ON / OFF & Line notification from Apple Watch on the go
A story stuck with NotSerializableException
The story of making a binding for libui, a GUI library for Ruby that is easy to install
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
The story that a model is not a "correct representation of the real world" / the need for a bounded context
Graph the sensor information of Raspberry Pi in Java and check it with a web browser
Create a simple web server with the Java standard library com.sun.net.httpserver
Try to imitate the idea of a two-dimensional array with a one-dimensional array
The story of Collectors.groupingBy that I want to keep for posterity
The story that standard output also fatally changes the behavior of the program
The story of toString () starting with passing an array to System.out.println
The story that Tomcat suffered from a timeout error in Eclipse
The story of making a communication type Othello game using Scala.
[Illustration] Finding the sum of coins with a recursive function [Ruby]
The story that I struggled because I couldn't do "Rails db: migrate".
Let's make a custom_cop that points out the shaking of the name
Three Reasons to Frustrate Before the Release of a Web Service
The story that ARM's processing performance of Open JDK was low
A story that addresses the problem that REMOTE_ADDR cannot be acquired in a cluster built with Docker Swarm + Traefik (1.7).
Perform a large amount of csv export (output) of log information etc. on the WEB application with Rails application
How to operate IGV using socket communication, and the story of making a Ruby Gem using that method
Ubuntu 20.04 The story of creating CFn that installs CloudWatch agent on LTS and creates a configuration file
About the matter that tends to be confused with ARG of Dockerfile which is a multi-stage build
The story of introducing Gradle as a retrofit to an existing system that did not manage packages
[Java version] The story of serialization
This and that of the JDK
Build a web application with Javalin
The story of @ViewScoped consuming memory