Sign in to your Bani merchant account to get your API keys. You will need your public key to initiate the Bani Pop Payment Widget.
You can generate an API key from your Dashboard at any time.
Getting started
To initialise the transaction, you'll need to pass information such as phone number, email, first name, last name, amount etc. Amount, phone number, email, first name, last name, and merchant public key are required. You can also pass any other additional information in the metadata object field and custom reference. Here is the full list of fields you can pass:
In the sample below, notice how:
The Bani Pop javascript is included using a script tag. This is how you import Bani Pop Widget into your code.
The amount here can be hardcoded if you want to charge a specific amount.
The Pay button has been tied to an onClick function called payWithBani. This is the action that causes the Bani Pop Widget to load.
constpaymentForm=document.getElementById('paymentForm');paymentForm.addEventListener('submit',(e)=>payWithBani(e),false);functionpayWithBani (e) {e.preventDefault()let handler =BaniPopUp({ amount:document.getElementById('amount').value,//The amount the customer wants to pay phoneNumber: document.getElementById('phone-number').value, //The mobile number of the customer in int format i.e +2348173709000
email:document.getElementById('email').value,//The email of the customer firstName:document.getElementById('first-name').value,//The first name of the customer lastName:document.getElementById('last-name').value,//The last name of the customer merchantKey:"pub_test_EGB9QD8TQPV0ZD",//The merchant Bani public key metadata:"",//Custom JSON object passed by the merchant. This is optional merchantRef:"",//Custom payment reference passed by the merchant. This is optionalonClose: (response) => {console.log("ONCLOSE DATA",response) },callback:function (response) {let message ='Payment complete! Reference: '+response?.referenceconsole.log(message, response) } }) handler }