Basic Integration
This page will guide you to accept mada, Visa, Mastercard, American Express, and UnionPay payments using our Payment Form Javascript library.
Before Starting
Before you start accepting credit/debit card payments, make sure you complete these steps first:
- Sign up for a Moyasar account on our dashboard.
- Get your publishable API key to authenticate your form payment requests.
- Review the Moyasar form configuration here.
Including Moyasar Form
Moyasar Form is a lightweight Javascript library that will take care of creating the payment components within your website using a modern and responsive design.
You can start the integration by including the following tags within the <head> tag of your page:
Initiating the Payment Form
Once you decide on a good place for the form, add an empty <div> tag and then invoke the init method on
the global Moyasar class.
HTML
<div class="mysr-form"></div>
<script>
Moyasar.init({
element: '.mysr-form',
// Amount in the smallest currency unit.
// For example:
// 10 SAR = 10 * 100 Halalas
// 10 KWD = 10 * 1000 Fils
// 10 JPY = 10 JPY (Japanese Yen does not have fractions)
amount: 1000,
currency: 'SAR',
description: 'Coffee Order #1',
publishable_api_key: 'pk_test_AQpxBV31a29qhkhUYFYUFjhwllaDVrxSq5ydVNui',
callback_url: 'https://moyasar.com/thanks',
supported_networks: ['visa', 'mastercard', 'mada', 'unionpay'],
methods: ['creditcard'],
});
</script>