# Testing
source: https://developer.mastercard.com/mastercard-send-funding/documentation/testing/index.md

## Sandbox Testing {#sandbox-testing}

Use this guidance to perform initial Sandbox testing for the Funding and Funding Reversal APIs. It covers the recommended workflow, positive and negative coverage, and test cases.

The Sandbox server returns simulated responses, enabling you to try the APIs 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/mastercard-send-funding/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/mastercard-send-funding/documentation/developer-tools/postman-collection/index.md)** --- pre-built requests with OAuth configured.

<!-- -->

* **[Reference Application](https://developer.mastercard.com/mastercard-send-funding/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/mastercard-send-funding/documentation/tutorials-and-guides/api-tutorial/index.md).

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

Use the following sequence to validate the endpoints with a realistic flow:

1. Create a transfer using the Funding POST API.
2. Retrieve the transfer details using the GET API with the Transfer ID.
3. Retrieve the transfer details using the GET API with the Transfer Reference.
4. Reverse the transfer using the Funding Reversal POST API.

### Positive testing {#positive-testing}

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

* Valid request bodies return success codes such as `201 Created` or `200 OK`.
* Created transfers have the expected response values.
* Transfers can be retrieved by Transfer Reference or Transfer ID.
* Transfers can be reversed.

For test data and expected responses, see [Test cases](https://developer.mastercard.com/mastercard-send-funding/documentation/testing/index.md#test-cases).

The example below is a positive test case request body for a Funding `POST /v1/partners/{partnerId}/transfers/funding` API call. It includes a special `transfer_reference` value that should give a Sandbox success response.
* JSON
* XML

```JSON
{
  "funding_transfer": {
    "transfer_reference": "HAPPYPATH_FRV_000001",
    "payment_type": "P2P",
    "amount": "5300",
    "currency": "USD",
    "funding_source": "DEBIT",
    "transaction_purpose": "00",
    "sender_account_uri": "pan:5102589999999921;exp=2077-02;cvc=123",
    "sender": {
      "first_name": "John",
      "last_name": "Jones",
      "account_type": "03",
      "address": {
        "line1": "1 Main St",
        "line2": "Apartment 9",
        "city": "St. Louis",
        "country_subdivision": "MO",
        "postal_code": "63368",
        "country": "USA"
      }
    },
    "recipient_account_uri": "pan:5102589999999913;exp=2077-02;cvc=123",
    "recipient": {
      "first_name": "Jane",
      "last_name": "Smith",
      "account_type": "03",
      "address": {
        "line1": "1 Main St",
        "line2": "Apartment 9",
        "city": "St. Louis",
        "country_subdivision": "MO",
        "postal_code": "63368",
        "country": "USA"
      }
    }
  }
}
```

```XML
<funding_transfer>
  <transfer_reference>HAPPYPATH_FRV_000001</transfer_reference>
  <payment_type>P2P</payment_type>
  <amount>5300</amount>
  <currency>USD</currency>
  <funding_source>DEBIT</funding_source>
  <transaction_purpose>00</transaction_purpose>
  <sender_account_uri>pan:5102589999999921;exp=2077-02;cvc=123</sender_account_uri>
  <sender>
    <first_name>John</first_name>
    <last_name>Jones</last_name>
    <account_type>03</account_type>
    <address>
      <line1>1 Main St</line1>
      <line2>Apartment 9</line2>
      <city>St. Louis</city>
      <country_subdivision>MO</country_subdivision>
      <postal_code>63368</postal_code>
      <country>USA</country>
    </address>
  </sender>
  <recipient_account_uri>pan:5102589999999913;exp=2077-02;cvc=123</recipient_account_uri>
  <recipient>
    <first_name>Jane</first_name>
    <last_name>Smith</last_name>
    <account_type>03</account_type>
    <address>
      <line1>1 Main St</line1>
      <line2>Apartment 9</line2>
      <city>St. Louis</city>
      <country_subdivision>MO</country_subdivision>
      <postal_code>63368</postal_code>
      <country>USA</country>
    </address>
  </recipient>
</funding_transfer>
```

Expected result: `201 Created` and a response body containing the `transfer_reference` value used in the API request, a generated `id` value ('HAPPYPATH_FRV_000001_txn' for this request), and a `status` of 'APPROVED'.

Additional checks:

* `GET /v1/partners/{partnerId}/transfers` with `ref` header value of 'HAPPYPATH_FRV_000001' returns `200 OK` and the transfer details.
* `GET /v1/partners/{partnerId}/transfers/HAPPYPATH_FRV_000001_txn` returns `200 OK` and the transfer details.
* Funding Reversal `POST /v1/partners/{partnerId}/transfers/HAPPYPATH_FRV_000001_txn/transactions/txn_HAPPYPATH_FRV_0000_000001/reversals` with a `reversal_reason` value returns `200 OK` and a response body containing a `status` of 'REVERSED'.

### 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`.
* GET or Funding Reversal POST requests for unknown transfers return `404 Not Found`.
* Incorrect or missing authentication data is rejected.

For test data and expected responses, see [Test cases](https://developer.mastercard.com/mastercard-send-funding/documentation/testing/index.md#test-cases). For the error response message structure and a complete list of error codes and reason codes, see [Error Codes](https://developer.mastercard.com/mastercard-send-funding/documentation/response-error-codes/error-codes/index.md).

### Test cases {#test-cases}

Use the following test cases to produce specific responses. As long as the request message is properly formatted, a valid response will be returned.

##### Funding POST - Create Funding Transfer {#funding-post---create-funding-transfer}

|              Test Scenario              |                                                   Test Data                                                    | HTTP Status Code/Reason Code |                                  Expected Result                                   |
|-----------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------|------------------------------------------------------------------------------------|
| Always transfer approval                | Valid request with `transfer_reference` value HAPPYPATH_FRV_000001                                             | 201/CREATED                  | Approved                                                                           |
| Transfer approval                       | Valid request with unique valid `transfer_reference` value that does not match one of the test scenarios below | 201/CREATED                  | Approved                                                                           |
| Decline - 402 response                  | `transfer_reference` starts with DCL05                                                                         | 402/DECLINE                  | Card declined                                                                      |
| Unknown - 202 response                  | `transfer_reference` starts with UNKNWN                                                                        | 202/ACCEPTED                 | Status unknown                                                                     |
| Decline - duplicate transfer reference  | In same day, send request with same `transfer_reference` as a previous request                                 | 409/RESOURCE_ERROR           | Error: `transfer_reference`, duplicate value (110501)                              |
| Country not eligible                    | `transfer_reference` starts with CNELG                                                                         | 400/INVALID_INPUT_VALUE      | Error: `payment_origination_country`, invalid value (082000)                       |
| Sending account not eligible            | `transfer_reference` starts with NTELG                                                                         | 400/RESOURCE_ERROR           | Error: `sender_account_uri`, account not eligible (110503)                         |
| Payment type not eligible               | `transfer_reference` starts with PMTTYP                                                                        | 400/RESOURCE_ERROR           | Error: `payment_type`, account not eligible (110503)                               |
| Card type not supported                 | `transfer_reference` starts with CDELG                                                                         | 400/RESOURCE_ERROR           | Error: `Account Error`, card type is not supported for merchant (110504)           |
| Card Acceptor ID not allowed            | `transfer_reference` starts with CANA                                                                          | 400/RESOURCE_ERROR           | Error: `participant.card_acceptor_id`, Card Acceptor ID not allowed (110520)       |
| Invalid value                           | `payment_type` = ABC                                                                                           | 400/INVALID_INPUT_VALUE      | Error: Invalid value (082000)                                                      |
| Invalid field length                    | `transfer_reference` = 123                                                                                     | 400/INVALID_INPUT_LENGTH     | Error: Invalid length (072000)                                                     |
| Invalid field format                    | `sender_account_uri` = ABC                                                                                     | 400/INVALID_INPUT_FORMAT     | Error: Value contains invalid character(s) (062000)                                |
| Missing required field                  | Omit a required parameter, such as `transfer_reference`                                                        | 400/MISSING_REQUIRED_INPUT   | Error: Value is required (092000)                                                  |
| Missing required field for Visa AFT     | `transfer_reference` starts with FUNVS and `funding_source` field is missing                                   | 400/MISSING_REQUIRED_INPUT   | Error: Value is required (092000)                                                  |
| Transaction limit error                 | `transfer_reference` starts with TNLMT                                                                         | 400/DECLINE                  | Error: `sender_account_uri`, per transaction maximum amount limit reached (130004) |
| Partner not active                      | `transfer_reference` starts with PINA                                                                          | 401/INVALID_INPUT_VALUE      | Error: `partnerId`, invalid value (082000)                                         |
| Partner not onboarded                   | `transfer_reference` starts with PUNK                                                                          | 401/INVALID_INPUT_VALUE      | Error: `partnerId`, invalid value (072000)                                         |
| Client user not associated with partner | `transfer_reference` starts with PCLNT                                                                         | 401/UNAUTHORIZED_ACCESS      | Error: `OpenAPIClientId`, unauthorized access (050007)                             |
| Application system error                | `transfer_reference` starts with SE500                                                                         | 500/SYSTEM_ERROR             | Error: Internal exception occurred                                                 |

##### Funding GET - Retrieve by Transfer ID {#funding-get---retrieve-by-transfer-id}

|                 Test Scenario                 |                                              Test Data                                              | HTTP Status Code/Reason Code |                 Expected Result                 |
|-----------------------------------------------|-----------------------------------------------------------------------------------------------------|------------------------------|-------------------------------------------------|
| Retrieve details of previous transfer request | `transferId` path value matches the `id` returned in a previous successful POST API call to Sandbox | 200/OK                       | Successful                                      |
| Unsuccessful GET call                         | `transferId` path value not used before                                                             | 404/RESOURCE_ERROR           | Error: `transfer_id`, record not found (110507) |

##### Funding GET - Retrieve by Transfer Reference {#funding-get---retrieve-by-transfer-reference}

|                 Test Scenario                 |                                                    Test Data                                                    | HTTP Status Code/Reason Code |                    Expected Result                     |
|-----------------------------------------------|-----------------------------------------------------------------------------------------------------------------|------------------------------|--------------------------------------------------------|
| Retrieve details of previous transfer request | `ref` query value matches the `transfer_reference` value used in a previous successful POST API call to Sandbox | 200/OK                       | Successful                                             |
| Unsuccessful GET call                         | `ref` query value not used before                                                                               | 404/RESOURCE_ERROR           | Error: `transfer_reference`, record not found (110507) |

##### Funding Reversal POST - Reverse Funding Transfer {#funding-reversal-post---reverse-funding-transfer}

|                                                  Test Scenario                                                   |                                                                                                                      Test Data                                                                                                                       | HTTP Status Code/Reason Code |                     Expected Result                     |
|------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|---------------------------------------------------------|
| Reverse previously approved funding transfer within 30 minutes                                                   | `transferId` and `transactionId` path values match the `id` and `transaction_history.data.transaction[].id` (respectively) returned in a previous approved Funding POST API call to Sandbox                                                          | 200/OK                       | Successful                                              |
| Unsuccessful - attempt to reverse funding transfer that has already been reversed or outside 30-minute timeframe | Use same values as previous test scenario, except if they relate to a funding transfer with the test `transfer_reference` value HAPPYPATH_FRV_000001. Continually reversing that test transfer will always result in a successful reversal response. | 403/RESOURCE_ERROR           | Error: `transaction.id`, operation not allowed (110511) |
| Unsuccessful - funding transfer not found                                                                        | `transferId` and `transactionId` path values not used before                                                                                                                                                                                         | 404/RESOURCE_UNKNOWN         | Error: `transfer_id`, record not found (110507)         |

## MTF Testing {#mtf-testing}

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

### Test Card Numbers and Associated Networks {#test-card-numbers-and-associated-networks}

For test debit 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 consumer card numbers in the test environment. Transactions in the MTF environment are not executed against other networks.

### Simulated Scenarios {#simulated-scenarios}

The MTF environment simulates transaction responses based on the `amount` value passed in the API request. Any card number may be used as long as it passes the basic card number validation.

|                       Amount                       |                                  Simulated Response                                  |
|----------------------------------------------------|--------------------------------------------------------------------------------------|
| Any other amount except the following listed below | Approved Transaction                                                                 |
| 1                                                  | Declined Transaction                                                                 |
| 2                                                  | Error returned during transaction processing                                         |
| 3                                                  | Service will be delayed 30 seconds before returning an approved transaction response |
| 4                                                  | Time out during processing                                                           |
| 5                                                  | Error returned during deposit funds processing                                       |

### Card Numbers for Different Funds Availability Options {#card-numbers-for-different-funds-availability-options}

|                        Card Number                         |    Funds availability     |
|------------------------------------------------------------|---------------------------|
| 5000333641352301                                           | Next Business Day         |
| 5000361001156749                                           | Two to Five Business Days |
| Any other card number (published on Mastercard Developers) | Immediate                 |

## Next Steps {#next-steps}

* Consult the [API Reference](https://developer.mastercard.com/mastercard-send-funding/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/mastercard-send-funding/documentation/support/index.md) for FAQs and troubleshooting guidance.
