Introduction
This guide covers the steps to integrate Apple Pay as a payment option. For users that are supported, users can select Apple Pay and complete the transaction on their device via the Apple Pay payment sheet. Push will authorize the transaction with the user’s bank and return the payment result to your backend.Step 1: Display Apple Pay option to user
Load the SDK from the CDN
To render the Apple Pay option, you must load the Push Javascript SDK from our CDN.Render Apple Pay button
Display an option for the user to select Apple Pay as their payment method. Make a call to the Push Cash SDK to determine if Apple Pay is supported on the user’s device.Step 2: Create Apple Pay Intent & Token
Once a user has selected to use Apple Pay, present the Apple Pay experience to them. In order to do this, you must:- Register a user
- Create an Apple Pay intent & token
Register a user
If a user has not previously used Push, you must register them. Make a request to thecreate user
endpoint with all the required information and store the user ID returned in the response in your database along with the user record.
It is important to ensure that users are registered only once with Push. If a user has previously used Push for a withdrawal OR deposit, you MUST re-use the user created from that flow in order to ensure that the user’s stored payment information is persisted.
Create Apple Pay Intent & Token
Make a request to Push to create a payment intent. Submit the user ID, the payment amount & currency, direction =cash_in
, and type = apple_pay
.
Step 3: Launch Apple Pay Experience
After creating a payment intent and token with Push, use the token to initiate the Apple Pay experience on the user’s device via the Push SDK.Use token to create an Apple Pay session
Use the Apple Pay token to create a new session.Start session & specify callback
Set the callback on the session. The callback will receive an intent ID which can be used to fetch the intent status from the Push Cash API. In your callback function, you should:- Make a request to
get an intent
with the intent ID - Update your database with the payment result
- Notify the user by displaying your transaction confirmation page
- Approved - payment was approved
- Declined - payment was declined
- Canceled - user canceled payment / didn’t happen