Table of Contents

Pop-Up Payment

You are here:
< All API Documentations

1. Payment Page

Mobile money API payment

  • HTML
<div id="pay-btn"></div>
  • JavaScript

Pop-up opening : 

This function openPopUp() defines the different arguments expected by the Pop-up.

The function getPopUp() first calls the script which will provide the URL of the Orange Money payment page (script which itself makes a call to our Orange Money API).

If the answer is not an error, the reqListener() function takes over. It puts the response in real JSON format then displays in the HTML tag above the “Orange Money by Bizao” button which will call the openPopUp() function.

<script type="text/javascript">
function openPopUp(url){
window.open(url,"Orange Money by Bizao","menubar=no, status=no,
scrollbars=no, menubar=no, width=450, height=600");
//The parameters "left" and "top" can be used to center the popup but the
values must be set dynamically, depending on the user screen size
}
function getPopUp(){
let req = new XMLHttpRequest();
function reqListener(){
let response = JSON.parse(this.response);
document.getElementById('pay-btn').innerHTML = ' type="button" class="btn btn-success" value="Orange Money by
Bizao" onclick="openPopUp(\''+ response.payment_url +'\')"/>';
}
function reqError(err){
//code in case of error on the request
}
function reqTimeout(){
//code in case of timeout
}
req.open('get', 'the_request_url_that_will_provide_the_orange_money_url',
true);
req.timeout = 5000;
req.onload = reqListener;
req.onerror = reqError;
req.ontimeout = reqTimeout;
req.send();
} </script>

2. “return_url Page”

  • JavaScript
<script type="text/javascript"> //this script will close the window after 3sec
setTimeout(function() {
window.close();
}, 3000);
</script>