# Real Time API
source: https://developer.mastercard.com/unified-installments/documentation/testing/mastercard-installments-payment-services/real-time-api/index.md

## Prerequisites {#prerequisites}

API to be hosted by issuers to support real time installment offers on card. Mastercard Installments will call this API real time to fetch the installment offers on the card.

## Positive test scenario {#positive-test-scenario}

#### Test Case: Successful delivery of Notification API for a funding PAN-based transaction {#test-case-successful-delivery-of-notification-api-for-a-funding-pan-based-transaction}

**GIVEN** : The consumer is integrated with the Mastercard Installments API /installments/offers endpoint.  

**WHEN:** A request is submitted to the /installments/offers endpoint.   

**AND:** The request is identified as a Generic Realtime offer scenario. And invoke the call for the issuer /card-offers/searches API.   

**AND:** An eligible Generic Realtime offer is available for the supplied request data.  

**AND:** The issuer API returns the eligible Generic Realtime offer.  

**THEN:** The consumer receives the eligible Generic Realtime offer details in the response.   

These are the criteria:

* amount
* currency
* localdatetime
* country
* mcc
* url
* acquirerId
* merchantId
* PAN (Encryption required)

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

* JSON

```JSON
{
    "transaction": {
        "amount": 700.0,
        "currency": "USD",
        "localDateTime": "2023-10-26T00:00:00Z"
    },
    "merchant": {
        "name": "Kohls",
        "country": "USA",
        "mcc": "1711",
        "url": "https://corporate.kohls.com",
        "acquirerId": 234353,
        "merchantId": "121234",
        "dpMerchantId": "AB0C5342F0012ADC45"
    },
    "sensitiveData": "eyJraWQiOiI2ZjQ4NDZjZjBkMTFlOWM4NThmMGFhYWYzMDBlZDM5ZDEwYjJmZmU4NmRkNDQ2MTJmMGM4N2FmZDZjNGY0MjkyIiwiY3R5IjoiYXBwbGljYXRpb24vanNvbiIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJSU0EtT0FFUC0yNTYifQ.MUfK9BU4AyAtlh2jaUTGSpcfrHUfOwBc-IcAVAdF93KASsZAroZJR_rBv7-meVLzRs1Yp0VDmrFGhv3pi6CyyLZWCfNIXRW27TgxXhOrrV25Kxdj3Vd2uknLzAewv1LrpSUhdOsItRKdGjh0CxxU3J48tB5KP3aj0PiJZna-kIP2E4cBBbkk0weykZH8gKykff-z0Ldqt0-XbHHyKNVoTQSx8YrQoCTLXs8QEnA26gXiR-xYZOx9wwV9TSx_WqcW-4bQTwXslyXbGv_BK_EYtlfM6O8F2GWkhZnG7QMs22K2kDAT_NWlJAomSRb70qXn53Cmo1CK9rJR7upGu8yIBQ.xqgOZ228IFSa-fM9VvZyQQ.Q7-E4wvdN2DzoVB3iL83kx18Ujyd3AIDismVhIfaO8tBAFqoRj6-GYyNX8zBFk3hdf9yyypiX8o.g6hlL5fDcQnY0c-U4zresg"
}
```

##### Response {#response}

* JSON

```JSON
{
	"total": 1,
	"offers": [
		{
			"priority": 1,
			"offerId": "21345693",
			"offerType": "CARDED_EXTERNAL_REALTIME",
			"currencySymbol": "$",
			"apr": 15.14,
			"transactionCurrency": "USD",
			"totalInterestAndFeeAmount": 40,
			"tenure": 6,
			"frequency": "BIWEEKLY",
			"interestRate": 0,
			"totalInterestAmount": 5,
			"oneTimeFeeAmount": 100,
			"disclosureLinks": [
				{
					"linkText": "Disclosure Text example",
					"linkURL": "https://example.com/disclosure"
				}
			],
			"recurringFeeAmount": 20,
			"firstInstallmentSchedule": "TRANSACTION_DATE",
			"totalAmount": 400,
			"firstInstallmentAmount": 66.67,
			"otherInstallmentAmount": 66.67,
			"totalFeeAmount": 0,
			"schedulePayments": [
				{
					"installmentNumber": 1,
					"installmentAmount": 66.67
				},
				{
					"installmentNumber": 2,
					"installmentAmount": 66.67
				},
				{
					"installmentNumber": 3,
					"installmentAmount": 66.67
				},
				{
					"installmentNumber": 4,
					"installmentAmount": 66.67
				},
				{
					"installmentNumber": 5,
					"installmentAmount": 66.67
				},
				{
					"installmentNumber": 6,
					"installmentAmount": 66.67
				}
			]
		}
	]
}
```

## Negative test scenarios {#negative-test-scenarios}

#### Test Case 1: Verify that the consumer is not able to see the generic realtime offers if the criteria are not matched {#test-case-1-verify-that-the-consumer-is-not-able-to-see-the-generic-realtime-offers-if-the-criteria-are-not-matched}

**GIVEN:** The consumer is integrated with the Mastercard Installments API /installments/offers endpoint.   

**WHEN:** A request is submitted to the /installments/offers endpoint.  

**AND:** The request is identified as a Generic Realtime offer scenario. And invoke call for the issuer /card-offers/searches API.  

