public void Process() { string googleOrderNum = N1.googleordernumber; Order order = OrderDataSource.LoadForGoogleOrderNumber(googleOrderNum); if (order == null) { Logger.Warn("Unknown Google Order Number Charged. GoogleOrderNumber=" + googleOrderNum + ". Amount=" + N1.latestchargeamount.Value); } else { Payment payment = AcHelper.GetGCPayment(order, GatewayInstance, true); Transaction trans = payment.Transactions.LastCapturePending; if (trans == null) { trans = new Transaction(); } else { //remove the transaction from collection for correct calculations payment.Transactions.Remove(trans); } trans.TransactionStatus = TransactionStatus.Successful; //trans.TransactionDate = N1.timestamp; trans.Amount = N1.latestchargeamount.Value; trans.PaymentGatewayId = GatewayInstance.PaymentGatewayId; trans.ProviderTransactionId = googleOrderNum; LSDecimal totalAuth = payment.Transactions.GetTotalAuthorized(); LSDecimal totalCapt = payment.Transactions.GetTotalCaptured(); LSDecimal remainCapt = totalAuth - totalCapt; trans.TransactionType = TransactionType.PartialCapture; if (remainCapt > trans.Amount) { trans.TransactionType = TransactionType.PartialCapture; } else { trans.TransactionType = TransactionType.Capture; } if (payment.PaymentStatus == PaymentStatus.CapturePending) { PaymentEngine.ProcessCapturePending(payment, trans); } else { PaymentEngine.ForceTransaction(payment, trans); } } }
public void Process() { // Google has successfully refunded the customer's credit card. string googleOrderNum = N1.googleordernumber; Order order = OrderDataSource.LoadForGoogleOrderNumber(googleOrderNum); if (order == null) { Logger.Warn("Unknown Google Order Number Refunded. GoogleOrderNumber=" + googleOrderNum + ". Amount=" + N1.latestrefundamount.Value); } else { Payment payment = AcHelper.GetGCPayment(order, GatewayInstance, true); Transaction trans = payment.Transactions.LastRefundPending; if (trans == null) { trans = new Transaction(); } else { //remove the transaction from collection for correct calculations payment.Transactions.Remove(trans); } trans.TransactionStatus = TransactionStatus.Successful; trans.PaymentGatewayId = GatewayInstance.PaymentGatewayId; //LSDecimal totalRefunded = payment.Transactions.GetTotalRefunded(); //trans.Amount = N1.totalrefundamount.Value - totalRefunded; trans.Amount = N1.latestrefundamount.Value; trans.ProviderTransactionId = N1.googleordernumber; LSDecimal totalCharged = payment.Transactions.GetTotalCaptured(); if (totalCharged > trans.Amount) { trans.TransactionType = TransactionType.PartialRefund; } else { trans.TransactionType = TransactionType.Refund; } if (payment.PaymentStatus == PaymentStatus.RefundPending) { PaymentEngine.ProcessRefundPending(payment, trans); } else { PaymentEngine.ForceTransaction(payment, trans); } } }