on ‎2020 Jan 22 7:44 PM
Hello all,
I would like to know in what way, I can make validations when payment items are added to a receipt.
For example:
When I add a payment method, such as a credit card. I would like to make a validation and if the validation fails, prevent the payment method (credit card) from being added to the receipt.
anyone knows how to do this?
Thanks in advance.
Jose.
Request clarification before answering.
Hi joerg.ceo & josehrmatos ,
you can check out the method addOrUpdatePaymentItem in the ReceiptPosService.class.
You plugin method should look something like this:
@PluginAt(pluginClass = ReceiptPosService.class, method = "addOrUpdatePaymentItem", where = POSITION.BEFORE)
public void addSalesItem(Object proxy, Object[] args, StackTraceElement[] ste) throws BreakExecutionException
The method is overloaded, so your method should be called multiple times with a different count of arguments in the Object[] args array.
Check for count 6.
You'll get receipt, the type, the amount, the tip, the currencyCode and a internal helper class.
If these informations are enough to do your validation you may throw a BreakExecutionException if your validation fails, so CCO does not add the paymentItem...
If you need the paymentItem added to the receipt to do your validation, then you should use the POSITION.AFTER, then look for the last added paymentItem, do your validation and remove the paymentItem if your validation fails.
hth
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert Zieschang!
I hope you are doing great, I have tried to test the code lines but I cannot get the event to be triggered in the backend when debugging, I have tried to do it the next ways:
1.- Just trying to catch the event and printing a message in the console
2.- Getting the argument in position 6 and trying to get its data
3.- Getting the argument in position 0 for the Receipt data and 1 for the PaymentItam data
@PluginAt(pluginClass = ReceiptPosService.class, method = "addOrUpdatePaymentItem", where = POSITION.BEFORE)
public void addSalesItem(Object proxy, Object[] args, StackTraceElement[] ste) throws BreakExecutionException
{
System.out.println("Add Payment Item Event Triggered");
}
@PluginAt(pluginClass = ReceiptPosService.class, method = "addOrUpdatePaymentItem", where = POSITION.BEFORE)
public void addSalesItem(Object proxy, Object[] args, StackTraceElement[] ste) throws BreakExecutionException
{
PaymentItemEntity paymentItem = (PaymentItemEntity) args[6];
if (!paymentItem.getKey().isEmpty())
{
String PaymentKey = paymentItem.getKey();
String PaymentAmount = paymentItem.getBusinessTransactionAmount().toString();
}
System.out.println("Add Payment Item Event Triggered");
}
@PluginAt(pluginClass = ReceiptPosService.class, method = "addOrUpdatePaymentItem", where = POSITION.BEFORE)
public void addSalesItem(Object proxy, Object[] args, StackTraceElement[] ste) throws BreakExecutionException
{
ReceiptEntity receipt = (ReceiptEntity)args[0];
PaymentItemEntity PaymentItem = (PaymentItemEntity)args[1];
if(PaymentItem.getKey() != null)
{
System.out.println(PaymentItem.getKey().toString());
}
System.out.println("Entro OK");
}
I do think this event is triggered once the button "OK" is clicked (which performs adding payment item action), right?

I would really appreciate it if you could tell me what step I am missing or if the method has been changed or deprecated.
Thanks in advace for all and best regards Robert!
rzieschang Can you help here? What we need is the correct ExitPoint to intercept and validate individual payment items added to the receipt...!? Should be easy enough... 🙂
Thanks!
Joerg.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.