# Aggregate Transaction Footprint
source: https://developer.mastercard.com/carbon-calculator/documentation/testing/testcase/test_case_aggregate_transaction_footprint/index.md

Fetches carbon score for payment cards and aggregates the same on weekly and monthly basis.

## Pre-requisites {#pre-requisites}

Refer to the [View Aggregate Transaction Footprints](https://developer.mastercard.com/carbon-calculator/documentation/use-cases/aggregate_txn_footprint/index.md) use case.


API Reference: `GET /payment-cards/transaction-footprints/aggregates`

<br />

## Test Cases {#test-cases}

### Test Case: Success-Aggregate Transaction Footprint {#test-case-success-aggregate-transaction-footprint}

##### Request {#request}

```json
{
  "aggregateType": 2,
  "crossPANAggregate": "Y",
  "paymentCardIds": [
     "76182790-092a-44d0-bb2b-23bacdfa0882",
     "da541e91-23a9-49a1-a500-5dc034cc18d7"
  ],
  "fromDate": "2022-01-01",
  "toDate": "2022-02-01"
}
```

##### Response {#response}

```json
{
  "aggregateTransactionFootprint": [
    {
      "paymentCardId": "da541e91-23a9-49a1-a500-5dc034cc18d7",
      "footprintAggregations": [
        {
          "carbonEmissionInGrams": 9524.56,
          "carbonEmissionInOunces": 335.96,
          "aggregateValue": "February|2022"
        },
        {
          "carbonEmissionInGrams": 540748.0,
          "carbonEmissionInOunces": 19074.28,
          "aggregateValue": "January|2022"
        }
      ]
    },
    {
      "paymentCardId": "76182790-092a-44d0-bb2b-23bacdfa0882",
      "footprintAggregations": [
        {
          "carbonEmissionInGrams": 3398.54,
          "carbonEmissionInOunces": 119.88,
          "aggregateValue": "February|2022"
        },
        {
          "carbonEmissionInGrams": 291991.76,
          "carbonEmissionInOunces": 10299.67,
          "aggregateValue": "January|2022"
        }
      ]
    }
  ],
  "crossPANAggregations": [
       {
         "carbonEmissionInGrams": 12923.10,
         "carbonEmissionInOunces": 455.84,
         "aggregateValue": "February|2022"
       },
       {
         "carbonEmissionInGrams": 832739.76,
         "carbonEmissionInOunces": 29373.95,
         "aggregateValue": "January|2022"
       }
  ]
}
```

### Test Case: Fail-Invalid request parameter {#test-case-fail-invalid-request-parameter}

##### Request {#request-1}

```json
{
  "aggregateType": 7,
  "crossPANAggregate": "Y",
  "paymentCardIds": [
     "76182790-092a-44d0-bb2b-23bacdfa0882",
     "da541e91-23a9-49a1-a500-5dc034cc18d7"
  ],
  "fromDate": "2022-01-01",
  "toDate": "2022-02-01"
}
```

##### Response {#response-1}

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "Service-Provider-Mgmt",
        "ReasonCode": "INVALID_REQUEST_PARAMETER",
        "Description": "One of the request parameters is invalid, try again with correct request.",
        "Recoverable": false,
        "Details": "aggregateType must be less than or equal to 3"
      }
    ]
  }
}
```

### Test Case: Fail-Payment card invalid or not found {#test-case-fail-payment-card-invalid-or-not-found}

##### Request {#request-2}

```json
{
  "aggregateType": "2",
  "crossPANAggregate": "N",
  "paymentCardIds": [
    "8a581a55-bcea-4c3e-8e0f-9b4726e5e6d3",
    "328b62d4-287c-4c9f-a05d-6d4a67f208d8",
    "b86fd2ba-c095-4acb-b9df-f3805655ba24"
  ],
     "fromDate": "2022-01-01",
     "toDate": "2022-02-01"
}
```

##### Response {#response-2}

```json
{
  "Errors": {
    "Error": [
      {
         "Source": "Service-Provider",
         "ReasonCode": "INVALID_REQUEST_PARAMETER",
         "Description": "Payment card id - [b86fd2ba-c095-4acb-b9df-f3805655ba24,328b62d4-287c-4c9f-a05d-6d4a67f208d8 ] is/are invalid or not found. Please try again with valid payment card id.",
         "Recoverable": false,
         "Details": ""
      }
    ]
  }
}
```

### Test Case: Fail-Invalid Date Range {#test-case-fail-invalid-date-range}

##### Request {#request-3}

```json
{
  "aggregateType": 1,
  "crossPANAggregate": "Y",
  "paymentCardIds": [
     "76182790-092a-44d0-bb2b-23bacdfa0882",
     "da541e91-23a9-49a1-a500-5dc034cc18d7"
  ],
  "fromDate": "2022-01-01",
  "toDate": "2023-08-01"
}
```

##### Response {#response-3}

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "Service-Provider",
        "ReasonCode": "INVALID_DATE_RANGE",
        "Description": "Requested date range is either invalid or exceeds supported limit (i.e. 26 weeks for weekly aggregate and 12 months for monthly aggregate).",
        "Recoverable": false,
        "Details": ""
      }
    ]
  }
}
```

### Test Case: Fail-Invalid Date Format {#test-case-fail-invalid-date-format}

##### Request {#request-4}

```json
{
  "aggregateType": 1,
  "crossPANAggregate": "Y",
  "paymentCardIds": [
     "76182790-092a-44d0-bb2b-23bacdfa0882",
     "da541e91-23a9-49a1-a500-5dc034cc18d7"
  ],
  "fromDate": "01-01-2022",
  "toDate": "01-02-2022"
}
```

##### Response {#response-4}

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "Service-Provider",
        "ReasonCode": "INVALID_REQUEST_PARAMETER",
        "Description": "One of the request parameters is invalid, try again with correct request.",
        "Recoverable": false,
        "Details": "fromDate must match \"^((?:19|20)[0-9][0-9])-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$\""
      },
      {
        "Source": "Service-Provider",
        "ReasonCode": "INVALID_REQUEST_PARAMETER",
        "Description": "One of the request parameters is invalid, try again with correct request.",
        "Recoverable": false,
        "Details": "toDate must match \"^((?:19|20)[0-9][0-9])-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$\""
      }
    ]
  }
}
```

