PaymentMethodTokenizationResponse Class

Gateway response sent by payment gateway adapters for the payment method tokenization request. The response includes the payment method’s token ID value.

CommercePayments

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

CommercePayments.PaymentMethodTokenizationResponse pmtr = new CommercePayments.PaymentMethodTokenizationResponse();

After the payment gateway processes a tokenization request, the fields of PaymentMethodTokenizationResponse receive and store information from the gateway’s response. The gateway’s response shows whether the tokenization request was successful, the token value, and any additional messages or information about the tokenization process. You can then pass an instance of PaymentMethodTokenizationResponse to an authorization response or a sale response. This class is mapped to a response class in the Java layer.

This constructor builds a new instance of the PaymentMethodTokenizationResponse class.

PaymentMethodTokenizationResponse contains only setter methods. Each setter accepts a value from the payment gateway and use it to set an attribute of PaymentMethodTokenizationResponse.

The most important method in PaymentMethodTokenizationResponse is setGatewayTokenEncrypted, which uses Salesforce encryption to set an encrypted token value for a payment method. The setGatewayTokenEncrypted method is available in Salesforce API v52.0 and later. We recommend using it to ensure your tokenized payment method values are encrypted and secure. While the setGatewayToken method (available in earlier API versions) also returns a payment method token, the tokenized value isn’t encrypted.

If the instantiated class already has a gateway token, setGatewayTokenEncrypted throws an error.

A typical instantiation of PaymentMethodTokenizationResponse sets the encrypted gateway token alongside the other tokenization response values sent by the gateway.

After you’ve built a PaymentMethodTokenizationResponse object and set the encrypted gateway token, pass the object to the setPaymentMethodTokenizationResponse method of an authorization response or a sale response.

The following are methods for PaymentMethodTokenizationResponse.

Sets the amount for payment tokenization. Can be positive, negative, or zero.

public void setAmount(Double amount)

Type: void

Indicates whether the gateway response is received asynchronously (true) or not (false). When set to true, the saved payment method remains in a pending state until the async notification is received.

public void setAsync(Boolean async)

Type: void

Sets the bank name for payment tokenization.

public void setBankName(String bankName)

Type: void

Sets the unique hash of the payment method that the gateway returned.

public void setChecksum(String checksum)

Type: void

Sets the customer reference number that the gateway returned.

public void setCustomerReference(String customerReference)

  • customerReference: Type: String

Type: void

Sets the AVS (address verification system) result code information that the gateway returned. Maximum length of 64 characters.

global void setGatewayAvsCode(String gatewayAvsCode)

  • gatewayAvsCode: Type: String Used to verify the address mapped to a payment method when the payments platform requests tokenization from the payment gateway.

Type: void

Sets the date that the tokenization occurred. Some gateways don’t send this value.

global void setGatewayDate(Datetime gatewayDate)

Type: void

Sets error messages that the gateway returned for the tokenization request. Maximum length of 255 characters.

global void setGatewayMessage(String gatewayMessage)

  • gatewayMessage: Type: String

Type: void

Sets any additional reference details that the gateway returned.

public void setGatewayReferenceDetails(String gatewayReferenceDetails)

  • gatewayReferenceDetails: Type: String

Type: void

Sets the reference number that the gateway returned.

public void setGatewayReferenceNumber(String gatewayReferenceNumber)

  • gatewayReferenceNumber: Type: String

Type: void

Sets a gateway-specific result code. The code may be mapped to a Salesforce-specific result code. Maximum length of 64 characters.

global void setGatewayResultCode(String gatewayResultCode)

  • gatewayResultCode: Type: String Gateway-specific result code. Must be used to map a Salesforce-specific result code.

Type: void

Sets a description of the gateway-specific result code that a payment gateway returned. Maximum length of 1000 characters.

global void setGatewayResultCodeDescription(String gatewayResultCodeDescription)

  • gatewayResultCodeDescription: Type: String Provides additional information about the result code and why the gateway returned the specific code. Descriptions will vary between different gateways.

Type: void

Sets the gateway token value that the gateway returned.

global void setGatewayToken(String gatewayToken)

  • gatewayToken: Type: String The gateway token that the payment gateway sends following a tokenization request. For the CardPaymentMethod and DigitalWallet objects, use the gatewyTokenEncrypted parameter, which encrypts the token value.

Type: void

Sets any additional information that the gateway returned about the payment token.

global void setGatewayTokenDetails(String gatewayTokenDetails)

  • gatewayTokenDetails: Type: String

Type: void

Sets the value of the gatewayTokenEncrypted field on a CardPaymentMethod or DigitalWallet object.

global void setGatewayTokenEncrypted(String gatewayTokenEncrypted)

  • gatewayTokenEncrypted: Type: String The gateway token that the payment gateway sends following a tokenization request. Salesforce Payments uses Salesforce encryption to encrypt the token value.

Type: void

Sets the Salesforce-specific result code information. Payment gateways have many response codes for payment calls. Salesforce uses the result code information to map payment gateway codes to a predefined set of standard Salesforce result codes.

global void setSalesforceResultCodeInfo(commercepayments.SalesforceResultCodeInfo salesforceResultCodeInfo)

Type: void