# Testing
source: https://developer.mastercard.com/account-validation/documentation/testing/index.md

## Sandbox Testing {#sandbox-testing}

Use this guidance to perform initial Sandbox testing for this API. It covers positive and negative coverage and test cases.

The Sandbox server returns simulated responses, enabling you to try this API quickly, and should not be used for full integration testing. For valid test card numbers that you can use in your requests, see [Sandbox Test Cards](https://developer.mastercard.com/mastercard-send/documentation/implementation/sandbox-test-cards/). Do not use real consumer card numbers in the Sandbox environment. When you are ready to test your integration, move to MTF, a production-like environment, to validate your integration before Production; see [MTF Testing](https://developer.mastercard.com/account-validation/documentation/testing/index.md#mtf-testing).

### Choose a testing method {#choose-a-testing-method}

Choose a testing method that best matches how you want to validate requests:

* **[Postman Collection](https://developer.mastercard.com/account-validation/documentation/developer-tools/postman-collection/index.md)** --- pre-built requests with OAuth configured.

<!-- -->

* **[Reference Application](https://developer.mastercard.com/account-validation/documentation/developer-tools/reference-app/index.md)** --- a working implementation you can run and inspect.
* Custom API client generated as per the guidance in [Java API Client](https://developer.mastercard.com/account-validation/documentation/tutorials-and-guides/api-tutorial/index.md).

### Positive testing {#positive-testing}

Positive testing confirms that valid requests succeed and return the expected data. Validate these behaviors:

* Valid request bodies return success code `200 OK`.
* The responses have the expected matching values.

For test data and expected responses, see the test cases table below.

The example below is a positive test case request body for a `POST /account-validations` API call. You may need to update the `transactionLocalDateTime` value.
* JSON

```JSON
{
  "referenceId": "AVM_0000001",
  "accountDetails": {
    "account": {
      "type": "PAN",
      "number": "5102589999999913",
      "expiry": "2050-10",
      "cvc": "123"
    },
    "name": {
      "firstName": "Jane",
      "middleName": "Michelle",
      "lastName": "Candy-Smith"
    }
  },
  "currency": "USD",
  "transactionLocalDateTime": "2021-06-17T18:05:02"
}
```

Expected result: `200 OK` and a response body containing `cvcValidationResults.status` and `nameValidationResults.status` values of 'MATCHED'.

##### Test cases {#test-cases}

Use the following test scenarios to produce specific responses. Ensure your POST call includes the required fields with valid values. For these tests, use:

* Mastercard scenarios: `account.number` = starts with 5 or 2, such as 5102589999999913
* Visa scenarios: `account.number` = starts with 4, such as 4007589999999904

`expiry` can be '2050-10', and `cvc` can be '123'.

The expected `cvcValidationResults.status` and `nameValidationResults.status` values are shown below.

|                          Test Scenario                          | `referenceId` Starts With | Provide `account.cvc`? | Expected CVC/CVV Status | Expected Name Status |
|-----------------------------------------------------------------|---------------------------|------------------------|-------------------------|----------------------|
| **Mastercard**                                                  |                           |                        |                         |                      |
| Name only partial matched                                       | AVPM                      | No                     | ---                     | PARTIAL_MATCHED      |
| CVC and name matched                                            | AVM                       | Yes                    | MATCHED                 | MATCHED              |
| CVC matched, name partial matched                               | AVPM                      | Yes                    | MATCHED                 | PARTIAL_MATCHED      |
| CVC matched, name not matched                                   | AVNM                      | Yes                    | MATCHED                 | NOT_MATCHED          |
| CVC matched, name not verified                                  | AVNV                      | Yes                    | MATCHED                 | NOT_VERIFIED         |
| CVC and name not matched                                        | AVNOM                     | Yes                    | NOT_MATCHED             | NOT_MATCHED          |
| CVC not verified, name partial matched                          | AVCNV                     | Yes                    | NOT_VERIFIED            | PARTIAL_MATCHED      |
| Issuer declines validation request (`networkResponseCode` = 05) | DEC05                     | No                     | ---                     | NOT_VERIFIED         |
| **Visa**                                                        |                           |                        |                         |                      |
| Name only matched                                               | AVNM                      | No                     | ---                     | MATCHED              |
| CVV and name matched                                            | AVNM                      | Yes                    | MATCHED                 | MATCHED              |
| CVV matched, name partial matched (first and middle name)       | AVPFM                     | Yes                    | MATCHED                 | PARTIAL_MATCHED      |
| CVV matched, name partial matched (middle and last name)        | AVCVM                     | Yes                    | MATCHED                 | PARTIAL_MATCHED      |
| CVV not matched, name partial matched (last name)               | AVCNM                     | Yes                    | NOT_MATCHED             | PARTIAL_MATCHED      |
| CVV and name not matched                                        | AVNOM                     | Yes                    | NOT_MATCHED             | NOT_MATCHED          |
| CVV and name not verified (code S)                              | AVCSV                     | Yes                    | NOT_VERIFIED            | NOT_VERIFIED         |
| CVV and name not verified (code U)                              | AVINV                     | Yes                    | NOT_VERIFIED            | NOT_VERIFIED         |

<br />

### Negative testing {#negative-testing}

Negative testing confirms that invalid requests fail cleanly and return useful error details. Validate these behaviors:

* Missing required fields return `400 Bad Request`.
* Invalid field values return validation errors with a clear `ReasonCode` and `Description`.
* Incorrect or missing authentication data is rejected.

For test data and expected responses, see the test cases table below. For the error response message structure and a complete list of error codes and reason codes, see [Error Codes](https://developer.mastercard.com/account-validation/documentation/code-and-formats/index.md#error-codes).

##### Test cases {#test-cases-1}

|                                                       Test Scenario                                                       |                                 Test Data                                 | HTTP Status Code/Reason Code |                                           Expected Result                                            |
|---------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|------------------------------|------------------------------------------------------------------------------------------------------|
| Missing required field                                                                                                    | Omit a required parameter, such as `referenceId`                          | 400/MISSING_REQUIRED_INPUT   | Error: Value is required                                                                             |
| Invalid field length                                                                                                      | `account.number` = 1234                                                   | 400/INVALID_INPUT_LENGTH     | Error: Invalid length                                                                                |
| Invalid field value                                                                                                       | `currency` = ABC                                                          | 400/INVALID_INPUT_VALUE      | Error: Invalid value                                                                                 |
| Request with both `originatingInstitutionPartnerId` and `acquiringCredentials`                                            | Provide both `originatingInstitutionPartnerId` and `acquiringCredentials` | 400/INVALID_INPUT_VALUE      | Error: Either acquiringCredentials or originatingInstitutionPartnerID should be present and not both |
| No Originating Institution (OI) Partner ID and no acquiring credentials provided but partner associated with multiple OIs | `referenceId` starts with AVMULOI                                         | 400/INVALID_INPUT_VALUE      | Error: Multiple Originating Institution Partner Ids found                                            |
| Too many acquiring credentials                                                                                            | Provide both `singleMessage` and `dualMessage` objects                    | 400/INVALID_INPUT_VALUE      | Error: Only Single or Dual Message is allowed                                                        |
| Partner not onboarded for a particular network (Mastercard or Visa)                                                       | `referenceId` starts with NTONB                                           | 400/RESOURCE_ERROR           | Error: Account is not eligible for the transaction                                                   |
| Account not eligible                                                                                                      | `referenceId` starts with ANELG                                           | 400/RESOURCE_ERROR           | Error: Account not eligible                                                                          |
| No Transfer Acceptor ID (TAID) provided but there are multiple TAs for partner                                            | `referenceId` starts with NTAID                                           | 400/RESOURCE_ERROR           | Error: Multiple transfer acceptors found                                                             |
| Invalid Originating Institution Partner ID and no acquiring credentials provided                                          | `originatingInstitutionPartnerId` starts with AVOIN                       | 400/RESOURCE_ERROR           | Error: Partner not eligible for the transaction                                                      |
| Country not eligible                                                                                                      | `referenceId` starts with CNELG                                           | 400/RESOURCE_ERROR           | Error: Partner not eligible for the transaction                                                      |
| Point of Service Interaction doesn't match the onboarded configuration                                                    | `referenceId` starts with POINM                                           | 400/RESOURCE_ERROR           | Error: Partner not eligible for the transaction                                                      |
| Partner not active                                                                                                        | `referenceId` starts with AVNA                                            | 400/RESOURCE_ERROR           | Error: Partner not eligible for the transaction                                                      |
| Partner not onboarded                                                                                                     | `referenceId` starts with AVNB                                            | 401/UNAUTHORIZED_ACCESS      | Error: Unauthorized Access                                                                           |
| Client user not associated with partner                                                                                   | `referenceId` starts with ACLNT                                           | 401/UNAUTHORIZED_ACCESS      | Error: Unauthorized Access                                                                           |
| Application system error                                                                                                  | `referenceId` starts with SE500                                           | 500/SYSTEM_ERROR             | Error: Internal exception occurred                                                                   |

## MTF Testing {#mtf-testing}

The Mastercard Customer Implementation Services (CIS) team, assigned during implementation, can provide test cases and assist with testing.

For test card numbers that you can use for testing in the MTF environment, see [MTF Test Cards](https://developer.mastercard.com/mastercard-send/documentation/implementation/test-cards/). Do not use real consumer card numbers in the MTF environment.

## Next Steps {#next-steps}

* Consult the [API Reference](https://developer.mastercard.com/account-validation/documentation/api-reference/index.md) for complete endpoint specifications, request and response schemas, and environment URLs.
* If you run into issues, visit [Support](https://developer.mastercard.com/account-validation/documentation/support/index.md) for FAQs and troubleshooting guidance.
