/mastercard-mpgs-sdk

SDK for Mastercard Payment Gateway Service - make MPGS requests easy

Primary LanguageJavaApache License 2.0Apache-2.0

mastercard-mpgs-sdk

make MPGS requests easy

Installation

Maven

<dependency>
    <groupId>com.github.marcoblos</groupId>
    <artifactId>mastercard-mpgs-sdk</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

Getting started

PAY METHOD

MastercardProperties properties = new MastercardProperties();
properties.setBaseUrl("https://eu-gateway.mastercard.com/api/rest/version/");
properties.setApiVersion("45");
properties.setMerchantId("TEST...");
properties.setApiKey("xxxxxxxxxxxxxxxxxx");

MastercardRestTemplate restTemplate = new MastercardRestTemplate(properties.getMerchantId(), properties.getApiKey());

// normally you get this informations from your user and your system (amount,
// credit card data, etc.) this isnecessary data to build the MPGS request
MastercardRequestDTO dto = MastercardRequestDTO.builder()
    .apiOperation(MastercardAPIOperationType.PAY)
    .amount(new BigDecimal("10000.00"))
    .cardNumber("cccccccccccccccc")
    ...
    .build();

MastercardRequestResponseDTO requestResponseDTO = MastercardObjectRequestFactory.build(dto);

MastercardResponse response = MastercardBaseRequest.execute(restTemplate, properties, requestResponseDTO, "myOrderId323214343");
// PS: the value "myOrderId323214343" is generated by you and you need tu used
// it to identify the orders in the Mastercard MPGS Panel

REFUND METHOD

...
...

MastercardRequestDTO dto = MastercardRequestDTO.builder()
    .apiOperation(MastercardAPIOperationType.REFUND)
    .amount(new BigDecimal("5000.00"))
    .currency("EUR")
    .build();

MastercardRequestResponseDTO requestResponseDTO = MastercardObjectRequestFactory.build(dto);

MastercardResponse response = MastercardBaseRequest.execute(restTemplate, properties, requestResponseDTO, "myOrderId323214343");
// PS: the value "myOrderId323214343" it is the same that you previously used in the pay method and that you wish to refund now

Development setup

mvn clean install

Meta

Marco Blos – marcoblos1234@gmail.com

Distributed under the Apache 2.0 license. See LICENSE for more information.

https://github.com/marcoblos/mastercard-mpgs-sdk

Contributing

  1. Fork it (https://github.com/marcoblos/mastercard-mpgs-sdk/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request