Initialize Payment
To initialize a payment in the NoWallet system, use the following endpoint:
{baseUrl}/init/paymentRequest Body Parameters
When initializing a payment, the request body must include the following parameters in JSON format:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | InitPaymentModelDTO | true | none |
Example Request Body
{
"transaction_id": "ca3a65bb-9008-443d-8d4b-61c3b0006438",
"additional_infos": {
"customer_email": "[email protected]",
"customer_lastname": "Doe",
"customer_firstname": "John",
"customer_phone": "691234567"
},
"amount": 200,
"callback_url": "https://example.com/callback",
"return_url": "https://example.com/return",
"country_code": "CM",
"operators_code": ["OM"],
"method": "MERCHANT",
"tunnel": "CHECKOUTPAGE",
"operator_otp": "123456"
}
Code Samples in Multiple Languages
To help you integrate the NoWallet API seamlessly, we provide code samples in various programming languages. These examples demonstrate how to make a request to the API endpoint and handle the response.
- Shell (cURL): For quick testing and command-line usage.
- HTTP: Raw HTTP request format for understanding the structure.
- JavaScript: Using
fetchfor browser or Node.js environments. - Ruby: Using the
rest-clientlibrary for Ruby applications. - Python: Using the
requestslibrary for Python projects. - PHP: Using
GuzzleHttpfor PHP integrations. - Java: Using
HttpURLConnectionfor Java applications. - Go: Using the
net/httppackage for Go projects.
Example Request
Below is an example of how to initialize a payment link using different languages. Select the tab corresponding to your preferred language to view the implementation.
Ensure you replace {access-token} with your actual API token and provide the required request body parameters.
- cURL
- HTTP
- JavaScript
- Ruby
- Python
- PHP
- Java
- Go
# Example of initializing a payment link using cURL
curl -X POST {baseUrl}/init/payment \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}'
POST {baseUrl}/init/payment HTTP/1.1
Content-Type: application/json
Accept: application/json
const inputBody = {
transaction_id: "ca3a65bb-9008-443d-8d4b-61c3b0006438",
additional_infos: {
customer_email: "[email protected]",
customer_lastname: "Doe",
customer_firstname: "John",
customer_phone: "691234567",
},
amount: 200,
callback_url: "https://example.com/callback",
return_url: "https://example.com/return",
country_code: "CM",
operators_code: ["OM"],
method: "MERCHANT",
tunnel: "CHECKOUTPAGE",
operator_otp: "123456",
};
const headers = {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer {access-token}",
};
fetch("{baseUrl}/init/payment", {
method: "POST",
body: inputBody,
headers: headers,
})
.then(function (res) {
return res.json();
})
.then(function (body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.post '{baseUrl}/init/payment',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.post('{baseUrl}/init/payment', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','{baseUrl}/init/payment', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("{baseUrl}/init/payment");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "{baseUrl}/init/payment", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
Response Parameters
When you make a request to the NoWallet API to initialize a payment, the server will respond with a status code and a JSON object containing the relevant information.
The response from the server will include the following parameters in JSON format:
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | PAYMENT_INITIATE - SUCCESS response sent to merchant | InitPaymentResponseModelDto |
| 400 | Bad Request | PAYMENT_INITIATE - BAD REQUEST possible errors | None |
Response Types
The response from the server will include the url of the payment initialization and any relevant information. The response will be in JSON format.
Success Response (200 OK)
PAYMENT_INITIATE - SUCCESS response sent to merchant
{
"country": "CM",
"currency": "XAF",
"signature": "EXAMPLE-XXXXX-XXXXX",
"available_operator": ["MTN", "OM"],
"authorized_operator": ["MTN", "OM"],
"payment_url": "https://example.com/payment"
}
Error Response (400 Bad Request)
PAYMENT_INITIATE - BAD REQUEST possible errors
{
"statusCode": 400,
"error": "ERROR_COUNTRY_CODE_NOT_FOUND",
"message": "It seems that this country code does not exist"
}
{
"statusCode": 400,
"error": "NOT_ALLOWED_TUNNEL_WITHOUT_PHONENUMBER",
"message": "API tunnel is allowed only if there is a customer_phone"
}
{
"statusCode": 400,
"error": "NOT_ALLOWED_TUNNEL_OPERATORS_CODE",
"message": "API tunnel is allowed only for single operators_code e.g. ['OM']"
}
{
"statusCode": 400,
"error": "ERROR_PHONE_NUMBER_LENGTH_IS_TOO_SHORT",
"message": "phone number invalid, the length of this phone number is too short"
}
{
"statusCode": 400,
"error": "ERROR_PHONE_NUMBER_OPERATOR_COUNTRY",
"message": "It seems that this number is not a valid phone number, the phone number is not valid for this operator or country"
}
{
"statusCode": 400,
"error": "ERROR_FEE_NOT_FOUND",
"message": "You cannot generate a signature, please contact administrator to get help."
}
{
"statusCode": 400,
"error": "ERROR_GENERATE_SIGNATURE",
"message": "Something went wrong during signature generation, please contact support to get help or try again."
}
{
"statusCode": 400,
"error": "ERROR_BALANCE_DEFICIT",
"message": "An error has occurred, the transaction signature could not be generated. Your balance is deficit. Please contact administrator to get help."
}
Was this page helpful?