Newer Version Available

This content describes an older version of this product. View Latest

PaymentGatewayContext Class

Wraps the information related to a payment request.

Namespace

CommercePayments

Usage

The constructor of this class takes no arguments. For example:

CommercePayments.PaymentGatewayContext pgc = new CommercePayments.PaymentGatewayContext();

Example

1global commercepayments.GatewayResponse processRequest(commercepayments.PaymentGatewayContext gatewayContext) {
2    commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();
3    if (requestType == commercepayments.RequestType.Capture) {
4        commercepayments.CaptureRequest captureRequest = (commercepayments.CaptureRequest) gatewayContext.getPaymentRequest();
5    }
6}

PaymentGatewayContext Constructors

The following are constructors for PaymentGatewayContext.

PaymentGatewayContext(request, requestType)

Constructor to enable instance creation. This constructor is intended for test usage and throws an exception if used outside of the Apex test context.

Signature

global PaymentGatewayContext(commercepayments.PaymentGatewayRequest request, String requestType)

Parameters

request
Type: commercepayments.PaymentGatewayRequest
Raw payload. Sensitive attributes are masked to ensure PCI compliance.
requestType
Type: String
Defines the type of request made to the gateway

PaymentGatewayContext Methods

The following are methods for PaymentGatewayContext.

getPaymentRequest()

Returns the payment request object.

Signature

global commercepayments.PaymentGatewayRequest getPaymentRequest()

Return Value

Type: PaymentGatewayRequest

getPaymentRequestType()

Returns the payment request type.

Signature

global String getPaymentRequestType()

Return Value

Type: String