Notes on the Pitfalls of iOS Sandbox Accounts and Apple Pay
Introduction Why am I writing this article? The reason is simple: a while ago, a new project at my company required us to integrate Google Pay and Apple Pay. The service had already completed its credit card payment flow. However, management later requested support for Google Pay and Apple Pay as well. Since none of our previous company projects had integrated Apple Pay, I became the first person in the company to take on this task. With the help of AI, the payment integration itself was completed in about one day. However, a new problem came up: The code was finished, but how were we supposed to test it in the UAT environment? This is basically a record of my experience and the problems I encountered while testing Apple Pay in the Sandbox environment. I hope it helps other engineers who are stuck in a similar testing environment. Problem 1: How to Configure the CER and Private Key At the moment, I only have a .p12 file. The payment integration side has already configured the Apple Pay certificate and generated the corresponding CSR. The only remaining step is to configure the environment variables on the application side. The contents of a .p12 file are generally as follows: .p12 ├── Certificate ├── Private Key └── Certificate Chain (may be included) The overall process is: .p12 ├── Extract the Certificate / PEM ├── Extract the Private Key └── Verify that the CSR, Certificate, and Private Key belong to the same key pair The following process uses OpenSSL: # Inspect the p12 contents without outputting the private key openssl pkcs12 -info -in apple-pay.p12 -noout # Extract the certificate openssl pkcs12 \ -in apple-pay.p12 \ -clcerts \ -nokeys \ | openssl x509 -out cert.pem # Extract the private key openssl pkcs12 \ -in apple-pay.p12 \ -nocerts \ -nodes \ | openssl pkey -out private-key.pem -nodes means that the exported private key will not be encrypted again. Therefore, the generated private-key.pem must be stored securely. It should never be committed to Git or pr