Skip to content

Commit

Permalink
Merge pull request #19 from amolun/master
Browse files Browse the repository at this point in the history
PR added to sync up Reference app with latest changes
  • Loading branch information
ajitkumarchauhan1704 authored Dec 11, 2024
2 parents 7766053 + 1ad1c9b commit 7c14b94
Show file tree
Hide file tree
Showing 7 changed files with 1,907 additions and 157 deletions.
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ See also:
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/elevate-accelerator-proxy-services.yaml</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/mbep-services.yaml</inputSpec>
<generatorName>java</generatorName>
<library>okhttp-gson</library>
<generateApiTests>false</generateApiTests>
Expand Down Expand Up @@ -106,40 +106,30 @@ Used to get benefits of the user.

2. **Check Eligibility**
Endpoint: "/eligibility".
Used to check eligibility of a credit card in mbep program for a specific benefit.
Used to check eligibility of a credit card in mbep program for a specific benefit. Access to this API requires mapping of client ID, please contact your mastercard representative to get this access.

3. **Create Redemptions**
Endpoint: "/redemptions".
Used to create a redemption for a credit card that was previously enrolled through the eligibilities resource.
Used to create a redemption for a credit card that was previously enrolled through the eligibilities resource. Access to this API requires mapping of client ID, please contact your mastercard representative to get this access.

4. **Store Payment Tokens**
Endpoint: "/payment-tokens".
Used to store Pan data as tokens by PSP on behalf of merchants.

