Session configure()

configure()

The configure( ) function allows you to configure Hosted Session interactions. You can choose to collect payment details either using proxy payment fields hosted by CommWeb payment gateway and rendered within an iFrame, or through a digital wallet interaction.

This function can be used to initiate the Multiple Hosted Session functionality.


Usage Copied to clipboard

PaymentSession.configure(configuration, [scope])


Example Copied to clipboard

PaymentSession.configure({
    fields: {
        // Attach hosted fields to your payment page
           card: {
              number: "#card-number",
              securityCode: "#security-code",
              expiryMonth: "#expiry-month",
              expiryYear: "#expiry-year",
              nameOnCard: "#cardholder-name"
           },
           giftCard: {
                  number: "#gift-card-number",
                  pin: "#gift-card-pin"
           },
           ach: {
                  accountType: "#ach-account-type",
                  bankAccountHolder: "#ach-account-holder",
                  bankAccountNumber: "#ach-account-number",
                  routingNumber: "#ach-routing-number"
           }
    },
    frameEmbeddingMitigation: ["javascript", "x-frame-options", "csp"],
    callbacks: {
        initialized: function(response) {
            //handle initialization response
            if(response.status === "ok") {
                // ...
            } else if (response.status === "system_error") {
                console.log(response.message);
            }
        },
        formSessionUpdate: function(response) {
            //handle session update response
        },
        visaCheckout: function(response) {
            //handle Visa Checkout response
        },
        amexExpressCheckout: function(response) {
            // handle Amex Express Checkout response
		}
    },
    interaction: {
        displayControl: {
            formatCard: "EMBOSSED",
            invalidFieldCharacters: "REJECT"
        }
    },
    order: {
        amount: 10.00,
        currency: "AUD"
    },
    wallets: {
        visaCheckout: {
            enabled: true
            // Add Visa Checkout API specific attributes here
            countryCode: "AU",
            displayName: "Display name",
            locale: "en_au",
            logoUrl: "http://logo.logo",
            payment: {
                cardBrands: [
                    "VISA"
                ]
            },
            review: {
                buttonAction: "Pay",
                message: "Message"
            },
            shipping: {
                acceptedRegions: [
                    "AU"
                ],
                collectShipping: true
            }
        }
       amexExpressCheckout: {
        enabled: true,
        // Add Amex Express Checkout API specific attributes here
        initTags: {
        "theme": "responsive",
        "env": "qa",
        "disable_btn": "false",
        "button_color": "light",
        "client_id": "398f9858-5567-434f-a929-242d6fc7fea8",
        "display_type":"custom"  // IF USING OWN IMAGE FOR BUTTON
        }
      }
   }
})
  

Arguments Copied to clipboard

configuration Copied to clipboard Object

The object parameter to specify the configuration for the Hosted Session interaction.

session Copied to clipboard String

The unique identifier for the session. If you do not provide a sessionID the client library creates one.

fields Copied to clipboard Object

An object containing selectors for the payment fields you want to replace with the corresponding proxy fields, which are hosted by CommWeb payment gateway and rendered within an iFrame. The proxy fields will have the same look and feel as the replaced fields.

card Copied to clipboard String

A container for the card fields.

number Copied to clipboard String

A selector for the card number field.

securityCode Copied to clipboard String

A selector for the security code field.

expiryMonth Copied to clipboard String

A selector for the expiry month field.

expiryYear Copied to clipboard String

A selector for the expiry year field.

nameOnCard Copied to clipboard String

A selector for the cardholder name field.

giftCard Copied to clipboard String

A container for the gift card fields.

number Copied to clipboard String

A selector for the gift card number field.

pin Copied to clipboard String

A selector for the gift card PIN field.

ach Copied to clipboard String

A container for the Automated Clearing House payment fields.

accountType Copied to clipboard String

A selector for the Automated Clearing House account type field.

bankAccountHolder Copied to clipboard String

