Online CheckoutComponents
Payment Button
Display the AlyaPay payment button on your checkout page
Payment Button
The payment button allows customers to start the AlyaPay payment flow.
Default Button
Use the pre-built button that appears automatically:
<div id="alyapay-button"></div>
<script>
AlyaPay.Payments.init({
session_token: SESSION_TOKEN,
locale: 'en'
});
AlyaPay.Payments.load({
container: '#alyapay-button'
});
</script>Custom Button
Use your own button and trigger payment programmatically:
<button id="my-button" class="btn-primary">
Confirm order
</button>
<script>
// Initialize SDK (don't call load())
AlyaPay.Payments.init({
session_token: SESSION_TOKEN,
locale: 'en'
});
// Trigger on your button click
document.getElementById('my-button').addEventListener('click', async () => {
try {
await AlyaPay.Payments.startFlow();
} catch (error) {
console.error('Payment error:', error);
}
});
</script>Styling
Style the container (not the button itself):
#alyapay-button {
max-width: 400px;
margin: 20px auto;
}
/* Mobile */
@media (max-width: 768px) {
#alyapay-button {
width: 100%;
}
}Options
Container
Specify where the button appears:
AlyaPay.Payments.load({
container: '#alyapay-button-container'
});Locale
Change button language:
AlyaPay.Payments.init({
session_token: SESSION_TOKEN,
locale: 'fr' // 'en', 'fr', or 'ar'
});Languages:
en- English: "Pay with Alya"fr- French: "Payer avec Alya"ar- Arabic: "Alya ادفع مع " (RTL)
What Happens When Clicked
- Popup opens with AlyaPay checkout
- Customer register a new account
- Customer completes ID verification
- Customer selects installment plan
- Customer confirms payment
- Popup closes
PaymentCallbackfires with transaction ID- You verify payment status
See Events for handling callbacks.
Troubleshooting
Button doesn't appear:
- Check container element exists
- Verify SDK loaded (
window.AlyaPayexists) - Call
init()beforeload() - Check browser console
Popup blocked:
- Browser blocked the window
- Guide user to enable popups
- See Errors