# Testing source: https://developer.mastercard.com/payment-account-management/documentation/testing/index.md ## Overview {#overview} Use this page to plan and run the Payment Account Management (PAM) API tests. Start in Sandbox, then run the full workflows in the Mastercard Test Facility (MTF). | Environment | What you can test | |-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Sandbox | OAuth 1.0a signing, field-level encryption and decryption, and request format. Sandbox returns mock responses and validates only the length and data type of request parameters. | | MTF | End-to-end processing, including downstream statuses and error codes from ABU, MDES, and the PAR Vault. | For base URLs and the keys to use in each environment, see [API Basics](https://developer.mastercard.com/payment-account-management/documentation/api-basics/index.md#environments-and-key-usage). ## Prerequisites {#prerequisites} You will require the following artifacts: * The P12 signing key file for your project for OAuth authorization to the API. * The client and Mastercard encryption keys used for the [field-level encryption](https://developer.mastercard.com/payment-account-management/documentation/api-basics/index.md#encryption) in the respective environments. ## Choose a Testing Method {#choose-a-testing-method} | Method | Use it to | Guide | |----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------| | Insomnia | Send individual requests with the Mastercard OAuth 1.0a plugin. Import the specification from the [API Reference](https://developer.mastercard.com/payment-account-management/documentation/api-reference/index.md) page. | [Insomnia Collection](https://developer.mastercard.com/platform/documentation/developer-tools/insomnia-collection/) | | Postman | Send individual requests and save them as a reusable collection. Import the specification from the [API Reference](https://developer.mastercard.com/payment-account-management/documentation/api-reference/index.md) page. | [Postman Collection](https://developer.mastercard.com/platform/documentation/developer-tools/postman-collection/) | | Generated API client | Run encrypted requests and multi-step flows from code. | [Integration tutorials](https://developer.mastercard.com/payment-account-management/documentation/onboarding/index.md) | Use a generated API client with the Mastercard client encryption library for encrypted endpoints. Use Insomnia or Postman for `/account-maintenance/requestStatus`, which is not encrypted. ## Testing Workflow {#testing-workflow} 1. Run the first Sandbox call in the [Quick Start Guide](https://developer.mastercard.com/payment-account-management/documentation/getting-started/index.md) to confirm OAuth 1.0a signing. 2. Configure field-level encryption in your API client with your Sandbox encryption keys. 3. Run the single-endpoint positive test cases in Sandbox. 4. Run the negative test cases and confirm each returns the expected reason code. 5. Switch to the MTF base URL and run the multi-endpoint flows. 6. Validate each result with the checks in [Validate Results](https://developer.mastercard.com/payment-account-management/documentation/testing/index.md#validate-results). 7. Record the `requestId`, response, and result of each test as evidence for production access. ## Positive Test Cases {#positive-test-cases} Use a new `requestId` for every request. A `requestId` contains 1 to 64 letters and numbers. **Endpoint** : `POST /getPaymentAccountReference` **Request** : A `requestId`, `assignPar` set to `"false"`, and an `encryptedPayload` whose `encryptedData` contains the `accountNumber`. **Expected result** : HTTP `200` with a `responseId` equal to your `requestId` and an `encryptedPayload`. After decryption, `paymentAccountReference` contains a 29-character PAR. **Endpoint** : `POST /getPaymentAccountReference` **Request** : Same as TC-01 with `assignPar` set to `"true"` and a PAN, not a token, as the `accountNumber`. **Expected result** : HTTP `200` with an `encryptedPayload` that decrypts to a `paymentAccountReference`. 1. Send `POST /addAccount` with reason code `NEW_ACCOUNT` and the encrypted card number and expiry date. 2. Confirm HTTP `200` and a `responseId` equal to your `requestId`. 3. Wait at least 60 seconds. 4. Send `POST /account-maintenance/requestStatus` with the same `requestId`. 5. Confirm the `Automatic_Billing_Updater` service has `status` `SUCCESS`. See [Add Account to ABU](https://developer.mastercard.com/payment-account-management/documentation/use-cases/add-account/index.md). 1. Send `POST /updateAccount` with reason code `EXPIRY_UPDATED`, the old expiry date in `oldCardInfo`, and the new expiry date in `newCardInfo`. Use the same card number in both. 2. Confirm HTTP `200` and a `responseId` equal to your `requestId`. 3. Wait at least 60 seconds, then send `POST /account-maintenance/requestStatus` with the same `requestId`. 4. Confirm a `SUCCESS` status for each service that the reason code updates. See [Update Account After a Card Reissue or Expiry Change](https://developer.mastercard.com/payment-account-management/documentation/use-cases/update-account/index.md). 1. Send `POST /closeAccount` with the encrypted card number. 2. Wait at least 60 seconds, then send `POST /account-maintenance/requestStatus` with the same `requestId`. 3. Confirm a status for each of `Automatic_Billing_Updater`, `PAN_Token_Mapping`, and `PAN_PAR_Mapping`. See [Close an Account and Delete Its Tokens](https://developer.mastercard.com/payment-account-management/documentation/use-cases/closures/index.md). 1. Send `POST /overrideForDeleteAccount` with the encrypted card number of an account that is in ABU. 2. Wait at least 60 seconds, then send `POST /account-maintenance/requestStatus` with the same `requestId`. 3. Confirm the `Automatic_Billing_Updater` service has `status` `SUCCESS`. See [Delete Account from ABU](https://developer.mastercard.com/payment-account-management/documentation/use-cases/delete-account/index.md). **Endpoint** : `POST /account-maintenance/requestStatus` **Request body**: * JSON ```JSON { "requestId": ["123456"] } ``` **Expected result** : HTTP `200` with a `statuses` array. Each entry contains the `requestId` and a `services` array with a `serviceName` and a `status`. ## Negative Test Cases {#negative-test-cases} Each case below returns HTTP `200` with an `errors` array, unless stated otherwise. Confirm the `reasonCode` matches the expected value. | ID | Test | Expected result | |---------|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | TC - N1 | Send a request without `requestId`. | `MISSING_REQUIRED_FIELD` | | TC - N2 | Send a `requestId` that contains a hyphen, for example `12-34`. | `INVALID_FIELD_FORMAT` | | TC - N3 | Send a `requestId` longer than 64 characters. | `INVALID_FIELD_LENGTH` | | TC - N4 | Send a body that is not valid JSON. | `INVALID_JSON` | | TC - N5 | Encrypt the payload with a key that is not configured for the environment. | `CRYPTOGRAPHY_ERROR` | | TC - N6 | Repeat a `requestId` that you already used (MTF). | `BAD_REQUEST` with HTTP `400` | | TC- N7 | Send a request without a valid OAuth 1.0a signature. | A gateway error. See [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/). | | TC - N8 | Send `/overrideForDeleteAccount` for an account that is not in ABU, then check its status (MTF). | `FAILURE` for `Automatic_Billing_Updater` with `additionalInformation` `100` | ## Validate Results {#validate-results} For every test, check that: 1. The HTTP status code matches the expected result. 2. For a successful call, the `responseId` equals the `requestId` you sent. 3. For an error, the `reasonCode` matches the expected value and the `recoverable` flag tells you whether a retry can succeed. 4. For encrypted endpoints, you can decrypt the `encryptedPayload` with your Mastercard encryption key. 5. For multi-endpoint flows, `/account-maintenance/requestStatus` reports a status for every service the request updates. ## Troubleshooting {#troubleshooting} For the meaning, cause, and resolution of each reason code and downstream status code, see [Code and Formats](https://developer.mastercard.com/payment-account-management/documentation/code-and-formats/error-codes/index.md). For common setup questions, see [Support](https://developer.mastercard.com/payment-account-management/documentation/support/index.md). ## Next Steps {#next-steps} * When all test cases pass in MTF, [request production access](https://developer.mastercard.com/payment-account-management/documentation/onboarding/move-project/index.md). * Review field details in the [API Reference](https://developer.mastercard.com/payment-account-management/documentation/api-reference/index.md).