> ## Documentation Index
> Fetch the complete documentation index at: https://wpay-feat-edp-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a card transaction

> Create a payment with a credit or debit card.

A card transaction can be created by calling the
[`POST /transactions`][authorize] API. The call requires an `amount`,
`currency`, and a `payment_method` for the card.

<Tip>
  Check out our guides to learn more about [payment methods](/guides/api/resources/payment-methods/overview) and
  the ability to tie a payment method to a [buyer](/guides/api/resources/buyers/overview).
</Tip>

<CodeGroup>
  ```bash cURL
  curl -i -X POST "https://api.example.gr4vy.app/transactions" \
      -H "Authorization: Bearer [JWT_TOKEN]" \
      -H "Content-Type: application/json" \
      -d '{
            "amount": 1299,
            "currency": "AUD",
            "payment_method": {
              "method": "card",
              "number": "4111111111111111",
              "expiration_date": "11/25",
              "security_code": "123"
            }
          }'
  ```

  ```js Node
  var fetch = require("node-fetch");

  fetch("https://api.example.gr4vy.app/transactions", {
    method: "POST",
    headers: {
      Authorization: "Bearer [JWT_TOKEN]",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      amount: 1299,
      currency: "AUD",
      payment_method: {
        method: "card",
        number: "4111111111111111",
        expiration_date: "11/21",
        security_code: "123",
      },
    }),
  });
  ```
</CodeGroup>

This API will return the [authorized transaction][authorize]. The status of this
transaction can vary for a few reasons including the status provided by the
payment service, as well as the requested `intent`.

<Info>
  **Statuses**

  See our guide on [transaction statuses](/guides/api/resources/transactions/statuses) for more
  details.
</Info>

## Capture

By default a card transaction is only authorized and not automatically captured.
A transaction can be captured either directly when creating a transaction, or as
a separate API call.

### Simultaneous authorize and capture

To capture a transaction immediately, set the `intent` to `capture`.

<CodeGroup>
  ```bash cURL
  curl -i -X POST "https://api.example.gr4vy.app/transactions" \
      -H "Authorization: Bearer [JWT_TOKEN]" \
      -H "Content-Type: application/json" \
      -d '{
            "amount": 1299,
            "currency": "AUD",
            "intent": "capture",
            "payment_method": {
              "method": "card",
              "number": "4111111111111111",
              "expiration_date": "11/25",
              "security_code": "123"
            }
          }'
  ```

  ```js Node
  var fetch = require("node-fetch");

  fetch("https://api.example.gr4vy.app/transactions", {
    method: "POST",
    headers: {
      Authorization: "Bearer [JWT_TOKEN]",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      amount: 1299,
      currency: "AUD",
      intent: "capture",
      payment_method: {
        method: "card",
        number: "4111111111111111",
        expiration_date: "11/21",
        security_code: "123",
      },
    }),
  });
  ```
</CodeGroup>

### Capture after authorization

Alternatively, it is possible to perform a capture on a previously authorized
transaction by calling the
[`POST /transactions/{transaction_id}/capture`][capture] API.

<CodeGroup>
  ```bash cURL
  curl -i -X POST "https://api.example.gr4vy.app/transactions/fe26475d-ec3e-4884-9553-f7356683f7f9/capture \
      -H "Authorization: Bearer [JWT_TOKEN]"
  ```

  ```js Node
  var fetch = require("node-fetch");

  fetch(
    "https://api.example.gr4vy.app/transactions/fe26475d-ec3e-4884-9553-f7356683f7f9/capture",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer [JWT_TOKEN]",
      },
    }
  );
  ```
</CodeGroup>

[authorize]: /reference/transactions/new-transaction

[capture]: /reference/transactions/capture-transaction
