teya integration / payment

This commit is contained in:
2023-11-08 19:21:17 +00:00
parent 5b81989f2f
commit b7bef162df
2 changed files with 36 additions and 15 deletions
@@ -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;
}
}
@@ -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<JPaymentSelectReceipt> 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<JPaymentSelectRefund> 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());
}
}
}