# How to call Donation and Program History APIs source: https://developer.mastercard.com/donations/tutorial/donation-api-details/historyapi/index.md ## View a Report of the Donations Made {#view-a-report-of-the-donations-made} * The `/donations/donors/transactions` endpoint retrieves a list of donation transactions for a given donor in a given time frame. * The `/donations/programs/transactions` endpoint retrieves a list of donation transactions by `programId` in a given time frame. ## ~~POST~~ GET /donors/{donor_id}/transactions {#post----get-donorsdonor_idtransactions} ## Prerequisites {#prerequisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [View Donation History](https://developer.mastercard.com/donations/documentation/use-cases/manage-donation-trns/view-dona-hist/index.md) * [Parameters to Retrieve Donation History](https://developer.mastercard.com/donations/documentation/parameters/track-donations-param/history/index.md) ## Test Cases {#test-cases} 1. To fetch information of the donations made by a donor, send a ~~POST~~ GET request. 2. To create a ~~POST~~ GET request, provide the `donorId` as the endpoint path parameter. 3. You may also provide these optional parameters in the header as required: * `offset`: The page number to start retrieval of the setups * `limit`: The number of donation setups to retrieve. ```py GET https://sandbox.api.mastercard.com/donations/donors/a96d0089-1d02-494c-9938-12f45c0549ab/transactions ``` ### Paramters {#paramters} * from_date * to_date 4. If a client is associated with more than one program, it is mandatory to pass a `programID` in the request header: > **Program ID**: 82e73e5c-f618-409a-8ca2-a212a0f649e3 5. A successful request returns the `HTTP 200 OK` status code and a JSON response body that includes all the one-time and recurring donations made by the donor in the provided time frame from all the registered cards. ```json { "data": { "limit": 10, "offset": 0, "total": 5, "count": 5, "items": [ { "charityName": "Stripe Charity", "primaryAccountNumberSuffix": "1118", "donationType": "ONE-TIME", "date": "2023-07-03", "updatedDate": "2023-07-03", "amount": 10, "currency": "USD", "paymentNetwork": "mastercard", "dedication": null, "clientId": "C7i6WOvQp2obVbB_EtX8XCsQ5YwQ_FN2yIz7Mf9m31e6102d", "programId": "aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c", "donorId": "bdacdcfc-7d74-406c-9be3-a9f46dcfa27f", "cardId": "88b34e2d-4c80-4469-8049-f713c39530f1", "charityId": "4b6047c8-b71a-f8e1-4a1f-7b00e09d19ab", "transactionId": "OTsb7v4QRGqR1Ci9xIcPEAsdfklnskfioPcK", "orderId": "b53bc97b-25b2-4116-927b-ba1f5fa3d809", "transactionStatus": "FAILURE" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "1118", "donationType": "ONE-TIME", "date": "2023-04-20", "updatedDate": "2023-04-20", "amount": 8, "currency": "USD", "paymentNetwork": "mastercard", "dedication": null, "clientId": "C7i6WOvQp2obVbB_EtX8XCsQ5YwQ_FN2yIz7Mf9m31e6102d", "programId": "aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c", "donorId": "bdacdcfc-7d74-406c-9be3-a9f46dcfa27f", "cardId": "88b34e2d-4c80-4469-8049-f713c39530f1", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTsb7v4QRGqR1Ci9xIcPEAsdfklnskfioPcK", "orderId": "89119e66-14d6-4a94-b2e2-f01a7932d9a3", "transactionStatus": "SUCCESS" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "1118", "donationType": "MICRO", "date": "2023-04-20", "updatedDate": "2023-04-20", "amount": 8, "currency": "USD", "paymentNetwork": "mastercard", "dedication": null, "clientId": "C7i6WOvQp2obVbB_EtX8XCsQ5YwQ_FN2yIz7Mf9m31e6102d", "programId": "aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c", "donorId": "bdacdcfc-7d74-406c-9be3-a9f46dcfa27f", "cardId": "88b34e2d-4c80-4469-8049-f713c39530f1", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "MIaIpn_bRsmOOYC-4IML8gsdhfjshfLopjpI", "orderId": "89119e66-14d6-4a94-b2e2-f01a7932d9a3", "transactionStatus": "SUCCESS" }, { "charityName": "AST-CLIENT-PROGRAM-CHARITY-1", "primaryAccountNumberSuffix": "1118", "donationType": "MICRO", "date": "2023-04-20", "updatedDate": "2023-04-20", "amount": 8, "currency": "USD", "paymentNetwork": "mastercard", "dedication": null, "clientId": "C7i6WOvQp2obVbB_EtX8XCsQ5YwQ_FN2yIz7Mf9m31e6102d", "programId": "aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c", "donorId": "bdacdcfc-7d74-406c-9be3-a9f46dcfa27f", "cardId": "88b34e2d-4c80-4469-8049-f713c39530f1", "charityId": "496e1703-7e2c-4135-8b99-6cba97cd2f9b", "transactionId": "MI5pPstFTpGFZdoR2Ho3yAsdhakklkIpskpO", "orderId": "188817d9-5d4a-430c-86a4-d38fac672d46", "transactionStatus": "FAILURE" }, { "charityName": "AST-CLIENT-PROGRAM-CHARITY-1", "primaryAccountNumberSuffix": "1118", "donationType": "MICRO", "date": "2023-04-20", "updatedDate": "2023-04-20", "amount": 5, "currency": "USD", "paymentNetwork": "mastercard", "dedication": null, "clientId": "C7i6WOvQp2obVbB_EtX8XCsQ5YwQ_FN2yIz7Mf9m31e6102d", "programId": "aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c", "donorId": "bdacdcfc-7d74-406c-9be3-a9f46dcfa27f", "cardId": "88b34e2d-4c80-4469-8049-f713c39530f1", "charityId": "496e1703-7e2c-4135-8b99-6cba97cd2f9b", "transactionId": "MIbLg8G5SEOGF6SB_f86aAkadhaklfshgpiK", "orderId": "51d96a3b-5493-48a6-b22e-42ab0b0e8ca0", "transactionStatus": "FAILURE", "reasonCode": "INCORRECT_NUMBER", "reasonMessage": "The card number is incorrect. Please check the card's number and try again use a different card." } ] } } ``` 1. To fetch information of the donations made by a donor, send a POST request. 2. To create a POST request, provide the `donorId` as the endpoint path parameter. 3. You may also provide these optional parameters in the header as required: * `offset`: The page number to start retrieval of the setups * `limit`: The number of donation setups to retrieve. ```py GET https://sandbox.api.mastercard.com/donations/donors/bdacdcfc-7d74-406c-9be3-a9f46dcfa27f/transactions?limit=25&offset=10 ``` ### Paramters {#paramters} * from_date * to_date 4. If a client is associated with more than one program, it is mandatory to pass a `programID` in the request header: > **Program ID**: aa0f99f5-75d2-46ed-81b8-7ac80ccd0f6c 5. A successful request returns the `HTTP 200 OK` status code and a JSON response body that includes all the one-time and recurring donations made by the donor in the provided time frame from all the registered cards. ```JSON { "data": { "limit": 1000, "offset": 0, "total": 602, "count": 602, "items": [ { "charityName": "Save the Children,", "primaryAccountNumberSuffix": "1111", "donationType": "ONE-TIME", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 10, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "d518967d-2b76-4d83-8fad-b9c43cdba076", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTrPjQjNS3SC0d-BCPeb1Q", "orderId": "84b57c00-63b8-4392-afc6-a1286f02ccd8", "transactionStatus": "FAILURE" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0019", "donationType": "ONE-TIME", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 40, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "2bd45372-c4cb-4cd2-8d20-9ac0b7f51e2f", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTtgadqNSrmybjRx6f9GmA", "orderId": "e0002e19-90de-422a-bac2-3001f4bd13ac", "transactionStatus": "SUCCESS" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0007", "donationType": "ONE-TIME,", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 100, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "234c51a1-ee50-4f98-ad3c-e304f2d6f846", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTUpK9mGShS_0BRY8Zv8Rg", "orderId": "0bf04655-ff03-4d09-82bf-e6b590dbffba", "transactionStatus": "FAILURE" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0007", "donationType": "MICRO", "date": "2019-08-24", "updatedDate": "2020-10-01", "amount": 50, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "234c51a1-ee50-4f98-ad3c-e304f2d6f812", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTUpK9mGShS_0BRY8Zv8Af", "orderId": "0bf04655-ff03-4d09-82bf-e6b590dbffer", "transactionStatus": "FAILURE" } ] } } ``` This section discusses some of the failed scenarios and the error messages expected. If you spell the donation type differently from the provided norms, the request terminates with the error code `400 Bad Request` as the response. For example, if you provide the `donationType` as 'OneTime' instead of correctly specifying as 'One-Time', the request throws an error. ### Request {#request} ```json { "charityId": "4b6047c8-b71a-f8e1-4a1f-7b00e09d19ab", "fromDate": "2024-05-01", "toDate": "2025-07-20", "donationType": "OneTime", "transactionStatus": "ALL" } ``` ### Response {#response} ```json { "Errors": { "Error": [ { "Source": "DONATE_SERVICE", "ReasonCode": "DONATION_TYPE_INVALID", "Description": "Donation Type is Invalid.", "Recoverable": false, "Details": null } ] } } ``` If you provide a `donationType` that is not supported by the associated program, the request terminates with the error code `400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "DONATE_SERVICE", "ReasonCode": "DONATION_TYPE_NOT_FOUND", "Description": "The donationType 'One-Time' is not supported by the program with programId 'd50e7303-c564-446c-8aa4-ce35700fd6ee'.", "Recoverable": false, "Details": null } ] } } ``` ## ~~POST~~ GET /donations/programs/{programId}/transactions {#post-get-donationsprogramsprogramidtransactions} ## Prerequisites {#prerequisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [View Program Donation History](https://developer.mastercard.com/donations/documentation/use-cases/manage-donation-trns/view-prg-hist/index.md) * [Parameters to Retrieve Program Donation History](https://developer.mastercard.com/donations/documentation/parameters/track-donations-param/prog-trans-hist/index.md) ## Test Cases {#test-cases} 1. To fetch information of the donations made by a donor, send a ~~POST~~ GET request. 2. To create a ~~POST~~ GET request, provide the `donorId` as the endpoint path parameter. 3. You may also provide these optional parameters in the header as required: * `offset`: The page number to start retrieval of the setups * `limit`: The number of donation setups to retrieve. ```py GET https://sandbox.api.mastercard.com/donations/program/da28a815-fd25-4df4-8b60-1a735d81e473/transactions&limit=25&offset=10 ``` ### Parameters {#parameters} "fromDate": "2024-05-01", "toDate": "2025-07-20", "transactionStatus": "SUCCESS" 4. A successful request returns the `HTTP 200 OK` status code and a JSON response body that includes all the one-time and recurring donations made by the donor in the provided time frame for the provided program. ```JSON { "data": { "limit": 10, "offset": 0, "total": 6, "count": 6, "items": [ { "charityName": "Save the Children,", "primaryAccountNumberSuffix": "1111", "donationType": "ONE-TIME", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 10, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "d518967d-2b76-4d83-8fad-b9c43cdba076", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTrPjQjNS3SC0d-BCPeb1Q", "orderId": "84b57c00-63b8-4392-afc6-a1286f02ccd8", "transactionStatus": "SUCCESS" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0019", "donationType": "ONE-TIME", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 40, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "2bd45372-c4cb-4cd2-8d20-9ac0b7f51e2f", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTtgadqNSrmybjRx6f9GmA", "orderId": "e0002e19-90de-422a-bac2-3001f4bd13ac", "transactionStatus": "SUCCESS" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0007", "donationType": "ONE-TIME,", "date": "2022-11-07", "updatedDate": "2022-11-07", "amount": 100, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "234c51a1-ee50-4f98-ad3c-e304f2d6f846", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTUpK9mGShS_0BRY8Zv8Rg", "orderId": "0bf04655-ff03-4d09-82bf-e6b590dbffba", "transactionStatus": "SUCCESS" }, { "charityName": "Save the Children", "primaryAccountNumberSuffix": "0007", "donationType": "MICRO", "date": "2019-08-24", "updatedDate": "2020-10-01", "amount": 50, "currency": "EUR", "paymentNetwork": "mastercard", "clientId": "4dG5GoNZizSe_hDkUULGvYoaK9jmbEZsQbGxg-CA7fca22dc", "programId": "da28a815-fd25-4df4-8b60-1a735d81e473", "donorId": "10d212f0-198e-466e-8d9b-ac26746f7fb4", "cardId": "234c51a1-ee50-4f98-ad3c-e304f2d6f812", "charityId": "9a2e0ca5-e574-440e-af0a-5f58c035d7e8", "transactionId": "OTUpK9mGShS_0BRY8Zv8Af", "orderId": "0bf04655-ff03-4d09-82bf-e6b590dbffer", "transactionStatus": "SUCCESS" } ] } } ``` This section discusses some of the failed scenarios and the error messages expected. The maximum limit size allowed for a query is 2000. If you exceed this value, the request terminates with the error code `400 Bad Request` as the response. ```json { "Errors": { "Error": [ { "Source": "DONATE_SERVICE", "ReasonCode": "INVALID_LIMIT", "Description": "Limit should be less than 2000.", "Recoverable": false, "Details": null } ] } } ```