How to integrate Apple Wallet into the mobile app?
There are already quite a lot of cases in our portfolio on creating applications with a loyalty program — they successfully replace plastic cards and allow us to provide customers with much more functionality than just a discount. Therefore, we have encountered Apple Wallet integration more than once.
We could not find a full–fledged instruction on how to do it — the information is scattered across different sources. So the idea was born to describe the Apple Wallet integration process from the very beginning and to the end. With our article, it will take no more than 30 minutes. Without it, it may take from 2 to 4 hours.
- Mac OS
- Access to an Apple Development account
Creating a PassType ID
- Come here
- Select PassTypeIDs from the list → click next
- Enter the description of your certificate (usually the name of the application) and the identifier pass.com.example.app — (ex. pass.by.johndory.app)
Creating a certificate
- Come here
- In software, select iOS App Development and in Services, select Pass Type ID Certificate → click next
- Enter the name of the certificate and select our newly created Pass Type Id in the PassType Id drop-down list
- Next, we are required to upload the key that we need to generate on Mac OS, now go to the header Creating keys (Mac OS)
Creating Mac OS Keys
Keychain → Certification Assistant → Request a Certificate
Click Download and download the pass.cer file
In the keychain, import the downloaded file
To find and select our certificate with its private key we search it by the application keyword in the Keychain. Right-click and export it to P12 format (it is the default), come up with a password, and be sure to remember/write it down, it will be useful for generating a push certificate.
Generating a certificate for Apple Wallet push updates
We transfer the CERTIFICATE.p12 file to any location and prescribe the following command, which will generate a certificate for push (You will need to enter the password that was prescribed when generating the CERTIFICATE.p12 file)
openssl pkcs12 -in CERTIFICATE.p12 -out pushcert.pem -nodes
Now we have 2 files CERTIFICATE.p12 and pushcert.pem, we transfer them to any convenient place in the project.
Alternatively, you can organize a wallet folder and throw these files there.
Then follow the link and download the general APPLEWDRCA certificate, we throw it into our keys by importing it, as we did earlier. Next, we find the Apple keyword and export it in .pem format, transfer it to the rest of the certificates.
As a result, we should have 3 files that are necessary for the correct operation of the Apple Wallet.
The above procedure must be performed for both development and production versions.
This instruction will be useful to anyone who wants to integrate cards into the application. It is universal, it does not depend on the back-end. But in this particular case, we have attached a library for PHP, which we use in the company.