More details can be found [here](https://developer.mastercard.com/elevate/documentation/use-cases/).
More details can be found [here](https://developer.mastercard.com/mbep/documentation/use-cases/).


## Execute the Use-Cases <a name="execute-the-use-cases"></a>
Below are the APIs exposed by this application:
- GET <HOST>/benefits
- POST <Host>/eligibility
- POST <Host>/redemptions
- POST <Host>/payment-tokens
Once you have added the correct properties, you are ready to build the application. You can do this by navigating to the project’s base directory from the terminal and then by running the following command.
`mvn clean install`
- GET <HOST>/mbep/benefits
- POST <Host>/mbep/eligibility
- POST <Host>/mbep/redemptions

**NOTE:**
- if you want to consume api on production environment please change the url values of
```mastercard.mbep.client.api.base.path``` in [application.properties](src%2Fmain%2Fresources%2Fapplication.properties),
```VALUE_BASE_URL``` in [RequestHelperTest.java](src%2Ftest%2Fjava%2Fcom%2Fmastercard%2Fdevelopers%2Fmbep%2Fhelper%2FRequestHelperTest.java) and
```VALUE_BASE_URL``` in [MBEPServiceImplTest.java](src%2Ftest%2Fjava%2Fcom%2Fmastercard%2Fdevelopers%2Fmbep%2Fservice%2FMBEPServiceImplTest.java)
to 'https://api.mastercard.com/elevate'
Once you have added the correct properties, you are ready to build the application. You can do this by navigating to the project’s base directory from the terminal and then by running the following command.

`mvn clean install`

When the project builds successfully, you can run the following command to start the project
- Run ```java -jar target/elevate-accelerator-1.0.0.jar``` command to run the application.
- Open the browser and enter the url ```http://localhost:8080/mbep/``` and you will land on benefits page.
- Click on ```benefits```, ```tokens```, ```eligibility``` or ```redemeptions``` tab and enter the details as required.
- Run ```java -jar target/mbep-1.0.0.jar``` command to run the application.
- Open the browser and enter the url ```http://localhost:5001/mbep/``` and you will land on benefits page.
- Click on ```benefits```, ```eligibility``` or ```redemeptions``` tab and enter the details as required.
- When submitted you will get JSON response for each service.

**NOTE:**
Expand All @@ -152,7 +142,7 @@ MBEP documentation can be found [here](https://developer.mastercard.com/mbep/doc


## API Reference <a name="api-reference"></a>
The Swagger API specification can be found [here](https://developer.mastercard.com/elevate/documentation/api-reference/).
The Swagger API specification can be found [here](https://developer.mastercard.com/mbep/documentation/api-ref/).

## Support <a name="support"></a>
Please email **[email protected]** with any questions or feedback you may have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.mastercard.developers.mbep.generated.models.RedemptionByRealTimePan;
import com.mastercard.developers.mbep.generated.models.RedemptionByRealTimeToken;
import com.mastercard.developers.mbep.generated.models.CheckEligibilityByPan;
import com.mastercard.developers.mbep.generated.models.CheckEligibilityByToken;

/*
* This class is used to invoke mbep APIs
Expand Down Expand Up @@ -52,4 +56,24 @@ public String storePaymentToken(@RequestBody CardToken cardToken) throws ApiExce
CardTokenInfo response = mbepService.saveToken(cardToken);
return new Gson().toJson(response);
}

@PostMapping(value = "/eligibilities/pan")
public String eligibilitiesByPan(@RequestBody CheckEligibilityByPan checkEligibilityByPan) throws ApiException {
return new Gson().toJson(mbepService.checkEligibilityByPan(checkEligibilityByPan));
}

@PostMapping(value = "/eligibilities/token")
public String eligibilitiesByToken(@RequestBody CheckEligibilityByToken checkEligibilityByToken) throws ApiException {
return new Gson().toJson(mbepService.checkEligibilityByToken(checkEligibilityByToken));
}

@PostMapping(value = "/redemptions/real-time/token")
public String realTimeRedemptionByToken(@RequestBody RedemptionByRealTimeToken redemptionByRealTimeToken) throws ApiException {
return new Gson().toJson(mbepService.createRedemptionByRealTimeToken(redemptionByRealTimeToken));
}

@PostMapping(value = "/redemptions/real-time/pan")
public String realTimeRedemptionByPan(@RequestBody RedemptionByRealTimePan redemptionByRealTimePan) throws ApiException {
return new Gson().toJson(mbepService.createRedemptionByRealTimePan(redemptionByRealTimePan));
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.mastercard.developers.mbep.service;

import com.google.gson.Gson;

import com.mastercard.developers.mbep.generated.apis.MbepApi;
import com.mastercard.developers.mbep.generated.invokers.ApiException;
import com.mastercard.developers.mbep.generated.models.CardToken;
import com.mastercard.developers.mbep.generated.models.CardTokenInfo;
import com.mastercard.developers.mbep.generated.models.CheckEligibility;
import com.mastercard.developers.mbep.generated.models.CheckEligibilityByPan;
import com.mastercard.developers.mbep.generated.models.CheckEligibilityByToken;
import com.mastercard.developers.mbep.generated.models.Eligibility;
import com.mastercard.developers.mbep.generated.models.PartnerBenefitDetails;
import com.mastercard.developers.mbep.generated.models.RedemptionByRealTimePan;
import com.mastercard.developers.mbep.generated.models.RedemptionByRealTimeToken;
import com.mastercard.developers.mbep.generated.models.RedemptionInfo;
import com.mastercard.developers.mbep.generated.models.Redemptions;
import com.mastercard.developers.mbep.helper.RequestHelper;
Expand Down Expand Up @@ -72,4 +75,45 @@ public CardTokenInfo saveToken(CardToken cardToken) throws ApiException {
log.info(RESPONSE + tokenInfo.toString());
return tokenInfo;
}

public Eligibility checkEligibilityByToken(CheckEligibilityByToken checkEligibilityByToken) throws ApiException {
String requestPayload = new Gson().toJson(checkEligibilityByToken);
String request = REQUEST_API + baseUrl + "/eligibilities/token\n" +
"Source: checkEligibility by Token \nRequest Payload : " + requestPayload;
log.info(request);
Eligibility eligibility = mbepApi.checkEligibilityByToken(checkEligibilityByToken);
log.info(RESPONSE + eligibility.toString());
return eligibility;

}
public Eligibility checkEligibilityByPan(CheckEligibilityByPan checkEligibilityByPan) throws ApiException {
String requestPayload = new Gson().toJson(checkEligibilityByPan);
String request = REQUEST_API + baseUrl + "/eligibilities/pan\n" +
"Source: checkEligibility by PAN \nRequest Payload : " + requestPayload;
log.info(request);
Eligibility eligibility = mbepApi.checkEligibilityByPan(checkEligibilityByPan);
log.info(RESPONSE + eligibility.toString());
return eligibility;

}

public RedemptionInfo createRedemptionByRealTimeToken(RedemptionByRealTimeToken redemptionByRealTimeToken) throws ApiException {
String requestPayload = new Gson().toJson(redemptionByRealTimeToken);
String request = REQUEST_API + baseUrl + "/redemptions/real-time/token\n" +
"Source: real time redemption with token \nRequest Payload : " + requestPayload;
log.info(request);
RedemptionInfo redemptionInfo = mbepApi.createRedemptionByRealTimeToken(redemptionByRealTimeToken);
log.info(RESPONSE + redemptionInfo.toString());
return redemptionInfo;
}

public RedemptionInfo createRedemptionByRealTimePan(RedemptionByRealTimePan redemptionByRealTimePan) throws ApiException {
String requestPayload = new Gson().toJson(redemptionByRealTimePan);
String request = REQUEST_API + baseUrl + "/redemptions/real-time/pan\n" +
"Source: real time redemption with pan \nRequest Payload : " + requestPayload;
log.info(request);
RedemptionInfo redemptionInfo = mbepApi.createRedemptionByRealTimePan(redemptionByRealTimePan);
log.info(RESPONSE + redemptionInfo.toString());
return redemptionInfo;
}
}
Loading

0 comments on commit 7c14b94

Please sign in to comment.