A selector for the Automated Clearing House accountholder field.

bankAccountNumber Copied to clipboard String

A selector for the Automated Clearing House account number field.

routingNumber Copied to clipboard String

A selector for the Automated Clearing House routing number field.

frameEmbeddingMitigation Copied to clipboard String REQUIRED

Specifies the mitigation option(s) for clickjacking prevention. For more information, see Implementing a Hosted Session Integration.

interaction Copied to clipboard Object

Control the payer's interaction with the payment process.

displayControl Copied to clipboard Object

Control the visibility of, and payer interaction with, the displayed information.

formatCard Copied to clipboard Enum

This field controls the formatting of the card number field.

Set the value to PLAIN to format the field with no character spacing. For example:

  • 375987654321002
  • 5412750123450988

Set the value to EMBOSSED to format the field with the same character spacing as embossed on a card. For example:

  • 3759 876543 21002
  • 5412 7501 2345 0988

By default, this field is set to PLAIN.

PLAINThe card number is displayed with no spacing between characters.
EMBOSSEDThe card number is displayed with the same character spacing as embossed on a card.
invalidFieldCharacters Copied to clipboard Enum

Control the behavior when invalid characters are entered by the payer.

For example, when an X character is passed in a credit card number field.

The default value is REJECT. Consider using ALLOW for a better experience for payers using assistive technology.

Value must be a member of the following list. The values are case-sensitive.
ALLOWThe character will be accepted and included in the field. If not corrected, then an error will be generated on submission.
REJECTThe character will not be accepted and will not be included in the input field.
lineOfBusiness Copied to clipboard String

Your Payment Services Provider might have configured your merchant profile to support several lines of business. Each line of business can have different payment parameters, such as bank account, supported cards or such. For example, lineOfBusiness = TICKET_SALES can have a different bank account from lineOfBusiness = MERCHANDISING. One line of business on your profile might be "null". To use that, do not provide the lineOfBusiness field.

wallets Copied to clipboard Object

An object containing the configuration for a wallet interaction. Currently, you can only initiate a Visa Checkout or an Amex Express Checkout interaction.

visaCheckout Copied to clipboard Object

An object containing configuration for a Visa Checkout wallet interaction. See Visa Checkout integration guidelines on how to retrieve the payment details from a Visa Checkout interaction.

enabled Copied to clipboard Boolean

Set this to true if you wish to enable Visa Checkout wallet. By default, the value is set to false.

amexExpressCheckout Copied to clipboard Object

An object containing configuration for an Amex Express Checkout wallet interaction. See Amex Express Checkout integration guidelines on how to retrieve the payment details from an Amex Express Checkout interaction.

enabled Copied to clipboard Boolean

Set this to true if you wish to enable Amex Express Checkout wallet. By default, the value is set to false.

initTags Copied to clipboard Object

An object containing initialization tag configuration for a Amex Express Checkout wallet interaction. Use this to provide parameters defined in the Amex Express Checkout Init Tags API. This object is required if wallets.amexExpressCheckout.enabled is set to true

order Copied to clipboard Object

An object containing order data required for the wallet interaction. Optionally, you can provide this order data in the session.

amount Copied to clipboard Decimal

Amount

currency Copied to clipboard String

Currency

callbacks Copied to clipboard Object

An object that specifies functions to be invoked for various Hosted Session events.

initialized Copied to clipboard Function

A function to be invoked when a wallet interaction is initialized.

formSessionUpdate Copied to clipboard Function

A function to be invoked when the session is updated.

visaCheckout Copied to clipboard Function

A function to be invoked when the Visa Checkout interaction is completed.

amexExpressCheckout Copied to clipboard Function

A function to be invoked when the Amex Express Checkout interaction is completed.

scope Copied to clipboard String

The optional named instance of a card payment data set within a session. See Multiple Hosted Sessions for more information.


Return Value Copied to clipboard

None