-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add different Transaction Listener's for different Cryptocurrency #765
Comments
hi, in your listener you can return different results based on the crypto currency of the current transaction, see |
Hello @pvyhnal-generalbytes, |
Hi, try using |
Thank you @pvyhnal-generalbytes, I tried this but this always throws NullPointerException for `private final Map<String,Double> atmPerDayLimitsInEUR = new HashMap<>(); public void fillLimitsHashmap(){
@OverRide
By checking the code u can find that we need the Thank You. |
Would this value be useful for you instead?
|
Thank you, @pvyhnal-generalbytes, for your valuable response. However, the solution you provided only allows us to check AML/KYC limits per user. Our main requirement is to set limits per ATM per day for a specific cryptocurrency. Here's an example scenario to illustrate our concern: Let's say we store all transaction amounts per day, and we check that the amount used is 950 Euros, while our set limit for that ATM is 1000 Euros. If a user creates a transaction, they will be allowed to insert notes because that ATMs limit for that day is 950 Euros, which is below our set limit. In this case, the user could potentially insert 200 Euros and buy the cryptocurrency for that amount, which violates our condition. We need to find a way to restrict this behavior. If we implement the restriction in com.generalbytes.batm.server.extensions.ExtensionContext#isTransactionApproved, the ATM will take the banknote, the transaction will fail, and the ATM will not return the banknote to the user. Could you please assist me in finding a solution to this problem? Thank you. |
Hello @pvyhnal-generalbytes, Do you have any updates on this so I can close this issue ?? Thank You |
I added Transaction Listeners for some Crypto Currencies with reference to the Transaction extension.
But I got the issue that if I restrict any one currencies listener that restriction will apply to all other currencies in which transaction listener is added.
So how i can create different transaction listeners for every different cryptocurrency?
This is how i implemented the transaction Listener:-
@OverRide
public void init(IExtensionContext ctx) {
super.init(ctx);
this.context_1 = ctx;
}
@OverRide
public boolean isTransactionPreparationApproved(ITransactionPreparation preparation) {
return true; //approve all transactions
}
@OverRide
public boolean isTransactionApproved(ITransactionRequest transactionRequest) {
if(Objects.equals(transactionRequest.getCryptoAmount(), new BigDecimal(1))) {
return true;
}
else {
return false;
}
}
@OverRide
public OutputQueueInsertConfig overrideOutputQueueInsertConfig(ITransactionQueueRequest transactionQueueRequest, OutputQueueInsertConfig outputQueueInsertConfig) {
return null;
}
@OverRide
public Map<String, String> onTransactionCreated(ITransactionDetails transactionDetails) {
String terminalSerialNumber = transactionDetails.getTerminalSerialNumber();
Long previousValue = ticketCounters.get(terminalSerialNumber);
Map<String, String> result = new HashMap<>();
Long value = (previousValue == null) ? 1 : (previousValue + 1);
ticketCounters.put(terminalSerialNumber, value);
result.put("ticket.counter", "" + value);
log.info("Ticket Counter"+ value);
result.put("ticket.previous.counter", ( (previousValue == null) ? "N/A" : "" + previousValue ) ); //result will be stored into database, linked to transdaction record and later be available in ticket template under key ticket.previous.counter
if(transactionDetails.getStatus() == 1){
context_1.addTransactionListener(this);
log.info("The mail address is:- "+transactionDetails.getCryptoAddress());
try{
log.info("Sending the mail");
EmailProviderForVoucher.sendEmailForBuyVoucher(context_1,transactionDetails.getCryptoAddress(),transactionDetails,locale);
}catch(Exception e){
e.printStackTrace();
}
}
return result;
}
@OverRide
public Map<String, String> onTransactionUpdated(ITransactionDetails transactionDetails) {
Map<String, String> result = new HashMap<>();
result.put("last.updated.at", "" + System.currentTimeMillis());
log.info("The mail address is:- "+transactionDetails.getCryptoAddress());
return result;
}
@OverRide
public void receiptSent(IReceiptDetails receiptDetails) {
log.info("Extension - receipt sent from {} - phone: {}, email: {}", receiptDetails.getTerminalSerialNumber(), receiptDetails.getCellphone(), receiptDetails.getEmail());
}
The text was updated successfully, but these errors were encountered: