UOCL-310: payment happy path
This commit is contained in:
@@ -11,3 +11,4 @@ docker.sock
|
|||||||
.factorypath
|
.factorypath
|
||||||
.settings/
|
.settings/
|
||||||
.project
|
.project
|
||||||
|
AGENTS.md
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.unicenta</groupId>
|
<groupId>com.unicenta</groupId>
|
||||||
<artifactId>unicentaopos</artifactId>
|
<artifactId>unicentaopos</artifactId>
|
||||||
<version>5.4.0</version>
|
<version>5.4.0</version>
|
||||||
@@ -116,7 +115,6 @@
|
|||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>3.17</version>
|
<version>3.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
@@ -181,7 +179,6 @@
|
|||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.swinglabs.swingx</groupId>
|
<groupId>org.swinglabs.swingx</groupId>
|
||||||
@@ -255,11 +252,11 @@
|
|||||||
<artifactId>derbytools</artifactId>
|
<artifactId>derbytools</artifactId>
|
||||||
<version>${derby.version}</version>
|
<version>${derby.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>org.apache.derby</groupId>-->
|
<!-- <groupId>org.apache.derby</groupId>-->
|
||||||
<!-- <artifactId>derbyshared</artifactId>-->
|
<!-- <artifactId>derbyshared</artifactId>-->
|
||||||
<!-- <version>${derby.version}</version>-->
|
<!-- <version>${derby.version}</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xml-apis</groupId>
|
<groupId>xml-apis</groupId>
|
||||||
<artifactId>xml-apis</artifactId>
|
<artifactId>xml-apis</artifactId>
|
||||||
@@ -293,7 +290,6 @@
|
|||||||
<artifactId>DynamicJasper-core-fonts</artifactId>
|
<artifactId>DynamicJasper-core-fonts</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||||
<artifactId>ecj</artifactId>
|
<artifactId>ecj</artifactId>
|
||||||
@@ -361,7 +357,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.unicenta</groupId>
|
<groupId>com.unicenta</groupId>
|
||||||
<artifactId>unicenta-plugins</artifactId>
|
<artifactId>unicenta-plugins</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gluonhq</groupId>
|
<groupId>com.gluonhq</groupId>
|
||||||
@@ -450,7 +446,6 @@
|
|||||||
<version>4.2.0</version>
|
<version>4.2.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
|
|||||||
initPayments("external", new ConfigPaymentPanelEmpty());
|
initPayments("external", new ConfigPaymentPanelEmpty());
|
||||||
initPayments("PaymentSense", new ConfigPaymentPanelEmpty());
|
initPayments("PaymentSense", new ConfigPaymentPanelEmpty());
|
||||||
initPayments("Teya", new ConfigPaymentPanelEmpty());
|
initPayments("Teya", new ConfigPaymentPanelEmpty());
|
||||||
|
initPayments("MediaPayments", new ConfigPaymentPanelEmpty());
|
||||||
|
|
||||||
// Lector de tarjetas.
|
// Lector de tarjetas.
|
||||||
jcboCardReader.addItem("Not defined");
|
jcboCardReader.addItem("Not defined");
|
||||||
@@ -91,9 +92,17 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
|
|||||||
|
|
||||||
jcboCardReader.setSelectedItem(config.getProperty("payment.magcardreader"));
|
jcboCardReader.setSelectedItem(config.getProperty("payment.magcardreader"));
|
||||||
jcboPaymentGateway.setSelectedItem(config.getProperty("payment.gateway"));
|
jcboPaymentGateway.setSelectedItem(config.getProperty("payment.gateway"));
|
||||||
|
|
||||||
|
String gateway = comboValue(jcboPaymentGateway.getSelectedItem());
|
||||||
|
if ("MediaPayments".equals(gateway)) {
|
||||||
|
urlValue.setText(config.getProperty("media-payments.pdq"));
|
||||||
|
deviceIdValue.setText(config.getProperty("media-payments.api-key"));
|
||||||
|
securityKeyValue.setText(config.getProperty("media-payments.secret"));
|
||||||
|
} else {
|
||||||
urlValue.setText(config.getProperty("payment.URL"));
|
urlValue.setText(config.getProperty("payment.URL"));
|
||||||
deviceIdValue.setText(config.getProperty("payment.device-id"));
|
deviceIdValue.setText(config.getProperty("payment.device-id"));
|
||||||
securityKeyValue.setText(config.getProperty("payment.security-key"));
|
securityKeyValue.setText(config.getProperty("payment.security-key"));
|
||||||
|
}
|
||||||
paymentConfiguration.loadProperties(config);
|
paymentConfiguration.loadProperties(config);
|
||||||
dirty.setDirty(false);
|
dirty.setDirty(false);
|
||||||
}
|
}
|
||||||
@@ -107,9 +116,17 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
|
|||||||
|
|
||||||
config.setProperty("payment.magcardreader", comboValue(jcboCardReader.getSelectedItem()));
|
config.setProperty("payment.magcardreader", comboValue(jcboCardReader.getSelectedItem()));
|
||||||
config.setProperty("payment.gateway", comboValue(jcboPaymentGateway.getSelectedItem()));
|
config.setProperty("payment.gateway", comboValue(jcboPaymentGateway.getSelectedItem()));
|
||||||
|
|
||||||
|
String gateway = comboValue(jcboPaymentGateway.getSelectedItem());
|
||||||
|
if ("MediaPayments".equals(gateway)) {
|
||||||
|
config.setProperty("media-payments.pdq", urlValue.getText());
|
||||||
|
config.setProperty("media-payments.api-key", deviceIdValue.getText());
|
||||||
|
config.setProperty("media-payments.secret", securityKeyValue.getText());
|
||||||
|
} else {
|
||||||
config.setProperty("payment.URL", urlValue.getText());
|
config.setProperty("payment.URL", urlValue.getText());
|
||||||
config.setProperty("payment.device-id", deviceIdValue.getText());
|
config.setProperty("payment.device-id", deviceIdValue.getText());
|
||||||
config.setProperty("payment.security-key", securityKeyValue.getText());
|
config.setProperty("payment.security-key", securityKeyValue.getText());
|
||||||
|
}
|
||||||
paymentConfiguration.saveProperties(config);
|
paymentConfiguration.saveProperties(config);
|
||||||
dirty.setDirty(false);
|
dirty.setDirty(false);
|
||||||
}
|
}
|
||||||
@@ -275,6 +292,9 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
|
|||||||
paymentConfiguration = paymentsName.get(comboValue(jcboPaymentGateway.getSelectedItem()));
|
paymentConfiguration = paymentsName.get(comboValue(jcboPaymentGateway.getSelectedItem()));
|
||||||
|
|
||||||
if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("PaymentSense")) {
|
if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("PaymentSense")) {
|
||||||
|
urlLabel.setText("URL");
|
||||||
|
deviceIdLabel.setText("Device ID");
|
||||||
|
securityKeyLabel.setText("Security Key");
|
||||||
emvConfigPanel.setVisible(Boolean.TRUE);
|
emvConfigPanel.setVisible(Boolean.TRUE);
|
||||||
jcboCardReader.setSelectedItem("EMV");
|
jcboCardReader.setSelectedItem("EMV");
|
||||||
jcboCardReader.setEnabled(Boolean.FALSE);
|
jcboCardReader.setEnabled(Boolean.FALSE);
|
||||||
@@ -285,7 +305,18 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
|
|||||||
jcboCardReader.setSelectedItem("EMV");
|
jcboCardReader.setSelectedItem("EMV");
|
||||||
jcboCardReader.setEnabled(Boolean.FALSE);
|
jcboCardReader.setEnabled(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
else if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("MediaPayments")) {
|
||||||
|
urlLabel.setText("Terminal ID");
|
||||||
|
deviceIdLabel.setText("API Key");
|
||||||
|
securityKeyLabel.setText("Security Key");
|
||||||
|
emvConfigPanel.setVisible(Boolean.TRUE);
|
||||||
|
jcboCardReader.setSelectedItem("EMV");
|
||||||
|
jcboCardReader.setEnabled(Boolean.FALSE);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
urlLabel.setText("URL");
|
||||||
|
deviceIdLabel.setText("Device ID");
|
||||||
|
securityKeyLabel.setText("Security Key");
|
||||||
emvConfigPanel.setVisible(Boolean.FALSE);
|
emvConfigPanel.setVisible(Boolean.FALSE);
|
||||||
jcboCardReader.setEnabled(Boolean.TRUE);
|
jcboCardReader.setEnabled(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public class PaymentGatewayFac {
|
|||||||
return new PaymentGatewayPaymentSense();
|
return new PaymentGatewayPaymentSense();
|
||||||
case "Teya":
|
case "Teya":
|
||||||
return new PaymentGatewayTeya();
|
return new PaymentGatewayTeya();
|
||||||
|
case "MediaPayments":
|
||||||
|
return new PaymentGatewayMediaPayments();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class PaymentGatewayMediaPayments implements PaymentGateway {
|
||||||
|
|
||||||
|
public PaymentGatewayMediaPayments() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Window getPaymentWindow(double amount) {
|
||||||
|
if (amount > 0) {
|
||||||
|
ArrayList<JPaymentSelectReceipt> paymentWindows = new ArrayList<>();
|
||||||
|
for (Window window : Window.getWindows()) {
|
||||||
|
if (window instanceof JPaymentSelectReceipt) {
|
||||||
|
paymentWindows.add((JPaymentSelectReceipt) window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paymentWindows.get(paymentWindows.size()-1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ArrayList<JPaymentSelectRefund> paymentWindows = new ArrayList<>();
|
||||||
|
for (Window window : Window.getWindows()) {
|
||||||
|
if (window instanceof JPaymentSelectRefund) {
|
||||||
|
paymentWindows.add((JPaymentSelectRefund) window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paymentWindows.get(paymentWindows.size()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(PaymentInfoMagcard payinfo) {
|
||||||
|
|
||||||
|
int timer = 0;
|
||||||
|
int timeout = 180;
|
||||||
|
|
||||||
|
double roundedValue = RoundUtils.round(payinfo.getTotal());
|
||||||
|
new Application().mediaPaymentsTransaction(roundedValue, getPaymentWindow(roundedValue));
|
||||||
|
|
||||||
|
while (AppContext.getIsProcessing() == null || AppContext.getIsProcessing()) {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppContext.getMediaPaymentsPaymentResult() == null) {
|
||||||
|
payinfo.paymentError("Transaction Error! Please try again", "No Response");
|
||||||
|
}
|
||||||
|
else if ("APPROVED".equals(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getStatus())) {
|
||||||
|
payinfo.setCardName(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getCard().getType());
|
||||||
|
payinfo.setVerification(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getVerificationMethod());
|
||||||
|
payinfo.setChipAndPin(true);
|
||||||
|
payinfo.paymentOK(
|
||||||
|
AppContext.getMediaPaymentsPaymentResult().getAdditionalInformation().getRequestId(),
|
||||||
|
AppContext.getMediaPaymentsPaymentResult().getTransactionDetails().getId(),
|
||||||
|
AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getStatus()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String errorMsg = AppContext.getMediaPaymentsPaymentResult().getErrorMessage();
|
||||||
|
if (errorMsg == null) {
|
||||||
|
errorMsg = AppContext.getMediaPaymentsPaymentResult().getMessage();
|
||||||
|
}
|
||||||
|
payinfo.paymentError("Transaction Error! Please try again", errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user