# Installments Approval API
source: https://developer.mastercard.com/unified-installments/documentation/testing/installments-approval-api/index.md

## Prerequisites {#prerequisites}

Refer to the [Installments Approval](https://developer.mastercard.com/unified-installments/documentation/use-cases/mastercard-installments-program-with-merchant-participation/installments/index.md#installments-approval-api-overview) use case.
Note: Before you test GET /approvals for a given Plan ID, you must first call 'POST /approvals' for your Plan ID.

#### Test Case 1: Success-POST Approval Sync (APPROVED) {#test-case-1-success-post-approval-sync-approved}

**GIVEN** : The client has access to the Mastercard Installment API and has integrated their solution or application with the [/approvals](https://developer.mastercard.com/unified-installments/documentation/api-reference/apis/index.md#apis) endpoint.  

**WHEN** : The client backend system makes a REST call to the '/approvals' endpoint.

The request URL param sync=true

The request body included an APPROVED plan,

The request body is encrypted using the suggested MC Encryption LIB,  

**THEN** : The plan is approved.  

##### Request Parameters {#request-parameters}

sync=true

##### Request Body {#request-body}

* JSON

```JSON
{
	"planId": "2fd24d3a-1f9e-4faf-97bf-caa1f7a3813f",
	"status": "APPROVED",
	"approvedAmount": 100,
	"approvedCurrency": "USD",
	"paymentAuthorization": {
		"primaryAccountNumber": "5120340101976862",
		"panExpirationMonth": "11",
		"panExpirationYear": "2023",
		"cardSecurityCode": "000",
		"cardholderFullName": "John Doe",
		"cardholderFirstName": "John",
		"cardholderLastName": "Doe",
		"billingAddress": {
			"line1": "123MAINSTREET",
			"line2": "2a",
			"city": "JerseyCity",
			"state": "NJ",
			"countryCode": "US",
			"zip": "07306"
		}
	}
}
```

##### Response {#response}

* JSON

```JSON
{
	"callbackUrl": "https://src.mastercard.com#%7B%22checkoutResponse%22%3A%22eyJpc3MiOiJodHRwczpcL1wvbWFzdGVyY2FyZC5jb20iLCJpYXQiOjE2NjkxMzg2OTQsImFsZyI6IlJTMjU2IiwianRpIjoiZTNlNjcyZWEtYjRmYS00ZjA3LTg2NjMtMDViZTQyOGI1OTRkIiwia2lkIjoiMTQ5MTI2LXNyYy1wYXlsb2FkLXZlcmlmaWNhdGlvbiJ9.eyJzcmN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MlQxNzoyNDoxMC4xMTdaIn0sImN1c3RvbU91dHB1dERhdGEiOnt9LCJhc3N1cmFuY2VEYXRhIjp7ImNhcmRWZXJpZmljYXRpb25FbnRpdHkiOiIwMiIsImNhcmRWZXJpZmljYXRpb25NZXRob2QiOiIwMyIsImNhcmRWZXJpZmljYXRpb25SZXN1bHRzIjoiMDMifX0.DuUd4CdLO9UVCgMgy3vS2Myqquy-3QkWXkc-17zsn1PKVEPQ2OoCRr0pnrfQw_NFVchkMs2TcTe6nZ9yjDR-07VlpM0mMx4h-LXEFFE-0-UsFGrbLFEapltkDf8NJE28aKl7OVFvQYJs7dP_GN2ZPIMiHrWnZ0AdY_rW3ypqn2yUzXdEZ6VI7y97YSE_LNbFl5VgM97j3O-0sNBqMo1HwPBEaoJoFtlz14aLh6YwEUl5GAHgFp1GmVvcw7b_EpTa_rua16yGvmh_dLqXT3EPO9c_qZpiP5AXTeMnntqzHgFaMUVcdw76Cs1K8d_7OIVH2uh2qEHnElE8LY6FIscnIg%22%2C%22action%22%3A%22COMPLETE%22%7D"
}
```

#### Test Case 2: Success-POST Approval Sync (DECLINED) {#test-case-2-success-post-approval-sync-declined}

**GIVEN** : The client has access to the Mastercard Installment API and has integrated their solution or application with the [/approvals](https://developer.mastercard.com/unified-installments/documentation/api-reference/apis/index.md#apis) endpoint.  

**WHEN** : The client backend system makes a REST call to the '/approvals' endpoint.  

The request URL param sync=true  

The request body included a DECLINED plan.  

The request body is encrypted using the suggested MC Encryption LIB.  

**THEN**: The plan is declined.

##### Request Parameters {#request-parameters-1}

sync=true

###### Request Body {#request-body-1}

* JSON

```JSON
{
	"planId": "9eb01b62-e832-43bd-8ea8-7eca0e82bd49",
	"status": "DECLINED",
	"rejectReasonCode": "OTHER_REASON",
	"rejectReasonDetail": "Credit score is too low"
}
```

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

* JSON

```JSON
{
	"callbackUrl": "https://src.mastercard.com#%7B%22action%22%3A%22MA_ERROR%22%7D"
}
```

#### Test Case 3: Success-POST Approval Asynchronously {#test-case-3-success-post-approval-asynchronously}

**GIVEN** : The client has access to the Mastercard Installment API and has integrated their solution or application with the [/approvals](https://developer.mastercard.com/unified-installments/documentation/api-reference/apis/index.md#apis) endpoint.  

**WHEN** : The client backend system makes a REST call to the '/approvals' endpoint.  

The request body included an APPROVED or DECLINED plan.  

The request body is encrypted using the suggested MC Encryption LIB.  

**THEN**: The request is asynchronously posted to Mastercard Installments. The client can then call GET /approvals/{planId} to return the status of their request at a later point.

##### Request Parameters {#request-parameters-2}

sync=false

###### Request Body {#request-body-2}

* JSON

```JSON
{
	"planId": "2fd24d3a-1f9e-4faf-97bf-caa1f7a3813f",
	"status": "DECLINED",
	"rejectReasonCode": "OTHER_REASON",
	"rejectReasonDetail": "Credit score is too low"
}
```

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

202

### Test Case 4: Success-GET status of checkout and callback URL to PSP {#test-case-4-success-get-status-of-checkout-and-callback-url-to-psp}

**GIVEN** : The client has access to the Mastercard Installment API and has integrated their solution/application with the [/approvals](https://developer.mastercard.com/unified-installments/documentation/api-reference/apis/index.md#apis) endpoint.  

**WHEN** : The client backend system makes an asynchronous REST call to the '/approvals/{planId}' endpoint. The request URL param plan_id={Plan ID that was asynchronously submitted to Mastercard Installments.}  

**THEN**: This API will be used by the provider to get the status of checkout and callback URL to PSP.

##### Request Parameters {#request-parameters-3}

2fd24d3a-1f9e-4faf-97bf-caa1f7a3813f

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

* JSON

```JSON
{
	"callbackUrl": "https://src.mastercard.com#%7B%22action%22%3A%22MA_ERROR%22%7D",
	"status": "COMPLETED"
}
```

