# capturePayment - Payment Module Reference

This documentation provides a reference to the `capturePayment` method. This belongs to the Payment Module.

You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](https://docs.medusajs.com/medusa-workflows-reference).

This method captures a payment using its associated payment provider.

Learn more about the payment flow in [this guide](https://docs.medusajs.com/resources/commerce-modules/payment/payment-flow)

## Example

```ts
const payment = await paymentModuleService.capturePayment({
  payment_id: "pay_123",
})
```

## Parameters

- data: (\[CreateCaptureDTO]\(../../../interfaces/payment.CreateCaptureDTO/page.mdx)) The payment capture to be created.

  - payment\_id: (\`string\`) The associated payment's ID.

  - amount: (\[BigNumberInput]\(../../../types/payment.BigNumberInput/page.mdx)) The amount of the capture.

    - value: (\`string\` \\| \`number\`)

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - captured\_by: (\`string\`) Who captured the payment. For example,
    a user's ID.

  - is\_captured: (\`boolean\`) Whether the capture was automatically captured.
- sharedContext: (\[Context]\(../../../interfaces/payment.Context/page.mdx)) A context used to share resources, such as transaction manager, between the application and the module.

  - transactionManager: (TManager) An instance of a transaction manager of type \`TManager\`, which is a typed parameter passed to the context to specify the type of the \`transactionManager\`.

  - manager: (TManager) An instance of a manager, typically an entity manager, of type \`TManager\`, which is a typed parameter passed to the context to specify the type of the \`manager\`.

  - isolationLevel: (\`string\`) A string indicating the isolation level of the context. Possible values are \`READ UNCOMMITTED\`, \`READ COMMITTED\`, \`REPEATABLE READ\`, or \`SERIALIZABLE\`.

  - enableNestedTransactions: (\`boolean\`) A boolean value indicating whether nested transactions are enabled.

  - eventGroupId: (\`string\`) A string indicating the ID of the group to aggregate the events to be emitted at a later point.

  - transactionId: (\`string\`) A string indicating the ID of the current transaction.

  - runId: (\`string\`) A string indicating the ID of the current run.

  - messageAggregator: (\[IMessageAggregator]\(../../../interfaces/payment.IMessageAggregator/page.mdx)) An instance of a message aggregator, which is used to aggregate messages to be emitted at a later point.

  - requestId: (\`string\`) A string indicating the ID of the current request.

  - idempotencyKey: (\`string\`) A string indicating the idempotencyKey of the current workflow execution.

  - parentStepIdempotencyKey: (\`string\`) A string indicating the idempotencyKey of the parent workflow execution.

  - preventReleaseEvents: (\`boolean\`) preventReleaseEvents

  - isCancelling: (\`boolean\`) A boolean value indicating whether the current workflow execution is being cancelled.

  - cancelingFromParentStep: (\`boolean\`) Weither or not a sub workflow cancellation is being triggered from a parent step.
    If true, the parent step will not be triggered by the sub workflow.

## Returns

- Promise: (Promise\&#60;\[PaymentDTO]\(../../../interfaces/payment.PaymentDTO/page.mdx)\&#62;) The payment's details.

  - id: (\`string\`) The ID of the payment.

  - amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The payment's total amount.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - currency\_code: (\`string\`) The ISO 3 character currency code of the payment.

  - provider\_id: (\`string\`) The ID of the associated payment provider.

  - payment\_collection\_id: (\`string\`) The ID of the associated payment collection.

  - raw\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The raw amount of the payment.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - authorized\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The authorized amount of the payment.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - raw\_authorized\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The raw authorized amount of the payment.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - data: (\`Record\<string, unknown>\`) The data relevant for the payment provider to process the payment.

  - created\_at: (\`string\` \\| \`Date\`) When the payment was created.

  - updated\_at: (\`string\` \\| \`Date\`) When the payment was updated.

  - captured\_at: (\`string\` \\| \`Date\`) When the payment was captured.

  - canceled\_at: (\`string\` \\| \`Date\`) When the payment was canceled.

  - captured\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The sum of the associated captures' amounts.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - raw\_captured\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The sum of the associated captures' raw amounts.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - refunded\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The sum of the associated refunds' amounts.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - raw\_refunded\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The sum of the associated refunds' raw amounts.

    - numeric: (\`number\`)

    - raw: (\[BigNumberRawValue]\(../../../types/payment.BigNumberRawValue/page.mdx))

    - bigNumber: (\`BigNumber\`)

  - captures: (\[CaptureDTO]\(../../../interfaces/payment.CaptureDTO/page.mdx)\[]) The associated captures.

    - id: (\`string\`) The ID of the capture.

    - amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The captured amount.

    - created\_at: (\`Date\`) The creation date of the capture.

    - payment: (\[PaymentDTO]\(../../../interfaces/payment.PaymentDTO/page.mdx)) The associated payment.

    - raw\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The raw captured amount.

    - created\_by: (\`string\`) Who the capture was created by. For example,
      the ID of a user.

  - refunds: (\[RefundDTO]\(../../../interfaces/payment.RefundDTO/page.mdx)\[]) The associated refunds.

    - id: (\`string\`) The ID of the refund

    - amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The refunded amount.

    - created\_at: (\`Date\`) The creation date of the refund.

    - payment: (\[PaymentDTO]\(../../../interfaces/payment.PaymentDTO/page.mdx)) The associated payment.

    - raw\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The raw refunded amount.

    - refund\_reason\_id: (\`null\` \\| \`string\`) The id of the refund\\\_reason that is associated with the refund

    - refund\_reason: (\`null\` \\| \[RefundReasonDTO]\(../../../interfaces/payment.RefundReasonDTO/page.mdx)) The id of the refund\\\_reason that is associated with the refund

    - note: (\`null\` \\| \`string\`) A field to add some additional information about the refund

    - created\_by: (\`string\`) Who created the refund. For example,
      the user's ID.

  - payment\_collection: (\[PaymentCollectionDTO]\(../../../interfaces/payment.PaymentCollectionDTO/page.mdx)) The associated payment collection.

    - id: (\`string\`) The ID of the payment collection.

    - currency\_code: (\`string\`) The ISO 3 character currency code of the payment sessions and payments associated with payment collection.

    - amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The total amount to be authorized and captured.

    - status: (\[PaymentCollectionStatus]\(../../../types/payment.PaymentCollectionStatus/page.mdx)) The status of the payment collection.

    - payment\_providers: (\[PaymentProviderDTO]\(../../../interfaces/payment.PaymentProviderDTO/page.mdx)\[]) The payment provider used to process the associated payment sessions and payments.

    - authorized\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The amount authorized within the associated payment sessions.

    - refunded\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The amount refunded within the associated payments.

    - captured\_amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The amount captured within the associated payments.

    - completed\_at: (\`string\` \\| \`Date\`) When the payment collection was completed.

    - created\_at: (\`string\` \\| \`Date\`) When the payment collection was created.

    - updated\_at: (\`string\` \\| \`Date\`) When the payment collection was updated.

    - metadata: (\`Record\<string, unknown>\`) Holds custom data in key-value pairs.

    - payment\_sessions: (\[PaymentSessionDTO]\(../../../interfaces/payment.PaymentSessionDTO/page.mdx)\[]) The associated payment sessions.

    - payments: (\[PaymentDTO]\(../../../interfaces/payment.PaymentDTO/page.mdx)\[]) The associated payments.

  - payment\_session: (\[PaymentSessionDTO]\(../../../interfaces/payment.PaymentSessionDTO/page.mdx)) The payment session from which the payment is created.

    - id: (\`string\`) The ID of the payment session.

    - amount: (\[BigNumberValue]\(../../../types/payment.BigNumberValue/page.mdx)) The amount to authorize.

    - currency\_code: (\`string\`) The 3 character currency code of the payment session.

    - provider\_id: (\`string\`) The ID of the associated payment provider.

    - data: (\`Record\<string, unknown>\`) The data necessary for the payment provider to process the payment session.

    - status: (\[PaymentSessionStatus]\(../../../types/payment.PaymentSessionStatus/page.mdx)) The status of the payment session.

    - created\_at: (\`string\` \\| \`Date\`) When the payment session was created

    - updated\_at: (\`string\` \\| \`Date\`) When the payment session was updated

    - payment\_collection\_id: (\`string\`) The ID of the associated payment collection.

    - context: (\`Record\<string, unknown>\`) The context necessary for the payment provider.

    - authorized\_at: (\`Date\`) When the payment session was authorized.

    - payment\_collection: (\[PaymentCollectionDTO]\(../../../interfaces/payment.PaymentCollectionDTO/page.mdx)) The payment collection the session is associated with.

    - payment: (\[PaymentDTO]\(../../../interfaces/payment.PaymentDTO/page.mdx)) The payment created from the session.

    - metadata: (\`Record\<string, unknown>\`) Holds custom data in key-value pairs.
