> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modempay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Payment Intent

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.

<iframe width="100%" height="425" src="https://www.youtube.com/embed/Gox1JSWZYdg?si=YoJPOWZHxGNiaRUt" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen />

#### 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**:

<CodeGroup>
  ```javascript nodejs  theme={null}
  const paymentIntent = await modempay.paymentIntents.create({ amount: 450 });
  ```

  ```python python  theme={null}
  payment_intent = modem_pay.payment_intents.create(params={"amount": 450})
  ```

  ```php php  theme={null}
  $payment_intent = $modemPay->paymentIntents()->create(['amount' => 450]);
  ```

  ```bash cURL  theme={null}
  cURL -X POST "https://api.modempay.com/v1/payments" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <your_api_key>" \
    -d '{
      "data": {
        "amount": 450,
        "from_sdk": false
      }
    }'
  ```
</CodeGroup>

* **Result**: A Payment Intent is created, along with a link to the payment page where the customer pays.

```json theme={null}
{
  "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**:

<CodeGroup>
  ```javascript nodejs  theme={null}
  const paymentIntent = await modempay.paymentIntents.create({
      amount: 450,
      customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
  });
  ```

  ```python python  theme={null}
  payment_intent = modem_pay.payment_intents.create(
      params={"amount": 450, "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330"}
  )
  ```

  ```php php  theme={null}
  $payment_intent = $modemPay->paymentIntents()->create([
      'amount' => 450,
      'customer' => 'd9bf8831-4db5-4a1c-8aa0-3de72492f330',
  ]);
  ```

  ```bash cURL  theme={null}
  cURL -X POST "https://api.modempay.com/v1/payments" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <your_api_key>" \
    -d '{
      "data": {
        "amount": 450,
        "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
        "from_sdk": false
      }
    }'
  ```
</CodeGroup>

#### 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**:

<CodeGroup>
  ```javascript nodejs  theme={null}
  const paymentIntent = await modempay.paymentIntents.create({
      amount: 450,
      customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
      payment_methods: ["card"],
  });
  ```

  ```python python  theme={null}
  payment_intent = modem_pay.payment_intents.create(
      params={
          "amount": 450,
          "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
          "payment_methods": ["card"],
      }
  )
  ```

  ```php php  theme={null}
  $payment_intent = $modemPay->paymentIntents()->create([
      'amount' => 450,
      'customer' => 'd9bf8831-4db5-4a1c-8aa0-3de72492f330',
      'payment_methods' => ['card'],
  ]);
  ```

  ```bash cURL  theme={null}
  cURL -X POST "https://api.modempay.com/v1/payments" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <your_api_key>" \
    -d '{
      "data": {
        "amount": 450,
        "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
        "payment_methods": ["card"],
        "from_sdk": false
      }
    }'
  ```
</CodeGroup>

#### 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**:

<CodeGroup>
  ```javascript nodejs  theme={null}
  const paymentIntent = await modempay.paymentIntents.create({
      amount: 450,
      payment_method: "ad47ccb9-687c-475b-90dc-1dd3b4cba68e",
      customer: "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
  });
  ```

  ```python python  theme={null}
  payment_intent = modem_pay.payment_intents.create(
      params={
          "amount": 450,
          "payment_method": "ad47ccb9-687c-475b-90dc-1dd3b4cba68e",
          "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
      }
  )
  ```

  ```php php  theme={null}
  $payment_intent = $modemPay->paymentIntents()->create([
      'amount' => 450,
      'payment_method' => 'ad47ccb9-687c-475b-90dc-1dd3b4cba68e',
      'customer' => 'd9bf8831-4db5-4a1c-8aa0-3de72492f330',
  ]);
  ```

  ```bash cURL  theme={null}
  cURL -X POST "https://api.modempay.com/v1/payments" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <your_api_key>" \
    -d '{
      "data": {
        "amount": 450,
        "customer": "d9bf8831-4db5-4a1c-8aa0-3de72492f330",
        "payment_method": "ad47ccb9-687c-475b-90dc-1dd3b4cba68e",
        "from_sdk": false
      }
    }'
  ```
</CodeGroup>

***

### 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.
