Accept payments
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
Parameter | Required? | Description |
---|---|---|
senderPhoneNumber | Yes | Customer's mobile money number It must respect the E.164 format without the + sign. Format: [country code][local phone number] Ex: 22951010588 |
senderFirstName | Yes | Customer's first name |
senderLastName | Yes | Customer's last name |
amount | Yes | Amount to be recovered from the customer |
currency | Yes | Currency See supported currencies |
webhookUrl | No | URL that we will contact to notify you of updates regarding the initiated payment. |
- HTTP
- Curl
- NodeJs
- Laravel
- PHP
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"}
curl --request POST \'https://apis.chipdeals.me/momo/requestpayment?apikey=test_FOdigzgSopV8GZggZa89' \--header 'Content-Type: application/json' \--data-raw '{ "senderFirstName": "Iyam", "senderLastName": "EVERICH", "senderPhoneNumber": "22951010588", "amount": 250, "currency": "XOF"}'
const momo = require("@chipdeals/momo-api");momo.setApiKey("test_FOdigzgSopV8GZggZa89");momo .collect() .amount(250) .currency("XOF") .from("22951010200") .firstName("Iyam") .lastName("EVERICH") .create();
<?php$client = new \GuzzleHttp\Client();$apikey = "test_FOdigzgSopV8GZggZa89";$url = "https://apis.chipdeals.me/momo/requestpayment?apikey=".$apikey;$data = [ 'senderFirstName'=> "Iyam", 'senderLastName'=> "EVERICH", 'senderPhoneNumber'=> "22951010588", 'amount'=> 100, 'currency'=> "XOF"];$response = $client->post($url, [ 'body' => json_encode($data) ]);$body = $response->getBody();print_r(json_decode( $result));
require_once("path/to/chipdeals-mobile-money-api.php");$momo = new Momo();$momo->setApiKey("test_FOdigzgSopV8GZggZa89");$collection = $momo ->collect() ->amount(2000) ->currency("XOF") ->from("22951010200") ->firstName("Iyam") ->lastName("EVERICH") ->create();print_r($collection->getArray());
Initiate a payment with the Javascript widget
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
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:
Properties | Required? | Meaning |
---|---|---|
amount | Yes | The amount you want the user to pay |
currency | No | The currency of the amount. The default is XOF |
img | No | Product Image URL |
name | No | The product name |
addFeeToUser | No | If 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.
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.
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.
document.addEventListener("chipdealsPaymentUpdated", (event) => {
console.log(event);
console.log(event.detail.description);
});