# Testing
source: https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/testing/index.md

This page helps you validate your Enhanced Currency Conversion Calculator API integration end-to-end in Sandbox before requesting Production access.

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

* [Postman Collection](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/developer-tools/postman-collection/index.md) --- fork Mastercard's Postman collection and run requests with saved credentials.
* [Insomnia Collection](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/developer-tools/insomnia-collection/index.md) --- import the OpenAPI specification into Insomnia and run requests with its OAuth 1.0a plugin.
* [Reference Application](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/developer-tools/reference-app/index.md) --- a downloadable Spring application that calls every endpoint using a signed OAuth 1.0a client.
* A custom API client generated from the OpenAPI specification --- see [API Basics](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-basics/index.md#how-to-consume-the-api).

## Recommended Testing Workflow {#recommended-testing-workflow}

Because every Enhanced Currency Conversion Calculator API endpoint is a read-only `GET` call, a full pass through Sandbox looks like this:

1. **Check rate availability** --- call `GET /rate-statuses` for today's date to confirm Mastercard's and the ECB's rates are published before relying on them.
2. **Retrieve currency lists** --- call `GET /mc-currencies` and `GET /ecb-currencies` to confirm the currency codes you plan to test with are supported by both sources.
3. **Retrieve a rate summary** --- call `GET /summary-rates` with a supported currency pair and today's date to retrieve the Mastercard rate, ECB rate, and calculated mark-up.
4. **Apply issuer fees** --- repeat the `summary-rates` call with `bank_fee_pct` and `bank_fee_fixed` populated, and confirm the fee-inclusive fields (`mastercardConvRateInclPctFee`, `crdhldBillAmtInclAllFees`, `effectiveConversionRate`, `pctDifferenceMastercardInclAllFeesAndEcb`) reflect the fee you supplied.
5. **Retrieve a historical rate** --- repeat the `summary-rates` call with a `rate_date` earlier than today (within the last 365 days) to confirm historical rate retrieval.
6. **Trigger error handling** --- repeat the `summary-rates` call with an invalid or out-of-range date to confirm your client correctly surfaces the `Errors` envelope (see [Negative Testing](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/testing/index.md#negative-testing) below).

This workflow exercises rate lookup, fee calculation, historical data retrieval, currency validation, and error handling --- the behaviors most issuers rely on before going live. The Enhanced Currency Conversion Calculator API does not use payload encryption, so there is no encrypted-payload behavior to validate.

## Positive Testing {#positive-testing}

Positive testing confirms that valid requests return a `200 OK`, that the returned rate, amount, and percentage-difference calculations are correct for the currency pair and date requested, and that currency list endpoints return the expected currencies.

### Positive Test Cases {#positive-test-cases}

###### Conversion-rate-summary {#conversion-rate-summary}

    GET /summary-rates?rate_date=2023-02-27&trans_curr=GBP&trans_amt=100&crdhld_bill_curr=EUR&bank_fee_pct=1.6754&bank_fee_fixed=0.5

**Expected result:** `200 OK` --- response `data` contains `mastercardConvRateInclPctFee`, `crdhldBillAmtInclAllFees`, `ecbReferenceRate`, `effectiveConversionRate`, and both `pctDifferenceMastercard...Ecb` fields for the `GBP`/`EUR` pair on `2023-02-27`.

Additional checks:

* Repeat without `bank_fee_pct`/`bank_fee_fixed` and confirm the fee-exclusive fields (`mastercardConvRateExclAllFees`, `crdhldBillAmtExclAllFees`) are still returned.
* Repeat with a historical `rate_date` within the last 365 days and confirm `mastercardFxRateDate`/`ecbReferenceRateDate` reflect the correct published date.

###### Conversion-rate-issued {#conversion-rate-issued}

    GET /rate-statuses?request_date=2023-02-27

**Expected result:** `200 OK` --- response `data` contains `mastercardRateIssued.status` and `ecbRateIssued.status`, each `yes` or `no`.

Additional checks:

* Call without `request_date` and confirm it defaults to checking the current day.

###### Mastercard-currencies {#mastercard-currencies}

    GET /mc-currencies

**Expected result:** `200 OK` --- response `data.currencyCount` matches the number of entries in `data.currencies`, each with an `alphaCd` and `currName`.

###### Ecb-currencies {#ecb-currencies}

    GET /ecb-currencies

**Expected result:** `200 OK` --- response `data.currencyCount` matches the number of entries in `data.currencies`, each with an `alphaCd` and `currName`.

## Endpoint Tutorials {#endpoint-tutorials}

For full request and response walkthroughs for each endpoint, see [Tutorials and Guides](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/tutorials-and-guides/index.md).

## Negative Testing {#negative-testing}

Negative testing confirms that invalid requests are rejected with the correct HTTP status and `Errors` envelope --- covering missing or malformed parameters, unsupported dates, and authentication failures --- rather than silently returning incorrect data.

### Negative Test Cases {#negative-test-cases}

##### Conversion-rate-summary {#conversion-rate-summary-1}

    GET /summary-rates?rate_date=27-02-2023&trans_curr=GBP&trans_amt=100&crdhld_bill_curr=EUR

**Expected result:** `400 BAD_REQUEST` --- `Date format is invalid (Expected date format yyyy-MM-dd)`.

Additional checks:

* Omit a required parameter (`trans_curr`, `trans_amt`, or `crdhld_bill_curr`) and confirm `400 BAD_REQUEST`.
* Request a `rate_date` more than 365 days in the past and confirm `403 FORBIDDEN` --- `Rate is not accessible for this date`.
* Request a future `rate_date` and confirm `404 NOT_FOUND` --- `Rates are not available for the selected date`.
* Call without a valid OAuth 1.0a signature and confirm `401 UNAUTHORIZED` --- `Invalid Client ID`.

##### Conversion-rate-issued {#conversion-rate-issued-1}

    GET /rate-statuses?request_date=27-02-2023

**Expected result:** `400 BAD_REQUEST` --- `Date format is invalid (Expected date format yyyy-MM-DD)`.

Additional checks:

* Request a date more than 365 days in the past and confirm `403 FORBIDDEN`.
* Request a future date and confirm `404 NOT_FOUND` --- `Rate issuance for future date not supported`.

##### Mastercard-currencies / Ecb-currencies {#mastercard-currencies--ecb-currencies}

    GET /mc-currencies
    GET /ecb-currencies

**Expected result:** Call without a valid OAuth 1.0a signature and confirm `401 UNAUTHORIZED`.

Additional checks:

* These endpoints take no input parameters, so there are no parameter-validation cases --- only authentication failures apply.

### Example Error Response {#example-error-response}

* JSON

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "Enhanced Currency Conversion Calculator API",
        "ReasonCode": "BAD_REQUEST",
        "Description": "Invalid input",
        "Recoverable": false,
        "Details": "Date format is invalid (Expected date format yyyy-MM-dd)"
      }
    ]
  }
}
```

For the full list of HTTP status codes, reason codes, and resolutions, see [Code and Formats](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md).

## Next Steps {#next-steps}

|                                                            Category                                                            |                   Description                    |
|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [API Reference](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-reference/index.md) | Try the Sandbox APIs directly from your browser. |
| [Support](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/support/index.md)             | FAQs and support.                                |

