# Agreement Management
source: https://developer.mastercard.com/account-to-account-commerce-for-dsp/documentation/testing/agreement-management/index.md

## Pre-requisites {#pre-requisites}

The following pre-requisites are applied to all the use cases:  

1. The client and signing keys have been exchanged.   
2. The outbound notification is set up at the participant's end.   
3. The debtor service provider onboarding completed and the DSPId shared.   
4. Successful connectivity testing.   

The following are the debtor service provider's responsibilities:

* Ensure that the debtor app or website is available, stable, and ready to be tested with these test cases.  
* The debtor service provider should also have tested debtors and accounts for testing some of these test cases.   

## Test Cases {#test-cases}

### Test Case 1: Link Account {#test-case-1-link-account}

|                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Test Title**             | Link Account                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **Description**            | The creditor service provider receives a request to link the creditor to a debtor, and the creditor service provider sends it to Mastercard. The debtor service provider retrieves the link, the debtor reviews the request, and the debtor service provider confirms the link to Mastercard.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Pre-Requisite**          | The creditor must be onboarded and a creditorId must be generated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Test Steps**             | **Step 1:** Use the Postman pack to execute the create agreement `(POST /agreements)` with any applicable agreement type (AOF, MRT, AMRT, MIT, or ALL), businessType of 2, and productId of PBARFP. Capture the agreementLifecycleId, agreementReferenceNumber, and agreementId from the response. **Step 2:** The debtor service provider must execute the retrieve agreement `(POST /agreement-retrievals)`with the agreementLifecycleId value received from Step 1. **Step 3:** The debtor service provider must execute the confirm agreement `(POST /agreements/{agreement_id}/updates)` with agreementId value received from Step 1. **Step 4:** Mastercard will receive the confirm agreement and send an outbound confirm agreement advice to the creditor service provider `(POST /agreements/{agreement_id}/updates)`. |
| **Postman Setup Scenario** | The creditor service provider Id should be populated in the environment variables.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Expected Result**        | **Step 1:** The create agreement should return a response code of 200 with a valid agreementLifecycleId, agreementReferenceNumber, and agreementId. **Step 2:** The retrieve agreement should return a response code of 200 from Mastercard. **Step 3:** The confirm agreement should return a response code of 200 from Mastercard.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| **Level of Necessity**     | Mandatory                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

### Test Case 2: Delete Linked Account by the Creditor Service Provider {#test-case-2-delete-linked-account-by-the-creditor-service-provider}

|                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Test Title**             | Delete Linked Account initiated by Creditor Service Provider                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| **Description**            | The creditor service provider receives a request from the debtor to delete a linked account. The creditor service provider forwards it to Mastercard and updates the linked account of the debtor at the creditor's website/app.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Pre-Requisite**          | The creditor must be onboarded, and a creditorId is generated. The debtor has been linked to the creditor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| **Test Steps**             | **Step 1:** The debtor logs in to the creditor app and views the list of linked account(s). The debtor selects an account to delete. **Step 2:** Use the Postman pack to execute the delete agreement `(POST /agreements/{agreement_id}/updates)` with agreementId received from the create agreement response, businessType of 2, and productId of PBARFP. **Step 3:** Mastercard will send the delete agreement notification to the debtor service provider `(POST /agreements/{agreement_id}/updates)`. The debtor service provider is to receive the delete notification and acknowledges Mastercard. The debtor service provider must update the linked accounts at their end. |
| **Postman Setup Scenario** | The CSPId should be populated in the environment variables. The agreement should be established and the agreementId captured.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **Expected Result**        | **Step 1:** The delete agreement should return a response code of 200. **Step 2:** The debtor service provider should be able to receive the delete notification and confirm with response code 200.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| **Level of Necessity**     | Mandatory                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

### Test Case 3: Delete Linked Account by Debtor Service Provider {#test-case-3-delete-linked-account-by-debtor-service-provider}

|                            |                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Test Title**             | Delete Linked Account initiated by the Debtor Service Provider                                                                                                                                                                                                                                                                                                                                                                        |
| **Description**            | The debtor service provider receives a request from the debtor to delete a linked account. The debtor login to the debtor service provider app and selects an account to delete. The creditor service provider receives the delete notification from Mastercard.                                                                                                                                                                      |
| **Pre-Requisite**          | The creditor must be onboarded and the creditorId generated. The debtor has been linked to the creditor.                                                                                                                                                                                                                                                                                                                              |
| **Test Steps**             | **Step 1:** The debtor login to the debtor service provider app and views the list of linked account(s). The debtor selects an account to delete. **Step 2:** The debtor service provider to execute Delete Agreement `(POST /agreements/{agreement_id}/updates)`using agreementId received during Create Agreement. **Step 3:** Mastercard will send an outbound notification to the creditor service provider's onboarded endpoint. |
| **Postman Setup Scenario** | NA                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Expected Result**        | The delete agreement should return a response code of 200 from Mastercard.                                                                                                                                                                                                                                                                                                                                                            |
| **Level of Necessity**     | Mandatory                                                                                                                                                                                                                                                                                                                                                                                                                             |

### Test Case 4: Update Linked Account {#test-case-4-update-linked-account}

|                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Test Title**             | Update Linked Account nickname notification                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Description**            | The debtor service provider receives a request from the debtor to update the account nickname for a linked account. The debtor chooses the account and sends a request to Mastercard. Mastercard notifies the creditor service provider using the agreement update notification.                                                                                                                                                               |
| **Pre-Requisite**          | The creditor must be onboarded and the creditorId generated. The debtor has been linked to the creditor.                                                                                                                                                                                                                                                                                                                                       |
| **Test Steps**             | **Step 1:** The debtor login to the debtor service provider app and views the list of linked account(s). The debtor selects an account to update. **Step 2:** The debtor service provider to execute the update agreement`(POST /agreements/{agreement_id}/updates)`using the agreementId received during the create agreement. **Step 3:** Mastercard will send an outbound notification to the creditor service provider onboarded endpoint. |
| **Postman Setup Scenario** | NA                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| **Expected Result**        | The update agreement should return a response code of 200 from Mastercard.                                                                                                                                                                                                                                                                                                                                                                     |
| **Level of Necessity**     | Optional                                                                                                                                                                                                                                                                                                                                                                                                                                       |

