From 7a084e37a046d9b889785adc7075605a36bc130d Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Wed, 1 Nov 2023 16:40:28 +0000 Subject: [PATCH 1/7] teya payment happy path --- pom.xml | 2 +- .../pos/config/JPanelConfigPayment.java | 7 ++ .../pos/payment/PaymentGatewayFac.java | 2 + .../pos/payment/PaymentGatewayTeya.java | 80 +++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java diff --git a/pom.xml b/pom.xml index b34f638..e24bae6 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ com.unicenta unicenta-plugins - 1.1 + 1.2-SNAPSHOT com.gluonhq diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java index 0e7391c..dfd6084 100644 --- a/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java @@ -52,6 +52,7 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf initPayments("Not defined", new ConfigPaymentPanelEmpty()); initPayments("external", new ConfigPaymentPanelEmpty()); initPayments("PaymentSense", new ConfigPaymentPanelEmpty()); + initPayments("Teya", new ConfigPaymentPanelEmpty()); // Lector de tarjetas. jcboCardReader.addItem("Not defined"); @@ -277,6 +278,12 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf emvConfigPanel.setVisible(Boolean.TRUE); jcboCardReader.setSelectedItem("EMV"); jcboCardReader.setEnabled(Boolean.FALSE); + + } + else if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("Teya")) { + emvConfigPanel.setVisible(Boolean.FALSE); + jcboCardReader.setSelectedItem("EMV"); + jcboCardReader.setEnabled(Boolean.FALSE); } else { emvConfigPanel.setVisible(Boolean.FALSE); diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java index 0ef0c94..c0a8f55 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java @@ -39,6 +39,8 @@ public class PaymentGatewayFac { return new PaymentGatewayExt(); case "PaymentSense": return new PaymentGatewayPaymentSense(); + case "Teya": + return new PaymentGatewayTeya(); default: return null; } diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java new file mode 100644 index 0000000..b2f1c1a --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java @@ -0,0 +1,80 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// uniCenta oPOS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with uniCenta oPOS. If not, see . + +package com.unicenta.pos.payment; + +import com.unicenta.plugins.Application; +import com.unicenta.plugins.common.AppContext; +import com.unicenta.pos.util.RoundUtils; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; + +@Slf4j +public class PaymentGatewayTeya implements PaymentGateway { + + /** Creates a new instance of PaymentGatewayExt */ + public PaymentGatewayTeya() { + } + + Window getPaymentWindow() { + for (Window window : Window.getWindows()) { + if (window.isActive()) { + return window; + } + } + return null; + } + + /** + * + * @param payinfo + */ + @Override + public void execute(PaymentInfoMagcard payinfo) { + + int timer = 0; + int timeout = 180; + + double roundedValue = RoundUtils.round(payinfo.getTotal()); + + new Application().teyaTransaction(roundedValue, getPaymentWindow()); + + while (!AppContext.getTeyaSuccessfulPayment()) { + try { + log.info("uniCenta-oPos: waiting for payment to complete ...."); + Thread.sleep(1000); + timer += 1; + if (timer > timeout) break; + } catch (InterruptedException e) { + log.error(e.getMessage()); + } + } + + payinfo.setCardName("Teya"); + payinfo.setVerification("Chip and Pin"); + payinfo.setChipAndPin(true); + payinfo.paymentOK( + "Teya", + "Teya", + "Teya" + ); + + } +} From 90114551ff095e85b54397ae3924cc8244c3636b Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Wed, 1 Nov 2023 17:21:22 +0000 Subject: [PATCH 2/7] fixing window binding --- .../com/unicenta/pos/payment/PaymentGatewayPaymentSense.java | 2 +- src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java index 055a4bd..5926253 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java @@ -36,7 +36,7 @@ public class PaymentGatewayPaymentSense implements PaymentGateway { Window getPaymentWindow() { for (Window window : Window.getWindows()) { - if (window.isActive()) { + if (window instanceof JPaymentSelectReceipt) { return window; } } diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java index b2f1c1a..4d51f8c 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java @@ -35,7 +35,7 @@ public class PaymentGatewayTeya implements PaymentGateway { Window getPaymentWindow() { for (Window window : Window.getWindows()) { - if (window.isActive()) { + if (window instanceof JPaymentSelectReceipt) { return window; } } From 5b81989f2f309d23fddba83cb9e5c57b6aae4bd6 Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Fri, 3 Nov 2023 12:43:41 +0000 Subject: [PATCH 3/7] teya integration / payment --- .../com/unicenta/pos/payment/PaymentGatewayTeya.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java index 4d51f8c..bfb75c1 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java @@ -54,9 +54,9 @@ public class PaymentGatewayTeya implements PaymentGateway { double roundedValue = RoundUtils.round(payinfo.getTotal()); - new Application().teyaTransaction(roundedValue, getPaymentWindow()); + new Application().teyaTransaction(roundedValue, getPaymentWindow(), payinfo.m_sTransactionID); - while (!AppContext.getTeyaSuccessfulPayment()) { + while (AppContext.getTeyaPaymentResult() == null) { try { log.info("uniCenta-oPos: waiting for payment to complete ...."); Thread.sleep(1000); @@ -71,9 +71,9 @@ public class PaymentGatewayTeya implements PaymentGateway { payinfo.setVerification("Chip and Pin"); payinfo.setChipAndPin(true); payinfo.paymentOK( - "Teya", - "Teya", - "Teya" + AppContext.getTeyaPaymentResult().getReferenceId(), + AppContext.getTeyaPaymentResult().getGatewayPaymentId(), + AppContext.getTeyaPaymentResult().getStatus() ); } From b7bef162df64c06541c5c6072413ca8273ec3117 Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Wed, 8 Nov 2023 19:21:17 +0000 Subject: [PATCH 4/7] teya integration / payment --- .../payment/PaymentGatewayPaymentSense.java | 2 +- .../pos/payment/PaymentGatewayTeya.java | 49 +++++++++++++------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java index 5926253..055a4bd 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java @@ -36,7 +36,7 @@ public class PaymentGatewayPaymentSense implements PaymentGateway { Window getPaymentWindow() { for (Window window : Window.getWindows()) { - if (window instanceof JPaymentSelectReceipt) { + if (window.isActive()) { return window; } } diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java index bfb75c1..91b78f8 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java @@ -25,6 +25,7 @@ import com.unicenta.pos.util.RoundUtils; import lombok.extern.slf4j.Slf4j; import java.awt.*; +import java.util.ArrayList; @Slf4j public class PaymentGatewayTeya implements PaymentGateway { @@ -33,13 +34,26 @@ public class PaymentGatewayTeya implements PaymentGateway { public PaymentGatewayTeya() { } - Window getPaymentWindow() { - for (Window window : Window.getWindows()) { - if (window instanceof JPaymentSelectReceipt) { - return window; + Window getPaymentWindow(double amount) { + if (amount > 0) { + ArrayList paymentWindows = new ArrayList<>(); + for (Window window : Window.getWindows()) { + if (window instanceof JPaymentSelectReceipt) { + paymentWindows.add((JPaymentSelectReceipt) window); + } } + return paymentWindows.get(paymentWindows.size()-1); } - return null; + else { + ArrayList paymentWindows = new ArrayList<>(); + for (Window window : Window.getWindows()) { + if (window instanceof JPaymentSelectRefund) { + paymentWindows.add((JPaymentSelectRefund) window); + } + } + return paymentWindows.get(paymentWindows.size()-1); + } + } /** @@ -54,7 +68,7 @@ public class PaymentGatewayTeya implements PaymentGateway { double roundedValue = RoundUtils.round(payinfo.getTotal()); - new Application().teyaTransaction(roundedValue, getPaymentWindow(), payinfo.m_sTransactionID); + new Application().teyaTransaction(roundedValue, getPaymentWindow(roundedValue), payinfo.getTransactionID()); while (AppContext.getTeyaPaymentResult() == null) { try { @@ -67,14 +81,21 @@ public class PaymentGatewayTeya implements PaymentGateway { } } - payinfo.setCardName("Teya"); - payinfo.setVerification("Chip and Pin"); - payinfo.setChipAndPin(true); - payinfo.paymentOK( - AppContext.getTeyaPaymentResult().getReferenceId(), - AppContext.getTeyaPaymentResult().getGatewayPaymentId(), - AppContext.getTeyaPaymentResult().getStatus() - ); + if (AppContext.getTeyaPaymentResult().getStatus().equals("SUCCESSFUL")) { + payinfo.setCardName("Teya"); + payinfo.setVerification("Chip and Pin"); + payinfo.setChipAndPin(true); + payinfo.paymentOK( + roundedValue > 0 ? AppContext.getTeyaPaymentResult().getReferenceId() : "", + roundedValue > 0 ? AppContext.getTeyaPaymentResult().getGatewayPaymentId() : "", + AppContext.getTeyaPaymentResult().getStatus() + ); + } + else { + payinfo.paymentError("Transaction Error! Please try again", AppContext.getTeyaPaymentResult().getStatus()); + } + + } } From e9fff7f4a366d0dbebb9c33140d567cf1962dbec Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Wed, 8 Nov 2023 19:22:02 +0000 Subject: [PATCH 5/7] teya integration / payment --- src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java index 91b78f8..baafb12 100644 --- a/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayTeya.java @@ -64,7 +64,7 @@ public class PaymentGatewayTeya implements PaymentGateway { public void execute(PaymentInfoMagcard payinfo) { int timer = 0; - int timeout = 180; + int timeout = 150; double roundedValue = RoundUtils.round(payinfo.getTotal()); From d1fc482eb50c43c2cb8a78041f029dfaeecb34f1 Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Fri, 10 Nov 2023 17:54:59 +0000 Subject: [PATCH 6/7] teya finish up --- pom.xml | 2 +- src/main/java/com/unicenta/pos/forms/JRootKiosk.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index e24bae6..59d720c 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ com.unicenta unicenta-plugins - 1.2-SNAPSHOT + 1.2 com.gluonhq diff --git a/src/main/java/com/unicenta/pos/forms/JRootKiosk.java b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java index 433e262..2d8fdf6 100644 --- a/src/main/java/com/unicenta/pos/forms/JRootKiosk.java +++ b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java @@ -86,12 +86,6 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(0, 0, d.width, d.height); -/* - * 4 Sep 17 JG - * 2 Dec 17 - Mod' Thanks Hayk Sokolov! - * Change here for Linux/Ubuntu full screen - * Thanks to Hans Lengerke for solution -*/ String osName = System.getProperty("os.name").toLowerCase(); boolean isWindows = osName.startsWith("windows"); From 817168fc88ee97ecaa2ba2948c04232a04fa8f37 Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Fri, 10 Nov 2023 18:00:22 +0000 Subject: [PATCH 7/7] merge conflict --- .../com/unicenta/pos/forms/JRootKiosk.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/unicenta/pos/forms/JRootKiosk.java b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java index 2d8fdf6..dac2d37 100644 --- a/src/main/java/com/unicenta/pos/forms/JRootKiosk.java +++ b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java @@ -58,13 +58,25 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage { initComponents(); } + public JRootApp getRootapp() { + return m_rootapp; + } + + public void setRootapp(JRootApp m_rootapp) { + this.m_rootapp = m_rootapp; + } + /** * * @param props * @throws java.io.IOException */ public void initFrame(AppProperties props) throws IOException { - + + String osName = System.getProperty("os.name").toLowerCase(); + boolean isWindows = osName.startsWith("windows"); + boolean isMac = osName.startsWith("mac"); + m_OS = new OSValidator(); m_props = props; @@ -84,15 +96,16 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage { setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - setBounds(0, 0, d.width, d.height); + if (isMac) { + setBounds(0, 25, d.width, d.height - 25); + } + else { + setBounds(0, 0, d.width, d.height); + } - String osName = System.getProperty("os.name").toLowerCase(); - boolean isWindows = osName.startsWith("windows"); + GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - GraphicsDevice device = GraphicsEnvironment - .getLocalGraphicsEnvironment().getDefaultScreenDevice(); - - if (device.isFullScreenSupported() && !isWindows) { + if (device.isFullScreenSupported() && !isWindows && !isMac) { setResizable(true); addFocusListener(new FocusListener() { @@ -115,7 +128,8 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage { "Connection", JOptionPane.INFORMATION_MESSAGE); new JFrmConfig(props).setVisible(true); // Show the configuration window. - } + } + setRootapp(m_rootapp); } @Override