- Overview
- Requirements
- Integrating with OpenAPI Generator
- Configuration
- Use-Cases
- Execute the Use-Cases
- Service Documentation
- API Reference
- Support
- License
This is a reference application to demonstrate how MBEP APIs can be used. To call these APIs, consumer key and .p12 file required from your project on Mastercard Developers.
- Mastercard Developers Account with access to "MBEP" API
- Java 11
- Apache maven 3.3+
- A text Editor or any IDE
- Apache Maven
- OpenAPI Generator
OpenAPI Generator generates API client libraries from OpenAPI Specs. It provides generators and library templates for supporting multiple languages and frameworks. Check Generating and Configuring a Mastercard API Client to know more about how to generate a simple API client for consuming APIs.
See also:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/mbep-services.yaml</inputSpec>
<generatorName>java</generatorName>
<library>okhttp-gson</library>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<sourceFolder>src/gen/main/java</sourceFolder>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Now that you have all the dependencies you need, you can generate the sources. To do this, use one of the following two methods:
Using IDE
-
Method 1
In IntelliJ IDEA, open the Maven window (View > Tool Windows > Maven). Click the iconsReimport All Maven Projects
andGenerate Sources and Update Folders for All Projects
-
Method 2
In the same menu, navigate to the commands ({Project name} > Lifecycle), selectclean
andcompile
then click the iconRun Maven Build
.
Using Terminal
Navigate to the root directory of the project within a terminal window and execute mvn clean compile
command.
- Create your account on Mastercard Developers if you don't have it already.
- Create a new project here and add MBEP to it and click continue.
- Download Sandbox Signing Key, a
.p12
file will be downloaded. - In the Client Encryption Keys section of the dashboard, click on the
Actions
dropdown and download the client encryption key, a ``.pem``` file will be downloaded. - Copy the downloaded
.p12
and.pem
files tosrc/main/resources
folder in your code. - Open
src/main/resources/application.properties
and configure:mastercard.mbep.client.p12.path
- Path to keystore (.p12) file, just change the name as per the downloaded file in step 5.mastercard.mbep.client.ref.app.consumer.key
- Copy the Consumer key from "Sandbox/Production Keys" section on your project pagemastercard.mbep.client.ref.app.keystore.alias
- Alias of your key. Default key alias for the sandbox iskeyalias
.mastercard.mbep.client.ref.app.keystore.password
- Password of your Keystore. Default keystore password for sandbox project iskeystorepassword
.mastercard.mbep.client.ref.app.encryption.file
- Path to encryption key (.pem) file, just change the name as per the downloaded file in step 5, e.g.src/main/resources/<fileName>.pem
.
-
Get Benefits Endpoint: "/benefits". Used to get benefits of the user.
-
Check Eligibility
Endpoint: "/eligibility". 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. -
Create Redemptions
Endpoint: "/redemptions". 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.
More details can be found here.
Below are the APIs exposed by this application:
- GET /mbep/benefits
- POST /mbep/eligibility
- POST /mbep/redemptions
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/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
orredemeptions
tab and enter the details as required. - When submitted you will get JSON response for each service.
NOTE:
- Update request with valid details in json files under location /src/main/resources/templates/
in order to execute these apis successfully.
- For each new call, you should change the email address,such as, [email protected] or [email protected]. If you use the same email address, you may get an error that the benefit has already been redeemed (this is expected). For each new call, you should change the card number. Use the number generator to generate a number that passes the MOD10/Luhn test. The range of eligible PANs is 5555555555550000 through 5555555555559999.
MBEP documentation can be found here.
The Swagger API specification can be found here.
Please email [email protected] with any questions or feedback you may have.
Copyright 2021 Mastercard
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.