---
schema_version: "1"
id: 29ab7d28c5394829b59e0281b804464550a80175fe35b16243ce0e1eab315404
title: BankPaymentMethodRequest Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_commercepayments_BankPaymentMethodRequest.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 30197e6a6edcfe20bd910a357c5ec9f71aa88b8d51b1c432565f3e2445628ea3
description: Sends data related to a bank payment method to a gateway adapter during a service call.The first name of the account holder for the bank payment method.The last name of the account holder for the bank payment method.The name of the account holder for the bank payment method.The type of the account holder.Salesforce Payments account ID associated with the bank payment method.The unique account number for the bank account.The type for the bank account.Indicates whether a token for recurring payments is being requested (true) or not (false). The token enables the payment method to be used for recurring payments.The routing number is a unique nine-digit code that identifies the bank.The bank type associated with the bank payment method.Additional details about the bank account.The email address of the bank account holder.Authorization from the account holder to debit their payment method.The nick name of the account holder.The three-letter code that identifies the type of electronic payment transaction being processed within the Automated Clearing House (ACH) network.Maintains the integrity of lists of type BankPaymentMethodRequest by determining the equality of external objects in a list. This method is dynamic and based on the equals method in Java.Maintains the integrity of lists of type BankPaymentMethodRequest.Converts a date to a string.
---
# BankPaymentMethodRequest Class

Sends data related to a bank payment method to a gateway adapter during a service call.

## Namespace

[CommercePayments](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commercepayments.htm "Use the CommercePayments namespace to provide a safe and customizable platform for managing customer payments and refunds.")

## Usage

Use the BankPaymentMethodRequest class to include bank payment details in a Tokenize request. The gateway adapter reads the fields from this class when constructing the tokenized JSON request for the payment gateway. You can create an instance of this class by calling bankPaymentMethod on the PaymentMethodTokenizationRequest class.

## Example

private String buildTokenizationRequest(commercepayments.PaymentMethodTokenizationRequest tokenizeRequest) {
    commercepayments.BankPaymentMethodRequest bankPaymentMethod = tokenizeRequest.bankPaymentMethod;

    // Setup currency
    String currencyIso = UserInfo.getDefaultCurrency();

    String accountId;
    JSONGenerator jsonGeneratorInstance = JSON.createGenerator(true);
    jsonGeneratorInstance.writeStartObject();

    // Basic fields
    jsonGeneratorInstance.writeStringField('merchantAccount', '{!$Credential.Username}');
    jsonGeneratorInstance.writeStringField('reference', 'Tokenize\_' + String.valueOf(Datetime.now().getTime()));

    // Payment method details (from encrypted form input)
    jsonGeneratorInstance.writeFieldName('paymentMethod');
    jsonGeneratorInstance.writeStartObject();

    if (bankPaymentMethod != null) {
        accountId = bankPaymentMethod.accountId;
        if (bankPaymentMethod.bankType.equals(commercepayments.BankType.Ach)) {
            currencyIso = 'USD';
            jsonGeneratorInstance.writeStringField('type', 'ach');
            jsonGeneratorInstance.writeStringField('bankAccountNumber', bankPaymentMethod.accountNumber);
            jsonGeneratorInstance.writeStringField('bankLocationId', bankPaymentMethod.bankCode);
            jsonGeneratorInstance.writeStringField('ownerName', bankPaymentMethod.accountHolderName);

        } else if (bankPaymentMethod.bankType.equals(commercepayments.BankType.SepaDebit)) {

            currencyIso = 'EUR';
            jsonGeneratorInstance.writeStringField('type', 'sepadirectdebit');
            jsonGeneratorInstance.writeStringField('iban', bankPaymentMethod.accountNumber);
            jsonGeneratorInstance.writeStringField('ownerName', bankPaymentMethod.accountHolderName);

        } else if (bankPaymentMethod.bankType.equals(commercepayments.BankType.Bacs)) {

            currencyIso = 'GBP';
            jsonGeneratorInstance.writeStringField('type', 'directdebit\_GB');
            jsonGeneratorInstance.writeStringField('bankAccountNumber', bankPaymentMethod.accountNumber);
            jsonGeneratorInstance.writeStringField('bankLocationId', bankPaymentMethod.bankCode);
            jsonGeneratorInstance.writeStringField('holderName', bankPaymentMethod.accountHolderName);

        } else if (bankPaymentMethod.bankType.equals(commercepayments.BankType.Becs)) {

            currencyIso = 'AUD';
            jsonGeneratorInstance.writeStringField('type', 'directdebit\_AU');
            jsonGeneratorInstance.writeStringField('bankAccountNumber', bankPaymentMethod.accountNumber);
            jsonGeneratorInstance.writeStringField('bsb', bankPaymentMethod.bankCode);
            jsonGeneratorInstance.writeStringField('ownerName', bankPaymentMethod.accountHolderName);

        } else {
            //Add support for other banks if required in future.
        }

        jsonGeneratorInstance.writeEndObject();
    }

    // Zero-dollar amount
    jsonGeneratorInstance.writeFieldName('amount');
    jsonGeneratorInstance.writeStartObject();
    jsonGeneratorInstance.writeNumberField('value', 0);
    jsonGeneratorInstance.writeStringField('currency', currencyIso);
    jsonGeneratorInstance.writeEndObject();

    // Save payment method for later
    jsonGeneratorInstance.writeStringField('shopperReference', accountId);
    jsonGeneratorInstance.writeBooleanField('storePaymentMethod', true);
    jsonGeneratorInstance.writeStringField('shopperInteraction', 'Ecommerce');
    jsonGeneratorInstance.writeStringField('recurringProcessingModel', 'UnscheduledCardOnFile');

    commercepayments.AddressRequest billingAddress = tokenizeRequest.address;

    if (billingAddress != null) {
        jsonGeneratorInstance.writeFieldName('billingAddress');
        jsonGeneratorInstance.writeStartObject();
        jsonGeneratorInstance.writeStringField('street', billingAddress.street);
        jsonGeneratorInstance.writeStringField('stateOrProvince', billingAddress.state);
        jsonGeneratorInstance.writeStringField('city', billingAddress.city);
        jsonGeneratorInstance.writeStringField('postalCode', billingAddress.postalCode);
        jsonGeneratorInstance.writeStringField('country', billingAddress.country);
        jsonGeneratorInstance.writeEndObject();

    }
    jsonGeneratorInstance.writeEndObject();
    return jsonGeneratorInstance.getAsString();
}

