# Integrate Hosted Session
source: https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/index.md

To implement the basic Hosted Session solution in your system, follow the instructions below.

## Prerequisites {#prerequisites}

Before implementing a Hosted Session solution, check with your payment service provider to ensure you meet the following prerequisites:

* Ensure that [you have a merchant account](https://developer.mastercard.com/mastercard-gateway/documentation/getting-started/accessing-the-api/index.md) and that your merchant profile is enabled for the Hosted Session service.
* Select and set up your ***API authentication method***.

Tip: Integrate with API version 100 for full compatibility. Hosted Session functionality is supported only in API v18 or later.

## Implementing a Hosted Session Integration {#implementing-a-hosted-session-integration}

The Hosted Session solution works through API operations (requests and responses), which are used to, for example, manage sessions and initiate or retrieve information about various payment transactions. You also need the [Session JavaScript library](https://developer.mastercard.com/mastercard-gateway/documentation/api-reference/js-libraries/session/index.md) to manage the hosted payment form fields in your app or web page, when payer participation is needed to gather payment details for a transaction. For more information about handling sessions, see [Payment Sessions](https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/create-payment-session/index.md).

You can use all the API operations available for the [REST Server APIs](https://developer.mastercard.com/mastercard-gateway/documentation/api-reference/v100/rest/index.md). However, you do not need the Hosted Checkout-related API operations, as they are required for the related integration method.
For more information about making server API requests, see \[Making a Server API Request\].
Warning: To perform an operation, you must first have it enabled on your merchant profile by your payment service provider. To check which operations are available for you or to troubleshoot any API errors, contact your payment service provider. The operations available to you are limited to the capability of the acquirers configured on your merchant profile with the Mastercard Gateway. If a functionality is not supported for the acquirer on the gateway, any operation requests to execute that functionality are rejected by the gateway (for that acquirer).

When payer participation is needed, each task you perform with the Hosted Session integration method consists of the following steps:

1. In your server, create a new session as a container for all the sensitive data required by the transaction.
2. In your app or web site, attach the hosted form fields to your payment page and allow the payer to fill them in.
3. In your app or web site, update the session with the provided data.
4. In your server, send a payment transaction request to the gateway, referring to the session.
5. In your server, retrieve the response data from the payment transaction. Interpret the response and display the transaction result to the payer in your app or web site.

For information on handling the steps 1-4 above, see [Making a Payment](https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/make-a-payment/index.md). For information about handling the transaction result, see [Interpreting the Response](https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/interpret-transaction-response/index.md).

For a collection of example requests covering the common transaction operation requests, download the [Postman collection](https://www.postman.com/mastercard/mastercard-developers/collection/4fakvrd/mastercard-gateway-api).

After your integration is completed and you can manage basic requests and responses:

1. Consider your payment lifecycles and needs for any [subsequent operations](https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/subsequent-operations/index.md) after the basic payment transaction is completed.
2. Determine any customizations that you need to make based on the specific [payment methods](https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/index.md) you want to support.
3. Consider what kind of [security](https://developer.mastercard.com/mastercard-gateway/documentation/security-and-fraud/index.md) or other [additional features](https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-gateway-features/index.md) that you want to offer or use in your integration.
4. [Test](https://developer.mastercard.com/mastercard-gateway/documentation/testing/test-your-int/hosted-session/index.md) your entire solution.

### Hosted form fields {#hosted-form-fields}

To attach the hosted form fields to your payment page using Mastercard Gateway Hosted Session, use the `PaymentSession.configure()` function provided by Mastercard's JavaScript SDK.

Follow these steps to attach the hosted form fields:

1. Include the Mastercard Hosted Session Script.
2. Replace `<your_merchant_id>` and `<version>` with your actual values.
3. Configure the Hosted Fields Use `PaymentSession.configure()` to attach the hosted fields to your HTML form. Warning:   
   * Mastercard hosts secure iFrames that replace the fields you specify.
   * You must create a session through the API before calling `configure()`.
   * The API version used in the session creation must match the version in the script URL.
