Create Payment Code
curl --request POST \
--url https://api.monime.io/payment-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'Monime-Space-Id: <monime-space-id>' \
--data '
{
"name": "EDSA Office Top-up",
"mode": "oneTime",
"isActive": true,
"amount": {
"currency": "<string>",
"value": 123
},
"duration": "1h30m",
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": [
"m17",
"m18"
],
"financialAccountId": "<string>",
"metadata": {}
}
'import requests
url = "https://api.monime.io/payment-codes"
payload = {
"name": "EDSA Office Top-up",
"mode": "oneTime",
"isActive": True,
"amount": {
"currency": "<string>",
"value": 123
},
"duration": "1h30m",
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": ["m17", "m18"],
"financialAccountId": "<string>",
"metadata": {}
}
headers = {
"Monime-Space-Id": "<monime-space-id>",
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Monime-Space-Id': '<monime-space-id>',
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'EDSA Office Top-up',
mode: 'oneTime',
isActive: true,
amount: {currency: '<string>', value: 123},
duration: '1h30m',
customerTarget: {name: 'Musa Kamara', reference: '0123456789', payingPhoneNumber: '078000000'},
financialTarget: {
expectedPaymentCount: 10,
expectedPaymentSum: {currency: '<string>', value: 123}
},
allowedProviders: ['m17', 'm18'],
financialAccountId: '<string>',
metadata: {}
})
};
fetch('https://api.monime.io/payment-codes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.monime.io/payment-codes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'EDSA Office Top-up',
'mode' => 'oneTime',
'isActive' => true,
'amount' => [
'currency' => '<string>',
'value' => 123
],
'duration' => '1h30m',
'customerTarget' => [
'name' => 'Musa Kamara',
'reference' => '0123456789',
'payingPhoneNumber' => '078000000'
],
'financialTarget' => [
'expectedPaymentCount' => 10,
'expectedPaymentSum' => [
'currency' => '<string>',
'value' => 123
]
],
'allowedProviders' => [
'm17',
'm18'
],
'financialAccountId' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"Monime-Space-Id: <monime-space-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.monime.io/payment-codes"
payload := strings.NewReader("{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Monime-Space-Id", "<monime-space-id>")
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.monime.io/payment-codes")
.header("Monime-Space-Id", "<monime-space-id>")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.monime.io/payment-codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Monime-Space-Id"] = '<monime-space-id>'
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"messages": [
"<unknown>"
],
"result": {
"id": "pmc-TJh76H8hj778hftdtu66gjio",
"name": "Home EDSA Meter Top-up",
"mode": "oneTime",
"isActive": true,
"status": "pending",
"ussdCode": "\\*715\\*1\\*0123456789#",
"amount": {
"currency": "<string>",
"value": 123
},
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": [
"m17",
"m18"
],
"progress": {
"isCompleted": true,
"totalPaymentCount": 123,
"totalPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"financialAccountId": "<string>",
"expireTime": "2023-11-07T05:31:56Z",
"createTime": "2023-11-07T05:31:56Z",
"metadata": {}
}
}Authorizations
Bearer HTTP authentication specified with the header Authorization: Bearer <access_token>
Headers
The value is the tenancy parameter that Monime used to determine which space the request is intended for.
100^spc-.*$This header is used to uniquely identify a request, ensuring that the operation is not performed more than once during retries.
64Body
The name or intent indicating the purpose or use of the payment code.
1 - 100"EDSA Office Top-up"
Specifies whether the payment code can be used only once or multiple times.
oneTime, recurrent Denotes whether the payment code is active.
The amount to be paid. If Mode is recurrent, and financial target sum is also set, this represents the amount to be paid for every instance of payment for this code.
Show child attributes
Show child attributes
The duration of the payment code, indicating how long the code will remain active before expiring.
"1h30m"
The customer this payment code is targeting.
Show child attributes
Show child attributes
The financial target for this payment code.
Show child attributes
Show child attributes
The list of MoMo provider IDs for which the payment code is allowed to be used.
1 - 10 elements["m17", "m18"]
The ID of the financial account where the amount is settled to. This default to the owner's Main financial account.'
The metadata for the payment code.
Response
OK
Was this page helpful?
curl --request POST \
--url https://api.monime.io/payment-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'Monime-Space-Id: <monime-space-id>' \
--data '
{
"name": "EDSA Office Top-up",
"mode": "oneTime",
"isActive": true,
"amount": {
"currency": "<string>",
"value": 123
},
"duration": "1h30m",
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": [
"m17",
"m18"
],
"financialAccountId": "<string>",
"metadata": {}
}
'import requests
url = "https://api.monime.io/payment-codes"
payload = {
"name": "EDSA Office Top-up",
"mode": "oneTime",
"isActive": True,
"amount": {
"currency": "<string>",
"value": 123
},
"duration": "1h30m",
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": ["m17", "m18"],
"financialAccountId": "<string>",
"metadata": {}
}
headers = {
"Monime-Space-Id": "<monime-space-id>",
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Monime-Space-Id': '<monime-space-id>',
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'EDSA Office Top-up',
mode: 'oneTime',
isActive: true,
amount: {currency: '<string>', value: 123},
duration: '1h30m',
customerTarget: {name: 'Musa Kamara', reference: '0123456789', payingPhoneNumber: '078000000'},
financialTarget: {
expectedPaymentCount: 10,
expectedPaymentSum: {currency: '<string>', value: 123}
},
allowedProviders: ['m17', 'm18'],
financialAccountId: '<string>',
metadata: {}
})
};
fetch('https://api.monime.io/payment-codes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.monime.io/payment-codes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'EDSA Office Top-up',
'mode' => 'oneTime',
'isActive' => true,
'amount' => [
'currency' => '<string>',
'value' => 123
],
'duration' => '1h30m',
'customerTarget' => [
'name' => 'Musa Kamara',
'reference' => '0123456789',
'payingPhoneNumber' => '078000000'
],
'financialTarget' => [
'expectedPaymentCount' => 10,
'expectedPaymentSum' => [
'currency' => '<string>',
'value' => 123
]
],
'allowedProviders' => [
'm17',
'm18'
],
'financialAccountId' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"Monime-Space-Id: <monime-space-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.monime.io/payment-codes"
payload := strings.NewReader("{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Monime-Space-Id", "<monime-space-id>")
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.monime.io/payment-codes")
.header("Monime-Space-Id", "<monime-space-id>")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.monime.io/payment-codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Monime-Space-Id"] = '<monime-space-id>'
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"EDSA Office Top-up\",\n \"mode\": \"oneTime\",\n \"isActive\": true,\n \"amount\": {\n \"currency\": \"<string>\",\n \"value\": 123\n },\n \"duration\": \"1h30m\",\n \"customerTarget\": {\n \"name\": \"Musa Kamara\",\n \"reference\": \"0123456789\",\n \"payingPhoneNumber\": \"078000000\"\n },\n \"financialTarget\": {\n \"expectedPaymentCount\": 10,\n \"expectedPaymentSum\": {\n \"currency\": \"<string>\",\n \"value\": 123\n }\n },\n \"allowedProviders\": [\n \"m17\",\n \"m18\"\n ],\n \"financialAccountId\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"messages": [
"<unknown>"
],
"result": {
"id": "pmc-TJh76H8hj778hftdtu66gjio",
"name": "Home EDSA Meter Top-up",
"mode": "oneTime",
"isActive": true,
"status": "pending",
"ussdCode": "\\*715\\*1\\*0123456789#",
"amount": {
"currency": "<string>",
"value": 123
},
"customerTarget": {
"name": "Musa Kamara",
"reference": "0123456789",
"payingPhoneNumber": "078000000"
},
"financialTarget": {
"expectedPaymentCount": 10,
"expectedPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"allowedProviders": [
"m17",
"m18"
],
"progress": {
"isCompleted": true,
"totalPaymentCount": 123,
"totalPaymentSum": {
"currency": "<string>",
"value": 123
}
},
"financialAccountId": "<string>",
"expireTime": "2023-11-07T05:31:56Z",
"createTime": "2023-11-07T05:31:56Z",
"metadata": {}
}
}