- **[BankPaymentMethodRequest Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_properties)**
- **[BankPaymentMethodRequest Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_methods)**

## BankPaymentMethodRequest Properties

The following are properties for BankPaymentMethodRequest.

- **[accountHolderFirstName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountHolderFirstName)**  
    The first name of the account holder for the bank payment method.
- **[accountHolderLastName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountHolderLastName)**  
    The last name of the account holder for the bank payment method.
- **[accountHolderName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountHolderName)**  
    The name of the account holder for the bank payment method.
- **[accountHolderType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountHolderType)**  
    The type of the account holder.
- **[accountId](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountId)**  
    Salesforce Payments account ID associated with the bank payment method.
- **[accountNumber](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountNumber)**  
    The unique account number for the bank account.
- **[accountType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_accountType)**  
    The type for the bank account.
- **[autoPay](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_autoPay)**  
    Indicates whether a token for recurring payments is being requested (true) or not (false). The token enables the payment method to be used for recurring payments.
- **[bankCode](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_bankCode)**  
    The routing number is a unique nine-digit code that identifies the bank.
- **[bankType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_bankType)**  
    The bank type associated with the bank payment method.
- **[comments](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_comments)**  
    Additional details about the bank account.
- **[email](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_email)**  
    The email address of the bank account holder.
- **[mandate](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_mandate)**  
    Authorization from the account holder to debit their payment method.
- **[nickName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_nickName)**  
    The nick name of the account holder.
- **[standardEntryClassCode](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_standardEntryClassCode)**  
    The three-letter code that identifies the type of electronic payment transaction being processed within the Automated Clearing House (ACH) network.

### accountHolderFirstName

The first name of the account holder for the bank payment method.

#### Signature

public String accountHolderFirstName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### accountHolderLastName

The last name of the account holder for the bank payment method.

#### Signature

public String accountHolderLastName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### accountHolderName

The name of the account holder for the bank payment method.

#### Signature

public String accountHolderName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### accountHolderType

The type of the account holder.

#### Signature

public commercepayments.AccountHolderType accountHolderType {get; set;}

#### Property Value

Type: commercepayments.[AccountHolderType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_AccountHolderType.htm "Specifies the type of the account holder.")

### accountId

Salesforce Payments account ID associated with the bank payment method.

#### Signature

public String accountId {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### accountNumber

The unique account number for the bank account.

#### Signature

public String accountNumber {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### accountType

The type for the bank account.

#### Signature

public commercepayments.AccountType accountType {get; set;}

#### Property Value

Type: commercepayments.[AccountType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_AccountType.htm "Specifies the account type.")

### autoPay

Indicates whether a token for recurring payments is being requested (true) or not (false). The token enables the payment method to be used for recurring payments.

#### Signature

public Boolean autoPay {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### bankCode

The routing number is a unique nine-digit code that identifies the bank.

#### Signature

public String bankCode {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### bankType

The bank type associated with the bank payment method.

#### Signature

public commercepayments.BankType bankType {get; set;}

#### Property Value

Type: commercepayments.[BankType](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_BankType.htm "Specifies the bank type.")

### comments

Additional details about the bank account.

#### Signature

public String comments {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### email

The email address of the bank account holder.

#### Signature

public String email {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### mandate

Authorization from the account holder to debit their payment method.

#### Signature

public String mandate {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### nickName

The nick name of the account holder.

#### Signature

public String nickName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### standardEntryClassCode

The three-letter code that identifies the type of electronic payment transaction being processed within the Automated Clearing House (ACH) network.

#### Signature

public commercepayments.StandardEntryClassCode standardEntryClassCode {get; set;}

#### Property Value

Type: commercepayments.[StandardEntryClassCode](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_StandardEntryClassCode.htm "Specifies the three-letter code that identifies the type of electronic payment transaction being processed within the Automated Clearing House (ACH) network.")

## BankPaymentMethodRequest Methods

The following are methods for BankPaymentMethodRequest.

- **[equals(obj)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_equals)**  
    Maintains the integrity of lists of type BankPaymentMethodRequest by determining the equality of external objects in a list. This method is dynamic and based on the equals method in Java.
- **[hashCode()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_hashCode)**  
    Maintains the integrity of lists of type BankPaymentMethodRequest.
- **[toString()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_BankPaymentMethodRequest.htm#apex_commercepayments_BankPaymentMethodRequest_toString)**  
    Converts a date to a string.

### equals(obj)

Maintains the integrity of lists of type BankPaymentMethodRequest by determining the equality of external objects in a list. This method is dynamic and based on the equals method in Java.

#### Signature

public Boolean equals(Object obj)

#### Parameters

- **obj**:
    
    Type: Object External object whose key is to be validated.

#### Return Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### hashCode()

Maintains the integrity of lists of type BankPaymentMethodRequest.

#### Signature

public Integer hashCode()

#### Return Value

Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")

### toString()

Converts a date to a string.

#### Signature

public String toString()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")