# Integration and Testing source: https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md ## Overview {#overview} This page is the central testing reference for the Payment Account Reference Inquiry API. It connects prerequisites, environment setup, endpoint testing, validation criteria, and production onboarding into a single navigation hub --- for both developers and AI agents working with this API. The API exposes one endpoint: `POST /getPaymentAccountReference`. All business scenarios (token association, fraud management, loyalty, transit, reporting, and acquirer delivery of PAR to merchants) use this same endpoint with the same structure. *** ** * ** *** ## Where to Start {#where-to-start} Choose the path that matches your goal: | I want to... | Go to... | |----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Make my first sandbox API call | [Quick Start Guide](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/getting-started/index.md) | | Understand authentication and encryption setup | [API Basics](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/api-basics/index.md) | | Review request and response schemas | [API Reference](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/api-reference/index.md) (embedded Swagger UI) | | Choose a testing tool | [Choose a Testing Tool](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#choose-a-testing-tool) below | | Implement a business workflow | [Use Case Implementation](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/use-cases/implementation/index.md) | | Test that wallet tokens for one card return the same PAR | [Testing Recommendations](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#token-linkage-testing) below | | Validate happy-path behavior | [Happy Path Validation](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#happy-path-validation) below | | Test error handling and failure scenarios | [Negative Testing](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#negative-testing-and-error-validation) below | | Understand all error codes and responses | [Error Codes](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/code-and-formats/error-codes/index.md) | | Prepare for go-live | [Production Readiness Checklist](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#production-readiness-checklist) below | *** ** * ** *** ## Choose a Testing Tool {#choose-a-testing-tool} Every tool below needs the same Sandbox credentials and must sign requests with OAuth 1.0a and encrypt the PAN with field-level encryption. Complete the [Pre-Flight Checklist](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#pre-flight-checklist) first. | Tool | Use it when you want to... | Guide | |--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Python first-call script | Send a signed, encrypted Sandbox request with only your credentials to edit | [Quick Start Guide --- Step 5](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/getting-started/index.md) | | Generated API client | Build and test the integration code for your application | [Integration Tutorial](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/tutorials/integrate/index.md) | | Postman | Run and save requests in a graphical client | [Postman Collection guide](https://developer.mastercard.com/platform/documentation/developer-tools/postman-collection/) | | Insomnia | Import the OpenAPI specification from the [API Reference](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/api-reference/index.md) and sign requests with the Mastercard plugin | [Insomnia Collection guide](https://developer.mastercard.com/platform/documentation/developer-tools/insomnia-collection/) | | curl | Send a request whose `Authorization` header and `encryptedPayload` you generated with the Mastercard libraries | [Sandbox curl Command](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#sandbox-curl-command) below | Follow the Postman or Insomnia guide to configure OAuth 1.0a signing and field-level encryption for your requests. After you send a request with any tool, validate it with [Happy Path Validation](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#happy-path-validation) and [Negative Testing](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#negative-testing-and-error-validation). *** ** * ** *** ## Pre-Flight Checklist {#pre-flight-checklist} Complete all items below before running any tests. **Account and Project** * Mastercard Developers account created at [developer.mastercard.com](https://developer.mastercard.com/account/sign-up) * New project created with the Payment Account Reference Inquiry service added * Project is in the **Sandbox** environment for initial testing **Credentials Downloaded (from project dashboard)** * OAuth signing key --- `.p12` file containing RSA private key * Consumer Key (Client ID) --- visible on project dashboard summary * Mastercard Sandbox Encryption Certificate --- `.pem` file * Sandbox Decryption Key --- `.p12` file **Libraries Installed** * Mastercard OAuth 1.0a signing library for your language * Mastercard field-level encryption (FLE) library for your language **Network** * Outbound HTTPS (port 443) to `sandbox.api.mastercard.com` permitted * TLS 1.2 or TLS 1.3 supported by your HTTP client *** ** * ** *** ## Testing Environments {#testing-environments} Work through environments in sequence. Do not skip to Production. 1. **Sandbox** --- initial testing with fixed responses. No onboarding required. 2. **MTF** --- integration testing. Requires a CIS project. 3. **Production** --- live traffic. Requires a CIS project and Production keys. For base URLs, the keys each environment uses, and India region URLs, see [API Basics --- Environment Information](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/api-basics/index.md#environment-information). *** ** * ** *** ## Single Endpoint Testing {#single-endpoint-testing} ### Endpoint {#endpoint} POST /getPaymentAccountReference ### Required Headers {#required-headers} | Header | Value | |-----------------|----------------------------------------------------------------| | `Content-Type` | `application/json` | | `Authorization` | OAuth 1.0a signature generated by the Mastercard OAuth library | ### Request Construction Steps {#request-construction-steps} 1. Build the plaintext object: ```json { "accountNumber": "5412346789012345" } ``` 2. Pass the plaintext object to the FLE library --- it produces the complete `encryptedPayload` with `encryptedData` as a hex string. 3. Build the request body with `requestId` and the `encryptedPayload` from step 2. 4. Generate the `Authorization` header using the OAuth library (Consumer Key + RSA signing key + request URL + request body). 5. Send `POST` to the full endpoint URL. ### Sandbox curl Command {#sandbox-curl-command} * Bash ```bash curl --request POST \ --url 'https://sandbox.api.mastercard.com/par/paymentaccountreference/static/1/0/getPaymentAccountReference' \ --header 'Content-Type: application/json' \ --header 'Authorization: OAuth realm="sandbox.api.mastercard.com",oauth_consumer_key="",oauth_signature_method="RSA-SHA256",oauth_timestamp="",oauth_nonce="",oauth_version="1.0",oauth_body_hash="",oauth_signature=""' \ --data '{ "requestId": "TEST-001", "encryptedPayload": { "publicKeyFingerprint": "1757a69b510bc33935ca55f1cde10ddcbecaae70194978bef47985f162b9be29", "encryptedKey": "1bee40a93f6261f156b8b14d56244f31df2d9b2e24a8337d8b9832e0809668465b05edd19bca0869730466982bbac9a538ea150cccc1c292e745e6582f2680a2d6f931572f9ed04943bda9e63d79e23c68617901ea062225583ba55468af08e7e3a9036fc7e269831391d876fc2f208239bae160decc583838e024765c548ef5d5ed8ca88c71189828b95696fe30940b9c4e4331e4cc05a0acc4b73190fc18b60841fa36d4b64afe59ccdb35929b2f4e4ce4042d3735058ef42559ea4ea27d3f5cea65c23bd67cc2a4684a458243e060703a1bc9b96eafaa5dd1110b2af2e119bccce2f6fb6b5162d8a5f42a9361f67f3c32499f1adb51789cd3aeb7b6b82a14", "oaepHashingAlgorithm": "SHA512", "iv": "ac810cebcaf41bd9218833803d021aac", "encryptedData": "b3b6cf73efbf932655bd6b20d6c89dd6877efdbff1844f9fad0abf428448f839f7733a53b4b393ed07f7a4d28dbb20a4" } }' ``` *** ** * ** *** ## Happy Path Validation {#happy-path-validation} ### Objective {#objective} Confirm that a correctly authenticated, correctly encrypted request returns a valid PAR response. ### Preconditions {#preconditions} * All [Pre-Flight Checklist](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/integration-and-testing/index.md#pre-flight-checklist) items completed * OAuth library initialized with Consumer Key and `.p12` signing key * FLE library configured with Mastercard Sandbox Encryption Certificate ### Expected HTTP Status {#expected-http-status} `200 OK` ### Expected Response Payload {#expected-response-payload} * Json ```json { "responseId": "TEST-001", "encryptedPayload": { "encryptedData": { "paymentAccountReference": "50019P9LBXOLHN9G7QMU5VN520YSY" } } } ``` ### Required Response Fields {#required-response-fields} | Field | Expected Value | |----------------------------------------------------------|------------------------------------------------| | `responseId` | Must match the `requestId` sent in the request | | `encryptedPayload` | Object must be present | | `encryptedPayload.encryptedData.paymentAccountReference` | 29-character string beginning with `5001` | ### Success Criteria {#success-criteria} * HTTP `200 OK` received * `responseId` matches `requestId` * `encryptedPayload` is present in the response body * After decryption, `paymentAccountReference` is exactly 29 characters * `paymentAccountReference` begins with `5001` * No `errors` array is present in the response body *** ** * ** *** ## Negative Testing and Error Validation {#negative-testing-and-error-validation} Note: Application errors from this API return **HTTP 200** with an `errors` array in the response body. OAuth/gateway authentication failures return **HTTP 4xx** directly from the gateway before the application processes the request. See [Error Codes](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/code-and-formats/error-codes/index.md) for the full reference. ### Scenario 1: Missing Required Field (`encryptedPayload`) {#scenario-1-missing-required-field-encryptedpayload} **How to trigger:** Omit the `encryptedPayload` field from the request body. **Request:** * Json ```json { "requestId": "NEG-001" } ```
**Expected HTTP Status:** `200 OK` **Expected Response:** * Json ```json { "responseId": "NEG-001", "errors": [ { "source": "INPUT", "description": "Missing Required Field - encryptedPayload", "reasonCode": "MISSING_REQUIRED_FIELD", "recoverable": false } ] } ```
**Validation Criteria:** * HTTP `200 OK` received * `errors[0].reasonCode` = `MISSING_REQUIRED_FIELD` * `errors[0].description` contains `encryptedPayload` * `errors[0].recoverable` = `false` *** ** * ** *** ### Scenario 2: Invalid Authentication (OAuth Failure) {#scenario-2-invalid-authentication-oauth-failure} **How to trigger:** Send a request with an incorrect or expired OAuth signature (e.g., wrong Consumer Key, stale timestamp). **Expected HTTP Status:** `401 Unauthorized` (gateway-level, before the application processes the request) **Expected Response:** Gateway error response --- see [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/). **Validation Criteria:** * HTTP `401` received (not `200`) * Response originates from the Mastercard API gateway, not the application * No `responseId` field is present (gateway errors do not include it) **Resolution:** Verify Consumer Key is correct, system clock is within 5 minutes of server time, and the RSA private key matches the project's registered public key. *** ** * ** *** ### Scenario 3: Encryption Error (`encryptedData` Sent as Object) {#scenario-3-encryption-error-encrypteddata-sent-as-object} **How to trigger:** Send `encryptedData` as a JSON object instead of the hex string produced by the FLE library. **Request:** * Json ```json { "requestId": "NEG-003", "encryptedPayload": { "publicKeyFingerprint": "1757a69b510bc33935ca55f1cde10ddcbecaae70194978bef47985f162b9be29", "encryptedKey": "", "oaepHashingAlgorithm": "SHA512", "iv": "ac810cebcaf41bd9218833803d021aac", "encryptedData": { "accountNumber": "5412346789012345" } } } ```
**Expected HTTP Status:** `200 OK` **Expected Response:** * Json ```json { "responseId": "NEG-003", "errors": [ { "source": "INPUT", "description": "Cryptography Error", "reasonCode": "CRYPTOGRAPHY_ERROR", "recoverable": false } ] } ```
**Validation Criteria:** * HTTP `200 OK` received * `errors[0].reasonCode` = `CRYPTOGRAPHY_ERROR` * `errors[0].recoverable` = `false` **Resolution:** Always use the FLE library to produce `encryptedData` --- it must be a hex-encoded AES-CBC ciphertext string, not a JSON object. *** ** * ** *** ### Scenario 4: Invalid Request Format (Malformed JSON) {#scenario-4-invalid-request-format-malformed-json} **How to trigger:** Send a request body that is not valid JSON. **Expected HTTP Status:** `200 OK` **Expected Response:** * Json ```json { "errors": [ { "source": "INPUT", "description": "Invalid JSON", "reasonCode": "INVALID_JSON", "recoverable": false } ] } ```
**Validation Criteria:** * HTTP `200 OK` received * `errors[0].reasonCode` = `INVALID_JSON` * `errors[0].recoverable` = `false` *** ** * ** *** ### Scenario 5: Invalid Field Value (`oaepHashingAlgorithm`) {#scenario-5-invalid-field-value-oaephashingalgorithm} **How to trigger:** Send an unsupported value for `oaepHashingAlgorithm` (valid values: `SHA256`, `SHA512`). **Request fragment:** * Json ```json { "requestId": "NEG-005", "encryptedPayload": { "oaepHashingAlgorithm": "MD5", "..." } } ```
**Expected HTTP Status:** `200 OK` **Expected Response:** * Json ```json { "responseId": "NEG-005", "errors": [ { "source": "INPUT", "description": "Invalid Field Value - oaepHashingAlgorithm", "reasonCode": "INVALID_FIELD_VALUE", "recoverable": false } ] } ```
**Validation Criteria:** * HTTP `200 OK` received * `errors[0].reasonCode` = `INVALID_FIELD_VALUE` * `errors[0].description` contains the field name *** ** * ** *** ### Scenario 6: PAR Not Found {#scenario-6-par-not-found} **How to trigger:** Supply a PAN where Mastercard is not the BIN Controller, or a PAN not eligible for PAR generation. **Expected HTTP Status:** `200 OK` **Expected Response:** * Json ```json { "responseId": "NEG-006", "errors": [ { "source": "INPUT", "description": "Payment Account Reference Not Found", "reasonCode": "PAYMENT_ACCOUNT_REFERENCE_NOT_FOUND", "recoverable": false } ] } ```
**Validation Criteria:** * HTTP `200 OK` received * `errors[0].reasonCode` = `PAYMENT_ACCOUNT_REFERENCE_NOT_FOUND` * `errors[0].recoverable` = `false` **Resolution:** Confirm that the PAN falls within a Mastercard product range where BIN Controller Identifier is `5001`. See the [Overview](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/index.md) for eligible Mastercard product ranges. *** ** * ** *** ### Error Testing Checklist {#error-testing-checklist} * Each triggered error returns the expected `reasonCode` * Application errors return HTTP `200` with `errors` in the response body * OAuth failures return HTTP `4xx` from the gateway (no `responseId` in response) * `recoverable: false` is returned for all non-transient errors * `recoverable: true` is returned only for transient errors (`INTERNAL_SERVICE_FAILURE`) * Your application handles both HTTP-level errors (4xx/5xx) and body-level application errors (HTTP 200 with `errors` array) *** ** * ** *** ## Multi-Step Workflow Testing {#multi-step-workflow-testing} The Payment Account Reference Inquiry API has a single endpoint. A "multi-step workflow" in the context of this API involves calling `POST /getPaymentAccountReference` for multiple payment identifiers belonging to the same cardholder, then verifying PAR consistency across them. ### Workflow: Token Association Verification {#workflow-token-association-verification} **Objective:** Confirm that the same PAR is returned for the underlying PAN and all associated MDES tokens. | Step | Input | Expected PAR | |------|-----------------------------------|---------------------------------| | 1 | PAN (`5412346789012345`) | `50019P9LBXOLHN9G7QMU5VN520YSY` | | 2 | Device token linked to same PAN | Same PAR as step 1 | | 3 | Wearable token linked to same PAN | Same PAR as step 1 | **Validation:** All three calls return the same `paymentAccountReference` value after decryption. Note: In the Sandbox static environment, all correctly formatted requests return the same fixed PAR value regardless of input. Token-consistency testing requires MTF with real test accounts. ### Testing Recommendations {#testing-recommendations} Use these tests in MTF to prove that wallet tokens for the same card resolve to the same PAR. Ask your Mastercard Implementation Manager for test card numbers and the MDES tokens affiliated with them. **Acceptance criterion:** Given two eligible MDES tokens affiliated with the same Mastercard PAN, each `POST /getPaymentAccountReference` request returns the same PAR, and that PAR matches the PAR returned for the PAN. | Test | Input | Expected result | |-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Same-card tokens | Two MDES tokens affiliated with the same PAN, then the PAN | Three responses with the same 29-character PAR beginning with `5001` | | Unrelated token | An MDES token affiliated with a different PAN | A different PAR from the same-card tokens | | Ineligible card range | A PAN outside the Mastercard ranges in the [Overview](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/index.md), or a processor token | `PAYMENT_ACCOUNT_REFERENCE_NOT_FOUND` with `recoverable: false` | | Malformed encrypted payload | `encryptedData` that is not the hex string from the FLE library, or encrypted with the wrong key | `CRYPTOGRAPHY_ERROR` | | Newly generated PAR | An eligible PAN that has no PAR yet, then one of its MDES tokens | A new PAR on the first call, and the same PAR on every later call for the PAN or token | | Rate limiting | A batch of requests from your client | Your client stays at or below [20 TPS](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/support/index.md#does-mastercard-apply-throttling-rules) and retries with exponential backoff. For higher TPS, Mastercard approval would be required. | **Validation:** * Same-card tokens and the PAN return one PAR * Unrelated tokens return a different PAR * Ineligible and unmapped inputs may return `PAYMENT_ACCOUNT_REFERENCE_NOT_FOUND` *** ** * ** *** ## Troubleshooting {#troubleshooting} For the cause and resolution of each error, see [Error Codes](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/code-and-formats/error-codes/index.md). For connection or TLS errors, see [Why does my integration work locally but fail on a server?](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/support/index.md#why-does-my-integration-work-locally-but-fail-on-a-server). *** ** * ** *** ## Production Readiness Checklist {#production-readiness-checklist} Complete all items before requesting Production access. **Sandbox Validation** * Happy-path test returns HTTP `200` with valid PAR * `paymentAccountReference` is 29 characters beginning with `5001` * All error scenarios return expected `reasonCode` values * Application handles both gateway `4xx` errors and body-level application errors (HTTP `200` + `errors`) **Security** * OAuth signing key stored in a secure keystore (not in source code or config files) * Encryption keys stored securely; not hardcoded * `requestId` values are unique per request per Client ID * `dataValidUntilTimestamp` included in FLE payload for production workloads **Integration** * API client generated from the OpenAPI specification * FLE library integration tested end-to-end (encrypt request, decrypt response) * Retry logic implemented for `INTERNAL_SERVICE_FAILURE` (`recoverable: true`) with exponential backoff * Request rate does not exceed **20 TPS** ([Mastercard recommended limit](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/support/index.md#does-mastercard-apply-throttling-rules)) **MTF Testing** * CIS project opened with Mastercard Customer Delivery contact * Full integration tested in MTF with your Sandbox credentials * All use case workflows validated in MTF **Go-Live** * [Move a Project to Production](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/tutorials/move-project/index.md) tutorial completed * Production OAuth key and encryption keys generated and exchanged * Production endpoint URLs updated in all application configuration *** ** * ** *** ## Next Steps {#next-steps} * **[Quick Start Guide](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/getting-started/index.md)** --- Make your first Sandbox call in seven steps. * **[API Reference](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/api-reference/index.md)** --- Interactive Swagger UI with all request/response schemas. * **[Error Codes](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/code-and-formats/error-codes/index.md)** --- Full error code reference with HTTP status codes and resolution guidance. * **[Integration Tutorial](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/tutorials/integrate/index.md)** --- Configure FLE and generate an API client. * **[Move a Project to Production](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/tutorials/move-project/index.md)** --- Production onboarding steps. * **[Support](https://developer.mastercard.com/payment-account-reference-inquiry/documentation/support/index.md)** --- Frequently asked questions and Mastercard developer support.