-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce1e026
commit 9badbaa
Showing
14 changed files
with
537 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
in-person-payments-example/src/main/java/com/adyen/ipp/service/PosAbortService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.adyen.ipp.service; | ||
|
||
import com.adyen.ipp.util.IdUtility; | ||
import com.adyen.service.exception.ApiException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import com.adyen.model.nexo.*; | ||
import com.adyen.model.terminal.*; | ||
|
||
import java.io.IOException; | ||
|
||
@Service | ||
public class PosAbortService { | ||
@Autowired | ||
private TerminalCloudApiService terminalCloudAPIService; | ||
|
||
public TerminalAPIResponse sendAbortRequestAsync(String serviceId, String poiId, String saleId) throws IOException, ApiException { | ||
TerminalAPIRequest request = getAbortRequest(serviceId, poiId, saleId); | ||
return terminalCloudAPIService.getTerminalCloudApi().sync(request); | ||
} | ||
|
||
private TerminalAPIRequest getAbortRequest(String serviceId, String poiId, String saleId) { | ||
var messageHeader = new MessageHeader(); | ||
messageHeader.setMessageCategory(MessageCategoryType.ABORT); | ||
messageHeader.setMessageClass(MessageClassType.SERVICE); | ||
messageHeader.setMessageType(MessageType.REQUEST); | ||
messageHeader.setPOIID(poiId); | ||
messageHeader.setSaleID(saleId); | ||
messageHeader.setServiceID(IdUtility.getRandomAlphanumericId(10)); | ||
|
||
var messageReference = new MessageReference(); | ||
messageReference.setMessageCategory(MessageCategoryType.PAYMENT); | ||
messageReference.setServiceID(serviceId); | ||
messageReference.setPOIID(poiId); | ||
messageReference.setSaleID(saleId); | ||
|
||
var abortRequest = new AbortRequest(); | ||
abortRequest.setAbortReason("MerchantAbort"); | ||
abortRequest.setMessageReference(messageReference); | ||
|
||
var saleToPOIRequest = new SaleToPOIRequest(); | ||
saleToPOIRequest.setMessageHeader(messageHeader); | ||
saleToPOIRequest.setAbortRequest(abortRequest); | ||
|
||
var terminalAPIRequest = new TerminalAPIRequest(); | ||
terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest); | ||
|
||
return terminalAPIRequest; | ||
} | ||
} |
Oops, something went wrong.