UOCL-310: linked refunds working
This commit is contained in:
@@ -30,69 +30,68 @@ import java.util.ArrayList;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class PaymentGatewayMediaPayments implements PaymentGateway {
|
public class PaymentGatewayMediaPayments implements PaymentGateway {
|
||||||
|
|
||||||
public PaymentGatewayMediaPayments() {
|
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),
|
||||||
|
payinfo.getTransactionID());
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Window getPaymentWindow(double amount) {
|
if (AppContext.getMediaPaymentsPaymentResult() == null) {
|
||||||
if (amount > 0) {
|
payinfo.paymentError("Transaction Error! Please try again", "No Response");
|
||||||
ArrayList<JPaymentSelectReceipt> paymentWindows = new ArrayList<>();
|
} else if ("APPROVED".equals(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getStatus())) {
|
||||||
for (Window window : Window.getWindows()) {
|
payinfo.setCardName(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getCard().getType());
|
||||||
if (window instanceof JPaymentSelectReceipt) {
|
payinfo
|
||||||
paymentWindows.add((JPaymentSelectReceipt) window);
|
.setVerification(AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getVerificationMethod());
|
||||||
}
|
payinfo.setChipAndPin(true);
|
||||||
}
|
payinfo.paymentOK(
|
||||||
return paymentWindows.get(paymentWindows.size()-1);
|
AppContext.getMediaPaymentsPaymentResult().getAdditionalInformation().getRequestId(),
|
||||||
}
|
AppContext.getMediaPaymentsPaymentResult().getTransactionDetails().getId(),
|
||||||
else {
|
AppContext.getMediaPaymentsPaymentResult().getProcessingDetails().getStatus());
|
||||||
ArrayList<JPaymentSelectRefund> paymentWindows = new ArrayList<>();
|
} else {
|
||||||
for (Window window : Window.getWindows()) {
|
String errorMsg = AppContext.getMediaPaymentsPaymentResult().getErrorMessage();
|
||||||
if (window instanceof JPaymentSelectRefund) {
|
if (errorMsg == null) {
|
||||||
paymentWindows.add((JPaymentSelectRefund) window);
|
errorMsg = AppContext.getMediaPaymentsPaymentResult().getMessage();
|
||||||
}
|
}
|
||||||
}
|
payinfo.paymentError("Transaction Error! Please try again", errorMsg);
|
||||||
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), roundedValue > 0 ? payinfo.getTransactionID() : null);
|
|
||||||
|
|
||||||
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