# Visa Click to Pay

## JavaScript Reference - Unified Click to Pay

### Integration Overview

Unified Click to Pay provides quick integration with partners and merchants who want to accept payments from consumers. You can integrate Unified Click to Pay within your existing website pages and implement business and event logic using programming languages, tools, and techniques in the same way you currently do. For this reason, Unified Click to Pay is quite flexible and imposes very few requirements for use.

### JavaScript Library

Use the sdk.js Unified Click to Pay JavaScript library to control the operation of Unified Click to Pay on your site.

The Javascript SDK endpoint to use depends on whether you want to run in sandbox or production environment.

| Environment | Javascript SDK Endpoint |
| --- | --- |
| Sandbox | https://sandbox.secure.checkout.visa.com/checkout-widget/resources/js/integration/v2/sdk.js?dpaId={dpaId}&cardBrands={cardBrands}&dpaClientId={dpaClientId} |
| Production | https://secure.checkout.visa.com/checkout-widget/resources/js/integration/v2/sdk.js?dpaId={dpaId}&cardBrands={cardBrands}&dpaClientId={dpaClientId} |

### URL Parameters

The following parameters are required to be passed while invoking the SDK as URL parameters.

| Query Parameters | R/C/O | Description |
| dpaId<br>Type: String<br>Max Length = 255 | R | Reference identifier of the DPA. Based on the previously generated identifier during the DPA registration process. DPA can either be a merchant or partner. |
| cardBrands<br>Type: String | R | List of card schemes the merchant accepts.<br>It is a comma separated string with the following supported values.<br>- visa<br>- mastercard<br>Example, “visa, mastercard”. |
| dpaClientId<br>Type: String | C | Reference identifier of the merchant. Based on the previously generated identifier during the DPA registration process. This DPA will always be a merchant and not a partner.<br>**Conditionality**: Required when the dpaId is representing a partner and has multiple merchants on boarded via the partner. This reference identifier will represent the merchant on boarded via the partner. |

### JavaScript Methods

- initialize()
- getCards()
- checkout()
- initiateIdentityValidation()
- unbindAppInstance()

#### initialize

This method initializes the app with common state. The initialize method must be called before any other methods. It is synchronous in operation.

### Request Parameters

| **Name** | **R/C/O** | **Description** |
| --- | --- | --- |
| dpaTransactionOptions<br>Type: [DpaTransactionOptions](https://developer.visa.com/capabilities/visa-secure-remote-commerce/docs-data-elements) | O | These options can be used to override transaction options for the DPA that were configured during the DPA Registration.

### Application Errors

| **Reason Code** | **Description** |
| --- | --- |
| AUTH_INVALID | Invalid federated id token. |
| ACCT_INACCESSIBLE | The user account exists but is not currently accessible. |
| ACCT_FRAUD | The user account was locked or disabled. |
| CONSUMER_ID_MISSING | The consumerIdentity parameter is missing. |
| CONSUMER_ID_FORMAT_UNSUPPORTED | Unsupported consumer identity type. |
| CONSUMER_ID_FORMAT_INVALID | Invalid consumer identity. |

### checkout

This method performs checkout using the specified Digital Card or PAN. If successful, the response contains summary checkout information and, conditionally, an encrypted payload signed by the SRC System containing PCI and/or PII data.

### Request Parameters

| **Field** | **R/C/O** | **Description** |
| --- | --- | --- |
| srcDigitalCardId<br>Type: String | C | A reference identifier of the card to be used for checkout.<br>**Conditionality**: Required for checkout when a card is selected from a candidate list.<br>**Note**: If srcDigitalCardId and encryptedCard both are provided then srcDigitalCardId takes precedence. |
| encryptedCard<br>Type: JWE< [Card](https://developer.visa.com/capabilities/visa-secure-remote-commerce/docs-data-elements) > | C | The card being enrolled with the SRC System. Encrypted using a public key that is shared with the partner during onboarding.<br>**Conditionality**: Required for a combined flow where this card is being enrolled during checkout.<br>**Note**: If srcDigitalCardId and encryptedCard both are provided then srcDigitalCardId takes precedence. |

## Response Attributes

| **Field** | **R/C/O** | **Description** |
| --- | --- | --- |
| actionCode<br>Type: ActionCode enum | R | A code indicating the behavior to be handled by the SRC Initiator.<br>Values applicable:<br>- SUCCESS<br>- ERROR |
| checkoutResponse<br>Type: JWS <CheckoutPayloadResponse> | C | Signed checkout response.<br>**Conditionality**: Required when the actionCode is set to SUCCESS. |

### initiateIdentityValidation

This method initiates a process to validate that the consumer is in possession of, or has access to, the consumer identity.

## Request Parameters

| **Field** | **R/C/O** | **Description** |
| --- | --- | --- |
| requestedValidationChannelId<br>Type: String | O | Identifier of the channel over which the identity validation should be initiated. |

### Application Errors

| **Reason Code** | **Description** |
| --- | --- |
| OTP_SEND_FAILED | The OTP could not be sent to the recipient. |
| RETRIES_EXCEEDED | The limit for the number of retries exceeded. |
| ACCT_INACCESSIBLE | The user account exists but is not currently accessible. |

### unbindAppInstance

This method unbinds a device identity (an application instance) from an SRC profile.
