CaptureRequest Class

Represents a capture request. This class extends the BaseRequest class and inherits all its methods.

Namespace

CommercePayments

Usage

The CaptureRequest class’s buildCaptureRequest method creates a CaptureRequest object to store payment information, such as value and currency, as JSON strings.

Example

Builds a CaptureRequest object for a multicurrency org.
1private String buildCaptureRequest(commercepayments.CaptureRequest captureRequest) {
2        Boolean IS_MULTICURRENCY_ORG = UserInfo.isMultiCurrencyOrganization();
3        QueryUtils qBuilderForAuth = new QueryUtils(PaymentAuthorization.SObjectType);
4        // Add required fields
5        qBuilderForAuth.getSelectClause().addField('GatewayRefNumber', false);
6        if (IS_MULTICURRENCY_ORG) {
7            // addField also takes a boolean to enable translation (uses label instead of actual value)
8            qBuilderForAuth.getSelectClause().addField('CurrencyIsoCode', false);
9        }

CaptureRequest Constructors

The following are constructors for CaptureRequest.

CaptureRequest(amount, authorizationId)

This constructor is intended for test usage and throws an exception if used outside of the Apex test context.

Parameters

  • amount:

    Type: Double

    The amount to be debited or captured.

  • authorizationId:

    Type: String

    Represents

    a payment authorization record.

CaptureRequest Properties

The following are properties for CaptureRequest.

accountId

Account ID value. References an account record.

Property Value

Type: String

amount

Amount of currency that needs to be captured.

Property Value

Type: Double

paymentAuthorizationId

ID value that references a PaymentAuthorization.

Property Value

Type: String