# Reverse a Transaction source: https://developer.mastercard.com/mastercard-processing-core/documentation/sandbox-testing/transactions-and-fees-management/reverse-a-trans/index.md ## Test case -- Success {#test-case--success} This test case describes reversing a specified transaction. **Sample request** `POST /transactions/90001/reversal` ```JSON { "reason" : "REVERSAL" } ``` **Sample response** `201` `Location: /transaction-documents?transaction_selector_type=ID&transaction_selector_value=2829673` ```JSON { "transactionId": 2829673 } ``` ## Test case -- Fail -- No serviceClassCode linked to the Transaction {#test-case--fail--no-serviceclasscode-linked-to-the-transaction} This test case describes an attempt to reverse a specified transaction for which the CMS does not store the `serviceClassCode` value. For this test case, use the following information in the request: | Path parameter | Available value | |------------------|-----------------| | `transaction_id` | 99210 | **Sample request** `POST /transactions/99210/reversal` ```JSON { "reason": "REVERSAL" } ``` **Sample response** `400` ```JSON { "Errors": { "Error": [ { "Source": "MASTERCARD PROCESSING", "ReasonCode": "REVERSE_DOC_FLOW_INTERRUPT", "Description": "ServiceClass is missing in the CMS for transaction with id 99210", "Recoverable": false } ] } } ``` ## Test case -- Fail -- No transactionType linked to the Transaction {#test-case--fail--no-transactiontype-linked-to-the-transaction} This test case describes an attempt to reverse a specified transaction for which the CMS does not store the `transactionType` value. For this test case, use the following information in the request: | Path parameter | Available value | |------------------|-----------------| | `transaction_id` | 99110 | **Sample request** `POST /transactions/99110/reversal` ```JSON { "reason": "REVERSAL" } ``` **Sample response** `400` ```JSON { "Errors": { "Error": [ { "Source": "MASTERCARD PROCESSING", "ReasonCode": "REVERSE_DOC_FLOW_INTERRUPT", "Description": "TransactionType is missing in the CMS for the transaction with id 99110.", "Recoverable": false } ] } } ``` ## Test case -- Fail -- Reverse not allowed for the given serviceClassCode {#test-case--fail--reverse-not-allowed-for-the-given-serviceclasscode} This test case describes an attempt to reverse a specified transaction for which the `serviceClassCode` value is not allowed to be reversed by the CMS. For this test case, use the following information in the request: | Path parameter | Available value | |------------------|-----------------| | `transaction_id` | 99410 | **Sample request** `POST /transactions/99410/reversal` ```JSON { "reason": "REVERSAL" } ``` **Sample response** `400` ```JSON { "Errors": { "Error": [ { "Source": "MASTERCARD PROCESSING", "ReasonCode": "REVERSE_DOC_FLOW_INTERRUPT", "Description": "ServiceClassCode for a transaction with id 99410 is not on the list of parameters permitted to reverse a transaction.", "Recoverable": false } ] } } ``` ## Test case -- Fail -- Reverse not allowed for the given transactionType {#test-case--fail--reverse-not-allowed-for-the-given-transactiontype} This test case describes an attempt to reverse a specified transaction which the `transactionType` value is not allowed to be reversed by the CMS. For this test case, use the following information in the request: | Path parameter | Available value | |------------------|-----------------| | `transaction_id` | 99310 | **Sample request** `POST /transactions/99310/reversal` ```JSON { "reason": "REVERSAL" } ``` **Sample response** `400` ```JSON { "Errors": { "Error": [ { "Source": "MASTERCARD PROCESSING", "ReasonCode": "REVERSE_DOC_FLOW_INTERRUPT", "Description": "TransactionType for a transaction with id 99310 is not on the list of parameters permitted to reverse the transaction.", "Recoverable": false } ] } } ``` ## Test case -- Fail -- Incorrect Transaction status {#test-case--fail--incorrect-transaction-status} This test case describes an attempt to reverse a specified transaction which the `postingStatus` value in the CMS is other than `Posted`. For this test case, use the following information in the request: | Path parameter | Available value | |------------------|-----------------| | `transaction_id` | 99510 | **Sample request** `POST /transactions/99510/reversal` ```JSON { "reason": "REVERSAL" } ``` **Sample response** `400` ```JSON { "Errors": { "Error": [ { "Source": "MASTERCARD PROCESSING", "ReasonCode": "UNEXPECTED_DOCUMENT_STATUS", "Description": "Transaction with id 99510 not in the postingStatus permitted to be reversed.", "Recoverable": false } ] } } ```