# Testing
source: https://developer.mastercard.com/identity-insights-for-transactions/documentation/testing/index.md

This section provides the testing guides for your API integration in the sandbox environment.

## Test Cases {#test-cases}

This tutorial explains different test cases to verify positive and negative scenarios for the Identity Insights for
Transactions (IIT) API endpoints.  

| **Test Case ID** |        **Test Type**         |     **Test Type Details**     |   **Input**   | **Output** |                                   **Test Success Criteria**                                   |
|------------------|------------------------------|-------------------------------|---------------|------------|-----------------------------------------------------------------------------------------------|
| 1                | Customer input validation    | Individual \& Device Insights | Customer Data | Variable   | All inputs are correctly formatted, 200 response is returned and match customer expectations. |
| 2                | Simulating 400 client errors | Omitting required field       | Customer Data | Variable   | Provided data input returns expected output, simulating the desired error message.            |
| 3                | Simulating 400 client errors | Incorrect length/format       | Customer Data | Variable   | Provided data input returns expected output, simulating the desired error message.            |

#### Use case fields criteria {#use-case-fields-criteria}

Refer to the [Request Body Model](https://developer.mastercard.com/identity-insights-for-transactions/documentation/api-reference/index.md) .  

#### The following are the sample request, and responses for the Test cases validations for both positive and negative test scenarios. \*\* {#the-following-are-the-sample-request-and-responses-for-the-test-cases-validations-for-both-positive-and-negative-test-scenarios-brbr}

#### Introduction {#introduction}

The end-point allows the client to obtain insights for all possible transactions regardless of card brand .  

#### Pre-requisites {#pre-requisites}

Refer to the [Obtain insights for all transactions](https://developer.mastercard.com/identity-insights-for-transactions/documentation/use-cases/use-cases-2/index.md) details.  

#### Sandbox test data for the end-point {#sandbox-test-data-for-the-end-point}

Sandbox data is consistent across all users.   

#### Sample Request and Response with required fields {#sample-request-and-response-with-required-fields}

**Request**

```json
{
  "purchaseDate": "20220721173228",
  "purchaseAmount": 12345,
  "purchaseCurrencyExponent": "2",
  "purchaseCurrency": 840,
  "accountDetails": {
    "accountNumber": 30000000000004,
    "cardExpiryDate": "2203"
  },
  "merchantName": "Acme Inc",
  "merchantCountryCode": "840",
  "mcc": "0001",
  "ipAddress": "1.1.1.160",
  "userAgent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "cardHolderName": "Waidong L Syrws",
  "endCustomerRefId": "123"
}
```

**Response**

```json
{
  "id": "819bedc4-1a43-435b-8f06-747fa653092c",
  "deviceInsights": {
    "deviceInfo": {
      "browser": "IE",
      "platform": "Windows",
      "deviceType": "Generic"
    }
  },
  "individualInsights": {
    "primaryEmail": {},
    "ip": {
      "billingAddressDistance": 240,
      "lastSeenDays": 234,
      "connectionType": "cable-dsl",
      "shippingAddressDistance": 240,
      "providerDetails": {
        "country": "australia",
        "ipCarrier": "cloudflare",
        "city": "research (melbourne)",
        "state": "victoria"
      },
      "isProxy": true,
      "proxyRiskClass": "low"
    },
    "shippingAddress": {
      "validityLevel": "missing_address"
    },
    "billingAddress": {
      "validityLevel": "missing_address"
    },
    "scores": {
      "ipRisk": {
        "score": 0.935
      },
      "identityRisk": {
        "score": 61,
        "reasonCode": "RN"
      }
    },
    "paymentCard": {
      "cardHolderNamefirstSeenDays": 0,
      "cardHolderNameVelocity": 0
    }
  }
}
```

#### Sample Request and Response with required and optional fields {#sample-request-and-response-with-required-and-optional-fields}

**Request**

```json
{
  "purchaseDate": "20220721173228",
  "purchaseAmount": 12345,
  "purchaseCurrencyExponent": "2",
  "purchaseCurrency": 840,
  "accountDetails": {
    "accountNumber": 30000000000004,
    "cardExpiryDate": "2203",
    "cardLast4": "4113"
  },
  "merchantName": "Acme Inc",
  "merchantCountryCode": "840",
  "mcc": "0001",
  "ipAddress": "1.1.1.160",
  "secondaryName": "Waidong L Syrws",
  "userAgent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "acquirerMerchantId": "acquirerMerchantId",
  "acquirerBin": "acquirerBin",
  "cardHolderName": "Waidong L Syrws",
  "primaryEmail": "john@mastercard.com",
  "secondaryEmail": "ted@mastercard.com",
  "mobilePhone": {
    "cc": "1",
    "subscriber": "4143978691"
  },
  "billingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "shippingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "homePhone": {
    "cc": "1",
    "subscriber": "314397869122"
  },
  "workPhone": {
    "cc": "1",
    "subscriber": "2143978691"
  },
  "timeZone": "123",
  "screenWidth": "1792",
  "screenHeight": "828",
  "language": "zh-tw",
  "colorDepth": "98",
  "endCustomerRefId": "noflag"
}
```

**Response**

```json
{
  "id": "1b2cb8d4-caa2-433d-a201-d858b10ffd92",
  "deviceInsights": {
    "deviceInfo": {
      "browser": "IE",
      "platform": "Windows",
      "deviceType": "Generic"
    },
    "deviceIpTzDifference": 42,
    "deviceEmailPaymentFirstSeenDays": 11,
    "deviceIpPaymentFirstSeenDays": 11,
    "deviceIpFirstSeenDays": 39,
    "deviceIpEmailFirstSeenDays": 39,
    "deviceRisk": {
      "score": 0.996
    }
  },
  "individualInsights": {
    "primaryEmail": {
      "firstSeenDays": 3751,
      "lastSeenDays": 3751,
      "matchToName": "no-match",
      "domainCreationDate": "1994-07-27",
      "valid": true,
      "emailRisk": {
        "score": 0.019
      },
      "mailboxVelocity": 0,
      "isDisposable": false
    },
    "ip": {
      "billingAddressDistance": 240,
      "lastSeenDays": 234,
      "connectionType": "cable-dsl",
      "shippingAddressDistance": 240,
      "providerDetails": {
        "country": "australia",
        "ipCarrier": "cloudflare",
        "city": "research (melbourne)",
        "state": "victoria"
      },
      "isProxy": true,
      "proxyRiskClass": "low"
    }
    "homePhone": {
      "valid": false
    },
    "mobilePhone": {
      "matchToName": "not-found",
      "phoneNumberCarrier": "T-Mobile Usa",
      "lineType": "mobile",
      "valid": true
    },
    "shippingAddress": {
      "validityLevel": "valid_to_country"
    },
    "billingAddress": {
      "validityLevel": "valid_to_country"
    },
    "workPhone": {
      "matchToName": "no-match",
      "phoneNumberCarrier": "Metropcs Wireless Inc.",
      "lineType": "mobile",
      "valid": true
    },
    "scores": {
      "ipRisk": {
        "score": 0.935
      },
      "identityRisk": {
        "score": 212,
        "reasonCode": "JF"
      }
    },
    "paymentCard": {
      "cardHolderNamefirstSeenDays": 0,
      "cardHolderNameVelocity": 0
    }
  }
}
```

#### Introduction {#introduction}

The end-point allows the client to obtain error insights for all card transactions for invalid or missing fields.   

#### Pre-requisites {#pre-requisites}

Refer to the [Code and format section](https://developer.mastercard.com/identity-insights-for-transactions/documentation/code-and-formats/index.md) for details.  

#### Sandbox test data for the end-point {#sandbox-test-data-for-the-end-point}

Sandbox error data is consistent across all users, and the different use cases are different for all card
transactions.   

#### EndCustomerRefId is required {#endcustomerrefid-is-required}

**Request**

```json
{
  "purchaseDate": "20220721173228",
  "purchaseAmount": 12345,
  "purchaseCurrencyExponent": "2",
  "purchaseCurrency": 840,
  "accountDetails": {
    "accountNumber": 5005303006786299,
    "cardExpiryDate": "2203",
    "cardLast4": "4113"
  },
  "merchantName": "Acme Inc",
  "merchantCountryCode": "840",
  "mcc": "0001",
  "ipAddress": "1.1.1.160",
  "secondaryName": "Waidong L Syrws",
  "userAgent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "acquirerMerchantId": "acquirerMerchantId",
  "acquirerBin": "acquirerBin",
  "cardHolderName": "Waidong L Syrws",
  "primaryEmail": "john@mastercard.com",
  "secondaryEmail": "ted@mastercard.com",
  "mobilePhone": {
    "cc": "1",
    "subscriber": "4143978691"
  },
  "billingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "shippingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "homePhone": {
    "cc": "1",
    "subscriber": "314397869122"
  },
  "workPhone": {
    "cc": "1",
    "subscriber": "2143978691"
  },
  "timeZone": "123",
  "screenWidth": "1792",
  "screenHeight": "828",
  "language": "zh-tw",
  "colorDepth": "98"
}
```

**Response**

```json
Error :
{
  "Errors": {
    "Error": [
      {
        "Source": "IIT",
        "ReasonCode": "VALIDATION_ERROR",
        "Description": "endCustomerRefId is required",
        "Recoverable": false,
        "Details": "endCustomerRefId"
      }
    ]
  }
}
```

#### Introduction {#introduction}

The end-point allows the client to obtain error insights for all card transactions for unauthorized request.   

#### Pre-requisites {#pre-requisites}

Refer to the [Code and format section](https://developer.mastercard.com/identity-insights-for-transactions/documentation/code-and-formats/index.md) for details.  

#### Sandbox test data for the end-point {#sandbox-test-data-for-the-end-point}

Sandbox error data is consistent across all users, and the different use cases are different for all card
transactions.   

#### Unauthorized - Access granted Scenario {#unauthorized---access-granted-scenario}

**Request**

```json
{
  "purchaseDate": "20220721173228",
  "purchaseAmount": 12345,
  "purchaseCurrencyExponent": "2",
  "purchaseCurrency": 840,
  "accountDetails": {
    "accountNumber": null,
    "cardExpiryDate": "2203",
    "cardLast4": null
  },
  "merchantName": "Acme Inc",
  "merchantCountryCode": "840",
  "mcc": "0001",
  "ipAddress": "1.1.1.160",
  "secondaryName": "Waidong L Syrws",
  "userAgent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "acquirerMerchantId": "acquirerMerchantId",
  "acquirerBin": "acquirerBin",
  "cardHolderName": "Waidong L Syrws",
  "primaryEmail": "john@mastercard.com",
  "secondaryEmail": "ted@mastercard.com",
  "mobilePhone": {
    "cc": "1",
    "subscriber": "4143978691"
  },
  "billingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "shippingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "homePhone": {
    "cc": "1",
    "subscriber": "314397869122"
  },
  "workPhone": {
    "cc": "1",
    "subscriber": "2143978691"
  },
  "timeZone": "123",
  "screenWidth": "1792",
  "screenHeight": "828",
  "language": "zh-tw",
  "colorDepth": "98"
}
```

**Response**

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "IIT",
        "ReasonCode": "UNAUTHORIZED",
        "Description": "Unauthorized Request",
        "Recoverable": false
      }
    ]
  }
}
```

#### Introduction {#introduction}

The end-point allows the client to obtain error insights for all card transactions with transient system failure.   

#### Pre-requisites {#pre-requisites}

Refer to the [Code and format section](https://developer.mastercard.com/identity-insights-for-transactions/documentation/code-and-formats/index.md) for details.  

#### Sandbox test data for the end-point {#sandbox-test-data-for-the-end-point}

Sandbox error data is consistent across all users, and the different use cases are different for all card
transactions.   

#### Unable to get insights from Nudata and Ekata server. {#unable-to-get-insights-from-nudata-and-ekata-server}

**Request**

```json
{
  "purchaseDate": "20220721173228",
  "purchaseAmount": 12345,
  "purchaseCurrencyExponent": "2",
  "purchaseCurrency": 840,
  "accountDetails": {
    "accountNumber": 5599991212121212,
    "cardLast4": "4402",
    "cardExpiryDate": "2203",
    "cardBin": "1234"
  },
  "merchantName": "Acme Inc",
  "merchantCountryCode": "840",
  "mcc": "0001",
  "ipAddress": "1.1.1.160",
  "secondaryName": "Waidong L Syrws",
  "userAgent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "acquirerMerchantId": "acquirerMerchantId",
  "acquirerBin": "acquirerBin",
  "cardHolderName": "Waidong L Syrws",
  "primaryEmail": "john@mastercard.com",
  "secondaryEmail": "ted@mastercard.com",
  "mobilePhone": {
    "cc": "1",
    "subscriber": "4143978691"
  },
  "billingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "shippingAddress": {
    "addressLine1": "912 Uclan Dr",
    "addressLine2": "Apt 34",
    "addressCity": "Houston",
    "addressState": "TX",
    "addressPostCode": "63124",
    "addressCountry": "840"
  },
  "homePhone": {
    "cc": "1",
    "subscriber": "314397869122"
  },
  "workPhone": {
    "cc": "1",
    "subscriber": "2143978691"
  },
  "timeZone": "123",
  "screenWidth": "1792",
  "screenHeight": "828",
  "language": "zh-tw",
  "colorDepth": "98"
}
```

**Response**

```json
{
    "Errors": {
        "Error": [
            {
                "Source": "IIT",
                "ReasonCode": "Transient System Failure",
                "Description": "System failure",
                "Recoverable": true
            }
        ]
    }
}
```

