Skip to main content

Accept payments

Info
Info

To accept a payment, prepare the payment informations and then send a payment request using our API, Nodejs library, JS widget or our SDKs.

Each transaction includes a reference that can be used to verify the payment.

Test and production environment

We can't stress this enough: please test our APIs against our sandbox environment before pushing them into production. We prefer to avoid service interruptions in production caused by untested code.

The base URL is the same whether in production or in test. Only your API key distinguishes the two environments.


Request URL

https://apis.chipdeals.me/momo/requestpayment?apikey=<YOUR_API_KEY>

Initiate a payment with the API

To initiate a payment, you will need to submit information such as mobile money number, name, amount, etc.

The number, amount, currency and surnames and first names are mandatory. You can also pass another parameter which is the URL to contact when the transaction changes state.

Here is the complete list of parameters you can pass to accept a payment


ParameterRequired?Description
senderPhoneNumberYesCustomer's mobile money number
It must respect the E.164 format without the + sign.
Format: [country code][local phone number]
Ex: 22951010588
senderFirstNameYesCustomer's first name
senderLastNameYesCustomer's last name
amountYesAmount to be recovered from the customer
currencyYesCurrency See supported currencies
webhookUrlNoURL that we will contact to notify you of updates regarding the initiated payment.

POST https://apis.chipdeals.me/momo/requestpayment?apikey=test_FOdigzgSopV8GZggZa89 HTTP/1.1content-type: application/json{  "senderFirstName": "Iyam",  "senderLastName": "EVERICH",  "senderPhoneNumber": "22951010588",  "amount": 250,  "currency": "XOF"}

Initiate a payment with the Javascript widget

Info
Info

The payment widget allows you to accept payment from your website without writing a lot of code. To accept a payment from your website with our Javascript widget, fill in your API key, include the JS script provided by Chipdeals and add a payment button to get paid

The Mobile Money Javascript Widget from Chipdeals provides an easy and convenient payment flow for the web. It can be integrated in 3 easy steps, making it the easiest way to start receiving payments. Access the widget demo here.

Integrate the widget in 3 steps

Integrate our widget on your own website in 3 easy steps. You can also directly see a demo of the result after integration.

1. Get your API key

Retrieve your api key from the dashboard. We will use a test api key as an example here.

API key: test_FOdigzgSopV8GZggZa89

2. Include the JavaScript script

Add this code in the header of your HTML page. Remember to replace your own API key.

<script
src="https://cdn.jsdelivr.net/gh/Chipdeals/mobile-money-api-Javascript@1.6.1/lib.min.js"
apiKey="test_FOdigzgSopV8GZggZa89"
successfulRedirection="https://chipdeals.me/mobile-money"
></script>

✓ The src attribute is the script URL of the Chipdeals library version you are including

✓ The apiKey attribute is your apiKey obtained after registering with us
✓ The successRedirection attribute is optional. It contains a URL where you want your users to be redirected after paying

3. Add a payment button

Add this payment button to your code.

The button must contain the chipdeals-button class to allow our script to find it and add a click listener.

<button class="chipdeals-button" amount="3000">Pay 3000 XOF</button>



There you go!

When you click your button, the Chipdeals payment widget will appear and you can accept payments with ease.




Customize your payment widget

Most of the changes you can make are available through properties that you can add to your button or just ignore.

Customization properties:

PropertiesRequired?Meaning
amountYesThe amount you want the user to pay
currencyNoThe currency of the amount. The default is XOF
imgNoProduct Image URL
nameNoThe product name
addFeeToUserNoIf you add this attribute to your button, your user will bear the cost. Ex: if the fee is 2% we will ask the user to pay 1020 XOF for an amount of 1000 XOF



Some examples of customizations


Customize currency


Customize product image


Customize product name


Customize the support of expenses




Advanced widget customization

In your javascript code, you can add handlers to catch transaction state change events.


Successful payment event

You can add a code that will be executed as soon as the user succeeds in his payment. To do this, just listen to the chipdealsPaymentSucceeded event on the document object.

Example of successful payment event listening
document.addEventListener("chipdealsPaymentSucceeded", (event) => {
console.log(event);
console.log(event.detail.description);
});

Failed payment event

You can add a code that will be executed as soon as the user fails his payment. To do this, just listen to the chipdealsPaymentFailed event on the document object.

Example of failed payment event listening
document.addEventListener("chipdealsPaymentFailed", (event) => {
console.log(event);
console.log(event.detail.description);
});

Payment Status Update Event

You can add a handler so that your code is executed as soon as the status of the payment changes. You need to listen for the chipdealsPaymentUpdated event on the document object.

Example of listening to a payment update event
document.addEventListener("chipdealsPaymentUpdated", (event) => {
console.log(event);
console.log(event.detail.description);
});