Apple Pay is a mobile payment and digital wallet service developed by Apple Inc. It allows users to make payments in person, in iOS apps, and on the web using Safari. Users can add their credit, debit, or prepaid cards to their Apple devices, enabling them to make payments using these devices instead of physical cards.
Apple Pay only works with the Safari browser. Apple Pay is not compatible with Google Chrome and has never been.
Key features of Apple Pay include:
- Contactless Payments: Users can make secure, contactless payments at retail locations equipped with near-field communication (NFC) technology by holding their Apple device near the payment terminal.
- In-App Purchases: Apple Pay can be used to make purchases within supported apps on iOS devices.
- Web Payments: On Safari, Apple Pay allows users to pay on websites without entering their card details each time.
- Security: Apple Pay uses a security feature called “tokenization” where the actual card number is not stored on the device or Apple servers. Instead, a unique Device Account Number is assigned, encrypted, and securely stored.
- Privacy: Apple does not track users’ transactions, providing a level of privacy in their payment process.
To set up your Apple developer account and Xcode to implement Apple Pay in your apps, you complete three steps:
- Create a merchant identifier.
To enable your app to use Apple Pay, register an identifier with Apple that uniquely identifies your business as a merchant able to accept payments. This ID never expires, and you can use it in multiple websites and apps. - Create a Payment Processing certificate.
Using your registered merchant identifier, create a certificate to secure transaction data. Apple Pay servers use the certificate’s public key to encrypt payment data. You (or your payment service provider) use the private key to decrypt the data to process payments. Check Payment merchant available for Apple Pay
- Enable Apple Pay in Xcode.
After creating a merchant identifier, enable the Apple Pay capability in your Xcode project.
- Open your project with Xcode. In the Project navigator, select the project.
- Choose the target for the app from either the Project/Targets pop-up menu or in the Targets section of the outline view.
- Click the Signing & Capabilities tab in the project editor.
- In the toolbar, click the Library button (+) to open the Capabilities library and select the Apple Pay capability.
- Within the Apple Pay capability, click the refresh button to synchronize your merchant identifiers from the Apple Developer site.
- Select the merchant identifier to use with this app.
Create a New Apple ID for Sandbox:
- Go to Apple ID and create a new Apple ID.
- Fill in the required information. Use an email address that hasn’t been used with an Apple ID before.
- Verify your email address by following the instructions sent to your email.
Sign In to App Store Connect:
- Visit App Store Connect.
- Sign in with your main Apple Developer account (not the sandbox account you just created).
Add Sandbox Testers:
- In App Store Connect, navigate to Users and Access.
- Click the + button to add a new user.
- Enter the email address of the Apple ID you created for sandbox testing.
- Choose a role for the new user. The role doesn’t matter for sandbox testing purposes, so you can select any.
- Click Invite.
Sign In to iOS Device:
- On your iOS device, sign out of your current Apple ID.
- Sign in with the sandbox Apple ID you created.
- Go to Settings > iTunes & App Store and sign in with the sandbox Apple ID.
- Add sandbox cards in Apple wallet https://developer.apple.com/apple-pay/sandbox-testing/
Apple Pay Payment Workflow:
Prerequisite for perform Apple Pay Payment:
- Apple pay should be available in the corresponding country. https://support.apple.com/en-in/102775
- Supported Networks : we will get this from API like : .quicPay, .masterCard, .visa, .discover, .amex
- Country Code(US) and Currency Code(USD) .
- Payment Summary Items like Item to be purchased and price of cost.
When user accept and proceed for payment we are getting below token data we will send the data to API, then server and merchant payment gateway will validate/authorize these tokens and respond to APP through API :
{“data”:”9LHoyaK39yjehbo8Yck51m667IOmrocsv7i2gGsKjZ0Oiewl6jxEyS\/PoA5Tak82NZ97QWPJzUniX747sNpAqBc1uzTyXU8X8UYan4hZSQXXaDpDcjfgqCO9aRMNZ2TmzOGsoB3jG1WzVT+S+IrGi2ZoevlELCpH2XlTdrFqctQ5M0k3J54wwUSn\/m1RKRMudvxY+GilA7rKeDgPymbNuaIBoU6Mrvhb+AkKjqWJb5WB+VgVDVQFbrQzls5ilqw9dDPkVnLtbYUY\/dU5l2XAy1ruNEqnwmRQnlaPCX9iPTFQ53PkmvvbOZQlHAty4\/bDID2ofO\/7VDZf7JWPYVO0uk8W0u0WazVq+YnxF5qLtHez\/91JNwoa+du2pkeiq9REOsCxZR1MAx1maXfW”,”signature”:”MIAGCSqGSIb3DQEHAqCAMIACAQExDTALBglghkgBZQMEAgEwgAYJKoZIhvcNAQcBAACggDCCA+MwggOIoAMCAQICCBZjTIsOMFcXMAoGCCqGSM49BAMCMHoxLjAsBgNVBAMMJUFwcGxlIEFwcGxpY2F0aW9uIEludGVncmF0aW9uIENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRp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+d6cL+AjAyLdVEIbCjBXdsXfM4O5Bn\/Rd8LCFtlk\/GcmmCEm9U+Hp9G5nLmwmJIWEGmQ8Jkh0AADGCAYgwggGEAgEBMIGGMHoxLjAsBgNVBAMMJUFwcGxlIEFwcGxpY2F0aW9uIEludGVncmF0aW9uIENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUwIIFmNMiw4wVxcwCwYJYIZIAWUDBAIBoIGTMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTI0MDYzMDIwMDI1MlowKAYJKoZIhvcNAQk0MRswGTALBglghkgBZQMEAgGhCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIBAUpkzoxqAZVewf6GtVhXCN4ro1DdC1afAOOXqWKKgHMAoGCCqGSM49BAMCBEcwRQIgKgVrNQexqc+xSnghzWg4b2Ybswgt4UzCTObcsDq3QEgCIQD\/FfOdxh\/gb5Jh8BNiX0KnBYP60ew5IU0CYeAi\/4UeiQAAAAAAAA==”,”header”:{“publicKeyHash”:”hvufkm2j22zYGd1+88ioXAFWs+KdKfg5Slntvrmtz1g=”,”ephemeralPublicKey”:”MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWr+svjxMPZ13PZXU\/Cox8EWu\/xeuJWMMqx0nLlVl5GCcoMw\/e11j0PQb3pevQ6Ga1TWkI5j8Rzgn5Yr8V+O2\/w==”,”transactionId”:”6eb238af34c75f388a06d076f6d14943bf6f20ae5dc5c530ac65574a570f0022″},”version”:”EC_v1″}
Note FYI:
We won’t get selected card data until the user is not authorizing Apple pay payment.
Reference :
https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentmethod/1916110-displayname
https://stackoverflow.com/questions/28239635/applepay-pkpaymentauthorizationviewcontroller-always-shows-processing