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

# Capture payment Action

export const TxnTag = ({status}) => {
  const getStyles = status => {
    const baseStyle = {
      display: 'inline-block',
      padding: '4px 8px',
      borderRadius: '4px',
      fontSize: '13px',
      fontWeight: '400'
    };
    switch (status) {
      case "PENDING":
        return {
          ...baseStyle,
          backgroundColor: '#ececec',
          color: '#9f9f9f'
        };
      case "AUTHORIZED":
        return {
          ...baseStyle,
          backgroundColor: '#ecfdf5',
          color: '#047857'
        };
      case "SETTLED":
      case "PARTIALLY_SETTLED":
        return {
          ...baseStyle,
          backgroundColor: '#ecfdf5',
          color: '#047857'
        };
      case "DECLINED":
      case "FAILED":
        return {
          ...baseStyle,
          backgroundColor: '#fef2f2',
          color: '#dc2626'
        };
      case "CANCELLED":
        return {
          ...baseStyle,
          backgroundColor: '#fefce8',
          color: '#d78203'
        };
      case "SETTLING":
        return {
          ...baseStyle,
          backgroundColor: '#e0f2fe',
          color: '#0c4a6e'
        };
      default:
        return {
          ...baseStyle,
          backgroundColor: '#f3f4f6',
          color: '#374151'
        };
    }
  };
  return <span style={getStyles(status)}>{status}</span>;
};

## What does this Action do?

The "Capture payment" Action is responsible for sending the capture request. It enables you to define rules where you wish to perform an automatic capture of funds.

Learn more about capturing payments [here](/manage-payments/capture-payment).

<Frame caption="Workflow example">
  <img src="https://mintcdn.com/primer-cc826789/xLgoTOSuc1hi-Q-M/images/workflows/capture-payment/action-in-workflow.png?fit=max&auto=format&n=xLgoTOSuc1hi-Q-M&q=85&s=051059c481a81f36f4db34b4cfb053ad" alt="Workflow example" width="1536" height="880" data-path="images/workflows/capture-payment/action-in-workflow.png" />
</Frame>

<Warning>
  If the payment is not in the <TxnTag status="AUTHORIZED" /> state, you will not be able to perform a capture.
</Warning>

## How to use the Action

* Assign a `payment ID` - this will usually be the "Payment ID" from the ["Payment created" Trigger](/workflows/apps/native-apps/primer-payments-app/payment-created-trigger) output or ["Payment status updated" Trigger](/workflows/apps/native-apps/primer-payments-app/payment-status-updated-trigger) output
* \[Optional] Set `amount` input if you wish to [partial capture](/manage-payments/capture-payment#partial-capture)
* \[Optional] Uncheck `final` input if you wish to do multiple automated partial captures

<Note>
  Capture can be asynchronous i.e. once the capture call is sent to the processor, it can take some time for the payment to become <TxnTag status="SETTLED" />. Learn more [here](/manage-payments/capture-payment#handle-asynchronous-capture) and how to handle these scenarios.
</Note>

## Use cases

All your payments must be captured to charge the customer’s account and transfer the funds to your merchant account. Based on your needs, you can utilize this action in a few ways. Below are some examples for inspiration:

<Tip>
  Simple payment flow that if authorized, shows the success screen then captures, else it shows the failure screen to the customer.
</Tip>

<Frame caption="Use Case 1">
  <img src="https://mintcdn.com/primer-cc826789/xLgoTOSuc1hi-Q-M/images/workflows/capture-payment/auth_success.png?fit=max&auto=format&n=xLgoTOSuc1hi-Q-M&q=85&s=dbacadf5a9484b7b4c7e06c2bab01dd4" alt="Use Case 1" width="1536" height="712" data-path="images/workflows/capture-payment/auth_success.png" />
</Frame>

<Tip>
  Separate workflow using the "Payment status updated" Trigger to always automatically capture if the status becomes <TxnTag status="AUTHORIZED" />. This is very useful if you have multiple workflows using the "Payment created" Trigger but you want to handle authorized payments in one way (in this case, always capture).
</Tip>

<Frame caption="Use Case 2">
  <img src="https://mintcdn.com/primer-cc826789/xLgoTOSuc1hi-Q-M/images/workflows/capture-payment/trigger-set-up.png?fit=max&auto=format&n=xLgoTOSuc1hi-Q-M&q=85&s=334605311978b82ca108527fdde847b4" alt="Use Case 2" width="1536" height="744" data-path="images/workflows/capture-payment/trigger-set-up.png" />
</Frame>

<Tip>
  Single workflow to determine whether to capture the payment or not based on the results of the CVV and AVS checks.
</Tip>

<Frame caption="Use Case 3">
  <img src="https://mintcdn.com/primer-cc826789/xLgoTOSuc1hi-Q-M/images/workflows/capture-payment/capture_check.png?fit=max&auto=format&n=xLgoTOSuc1hi-Q-M&q=85&s=d0f2c03965212572774c551a3cfddc20" alt="Use Case 3" width="1536" height="774" data-path="images/workflows/capture-payment/capture_check.png" />
</Frame>
