AlyaPay Documentation
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

  1. Popup opens with AlyaPay checkout
  2. Customer register a new account
  3. Customer completes ID verification
  4. Customer selects installment plan
  5. Customer confirms payment
  6. Popup closes
  7. PaymentCallback fires with transaction ID
  8. You verify payment status

See Events for handling callbacks.

Troubleshooting

Button doesn't appear:

  • Check container element exists
  • Verify SDK loaded (window.AlyaPay exists)
  • Call init() before load()
  • Check browser console

Popup blocked:

  • Browser blocked the window
  • Guide user to enable popups
  • See Errors