3

https://developer.mastercard.com/page/java-sdk-guide#project-setup

I am referring this document but can not understand how to call API and configure SDK.

Update 2:

dependency used for payment gateway

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

getting started With the below code in the simple main class.

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");

Referance: github link

Everything works fine but the API response are all null. so we can determine that something wants wrong and also we got success response and no error logs.

karan shah
  • 304
  • 1
  • 3
  • 21
  • 1
    It would be really great if you can demonstrate what have you tried so far and be specific. This is too broad to answer. Also, this code sample from GitHub can help - https://github.com/Mastercard-Gateway/gateway-java-sample-code – isank-a Nov 19 '19 at 08:14
  • @Isank I have tried this code too and follow all the instructions provided in this git repository. but after running the code it shows me the gson error every time. – karan shah Nov 19 '19 at 11:45
  • One more think i am using the api key and password for authorization of merchant account. – karan shah Nov 19 '19 at 11:47
  • It will be great if you suggest me the full configuration for payment gateway or related things. – karan shah Nov 19 '19 at 11:48
  • We really need more information. What instructions have you followed (list them in the question)? What gson error are you getting (put it in the question) ? – matt freake Nov 21 '19 at 11:02
  • That dependency you are using is not an official Mastercard one. Maybe it's fine, maybe it's not, but personally I would use the official dependency as documented in the Mastercard documentation. – matt freake Nov 22 '19 at 15:51
  • @mattfreake yes you are right. but as you say the official dependency I did not find any appropriate repository for MPGS so after some research, I found this dependency for API calls and response handling, One more thing I want to tell you that I am trying to implement the direct payment method of Mastercard. So any solution to this will be appreciated. – karan shah Nov 25 '19 at 04:08
  • I see what you mean - I cannot see what is the correct dependency for direct payments. I have only used MPGS with directly contacting the their API from Java code (not using an SDK). I would contact Mastercard support directly, if I were you – matt freake Nov 25 '19 at 12:30
  • @mattfreake so what would you recommend.? are you trying to say the direct call of master card API by rest client.? – karan shah Nov 26 '19 at 05:23
  • If you want to use the SDK, I would contact Mastercard to find out where to get the SDK – matt freake Nov 26 '19 at 11:32
  • @mattfreake okay let me contact to the master card support for the current situation. – karan shah Nov 27 '19 at 04:33
  • Hi, hope all is well. I am currently using firebase as my backend and im starting the integration process with MPGS, will i be able to accomplish it with firebase or will i be to have a nodeJS express server to do that for me? – kd12345 Mar 28 '23 at 13:02

0 Answers0