Mastercard Petstore API
- API version: 1.0.0
- App version: 1.0.0
This application provides examples of how a Mastercard API should implement authentication, authorization, and payload encryption. Please follow the steps in the documentation here to understand how to utilize this application and adapt it for your service.
Building the API client library requires:
- Java 17+
- Maven (3.8.3+)
Please follow the instruction below to begin
mvn clean install
This will generate all required files as defined in petstore.yaml. They should be built into the target folder.
Set properties in application.properties
The authentication mode (MTLS or OAuth1.0a) must be set using
-Dspring.profiles.active=oauth
-Dspring.profiles.active=mtls
If using the API in OAuth1.0a mode the following are required in application-oauth.properties
mastercard.oauth.pkcs12KeyFile
mastercard.oauth.consumerKey
mastercard.oauth.keyAlias
mastercard.oauth.keyPassword
If using the API in MTLS mode the following are required in application-mtls.properties
mastercard.mtls.pfxKeyFile
mastercard.mtls.keyPassword
Encryption properties are required to be set. This API supports JWE encryption. This is in application.properties
mastercard.encryption.encryptionCert
mastercard.encryption.decryptionKeys
mastercard.encryption.decryptionKeyAlias
mastercard.encryption.decryptionKeyPassword
To see how the average flow of each use case please see the flow folder and run a test. Note this tests will not
run if a basePath
in application.properties is not set. These tests call
out to the service, so they must be set.
The tests can be run using
mvn test -Dspring.profiles.active=oauth
or
mvn test -Dspring.profiles.active=mtls
Example scenarios can be found under src/main/java/com/mastercard/app/petstore/examples
There are provide simples uses cases, documented below
This demonstrates the typical flow for an adoption.
- A new adoption is created
- The adoption is then retrieved using the adoption id from step 1
- Information is updated before removing it using the same id
- Clean up. The adoption is removed from the system
This demonstrates the typical flow for managing an employee.
- A new employee is added to the system
- The employee's information is then searched for via SSN
- Clean up. The employee is removed from the system
This demonstrates the typical flow for adding a new cat.
- A new cat is added to the system
- The cat's information is retrieved via it's id
- That cat's status is updated to
RESERVED
- Clean up. The cat is removed from the system
For more information, please visit https://developer.mastercard.com/support