- Overview
- Requirements
- Frameworks/Libraries
- 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 Mastercard Installment APIs can be used. To call the API, consumer key and .p12 file are required from your project on Mastercard Developers.
- Java 11
- IntelliJ IDEA (or any other IDE)
- Spring Boot
- 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.
The Mastercard Encryption Library provides interceptor class that you can use when configuring your API client. This class will take care of encrypting payload before sending the request and decrypting payload after receiving the response.
A Certificate
object can be created from a file by calling EncryptionUtils.loadEncryptionCertificate
:
Certificate encryptionCertificate = EncryptionUtils.loadEncryptionCertificate("<insert certificate file path>");
Supported certificate formats: PEM
A PrivateKey
object can be created from a PKCS#12 key store by calling EncryptionUtils.loadDecryptionKey
the following way:
PrivateKey decryptionKey = EncryptionUtils.loadDecryptionKey(
"<insert PKCS#12 key file path>",
"<insert key alias>",
"<insert key password>");
JweConfig config = JweConfigBuilder.aJweEncryptionConfig()
.withEncryptionCertificate(encryptionCertificate)
.withDecryptionKey(decryptionKey)
.withEncryptionPath("$", "$")
.withDecryptionPath("$.consumer.encryptedData", "$.consumer")
.withEncryptedValueFieldName("cipher")
.build();
-
Create your account on Mastercard Developers if you don't have it already.
-
Create a new project here and add Mastercard Installments API to it and click continue.
-
Download Sandbox Signing Key, a
.p12
file will be downloaded. -
Copy the downloaded
.p12
file tosrc/main/resources
folder in your code. -
Open
src/main/resources/application.yml
and configure:mastercard.api.environment.base-path
- refers to sandbox endpoint, it's a static field, will be used as a host to make API calls.
Below properties will be required for authentication of API calls.
mastercard.api.authentication.key-file
- path to keystore (.p12) file, just change the name as per the downloaded file in step 3.mastercard.api.authentication.consumer-key
- copy the Consumer key from "Sandbox/Production Keys" section on your project page.mastercard.api.authentication.keystore-alias
- alias of your key. Default key alias for a sandbox iskeyalias
.mastercard.api.authentication.keystore-password
- password of your Keystore. Default keystore password for sandbox project iskeystorepassword
.
Below properties will be required to encrypt and decrypt the request and response payloads
mastercard.api.encryption.key-file
- download Client Encryption Keys fromclient-encryption.pem
(this step will be used for approvals api).mastercard.api.decryption.key-file
- Mastercard encryption keykeyalias-encryption-mc.p12
(this step will be used for plans api).mastercard.api.decryption.keystore-alias
- alias of your mastercard encryption key.keyalias
.mastercard.api.decryption.keystore-password
- password of your mastercard encryption key.keystorepassword
.
-
Merchant Participation
Provides information on partner merchants with product code and IPP relationship. -
Approvals API
The approvals should be completed within 24 hours of initiation. -
Plans API
Provides "get plan" capability to retrieve information about the consumer and merchant. This operation returns a BNPL installment plan based on selected plan id provided in the request. The API response contains an encrypted value for the Consumer object, and the issuer needs to decrypt the response using Mastercard client encryption key.
More details can be found here.
- Run
mvn clean install
from the root of the project directory. - There are two ways to execute the use-cases:
-
Execute the use-cases (test cases):
- Go to
src/test/java/com/mastercard/installments/bnpl/reference/application/controller/
folder. - Execute the test case.
- Go to
-
Use REST API based Client (such as Insomnia or Postman)
-
Run
mvn spring-boot:run
command to run the application. -
Use any REST API based Client to test the functionality. Below is the API exposed by this application:
- GET <Host>/demo/merchants-participations - POST <Host>/demo/approvals?sync=true - POST <Host>/demo/approvals?sync=false - GET <Host>/demo/approvals/{plan_id} - GET <Host>/plans/{plan_id}
-
-
Mastercard Installments documentation can be found here.
The Swagger API specification can be found here.
Please send an email to [email protected] with any questions or feedback you may have.
Copyright 2022 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.