Skip to content

Dima2021/elevate-reference-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elevate Accelerator Reference App

Quality Gate Status Coverage Vulnerabilities

Table of Contents

Overview

This is a reference application to demonstrate how Elevate Accelerator Proxy APIs can be used. To call these APIs, consumer key and .p12 file required from your project on Mastercard Developers.

Requirements

Frameworks/Libraries

  • Apache Maven
  • OpenAPI Generator

Integrating with 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:

OpenAPI Generator Plugin Configuration

<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/elevate-accelerator-proxy-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>

Generating The API Client Sources

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 icons Reimport All Maven Projects and Generate Sources and Update Folders for All Projects

  • Method 2
    In the same menu, navigate to the commands ({Project name} > Lifecycle), select clean and compile then click the icon Run Maven Build.

Using Terminal

Navigate to the root directory of the project within a terminal window and execute mvn clean compile command.

Configuration

  1. Create your account on Mastercard Developers if you don't have it already.
  2. Create a new project here and add Elevate to it and click continue.
  3. Download Sandbox Signing Key, a .p12 file will be downloaded.
  4. 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.
  5. Copy the downloaded .p12 and .pem files to src/main/resources folder in your code.
  6. Open src/main/resources/application.properties and configure:
    • mastercard.elevate.client.p12.path - Path to keystore (.p12) file, just change the name as per the downloaded file in step 5.
    • mastercard.elevate.client.ref.app.consumer.key - Copy the Consumer key from "Sandbox/Production Keys" section on your project page
    • mastercard.elevate.client.ref.app.keystore.alias - Alias of your key. Default key alias for the sandbox is keyalias.
    • mastercard.elevate.client.ref.app.keystore.password - Password of your Keystore. Default keystore password for sandbox project is keystorepassword.
    • mastercard.elevate.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.

Use-Cases

  1. Check Eligibility
    Endpoint: "/eligibility". Used to check eligibility of a credit card in elevate program for a specific benefit.

  2. Create Redemptions
    Endpoint: "/redemptions". Used to create a redemption for a credit card that was previously enrolled through the eligibilities resource.

More details can be found here.

Execute the Use-Cases

Below are the APIs exposed by this application:
- POST /elevate/eligibility
- POST /elevate/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/elevate-accelerator-1.0.0.jar command to run the application.
  • Add argument checkEligibility or redemption in above command to execute each api individually:
    • For example, run java -jar target/elevate-accelerator-1.0.0.jar checkEligibility command to execute the /eligibility api,
    • Run java -jar target/elevate-accelerator-1.0.0.jar redemption command to execute the /redemption api.

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, dane+101@ifonly.com or dane+102@ifonly.com. 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.

Service Documentation

Elevate Accelerator Proxy documentation can be found here.

API Reference

The Swagger API specification can be found here.

Support

Please email apisupport@mastercard.com with any questions or feedback you may have.

License

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%