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() { Window getPaymentWindow() {
for (Window window : Window.getWindows()) { for (Window window : Window.getWindows()) {
if (window instanceof JPaymentSelectReceipt) { if (window.isActive()) {
return window; return window;
} }
} }
@@ -25,6 +25,7 @@ import com.unicenta.pos.util.RoundUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.awt.*; import java.awt.*;
import java.util.ArrayList;
@Slf4j @Slf4j
public class PaymentGatewayTeya implements PaymentGateway { public class PaymentGatewayTeya implements PaymentGateway {
@@ -33,13 +34,26 @@ public class PaymentGatewayTeya implements PaymentGateway {
public PaymentGatewayTeya() { public PaymentGatewayTeya() {
} }
Window getPaymentWindow() { Window getPaymentWindow(double amount) {
for (Window window : Window.getWindows()) { if (amount > 0) {
if (window instanceof JPaymentSelectReceipt) { ArrayList<JPaymentSelectReceipt> paymentWindows = new ArrayList<>();
return window; 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()); 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) { while (AppContext.getTeyaPaymentResult() == null) {
try { try {
@@ -67,14 +81,21 @@ public class PaymentGatewayTeya implements PaymentGateway {
} }
} }
payinfo.setCardName("Teya"); if (AppContext.getTeyaPaymentResult().getStatus().equals("SUCCESSFUL")) {
payinfo.setVerification("Chip and Pin"); payinfo.setCardName("Teya");
payinfo.setChipAndPin(true); payinfo.setVerification("Chip and Pin");
payinfo.paymentOK( payinfo.setChipAndPin(true);
AppContext.getTeyaPaymentResult().getReferenceId(), payinfo.paymentOK(
AppContext.getTeyaPaymentResult().getGatewayPaymentId(), roundedValue > 0 ? AppContext.getTeyaPaymentResult().getReferenceId() : "",
AppContext.getTeyaPaymentResult().getStatus() roundedValue > 0 ? AppContext.getTeyaPaymentResult().getGatewayPaymentId() : "",
); AppContext.getTeyaPaymentResult().getStatus()
);
}
else {
payinfo.paymentError("Transaction Error! Please try again", AppContext.getTeyaPaymentResult().getStatus());
}
} }
} }