updating status changes
This commit is contained in:
@@ -196,7 +196,8 @@ public class VelocityPaymentService {
|
|||||||
|
|
||||||
if ("MPGS".equalsIgnoreCase(transaction.getPaymentProcessorLabel())) {
|
if ("MPGS".equalsIgnoreCase(transaction.getPaymentProcessorLabel())) {
|
||||||
payload.setCancelUrl(velocityApiProperties.getCancelUrl() + "/" + transaction.getOrderId());
|
payload.setCancelUrl(velocityApiProperties.getCancelUrl() + "/" + transaction.getOrderId());
|
||||||
payload.setSuccessUrl(velocityApiProperties.getSuccessUrl() + "/" + transaction.getOrderId());
|
// not sending successUrl for now
|
||||||
|
// payload.setSuccessUrl(velocityApiProperties.getSuccessUrl() + "/" + transaction.getOrderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -216,6 +217,7 @@ public class VelocityPaymentService {
|
|||||||
String redirectUrl = body.containsKey("redirectUrl") ? (String) body.get("redirectUrl") : null;
|
String redirectUrl = body.containsKey("redirectUrl") ? (String) body.get("redirectUrl") : null;
|
||||||
|
|
||||||
if ("SUCCESS".equalsIgnoreCase(transactionStatus)) {
|
if ("SUCCESS".equalsIgnoreCase(transactionStatus)) {
|
||||||
|
transaction.setStatus(Status.SUCCESS);
|
||||||
transaction.setErpSalesPaymentRef(transactionName);
|
transaction.setErpSalesPaymentRef(transactionName);
|
||||||
transaction.setOrderTransactionTrace(tranTrace);
|
transaction.setOrderTransactionTrace(tranTrace);
|
||||||
transaction.setOrderTransactionId(tranId);
|
transaction.setOrderTransactionId(tranId);
|
||||||
@@ -257,7 +259,6 @@ public class VelocityPaymentService {
|
|||||||
throw new IllegalStateException("Error initiating payment: " + errorMessage);
|
throw new IllegalStateException("Error initiating payment: " + errorMessage);
|
||||||
}
|
}
|
||||||
transaction.setStatus(Status.valueOf((String) body.get("status")));
|
transaction.setStatus(Status.valueOf((String) body.get("status")));
|
||||||
transaction.setPaymentStatus(Status.valueOf((String) body.get("paymentStatus")));
|
|
||||||
transaction.setPollingStatus(Status.valueOf((String) body.get("pollStatus")));
|
transaction.setPollingStatus(Status.valueOf((String) body.get("pollStatus")));
|
||||||
transaction.setDebitRef((String) body.get("debitRef"));
|
transaction.setDebitRef((String) body.get("debitRef"));
|
||||||
transaction.setPaymentProcessorRef((String) body.get("paymentProcessorRef"));
|
transaction.setPaymentProcessorRef((String) body.get("paymentProcessorRef"));
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ public class MPGSWebPaymentProcessor implements TransactionProcessorInterface {
|
|||||||
try {
|
try {
|
||||||
// velocity expects VMC
|
// velocity expects VMC
|
||||||
transaction = velocityPaymentService.processPayment(transaction);
|
transaction = velocityPaymentService.processPayment(transaction);
|
||||||
|
|
||||||
|
// payment status comes back as pending for VMC,
|
||||||
|
// set it to SUCCESS
|
||||||
|
transaction.setPaymentStatus(Status.SUCCESS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("Network error during payment processing: {}", e.getMessage(), e);
|
logger.error("Network error during payment processing: {}", e.getMessage(), e);
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ public class GatewayPaymentHandler implements HandlerInterface {
|
|||||||
new ApiException("Transaction not found for ID: " + incomingTransaction.getId()));
|
new ApiException("Transaction not found for ID: " + incomingTransaction.getId()));
|
||||||
transaction.setType(incomingTransaction.getType()); // type should be REQUEST here
|
transaction.setType(incomingTransaction.getType()); // type should be REQUEST here
|
||||||
transaction.setAuthType(incomingTransaction.getAuthType());
|
transaction.setAuthType(incomingTransaction.getAuthType());
|
||||||
|
transaction.setErrorMessage(null);
|
||||||
|
transaction.setSystemErrorMessage(null);
|
||||||
|
transaction.setStatus(Status.PROCESSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we've done this before then return
|
// if we've done this before then return
|
||||||
@@ -58,9 +61,10 @@ public class GatewayPaymentHandler implements HandlerInterface {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// MAIN TRANSACTION LOGIC!
|
// MAIN TRANSACTION LOGIC!
|
||||||
transactionProcessorInterface.process(transaction);
|
transaction = (Transaction) transactionProcessorInterface.process(transaction);
|
||||||
transaction.setPaymentStatus(transaction.getStatus());
|
transaction.setPaymentStatus(transaction.getPaymentStatus());
|
||||||
transaction.setPollingStatus(Status.PENDING);
|
transaction.setPollingStatus(Status.PENDING);
|
||||||
|
transactionService.save(transaction);
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package zw.qantra.tm.domain.services.processors.workflows.handlers;
|
package zw.qantra.tm.domain.services.processors.workflows.handlers;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -13,6 +14,7 @@ import zw.qantra.tm.domain.services.factories.PaymentProcessorFactory;
|
|||||||
import zw.qantra.tm.domain.services.processors.TransactionProcessorInterface;
|
import zw.qantra.tm.domain.services.processors.TransactionProcessorInterface;
|
||||||
import zw.qantra.tm.exceptions.ApiException;
|
import zw.qantra.tm.exceptions.ApiException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service("pollStatus")
|
@Service("pollStatus")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PollStatusHandler implements HandlerInterface {
|
public class PollStatusHandler implements HandlerInterface {
|
||||||
@@ -24,7 +26,14 @@ public class PollStatusHandler implements HandlerInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(Transaction transaction) throws Exception {
|
public Object process(Transaction transaction) throws Exception {
|
||||||
Logger logger = LoggerFactory.getLogger(TransactionService.class);
|
|
||||||
|
// don't poll unless payment was success
|
||||||
|
if(transaction.getPaymentStatus() != Status.SUCCESS) {
|
||||||
|
transaction.setPollingStatus(Status.PENDING);
|
||||||
|
transaction.setErrorMessage("Transaction not yet successful");
|
||||||
|
transactionService.save(transaction);
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
// if the transaction is already successful, return it
|
// if the transaction is already successful, return it
|
||||||
if(transaction.getPollingStatus() == Status.SUCCESS){
|
if(transaction.getPollingStatus() == Status.SUCCESS){
|
||||||
@@ -40,7 +49,7 @@ public class PollStatusHandler implements HandlerInterface {
|
|||||||
|
|
||||||
// no persistence happens during polling unless the transaction status changes
|
// no persistence happens during polling unless the transaction status changes
|
||||||
String label = "REQUEST_" + transaction.getPaymentProcessorLabel() + "_" + transaction.getAuthType();
|
String label = "REQUEST_" + transaction.getPaymentProcessorLabel() + "_" + transaction.getAuthType();
|
||||||
logger.info("label: {}", label);
|
log.info("label: {}", label);
|
||||||
|
|
||||||
TransactionProcessorInterface transactionProcessorInterface =
|
TransactionProcessorInterface transactionProcessorInterface =
|
||||||
(TransactionProcessorInterface) paymentProcessorFactory.getPaymentProcessor(label);
|
(TransactionProcessorInterface) paymentProcessorFactory.getPaymentProcessor(label);
|
||||||
@@ -52,11 +61,9 @@ public class PollStatusHandler implements HandlerInterface {
|
|||||||
transactionEvent.setMessage(transaction.getErrorMessage());
|
transactionEvent.setMessage(transaction.getErrorMessage());
|
||||||
transactionEventService.save(transactionEvent);
|
transactionEventService.save(transactionEvent);
|
||||||
|
|
||||||
transaction.setPollingStatus(transaction.getStatus());
|
|
||||||
transaction.setPaymentStatus(transaction.getStatus());
|
|
||||||
|
|
||||||
// if transaction wasn't successful, throw and halt workflow
|
// if transaction wasn't successful, throw and halt workflow
|
||||||
if(transaction.getStatus() != Status.SUCCESS){
|
if(transaction.getPollingStatus() != Status.SUCCESS){
|
||||||
|
log.info("Verification pending: {}", transaction.getErrorMessage());
|
||||||
transactionService.save(transaction);
|
transactionService.save(transaction);
|
||||||
throw new ApiException("Verification pending: " + transaction.getErrorMessage() );
|
throw new ApiException("Verification pending: " + transaction.getErrorMessage() );
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ powertel.clientid=powertel_zesa
|
|||||||
ecocash.apikey=OUzGezwTgktLg_9v0I48I6WUM4LVLGFl
|
ecocash.apikey=OUzGezwTgktLg_9v0I48I6WUM4LVLGFl
|
||||||
ecocash.url=https://developers.ecocash.co.zw/api/ecocash_pay/api/v2/payment/instant/c2b/sandbox
|
ecocash.url=https://developers.ecocash.co.zw/api/ecocash_pay/api/v2/payment/instant/c2b/sandbox
|
||||||
|
|
||||||
velocity.api.base-url=https://api.velocityafrica.net
|
#velocity.api.base-url=https://api.velocityafrica.net
|
||||||
velocity.api.api-key=Ko7_hAZjDNAqj--VI1kpkgV4D6PsjS6eWWEIgcfhG8M
|
#velocity.api.api-key=Ko7_hAZjDNAqj--VI1kpkgV4D6PsjS6eWWEIgcfhG8M
|
||||||
#velocity.api.base-url=http://localhost:6975
|
velocity.api.base-url=http://localhost:6975
|
||||||
#velocity.api.api-key=gH13nirZdUQdqC9impgzTzqEqv-jdbLOTx_HD5fQr_A
|
velocity.api.api-key=gH13nirZdUQdqC9impgzTzqEqv-jdbLOTx_HD5fQr_A
|
||||||
velocity.api.cancel-url=http://localhost:9005/poll
|
velocity.api.cancel-url=http://localhost:9005/poll
|
||||||
velocity.api.success-url=http://localhost:9005/poll
|
velocity.api.success-url=http://localhost:9005/poll
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user