Accept Payments

To facilitate payment acceptance, you can initiate a transaction through our API, our client JavaScript library, Popup JS, or our SDKs. Each transaction will generate a unique link that enables users to finalize the payment process seamlessly.

Lahza Popup offers a user-friendly and hassle-free payment flow designed for web applications. Integrating it into your platform is a breeze and can be accomplished in just five simple steps, making it the most straightforward method to begin accepting payments.

Collect customer information

To initialize the transaction, you need to pass information such as email, mobile, amount, transaction reference, etc. The key, email ,mobile and amount parameters are the only required parameters. The table below lists the parameters that you can pass when initializing a transaction.

<form id="form">
  <div class="form-group">
    <label for="email">Email Address</label>
    <input type="email" id="email" required />
  <div class="form-group">
    <label for="amount">Amount</label>
    <input type="text" id="amount" required />
  <div class="form-submit">
    <button type="submit" onclick="pay()"> Pay </button>

<script src=""></script>

In this sample, notice how:

  1. The Lahza inline javascript is included using a script tag. This is how you import Lahza into your code.

  2. The amount here can be hardcoded if you want to charge a specific amount.

  3. The Pay button has been tied to an onClick function called pay. This is the action that causes the Lahza popup to load.

If you don't collect customer email addresses, you can generate email addresses using the available information (e.g., phone numbers) along with your website URL.

Handle the callback method.

The callback method is fired when the transaction is successful. This is where you include any action you want to perform when the transaction is successful.

The recommended next step here is to verify the transaction to confirm the status.

To verify a transaction, you need to set up a server route or page where you pass the transaction reference. From your server, you can call the Lahza verify endpoint to check the status of the transaction. The response from the verification is then returned to your frontend for further processing.

There are 2 ways you can call your server from the callback function

  1. Make an AJAX request to the endpoint on your server that handles the transaction verification

onSuccess: function(response){
    url: ''+ response.reference,
    method: 'get',
    success: function (response) {
      // the transaction status is in
  1. Redirect to the server URL by setting a window.location to the URL where the verification endpoint is set on your server.

onSuccess: function(response) {
  window.location = "" + response.reference;
// On the redirected page, you can call Lahza's verify endpoint.

For security reasons, it is essential to never directly call the Lahza API from your frontend. This prevents exposing your secret key on the client-side. Instead, all requests to the Lahza API should be initiated from your server. Your frontend can then receive the response from your server, ensuring the confidentiality of your secret key. This practice helps maintain the integrity of your payment system and safeguards sensitive information.

Verify the Transaction

After payment is made, the next step is to verify the transaction. Here's how to verify transactions with Lahza.

Handle Webhook

When a payment is successful, Lahza sends a charge.success webhook event to your webhook URL. You can learn more here.


Here, you call the Initialize TransactionAPI from your server to generate a checkout link, then redirect your users to the link so they can pay. After payment is made, the users are returned to your website at the callback_url

Please ensure that your server is capable of establishing a TLSv1.2 connection with Lahza's servers. The majority of modern software supports this capability. If you encounter any SSL errors, it is recommended to contact your service provider for guidance and assistance in resolving the issue.

Initialize transaction

To initiate a transaction, follow these steps:

  1. When a customer clicks the payment action button, send a POST request to our API to initialize the transaction. Include parameters such as email, amount, and any other required fields in the request to the Initialize Transaction API endpoint.

  2. Upon a successful API call, we will provide you with an authorization URL. Redirect the customer to this URL to allow them to input their payment information and complete the transaction.

Important notes:

  • Ensure that the amount field is converted to the lowest currency unit. Multiply the value by 100 to obtain the correct amount. For example, if you want to charge ULS50 or $50 or JOD50, multiply 50 by 100 and pass 5000 in the amount field.

  • You should utilize a unique transaction identifier from your own system as the reference.

  • If you wish to customize the callback URL for the transaction, set the callback_url in the transaction_data array. If not specified, we will use the callback URL set on your dashboard. Specifying the callback URL in the code allows you to be flexible with the redirect URL if necessary.

  • If you do not set a callback URL on either the dashboard or in the code, users will not be redirected back to your site after completing the payment.

  • For test transactions, you can set test callback URLs, while for live transactions, use live callback URLs. This distinction allows you to differentiate between test and live environments effectively.

  $url = "";

  $fields = [
    'email' => "",
    'amount' => "20000"

  $fields_string = http_build_query($fields);

  //open connection
  $ch = curl_init();
  //set the url, number of POST vars, POST data
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_POST, true);
  curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Authorization: Bearer SECRET_KEY",
    "Cache-Control: no-cache",
  //So that curl_exec returns the contents of the cURL; rather than echoing it
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); 
  //execute post
  $result = curl_exec($ch);
  echo $result;

Verify Transaction

If the transaction is successful, Lahza will redirect the user back to a callback_url you set. We'll append the transaction reference in the URL. In the example above, the user will be redirected to

So you retrieve the reference from the URL parameter and use that to call the verify endpoint to confirm the status of the transaction. Learn more about verifying transactions.

It's very important that you call the Verify endpoint to confirm the status of the transactions before delivering value. Just because the callback_url was visited doesn't prove that transaction was successful.

Handle Webhook

When a payment is successful, Lahza sends a charge.success webhook event to webhook URL that you provide. Learn more about using webhooks.

Mobile SDKs

You can integrate Lahza directly into your Android or iOS app using our mobile SDK. For mobile frameworks like Ionic or React Native, please find the libraries here.

Last updated