# Post a Debit Transaction
source: https://developer.mastercard.com/mastercard-processing-core/documentation/sandbox-testing/transactions-and-fees-management/post-debit-trans/index.md

## Test case -- Success {#test-case--success}

This test case describes posting a debit transaction for a specified contract (account contract or card contract).

For this test case, use the following information in the request:

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/70001/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Fee Posting",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`201`  

`Location: /transaction-documents?transaction_selector_type=ID&transaction_selector_value=90001`

```JSON
{
  "transactionId": 90001
}
```

## Test case -- Fail -- Not unique reference number {#test-case--fail--not-unique-reference-number}

This test case describes an attempt to post a debit transaction for a specified contract (account contract or card contract) by sending in the request the `uniqueReferenceNumber` value that already exists in the CMS.

For this test case, use the following information in the request:

|          Field          | Available value |
|-------------------------|-----------------|
| `transactionTypeCode`   | FP              |
| `uniqueReferenceNumber` | 111111          |

**Sample request**

`POST /contracts/70001/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Fee Posting",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "111111"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "NOT_UNIQUE_REFERENCE_NUMBER",
        "Description": "UniqueReferenceNumber 111111 already exists.",
        "Recoverable": false
      }
    ]
  }
}
```

## Test case -- Fail -- Insufficient funds {#test-case--fail--insufficient-funds}

This test case describes an attempt to post a debit transaction for a specified contract (account contract or card contract) that has insufficient funds in the CMS.

For this test case, use the following information in the request:

| Path parameter | Available value |
|----------------|-----------------|
| `contract_id`  | 45001           |

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/45001/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Fee Posting",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "NOT_SUFFICIENT_FUNDS",
        "Description": "Not sufficient funds available for the contract with id 45001.",
        "Recoverable": false
      }
    ]
  }
}
```

## Test case -- Fail -- Blockade by the usage limit maximum amount {#test-case--fail--blockade-by-the-usage-limit-maximum-amount}

This test case describes an attempt to post a debit transaction for a specified contract (account contract or card contract) that exceeds the maximum amount permitted by a specified usage limit.

For this test case, use the following information in the request:

| Path parameter | Available value |
|----------------|-----------------|
| `contract_id`  | 45002           |

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/45002/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Fee Posting",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`400`

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "USAGE_LIMIT_EXCEEDED",
        "Description": "Transaction amount exceeds the maximum value permitted by the Usage Limit DAILY_TOTAL",
        "Recoverable": false
      }
    ]
  }
}
```

## Test case -- Fail -- Transaction not allowed {#test-case--fail--transaction-not-allowed}

This test case describes an attempt to post a credit transaction that is not allowed for a specified contract.

For this test case, use the following information in the request:

| Path parameter | Available value |
|----------------|-----------------|
| `contract_id`  | 45003           |

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/45003/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Payment From Client Contract",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`400`

```JSON
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "TRANSACTION_NOT_ALLOWED",
                "Description": "Transaction not allowed for the contract with id 45003.",
                "Recoverable": false
            }
        ]
    }
}
```

## Test case -- Fail -- Card contract has no active card plastic {#test-case--fail--card-contract-has-no-active-card-plastic}

This test case describes an attempt to post a credit transaction for a card contract that does not have an active `Plastic`.

For this test case, use the following information in the request:

| Path parameter | Available value |
|----------------|-----------------|
| `contract_id`  | 45004           |

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/45004/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Payment From Client Contract",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`400`

```JSON
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "PLASTIC_NOT_ACTIVE",
                "Description": "Active plastic not found for the contract with id 45004.",
                "Recoverable": false
            }
        ]
    }
}
```

## Test case -- Fail -- Card contract is not active {#test-case--fail--card-contract-is-not-active}

This test case describes an attempt to post a credit transaction for a card contract that is not active.

For this test case, use the following information in the request:

| Path parameter | Available value |
|----------------|-----------------|
| `contract_id`  | 45005           |

|         Field         | Available value |
|-----------------------|-----------------|
| `transactionTypeCode` | FP              |

**Sample request**

`POST /contracts/45005/debits`

```JSON
{
  "amount": 1254,
  "currency": "EUR",
  "customData": [
    {
      "tagName": "TAG_NAME_1",
      "tagValue": "TAG_VALUE_A"
    }
  ],
  "description": "Payment From Client Contract",
  "feeCode": "FX_FEE",
  "postingDate": "2031-06-25",
  "transactionTypeCode": "FP",
  "transactionTypeExtension": "Ext",
  "uniqueReferenceNumber": "122357012766"
}
```

**Sample response**

`400`

```JSON
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "CARD_CONTRACT_STATUS_IS_WRONG",
                "Description": "Card contract with id 45005 in wrong status to post transaction.",
                "Recoverable": false
            }
        ]
    }
}
```

