SaleRequest Class

Stores information about a sales request.

Namespace

CommercePayments

Usage

This class holds all the required details about a sale request. Gateway adapters read the fields of this class object while constructing a sale JSON request thatis sent to the payment gateway. The object of this class is made available through commercepayments.paymentGatewayContext by calling getPaymentRequest().

Example

SaleRequest Constructors

The following are constructors for SaleRequest.

SaleRequest(amount)

Constructor for defining an amount for the sale request. This constructor is intended for test usage and throws an exception if used outside of the Apex test context.

Signature

global SaleRequest(Double amount)

Parameters

  • amount:

    Type: Double

    Amount of the sale request.

SaleRequest Properties

The following are properties for SaleRequest.

accountId

Customer account ID for the sale request.

Signature

global String accountId {get; set;}

Property Value

Type: String

amount

Amount of the sale request. Can be positive only.

Signature

global Double amount {get; set;}

Property Value

Type: Double

comments

Additional information about the sale request.

Signature

global String comments {get; set;}

Property Value

Type: String

currencyIsoCode

Currency code for the sale request.

Signature

global String currencyIsoCode {get; set;}

Property Value

Type: String

enhancedPaymentData

Represents enhanced payment data, including Level 2 and Level 3 fields.

Supported only for third-party payment gateways; not supported for native payments.

Signature

public commercepayments.EnhancedPaymentDataInput enhancedPaymentData {get; set;}

Property Value

Type: commercepayments.EnhancedPaymentDataInput

paymentInitiationSourceId

ID of the source that initiated the payment.

Supported only for third-party payment gateways; not supported for native payments. See PaymentInitiationSource object documentation for more information.

Signature

public String paymentInitiationSourceId {get; set;}

Property Value

Type: String

paymentMethod

Payment method used in the sale request.

Signature

global commercepayments.SaleApiPaymentMethodRequest paymentMethod {get; set;}

Property Value

Type: SaleApiPaymentMethodRequest

paymentMethodData

Payment method data used in the sale request.

This field is populated when SaleInput specifies a saved payment method. Accessible using paymentMethodData on SaleRequest. The map contains these fields from SavedPaymentMethod: GatewayToken, Type, GatewayReference, and StandardEntryCode for direct gateway interaction without querying the database.

Signature

public Map<String,String> paymentMethodData {get; set;}

Property Value

Type: Map<String,String>

submittedByMerchant

Indicates whether the sale request is submitted by the marchant (true) or not (false).

Signature

public Boolean submittedByMerchant {get; set;}

Property Value

Type: Boolean

SaleRequest Methods

The following are methods for SaleRequest.

equals(obj)

Compares this object with the specified object and returns true if both objects are equal; otherwise, returns false.

Signature

global Boolean equals(Object obj)

Parameters

  • obj:

    Type: Object

Return Value

Type: Boolean

hashCode()

Maintains the integrity of lists of type SaleRequest by determining the uniqueness of the external object records in a list.

Signature

global Integer hashCode()

Return Value

Type: Integer

toString()

Converts a date to a string.

Signature

global String toString()

Return Value

Type: String