**AND:** An eligible Generic Realtime offer is not available for the supplied request data.  

**AND:** The issuer API returns no eligible Generic Realtime offer.  

**THEN:** The consumer should not receive any generic real time offer.

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

* JSON

```JSON
{
    "transaction": {
        "amount": 700.0,
        "currency": "USD",
        "localDateTime": "2023-10-26T00:00:00Z"
    },
    "merchant": {
        "name": "Kohls",
        "country": "USA",
        "mcc": "1711",
        "url": "https://corporate.kohls.com",
        "acquirerId": 234353,
        "merchantId": "121234",
        "dpMerchantId": "AB0C5342F0012ADC45"
    },
    "sensitiveData": "eyJraWQiOiI2ZjQ4NDZjZjBkMTFlOWM4NThmMGFhYWYzMDBlZDM5ZDEwYjJmZmU4NmRkNDQ2MTJmMGM4N2FmZDZjNGY0MjkyIiwiY3R5IjoiYXBwbGljYXRpb24vanNvbiIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJSU0EtT0FFUC0yNTYifQ.b7vZI-xomBxWunZjN-9wmL1krVi2QlIhtjufEl8SONdKU_8KM5yAZY-vUtoEPprD3_BnZaQY4b8Ub0N2crGYUBAgNzJiiA9j6c0KpfgXJFMTIu-PrcQeNjI9JvGE9Svy-LlENMuFVcNSxjqtce7hWif8mRLWX7rhWBlfccKF4kRTSy9_U__ChyNMzw3cGIpfR-tc7e0r6_V4ItCWeW2GbeegL5rNLRFHbnvREZSeq11Bt4bwVbxsmx2bw8KfR-IBZQprnej87UK2aKmCiM6Cbnd-AmeZioZeIogQA4tZTyAlxzKs6Nx8G7tTiqvCfGF9eleVImZN-lFmIL1ArhH2WQ.F9uUTXhUqLqY_IoyoC2xjA._ko5DVggEw-3b-mPcOUbJhA3KjOz2TjnavqW2cZqQgYsBvW-2MFDs0-cf-i7YzKKuKen6JySFWHoBNg.ZPGOKKmexcWDOnJT5EtxSA"
}
```

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

* JSON

```JSON
{
	"total": 0,
	"offers": []
}
```

#### Test Case 2: Verify that the consumer is not able to see the offers if service is unavailable from the issuer end {#test-case-2-verify-that-the-consumer-is-not-able-to-see-the-offers-if-service-is-unavailable-from-the-issuer-end}

**GIVEN:** The consumer is integrated with the Mastercard Installments API /installments/offers endpoint.   

**WHEN:** A request is submitted to the /installments/offers endpoint.   

**AND:** The request is identified as a Generic Realtime offer scenario. And invoke the call for the issuer /card-offers/searches API.   

**AND:** An eligible Generic Realtime offer is not available for the supplied request data.  

**AND:** The issuer API returns 503 service unavailable.   

**THEN:** The consumer should not receive any generic real time offer.

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

* JSON

```JSON
{
	"transaction": {
		"amount": 999.0,
		"currency": "USD",
		"localDateTime": "2186-10-22T08:59:52.872510277Z"
	},
	"merchant": {
		"name": "Testing Merchants thes",
		"country": "USA",
		"mcc": null,
		"url": null,
		"acquirerId": 444444,
		"merchantId": "402405783600002",
		"dpMerchantId": null
	},
	"sensitiveData": "eyJraWQiOiI2ZjQ4NDZjZjBkMTFlOWM4NThmMGFhYWYzMDBlZDM5ZDEwYjJmZmU4NmRkNDQ2MTJmMGM4N2FmZDZjNGY0MjkyIiwiY3R5IjoiYXBwbGljYXRpb24vanNvbiIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJSU0EtT0FFUC0yNTYifQ.VT5grB1FDkpp2B_4zJyweDadrJQtg00EM3c8i9zSppfvf49qregLVmmn-jQtKyzMnXLKUR4DKZz7ddv6j9NtLnTBgIVTq8M1AE02vvKGRFVo7gFG7tJJkp3mKKUVw-tJ-qUBcqZCjEHEvx-ngdSNFmdq7g_pMdZbxHwg3CJfxmwXP6ScQMKj7cK1xnUW5hervlT5XzP0G0yHvWRezcD29pbBnuCMg4qVdbY7Mc-t8T1UMwYQnpcIYGcTb817MuGwPbZH8P1g2S1PK25rHY4SEIooE-s16SPBYmZKVYxrMPog9ULaysihepHk_DuHD8tGRhQO1otmJLaynchP4qEgZw.b6BOr-MQ6f5dZdNLP2cw_g._I3dzDvu7Bpkk5rnbbrGATKNb6jgiRDfNlkVjpVpbAUmZjb1hfw0F1Yph36tspPxRH78x6q_4GMhZlg.5HAV2SPEnfxOExZTtECBEQ"
}
```

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

* JSON

```JSON
{
	"errors": [
		{
			"type": "FATAL",
			"code": "serviceUnavailable",
			"details": "The service is temporarily unavailable. Please retry after some time.",
			"location": "genericOffer",
			"moreInfo": "https://developer.generic.com/errors/service-unavailable"
		}
	]
}
```

