Skip to main content
A Payment Intent captures that someone wants to pay. You create one by giving us the key details, how much to charge, who’s paying, and how, and we hand you back a link your customer can use to pay.

The general flow

Creating a Payment Intent usually goes like this:
  1. Say how much the customer needs to pay.
  2. Optionally, add more details, who the customer is, which payment methods to allow, and where to send them afterward.
  3. Get back a link to the payment page, where the customer pays.

Different ways to create a Payment Intent

1. Just the amount

The simplest case: all you need is the amount to charge. This is the most basic setup.
  • Situation: You want a customer to pay GMD 450, and you’re not adding a customer record or any other optional details.
  • Request:
const paymentIntent = await modempay.paymentIntents.create({ amount: 450 });
  • Result: A Payment Intent is created, along with a link to the payment page where the customer pays.
{
  "status": true,
  "message": "Payment intent created successfully. Please proceed to complete the payment.",
  "data": {
    "intent_secret": "8816a8e679d9df252fa80d09ebe21efaa3a8980cb053cb64afeed44c5df696f4",
    "payment_link": "https://test.checkout.modempay.com/6b63ccef-0232-4be1-b53d-be6823767874",
    "amount": 450,
    "currency": "GMD",
    "expires_at": "2025-02-13T12:31:15.601Z",
    "status": "requires_payment_method"
  }
}

2. Amount and customer

Here you add the customer who’s paying, on top of the amount. This ties the payment to a specific customer so it’s easier to keep track of.
  • Situation: You want to charge GMD 450 and link it to a particular customer.
  • Request:
const paymentIntent = await modempay.paymentIntents.create({
    amount: 450,
    customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
});

3. Amount, customer, and payment methods

A more specific setup: you set the amount, link a customer, and decide ahead of time which payment methods the customer can use. Handy when you want to limit things to certain methods.
  • Situation: You want to charge GMD 450, link it to a customer, and only allow a particular payment method.
  • Request:
const paymentIntent = await modempay.paymentIntents.create({
    amount: 450,
    customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
    payment_methods: ["card"],
});

4. Amount, customer, and a specific saved payment method

Here you point to one of the customer’s saved payment methods by its ID. Useful when you want to charge a saved card or bank account directly.
  • Situation: You want to charge GMD 450, link it to a customer, and use a specific saved payment method from their account. This lets you charge a saved method straight away, which makes things quicker for returning customers.
  • Request:
const paymentIntent = await modempay.paymentIntents.create({
    amount: 450,
    payment_method: "ad47ccb9-687c-475b-90dc-1dd3b4cba68e",
    customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
});

Common optional details

The amount is the only thing you must include. Everything else is optional, to round out the payment:
  • currency: The currency for the payment. If you leave it out, the default currency is used.
  • title: A title for the payment.
  • description: A description of the payment.
  • metadata: Any extra custom information you want to attach.
  • return_url: Where the customer is sent after they pay.
  • cancel_url: Where the customer is sent if they cancel.
  • payment_methods: A list of payment methods you’ll accept.

Wrapping up

Creating a Payment Intent is simple. You can give just the amount, or also add a customer and a payment method to shape the flow to your needs. Either way, you get back a unique link the customer uses to pay, keeping the experience smooth.