- JDK 17
- Set up the JAVA_HOME environment variable to match the location of your Java installation.
- Set up the MAVEN_HOME environment variable to match the location of your Maven bin folder.
This reference app supports two authentication strategies. The active profile is controlled by the spring.profiles.active property in application.properties.
Uses OAuth 2.0 with DPoP (Demonstrating Proof of Possession) and private key JWT authentication, following the FAPI 2.0 Security Profile. This is the recommended and default authentication method.
Required properties:
spring.profiles.active=oauth2
mastercard.api.key-file-path=<path-to-signing-key.p12>
mastercard.api.keystore-alias=<key-alias>
mastercard.api.keystore-password=<keystore-password>
mastercard.api.oauth2.client.id=<your-oauth2-client-id>
mastercard.api.oauth2.kid=<your-key-id>
mastercard.api.oauth2.token.url=https://sandbox.api.mastercard.com/oauth/token
mastercard.api.oauth2.issuer.url=https://sandbox.api.mastercard.com
mastercard.api.oauth2.scope=rewards-api-gateway:promotions-digital-enablement_readUses OAuth 1.0a with RSA-SHA256 signatures. This is an older authentication method.
To switch to this profile, update spring.profiles.active=oauth1 in application.properties and provide the OAuth 1.0a-specific keys below.
Required properties:
spring.profiles.active=oauth1
mastercard.api.key-file=<path-to-signing-key.p12>
mastercard.api.consumer-key=<your-consumer-key>
mastercard.api.keystore-alias=<key-alias>
mastercard.api.keystore-password=<keystore-password>The mastercard.api.consumer-key is only required for OAuth 1.0a. It can be found under Sandbox/Production Keys on your project page at the Mastercard Developer Portal.
- Open Mastercard Developers website and create an account at Mastercard Developers.
- Create a new project here.
- Add the
Promotions Digital EnablementAPI to your project and click continue. - Configure project and click continue.
- Download Sandbox Signing Key.
- A
.p12file is downloaded automatically. Note: On Safari, the file name will beUnknown. Rename it to a.p12extension. - Copy the downloaded
.p12file tosrc/main/resourcesfolder in the code. - Download Client Encryption Key.
- Copy the downloaded
.pemfile tosrc/main/resourcesfolder in the code. - Copy Client Encryption Key Fingerprint.
- Open
src/main/resources/application.propertiesand configure the following (OAuth 2.0 is already set as the default profile):spring.profiles.active= oauth2mastercard.api.key-file-path- Path to the.p12keystore file.mastercard.api.keystore-alias- Key alias. Default key alias for sandbox iskeyalias.mastercard.api.keystore-password- Keystore password. Default keystore password for sandbox project iskeystorepassword.mastercard.api.oauth2.client.id- OAuth 2.0 Client ID. Copy this from "Sandbox/Production Keys" on your project page.mastercard.api.oauth2.kid- Key ID. This is the same as the key alias. Default key alias for sandbox iskeyalias.mastercard.api.oauth2.token.url- OAuth 2.0 token endpoint URL. For sandbox environment, usehttps://sandbox.api.mastercard.com/oauth/token.mastercard.api.oauth2.issuer.url- OAuth 2.0 issuer URL. For sandbox environment, usehttps://sandbox.api.mastercard.com.mastercard.api.oauth2.scope- OAuth 2.0 scopes. Userewards-api-gateway:promotions-digital-enablement_read.
- Run
mvn clean installfrom the root of the project directory. - Run
mvn spring-boot:runto start the project. - Navigate to http://localhost:8080/swagger-ui.html in your browser.
-
Open
src/main/resources/application.propertiesand configure the following:spring.profiles.active= oauth1mastercard.api.key-file- Path to the.p12keystore file.mastercard.api.consumer-key- OAuth 1.0a Consumer Key. Copy this from "Sandbox/Production Keys" on your project page.mastercard.api.keystore-alias- Key alias. Default key alias for sandbox iskeyalias.mastercard.api.keystore-password- Keystore password. Default keystore password for sandbox project iskeystorepassword.
Note: The
mastercard.api.consumer-keyis only required for OAuth 1.0a. It can be found under Sandbox/Production Keys on your project page at the Mastercard Developer Portal. -
Run
mvn clean installfrom the root of the project directory. -
Run
mvn spring-boot:runto start the project. -
Navigate to http://localhost:8080/swagger-ui.html in your browser.
Both profiles require encryption/decryption configuration for payload security:
mastercard.api.encryption-certificate-file=<path-to-encryption.pem>
mastercard.api.encryption-key-fingerprint=<fingerprint>
mastercard.api.decryption-key-file-path=<path-to-decryption.p12>
mastercard.api.decryption-keystore-alias=<alias>
mastercard.api.decryption-keystore-password=<password>Note: Most of the fields in swagger are populated with example data. The fields that are left unpopulated should be populated with data specific to your promotions program.
A tutorial can be found here for setting up and using this service.
Promotions Digital Enablement service documentation can be found here
Please send an email to apisupport@mastercard.com with any questions or feedback you may have.