Accept a payment with a payment link

Create a hosted checkout link, send your customer to it, and confirm the payment server-side.

Every snippet runs against the sandbox: set MAMO_API_KEY to your sandbox key first.

1. Create the payment link

Call Create Payment Link with the amount, currency and the return_url your customer lands on after paying. Use your sandbox key while you build.

2. Send the customer to payment_url

Redirect the customer to the payment_url in the response, or email it to them. Mamo's checkout takes the card details, runs 3D Secure, and offers Apple Pay and Google Pay when the link's payment_methods include wallet.

3. Read the redirect

After paying, the customer returns to your return_url with status and transactionId in the query string. Use them to show a result page, but don't fulfil the order yet; the query string can be tampered with.

4. Confirm the payment server-side

Fetch the payment with Fetch Payment Info and fulfil the order only when status is captured. In production, also listen for the payment.succeeded webhook so you catch customers who close the browser before the redirect.

Full code

BASE=https://sandbox.dev.business.mamopay.com/manage_api/v1

# 1. Create the payment link
curl -s -X POST "$BASE/links" \
  -H "Authorization: Bearer $MAMO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Chocolate Box - Small",
    "amount": 119.99,
    "amount_currency": "AED",
    "return_url": "https://example.com/paid",
    "failure_return_url": "https://example.com/failed"
  }'
# 2. Send the customer to the payment_url in the response

# 4. Confirm with the transactionId from the redirect
curl -s "$BASE/payments/$TRANSACTION_ID" \
  -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',
};

// 1. Create the payment link
const link = await fetch(`${BASE}/links`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    title: 'Chocolate Box - Small',
    amount: 119.99,
    amount_currency: 'AED',
    return_url: 'https://example.com/paid',
    failure_return_url: 'https://example.com/failed',
  }),
}).then((r) => r.json());

// 2. Send the customer to link.payment_url

// 4. Confirm with the transactionId from the redirect
async function isPaid(transactionId) {
  const payment = await fetch(`${BASE}/payments/${transactionId}`, { headers })
    .then((r) => r.json());
  return payment.status === 'captured';
}
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 payment link
link = requests.post(f"{BASE}/links", headers=HEADERS, json={
    "title": "Chocolate Box - Small",
    "amount": 119.99,
    "amount_currency": "AED",
    "return_url": "https://example.com/paid",
    "failure_return_url": "https://example.com/failed",
}).json()

# 2. Send the customer to link["payment_url"]

# 4. Confirm with the transactionId from the redirect
def is_paid(transaction_id):
    payment = requests.get(f"{BASE}/payments/{transaction_id}", headers=HEADERS).json()
    return payment["status"] == "captured"
<?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 payment link
$link = mamo('POST', '/links', [
    'title' => 'Chocolate Box - Small',
    'amount' => 119.99,
    'amount_currency' => 'AED',
    'return_url' => 'https://example.com/paid',
    'failure_return_url' => 'https://example.com/failed',
]);

// 2. Send the customer to $link['payment_url']

// 4. Confirm with the transactionId from the redirect
$payment = mamo('GET', '/payments/' . $_GET['transactionId']);
$paid = $payment['status'] === 'captured';

Example response

{
  "id": "MB-LINK-37D90AAF51",
  "title": "Chocolate Box - Small",
  "amount": 119.99,
  "amount_currency": "AED",
  "active": true,
  "status": "active",
  "link_type": "standalone",
  "return_url": "https://example.com/paid",
  "failure_return_url": "https://example.com/failed",
  "payment_methods": ["card", "wallet"],
  "payment_url": "https://sandbox.dev.business.mamopay.com/pay/mamo-c1f890"
}

Did this page help you?