> For the complete documentation index, see [llms.txt](https://paymongo.ossph.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paymongo.ossph.org/reference/api-reference/payment-intents.md).

# Payment Intents

A \`PaymentIntent\` resource is used to track and handle different states of the payment until it succeeds.

## The Payment Intent Resource

A `PaymentIntent` resource is used to track and handle different states of the payment until it succeeds. To learn how to receive credit/debit card payments using PaymentIntent, you can check this [section](https://developers.paymongo.com/docs/accepting-cards). To learn how to receive PayMaya payments using PaymentIntent, you can check this [section](https://developers.paymongo.com/docs/accepting-paymaya-payments).

[More Details](https://developers.paymongo.com/reference/the-payment-intent-object)

## Creating a Payment Intent

```javascript
/**
 * These are the required properties
 * @param {Object} data The payload.
 * @param {Object} data.attributes Payload attributes.
 * @param {number} data.attributes.amount Amount to be collected by the PaymentIntent.
 * @param {string[]} data.attributes.payment_method_allowed The list of payment method types that the PaymentIntent is allowed to use. Possible value is card for now.
 * @param {string} data.attributes.currency Three-letter ISO currency code, in uppercase. PHP is the only supported currency as of the moment.
 */
const result = await paymongo.paymentIntents.create(data);

```

#### Payload

```javascript
{
  data: {
    attributes: {
      amount: 10000, // 10000 or 100 in money value is the smallest allowed amount.
      currency: 'PHP', // Three-letter ISO currency code. Only supports PHP for now.
      payment_method_allowed: ['card'] // The only available value for now is 'card'.
    }
  }
}

```

## Retrieving a Payment Intent

```javascript
/**
 * @param {string} id PaymentIntent id
 */
const result = await paymongo.paymentIntents.retrieve(id);

```

#### Attach to PaymentIntent

```javascript
/**
 * These are the required properties
 * @param {string} id PaymentIntent id.
 * @param {Object} data The payload.
 * @param {Object} data.attributes Payload attributes.
 * @param {string} data.attributes.payment_method Id of PaymentMethod to attach to the PaymentIntent.
 */
const result = await paymongo.paymentIntents.attach(id, data);

```

#### Payload

```javascript
{
  data: {
    attributes: {
      payment_method: 'abc123'
    }
  }
}

```

## Capture a PaymentIntent

```javascript
/**
 * @param {string} secret API private key
 * @param {string} id PaymentIntent id
 */
const result = await paymongo.paymentIntents.capture(id);
```

## Cancel a PaymentIntent

```javascript
/**
 * @param {string} secret API private key
 * @param {string} id PaymentIntent id
 */
const result = await paymongo.paymentIntents.cancel(id);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://paymongo.ossph.org/reference/api-reference/payment-intents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
