Custom Payments

Apple Pay on Websites

10min

Introduction

This guide will go through how to integrate Apple Pay JS API with Moyasar, we will go step by step through the process of including Apple Pay's scripts, Creating the payment request, Validating the merchant's URL, and finally Authorizing the payment.

Who is this guide for?

  • Advanced Users
  • Users who are building their own Apple Pay integration

Before Starting

Step 1: Displaying the Apple Pay Button

Add Apple Pay's Script

First, you need to include Apple Pay's CDN

HTML


Customizing the Apple Pay button

In this step, you need to set the styles for the Apple Pay button and include the button in your HTML

HTML


for more customization options check the Apple Pay Demo.

Step 2: Starting the session

JS


Step 3: Validating Merchant

JS


Step 3: Authorizing Payment

In the onpaymentauthorized event, you will receive the encrypted payment token, which will be sent to Moyasar to complete the transaction. We will be using Moyasar API for this.

Create the request body to send to Moyasar

JS


oncancel [optional]

Handling what happens when the user clicks on cancel on the Apple Pay payment sheet

JS




Updated 23 Nov 2023
Did this page help you?