# Integrate with Click to Pay for Web
source: https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/integrate-apis-tutorial/index.md
Use this tutorial to learn about the required steps to integrate with Click to Pay.
## 1. Onboard to Mastercard Checkout Solutions {#1-onboard-to-mastercard-checkout-solutions}
1. Order the [Mastercard Checkout Solutions - Sandbox](https://www.mastercardconnect.com/-/store-plus/item-details/A/srconbrmtf) on [Mastercard Connect](https://www.mastercardconnect.com/).
2. [Enroll in the programs](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/onboarding-sandbox-tutorial/index.md) you require for your sandbox projects.
3. [Create a sandbox project](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/onboarding-sandbox-tutorial/index.md). You can create up to 30 sandbox projects to allow testing in different lower environments.
4. Download the auto-generated [API Signing Key (OAuth key)](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/key-management-tutorial/index.md) and [Consumer Key](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/key-management-tutorial/index.md).
5. Download the auto-generated [Payload Encryption Key](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/key-management-tutorial/index.md).
Note: For detailed steps on onboarding for each product in Mastercard Checkout Solutions, please refer to the [Onboard to Sandbox](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/onboarding-sandbox-tutorial/index.md) tutorial.
## 2. Add the JavaScript Library {#2-add-the-javascript-library}
### Before You Start {#before-you-start}
Before you start integrating the JavaScript library, ensure you update your content security policy as per the following guidelines.
`Content-Security-Policy` is a layer of security implemented by browsers to detect and mitigate malicious attacks, including Cross-Site Scripting (XSS) and data injection attacks.
* Use the Content-Security-Policy HTTP header to specify your policy, like this:
Content-Security-Policy: policy
For more information refer to: [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)
* Through the HTTP Content-Security-Policy response header, website administrators are able to control resources that a user is allowed to load for a given web page.
* The server from which the resource is delivered, determines the policies that are applied to the given page.
### Adding the JS Library {#adding-the-js-library}
As an integrator, implement the JavaScript library into your application using one of these URLs (for either Sandbox or Production environments):
* The `mastercard.js` is provided as JavaScript code. Use a script tag in the `
` of the HTML page.
| Environment | Script tag containing the URL | Description |
|-------------|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Sandbox | `` | Sandbox credentials available in Mastercard Connect are useful for testing the integration. Checkouts made in this environment are simulated and do not reflect your Production records. |
| Production | ` ` | Upon successful integration testing, you can then request for Production credentials. You can change your initialization to use Production environment to start accepting live transactions. |
* Host this page on a webserver. When a browser loads a page containing this JavaScript library and it calls the [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) method, a hidden iFrame will be created with a `WindowRef` reference to ensure content is rendered to the correct window.
## 3. Initialize the JavaScript Library {#3-initialize-the-javascript-library}
* When the consumer clicks View Basket/Shopping Cart to initiate checkout, call the [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) method to initialize the JavaScript library.
* Calling [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) also creates a `window.click2pay` object which exposes the remaining methods you will require to complete a checkout.
* Consecutively, call **[isRecognized()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/is-recognized/index.md)** before any other actions to ensure a returning user has been recognized correctly.
## 4. Call the JavaScript Methods {#4-call-the-javascript-methods}
* Call the [JavaScript library](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/index.md) methods via the following window:
NAMESPACE = window.click2pay.
* For completing the checkout and receiving an encrypted payload,
* **Option 1** : Use [checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) method by passing `payloadTypeIndicatorCheckout` = `FULL` to get the full payload in `checkoutResponse`. In this case, you can refer to [Step 5](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/integrate-apis-tutorial/index.md) for authentication and then directly [Step 8](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/integrate-apis-tutorial/index.md) for decrypting the payload.
* **Option 2** : Use [Checkout](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/api-reference/apis/index.md#checkout) API to get the full payload in `checkoutResponse`.
All the JavaScript methods other than the \[init()\](/documentation/sdk-reference/init/) method use JavaScript promises instead of events/callbacks. Note: The JavaScript library interprets the backend API calls (as designed) and provides the responses back to the Integrator. While XHRs responses can log backend API errors (like 400, INVALID_STATE), Integrator should ignore such errors and honor the responses returned by the JavaScript library function calls.
## 5. Perform Transaction Authentication {#5-perform-transaction-authentication}
Note: This is an optional step to perform transaction authentication during checkout. For Token Authentication Service (TAS) and the passkey flow in Click to Pay, the `dpaName` field must be provided during SDK initialization. If omitted, authentication may fail without any explicit error indication, preventing passkey creation.
Refer to the [use cases](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/token-authentication/click-to-pay/use-case1/index.md) and take the following steps:
1. Initiate the [checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) method by passing the below parameters for [dpaTransactionOptions](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/common-objects/index.md#dpa-transaction-options) within a `windowRef`. Open a center-aligned pop-up (new window) and pass the `windowRef` to Mastercard:
* **authenticationPreferences.payloadRequested** = `AUTHENTICATED`
*Note : If **Issuer** requests **additional authentication** during a new card enrollment, Integrator's request for authenticated payload will be suppressed, and cardholder will undergo ID\&V before adding a new card to their Click to Pay profile.*
* **paymentOptions.dynamicDataType** = `CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM`
* **transactionAmount** : Provide the final transaction amount in `transactionAmount`.
* Mandatory data fields: **acquirerMerchantId** , **acquirerBIN** , **merchantCategoryCode** , and **merchantCountryCode** Note: Ensure `dpaName` is provided during SDK initialization when performing transaction authentication for TAS or passkey flows.
2. View the authentication results in `assuranceData` object of `checkoutResponseJWSPayload` in the following table:
| Authentication method used | Payload with an example of assuranceData |
|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Passkeys | * DSRP cryptogram and cloud token * verificationMethod = `07 - FIDO2 authentication` ```javascript { "assuranceData": { "verificationData": [ { "verificationType":"CARDHOLDER", "verificationEntity": "02", "verificationEvents": [ "01", ], "verificationMethod": "07", "verificationResults": "01", "verificationTimestamp": "2023-07-13T19:52:44.551Z", "verificationEvents": ["01"], "additionalData": "proof of passkeys authentication" } ] "eci": "02" } } ``` |
| Passive | * DSRP cryptogram and cloud token * verificationMethod = `24 -- Mastercard authentication with device binding and passive authentication` ```javascript { "assuranceData": { "verificationData": [ { "verificationEntity": "02", "verificationEvents": [ "01", ], "verificationMethod": "24", "verificationResults": "01", "verificationTimestamp": "2021-10-07T13:44:45.385Z", "verificationType": "CARDHOLDER" } ] "eci": "02" } } ``` |
| 3DS | * **threeDSOutputData** contains `dsTransId` and `authenticationValue` * verificationMethod = `01 -- 3D Secure (3DS)` ```javascript { "assuranceData ": { "verificationData": [ { "verificationType":"CARDHOLDER", "verificationEntity": "03", "verificationMethod": "01", "verificationResults": "01", "verificationTimestamp": "2023-07-13T19:52:44.551Z", "verificationEvents": [ "01", ], } "eci": "02" ] } } ``` |
## 6. Integrate the APIs {#6-integrate-the-apis}
* To get started with the API integration, you can generate an API client using an [OpenAPI Generator](https://openapi-generator.tech/), which provides generators and library templates for supporting multiple languages and frameworks.
* To help you sign requests and perform payload encryption/decryption, Mastercard provides [client authentication libraries](https://github.com/Mastercard?q=oauth1-signer) and [encryption libraries](https://github.com/Mastercard?&q=client-encryption).
* Follow the steps in [Generating and Configuring a Mastercard API Client](https://developer.mastercard.com/platform/documentation/security-and-authentication/generating-and-configuring-a-mastercard-api-client/) tutorial to enable authentication and perform encryption/decryption.
* Mastercard supports two protocols for authenticating client applications to integrate with Mastercard APIs. Learn more on \[API Basics\]/documentation/api-basics/ page.
Note: **In case of OAuth Authentication:**
* Site identifier `X-Src-Cx-Flow-Id` is added as a part of all inbound API response headers for resolving site affinity issues on subsequent calls.
* When making back-to-back API calls, the client must include the `X-Src-Cx-Flow-Id` of the initial API response in the header of the subsequent API request. This ensures that the consecutive API calls will be sent to the same Mastercard server that returned the initial response.
## 7. Call the APIs {#7-call-the-apis}
* If you are a merchant directly integrating with Mastercard Checkout Solutions, call [POST transaction/credentials](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/api-reference/apis/index.md#checkout) API to perform checkout.
* If you need to onboard merchants, you must register your merchants as DPAs using [DPA Registration](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/api-reference/apis/index.md#registration) API. Ensure you provide the `programType` as `SRC`.
After a successful checkout call using [checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) method, the `srcCorrelationId` returned in the `checkoutResponse` links the JavaScript calls and API calls for a specific transaction. This `srcCorrelationId` will then be used in the Checkout API call for the same transaction.
1. Call the [POST transaction/credentials](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/api-reference/apis/index.md#checkout) endpoint to retrieve the transaction credentials from Click to Pay. The response from Click to Pay will be a JWS which in turn includes an encrypted object - `encryptedPayload`.
2. Extract the `encryptedPayload` value from the `checkoutResponseJWSPayload`. This value contains a JWE in compact serializable form. The JWE content is signed or encrypted using the public Payload Encryption key (which is a part of the public/private payload encryption key pair) provided by you at the time of onboarding.
**Example of an encryptedPayload object:**
```Javascript
"eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiUlNBLU9BRVAtMjU2In0.MIq_v15_eowvwX8MRgrb_H1EevZKB9CZSMMD8-lcbTjQvPFwAyx1USZbZRDB3RGfA_of6aDggnbmQmgsUStPQEpzYMma5mxlv5-VT6ry94xyttBFuCjBV0hudmcOEHiQeIiwS5xBb1iBPFaXTEmMpgDv8lvAm_ncbJ0V5FFDUYYVhK0-SbaODY5OKMdP2N3Y9bCkqjLCAcmkkN3mkrJ6WbzJURmNdfPyL344Cxc14NLZW3fk_yHkmjXybIXJWnUUsdxwFWS5ImwaZGEhbeLGGdpsPTkTkwD86uZCYJlx_dsZi02Vbm9AIiPpKE4L8GS_ltmOQ3YfgfxS6UuzYzaxKw.Xi3KLm7BvjSQuPMSVwSepg.U6Yp-DXd55F6jqy8-LIbmxmExzLaZNCF9Rcmg0g7ViUN3ydm_G5IqJmCFgXg1aO50HYJvnxi5OWG_rs6uV-1I2rrpu3bkuSjkj03N82yhFJBbhr8W_ahlgAMv2FPu4k7aeGp5rWm5lEdvH2UpSvKG2Ae111iFtL842Pk0pgPLOv4jnxFaCrvAPZ4vTvHS1RU27XGW7qXfAOtqpZ38oUJFamYueCIycDrsvacPT650O_JM_QS0ReXkH49bgAt1Sog9r2PY7fjU22ff1oGno51uVK_D9EXyHWcD4I5LYdVd6NenPDfycuQZ_wA98nqMCTzrqx5yQjUQDNYOoDF8ztoKVpYsTJeIUcFTpGXfoLLPTWjoIUds3mIyrXtBWO46rqN8c2nQ6FKC04-CBK9RGbWr1q1ENgfmsBvfXPCIUZ5ACzM1UaU2LkgEYlyiaxn-I3MfauP1adsA3ZOhrDHwSNgA0aVejT_9OTOaBUmywKGtdD7E8PhP7JqbMTXH2gM_9xU7t7TRvntE5uXeALKv4EDurn0p5bASwsYie7xWbsMHGF8lN0aGqJhNKiHL_NFGnR0wzPWS3UXFP7wZFbLM9qSPw.XFMSREEcssFqUM5kIwChIA",
```
## 8. Decrypt the Payload {#8-decrypt-the-payload}
Decrypt the `encryptedPayload` using your private key from the Payload Encryption public / private key pair. Mastercard uses the public key of this key-pair to encrypt response payloads containing payment card credentials.
See [Key Management](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/key-management-tutorial/index.md) to understand more about which keys to use to decrypt the payload.
Mastercard returns the payload in the most secure format possible and in accordance with the `DpaTransactionOptions.PaymentOptions.dynamicDataType` parameter passed in the [JavaScript Request](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/common-objects/index.md#payment-options) ([checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) or [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) methods). The values in [dynamicDataType](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/common-objects/index.md#payment-options) derive the payload format returned by Mastercard, detailed in the table below:
| dynamicDataType | Description | Payload format |
|----------------------------------------|--------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM | Payment authorization using token \& DSRP cryptogram passed in **token** and **dynamicData** objects respectively. | **DSRP** : Dynamic Secure Remote Payments (DSRP) cryptogram is a type of dynamic data which the Integrator will have to pass within Dynamic Payment Data field (DE104 SE001) of the payment authorization request. This cryptogram is base64 encoded and can be up to 32 characters in length. It is passed within the `DpaTransactionOptions.PaymentOptions.dynamicDataType` parameter in the [SDK Request](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/common-objects/index.md#payment-options) in either [checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) or [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) method. Note: * While opting for transaction authentication, ensure that the **dynamicDataType** is `CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM` in payment options. The authenticated payload will include cloud token \& DSRP cryptogram as the response. See [Step 5](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/tutorials-and-guides/integrate-apis-tutorial/index.md) for integration details. * Integrators that support dual payload will receive a second payment credential in the **card** object, along with the **token** object. This payment credential should be used for additional cases outside of payment authorization. Work with your [Mastercard representative](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/support/index.md#get-help) for more details. |
| NONE | Payment authorization using PAN passed in **card** object. | **FPAN** : Integrators must pass this value when FPAN data is requested in `DpaTransactionOptions.PaymentOptions.dynamicDataType` parameter in either [checkout()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/checkout-method/index.md) or [init()](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/sdk-reference/init/index.md) methods. For countries that support only tokens (not FPANs), payment authorization is done using the token passed in **card** object. Optionally, merchants can pass Dynamic Token Verification Code (DTVC) present in **dynamicData** object as part of payment authorization in place of CVC2. |
Diagram encryption_decryption
1. For decrypting the payload, you can use [Mastercard's encryption/decryption libraries](https://github.com/Mastercard?&q=client-encryption)
2. [Add the library](https://github.com/Mastercard/oauth1-signer-java#maven) to your project.
3. Define `util`, which will set the JWE Decryption configuration as per instructions defined in the library.
```Java
private static JweConfig decryptionConfig; // Configuration defined by library
public static JweConfig getDecryptionConfig() throws Exception {
if (ObjectUtils.isEmpty(decryptionConfig)) {
File decryptionCert = ResourceUtils.getFile("{{Decryption Certificate Path}}"); //.p12 file
PrivateKey decryptionKey = EncryptionUtils.loadDecryptionKey(
decryptionCert.getPath(),
{{decryptionCertAlias}},
{{decryptionCertPassword}});
decryptionConfig = JweConfigBuilder.aJweEncryptionConfig()
.withDecryptionKey(decryptionKey)
.withDecryptionPath("$.encryptedPayload", "$")
.withEncryptedValueFieldName("encryptedPayload")
.build();
}
return decryptionConfig;
}
```
4. Define a service interface and implementation for decryption using configuration defined in util.
1. Service Interface: To define behavior and structure of the decryption function.
```Java
DecryptedPayloadDTO getDecryptedPayload(clicktopayResponseDTO clicktopayResponseDTO) throws Exception;
```
2. Service Implementation: Implement service function as per the defined interface.
```Java
public DecryptedPayloadDTO getDecryptedPayload(clicktopayResponseDTO clicktopayResponseDTO) throws
Exception {
JweConfig jweConfig = clicktopayUtils.getDecryptionConfig();
String payload = JweEncryption.decryptPayload(new Gson().toJson(clicktopayResponseDTO), jweConfig);
DecryptedPayloadDTO decryptedPayload = new Gson().fromJson(payload,DecryptedPayloadDTO.class)
return decryptedPayload;
}
```
When the `encryptedPayload` field is decrypted, you will see a JSON object containing transaction information.
* DSRP
* PAN
* PAN(Token-Only)
* DSRP+PAN
```DSRP
// DSRP cryptogram in the dynamicData object
{
"token": {
"paymentToken": "************3165",
"tokenExpirationMonth": "07",
"tokenExpirationYear": "22",
"paymentAccountReference": "50017Q9JP3JRJXIZ1BXQL2MKMX4LE"
},
"shippingAddress": {
"addressId": "adb12da8-474b-4e53-9c3b-5541af7c27bf",
"name": "John doe",
"line1": "test address",
"city": "New York",
"state": "NY",
"countryCode": "US",
"zip": "10011"
},
"consumerEmailAddress": "johndoe@dummyemail.com",
"consumerFirstName": "john",
"consumerLastName": "doe",
"consumerFullName": "john doe",
"consumerMobileNumber": {
"countryCode": "1",
"phoneNumber": "9912797896"
},
"srcTokenResultsData": {
"unpredictableNumber": "63f43cff",
"tokenRequesterId": "50123197928"
},
"dynamicData": {
"dynamicDataValue": "AIrqb3XZSbgpAAl2lQeDGgADFA==",
"dynamicDataType": "CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM"
},
"billingAddress": {
"addressId": "3374e6e9-293a-4612-aa5d-0e42a8ff7aae",
"name": "John doe",
"line1": "test address",
"city": "New York",
"state": "NY",
"countryCode": "US",
"zip": "10011"
}
}
```
```PAN
// Contains the PAN card object
{
"card": {
"primaryAccountNumber": "5120350100064537",
"panExpirationMonth": "08",
"panExpirationYear": "23",
"cardholderFullName": "John Doe",
"cardholderFirstName": "John",
"cardholderLastName": "Doe",
"billingAddress": {
"addressId": "ace92264-46eb-4cd8-b9b5-f2eff15b5ad8",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
}
},
"shippingAddress": {
"addressId": "20a3c19f-934d-4c9a-89c1-864e360da387",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
},
"consumerEmailAddress": "johndoe@dummyemail.com",
"consumerFirstName": "john",
"consumerLastName": "doe",
"consumerFullName": "john doe",
"consumerMobileNumber": {
"countryCode": "1",
"phoneNumber": "9912797895"
},
"billingAddress": {
"addressId": "ace92264-46eb-4cd8-b9b5-f2eff15b5ad8",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
}
}
```
```PAN(Token-Only)
// Contains Static token data and a Dynamic Token Verification Code
{
"card": {
"primaryAccountNumber": "5120350100064537",
"panExpirationMonth": "07",
"panExpirationYear": "22",
"cardholderFullName": "John Doe",
"cardholderFirstName": "John",
"cardholderLastName": "Doe",
"billingAddress": {
"addressId": "ace92264-46eb-4cd8-b9b5-f2eff15b5ad8",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
}
},
"shippingAddress": {
"addressId": "20a3c19f-934d-4c9a-89c1-864e360da387",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
},
"consumerEmailAddress": "johndoe@dummyemail.com",
"consumerFirstName": "john",
"consumerLastName": "doe",
"consumerFullName": "john doe",
"consumerMobileNumber": {
"countryCode": "1",
"phoneNumber": "9912797895"
},
dynamicData": {
"dynamicDataValue": 123,
"dynamicDataType": "DYNAMIC_CARD_SECURITY_CODE"
},
"billingAddress": {
"addressId": "ace92264-46eb-4cd8-b9b5-f2eff15b5ad8",
"name": "John doe",
"line1": "100 5th Avenue",
"line2": "Floor 10",
"city": "New York City",
"state": "NY",
"countryCode": "US",
"zip": "10011"
}
}
```
```DSRP+PAN
// Contains DSRP cryptogram in the dynamicData object and PAN in the card object
{
"card": {
"primaryAccountNumber": "5120350100064537",
"panExpirationMonth": "12",
"panExpirationYear": "2025",
"cardholderFullName": "John Doe",
"cardholderFirstName": "John",
"cardholderLastName": "Doe",
"billingAddress": {
"addressId": "4b870cd2-bc3f-46b1-952d-3da8f1b61907",
"name": "John Doe",
"line1": "150 5th Avenue",
"city": "New York",
"state": "NY",
"countryCode": "US",
"zip": "10011",
"createTime": "2024-06-28T09:58:21.799Z"
},
"paymentAccountReference": "5001CVSZVSHRWCG6YCKZD68DX3S43"
},
"token": {
"paymentToken": "************2505",
"tokenExpirationMonth": "07",
"tokenExpirationYear": "2027",
"paymentAccountReference": "5001CVSZVSHRWCG6YCKZD68DX3S43",
"panSequenceNumber": "00"
},
"shippingAddress": {
"addressId": "78afb7ed-613e-4289-b7c4-633342d0d34c",
"name": "John Doe",
"line1": "1 Angel Lane",
"city": "London",
"countryCode": "GB",
"zip": "EC4R3AB",
"createTime": "2024-07-03T12:06:34.993Z",
"lastUsedTime": "2024-07-23T10:11:13.017Z"
},
"consumerEmailAddress": "john.doe@mastercard.com",
"consumerFirstName": "John",
"consumerLastName": "Doe",
"consumerFullName": "John Doe",
"consumerMobileNumber": {
"countryCode": "44",
"phoneNumber": "7966778607"
},
"srcTokenResultsData": {
"unpredictableNumber": "1410ba3f"
},
"dynamicData": {
"dynamicDataValue": "AIzSpM52zu+PABIUELo/AAADFA==",
"dynamicDataType": "CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM"
}
}
```
| Field | Description |
|------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **token** object | Indicates that the transaction has been tokenized. |
| ↳ **paymentToken** | A 16 digit token rather than a PAN. |
| ↳ **tokenExpirationMonth** ↳ **tokenExpirationYear** | Parameters which provide the tokenized values for digitized card. |
| ↳ **paymentAccountReference** | Non-transactable value that is paired with a PAN and is linked to any token created that represents that PAN. |
| **dynamicData** object | A cryptogram object. |
| ↳ **dynamicDataValue** | DSRP: Containing the 32 char DSRP cryptogram in base64. |
| ↳ **dynamicDataType** | `CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM` indicates DSRP. `DYNAMIC_CARD_SECURITY_CODE` indicates DTVC. DTVC will be provided for PAN (token-only) countries also. |
| **srcTokenResultsData** object | Additional token data. |
| ↳ **tokenRequesterId** | Token Requester identifier. |
| ↳ **unpredictableNumber** | Unpredictable Number used to generate this cryptogram. |
Once the Mastercard Checkout Solution receives the payload response for a transaction, they can proceed to make a payment authorization with their acquirer or payment provider.
## 9. Send the Payload for Authorization {#9-send-the-payload-for-authorization}
When the consumer submits the order, send the decrypted payload for authorization.
For tokenized transactions, the response payload fields are passed in a Payment Authorization request as follows:
| Solution | Description |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **DSRP** | PAN with the **paymentToken** value, DE 104(Digital Payment Data), subelement 001 (Digital Payment Cryptogram) with the **dynamicDataValue** and Date Expiration (DE14) with **tokenExpirationMonth** and **tokenExpirationYear** in MMYY format. |
Note: The API specification does not define requirements for transaction processing. For more information about DSRP transactions, refer to:
* [DSRP --- Acquirer Implementation Guide](https://trc-techresource.mastercard.com/r/bundle/m_an5843/page/z/ndg1634167211641.html)
* [AN3363 --- Mandatory Use of Digital Payment Data Field for Remote Commerce Transactions with Cryptograms](https://trc-techresource.mastercard.com/r/bundle/m_an3363_en-us/page/d/en-US/jvw1585260985294.html)
## 10. Report the Transaction Results {#10-report-the-transaction-results}
Report the results of the transaction to Mastercard Integrated System using the [POST confirmations](https://developer.mastercard.com/mastercard-checkout-solutions/documentation/api-reference/apis/index.md#confirmations) endpoint.
The confirmation data is sent in the request body, and a successful response of 204 (No Content) will be returned.
Mastercard recommends the integrator to send the Confirmation API calls for the below scenarios :
* Payload is received but no authorization is submitted.
* Payload is received and authorization is successfully completed.
* Order cancellation is submitted after successful authorization.
* When payload is received and authorization was declined.
* Refund is submitted.
### View checkoutEventType and checkoutEventStatus field values required for different scenarios {#view-checkouteventtype-and-checkouteventstatus-field-values-required-for-different-scenarios}
| Merchant Action | Events for an order | Merchant Order Status | Confirmation API checkoutEventType | Confirmation API checkoutEventStatus |
|----------------------------|-------------------------------------------------|-----------------------|------------------------------------|--------------------------------------|
| No Authorization Submitted | Authorization will be submitted at a later time | Created | 01 - Authorize | 01 - Created |
| Authorization Submitted | Approval Code received | Approved | 01 - Authorize | 02 - Confirmed |
| Authorization Submitted | Order Cancelled -- reversal submitted | Cancelled | 04 - Cancel | 03 - Cancelled |
| Authorization Submitted | No Approval Code received | Cancelled | 01 - Authorize | 03 - Cancelled |
| Refund | Refund is processed | Refund | 03 - Refund | 02 - Confirmed |