Javascript widget integration

How to integrate IremboPay v2.0 into your website and web applications

1

Add the Irembopay CDN

<script src="https://dashboard.sandbox.irembopay.com/assets/payment/inline.js"></script>

2

Add the function to trigger your payment request

<script>
   function makePayment() {
       IremboPay.initiate({
           publicKey: "xxx",
           invoiceNumber: "xxx",
           locale: IremboPay.locale.EN,
           callback: (err, resp) => {
               if (!err) {
                   // Perform actions on success
                   // IremboPay.closeModal();
               } else {
                   // Perform actions on error
               }
           }
       })
   }
 </script>
3

Call the function where you need it

<button onclick="makePayment()">Pay</button>

Specific error scenarios

  • Public key is not valid

{
  "message": "Invalid request",
  "success": false,
  "errors": [
    {
      "code": "INVALID_KEY",
      "detail": "Public key is not valid"
    }
  ]
}
  • Invoice not found

{
  "message": "Invalid request",
  "success": false,
  "errors": [
    {
      "code": "INVOICE_NOT_FOUND",
      "detail": "Invoice not found"
    }
  ]
}
  • Invoice has already been paid

{
  "message": "Invalid request",
  "success": false,
  "errors": [
    {
      "code": "BAD_INVOICES_PAID",
      "detail": "Invoice has already been paid"
    }
  ]
}
  • Invoice has expired

{
  "message": "Invalid request",
  "success": false,
  "errors": [
    {
      "code": "BAD_INVOICES_PAYMENT_EXPIRED",
      "detail": "Invoice has expired"
    }
  ]
}
  • Invoice is already linked to a Batch Invoice

{
  "message": "Invalid request",
  "success": false,
  "errors": [
    {
      "code": "BAD_INVOICES_IN_BATCH",
      "detail": "Invoice is already linked to a Batch Invoice"
    }
  ]
}
  • No invoice provided

{
  "code":"INVOICE_MISSING",
  "message":"Invoice required"
}
  • The locale value is not valid

{
  "code":"BAD_LOCALE",
  "message":"Unsupported locale"
}

Last updated