Bill a customer every month
Create a monthly subscription, attach it to a payment link, and see who has subscribed.
Every snippet runs against the sandbox: set MAMO_API_KEY to your sandbox key first.
1. Create the billing schedule
Call Create Subscription with frequency set to monthly. payment_quantity caps the number of charges; monthly_start_date is the day of the month to bill on. Keep the returned identifier.
2. Attach it to a payment link
Create a payment link with the subscription's identifier as subscription_id, link_type set to inline, and the monthly amount. The link's payment_url is your sign-up page.
3. The customer subscribes
Their first payment on the link signs them up and saves their card. Mamo then charges that card on every billing date and sends a subscription.succeeded or subscription.failed webhook for each charge.
4. See your subscribers
List them with Fetch Subscribers. To stop billing one customer, use Unsubscribe subscription.
Full code
BASE=https://sandbox.dev.business.mamopay.com/manage_api/v1
# 1. Create the billing schedule
curl -s -X POST "$BASE/subscriptions" \
-H "Authorization: Bearer $MAMO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"frequency": "monthly", "frequency_interval": 1, "payment_quantity": 12, "monthly_start_date": 1}'
# 2. Attach it to a payment link
curl -s -X POST "$BASE/links" \
-H "Authorization: Bearer $MAMO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Pro plan", "amount": 99, "amount_currency": "AED",
"link_type": "inline", "subscription_id": "'"$SUBSCRIPTION_ID"'"}'
# 4. See your subscribers
curl -s "$BASE/subscriptions/$SUBSCRIPTION_ID/subscribers" \
-H "Authorization: Bearer $MAMO_API_KEY"const BASE = 'https://sandbox.dev.business.mamopay.com/manage_api/v1';
const headers = {
Authorization: `Bearer ${process.env.MAMO_API_KEY}`,
'Content-Type': 'application/json',
};
const mamo = (method, path, body) =>
fetch(`${BASE}${path}`, { method, headers, body: body && JSON.stringify(body) })
.then((r) => r.json());
// 1. Create the billing schedule
const sub = await mamo('POST', '/subscriptions', {
frequency: 'monthly', frequency_interval: 1, payment_quantity: 12, monthly_start_date: 1,
});
// 2. Attach it to a payment link
const link = await mamo('POST', '/links', {
title: 'Pro plan', amount: 99, amount_currency: 'AED',
link_type: 'inline', subscription_id: sub.identifier,
});
console.log('Sign-up page:', link.payment_url);
// 4. See your subscribers
const subscribers = await mamo('GET', `/subscriptions/${sub.identifier}/subscribers`);import os
import requests
BASE = "https://sandbox.dev.business.mamopay.com/manage_api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MAMO_API_KEY']}"}
# 1. Create the billing schedule
sub = requests.post(f"{BASE}/subscriptions", headers=HEADERS, json={
"frequency": "monthly", "frequency_interval": 1, "payment_quantity": 12, "monthly_start_date": 1,
}).json()
# 2. Attach it to a payment link
link = requests.post(f"{BASE}/links", headers=HEADERS, json={
"title": "Pro plan", "amount": 99, "amount_currency": "AED",
"link_type": "inline", "subscription_id": sub["identifier"],
}).json()
print("Sign-up page:", link["payment_url"])
# 4. See your subscribers
subscribers = requests.get(
f"{BASE}/subscriptions/{sub['identifier']}/subscribers", headers=HEADERS
).json()<?php
const BASE = 'https://sandbox.dev.business.mamopay.com/manage_api/v1';
function mamo($method, $path, $body = null) {
$ch = curl_init(BASE . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('MAMO_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body ? json_encode($body) : null,
]);
return json_decode(curl_exec($ch), true);
}
// 1. Create the billing schedule
$sub = mamo('POST', '/subscriptions', [
'frequency' => 'monthly', 'frequency_interval' => 1, 'payment_quantity' => 12, 'monthly_start_date' => 1,
]);
// 2. Attach it to a payment link
$link = mamo('POST', '/links', [
'title' => 'Pro plan', 'amount' => 99, 'amount_currency' => 'AED',
'link_type' => 'inline', 'subscription_id' => $sub['identifier'],
]);
echo 'Sign-up page: ' . $link['payment_url'];
// 4. See your subscribers
$subscribers = mamo('GET', '/subscriptions/' . $sub['identifier'] . '/subscribers');Example response
{
"identifier": "MPB-SUB-2162171A86",
"frequency": "month",
"frequency_interval": 1,
"start_date": "2026-11-01T00:00:00.000+04:00",
"end_date": null,
"payment_quantity": 12,
"monthly_start_date": 1,
"weekly_start_day": null
}Updated about 3 hours ago