Skip to main content
Solved

Status of the payment record showing pending processing


praveenpo
Semi-Pro II
Forum|alt.badge.img+3

​Hi,

I’m creating the payment programmatically but payment status is showing Pending Processing.Even tried setting the status to balanced and it didn't worked.

Payment is captured in the External system so we are filling the ExtranalTrsnaction table and below is the code that we used create the payment.


 ARPaymentEntry docgraph = PXGraph.CreateInstance<ARPaymentEntry>();
                ARPayment objPayment = new ARPayment();
                objPayment.DocType = ARDocType.Payment;
                objPayment.Status = ARDocStatus.Balanced;
                objPayment.CustomerID = order.CustomerID;
                objPayment.PaymentMethodID = filter?.PaymentMethod;
               // objPayment.CuryID = order.CuryID;
                objPayment.ExtRefNbr = filter?.PaymentRefNbr;
                objPayment.CuryOrigDocAmt = filter?.PaymentTotal;
                docgraph.Document.Cache.Insert(objPayment);

                SOAdjust adjnew = new SOAdjust();
                adjnew.AdjdOrderNbr = order.OrderNbr;
                adjnew.AdjdOrderType = order.OrderType;
                adjnew.CuryAdjgAmt = filter?.PaymentTotal;
                docgraph.SOAdjustments.Insert(adjnew);

                docgraph.Actions.PressSave();

                CCProcessingCenter objProcessingCenter = PXSelectJoin<CCProcessingCenter,
                                                        InnerJoin<CCProcessingCenterPmntMethod, On<CCProcessingCenter.processingCenterID, Equal<CCProcessingCenterPmntMethod.processingCenterID>>,
                                                        InnerJoin<PaymentMethod, On<PaymentMethod.paymentMethodID, Equal<CCProcessingCenterPmntMethod.paymentMethodID>>>>,
                                                        Where<CCProcessingCenterPmntMethod.paymentMethodID, Equal<Required<SOOrder.paymentMethodID>>,
                                                        And<PaymentMethod.paymentType, Equal<PaymentMethodType.creditCard>,
                                                        And<CCProcessingCenter.isActive, Equal<True>>>>>.Select(this, filter.PaymentMethod);
                if (objProcessingCenter != null)
                {
                    InsertRecords(docgraph);
                    docgraph.Document.Current.CCActualExternalTransactionID = docgraph.ExternalTran.Current?.TransactionID;
                    docgraph.Document.Current.IsCCCaptured = true;
                    docgraph.Document.Cache.Update(docgraph.Document.Current);
                    docgraph.Actions.PressSave();
                }

    private void InsertRecords(ARPaymentEntry docgraph)
        {          
            CCProcTran tran = PXSelectReadonly<CCProcTran, Where<CCProcTran.origRefNbr, Equal<Required<SOOrder.orderNbr>>, And<CCProcTran.origDocType, Equal<Required<SOOrder.orderType>>,
                             And<CCProcTran.refNbr, Equal<Required<ARPayment.refNbr>>,And< CCProcTran.pCTranNumber ,Equal<Required<CCProcTran.pCTranNumber>>>>>>>.Select(this, docgraph.SOAdjustments.Current?.AdjdOrderNbr, docgraph.SOAdjustments.Current?.AdjdOrderType, docgraph.Document.Current.RefNbr, docgraph.Document.Current.ExtRefNbr);

            if (tran == null)
            {
                ExternalTransaction objExternalTransaction = new ExternalTransaction();
                objExternalTransaction.ProcessingCenterID  = docgraph.Document.Current.ProcessingCenterID;
                objExternalTransaction.PMInstanceID = docgraph.Document.Current.PMInstanceID;
                objExternalTransaction.ProcStatus = "CAS";
                objExternalTransaction.DocType = ARDocType.Payment;
                objExternalTransaction.RefNbr = docgraph.Document.Current.RefNbr;
                //objExternalTransaction.OrigDocType = docgraph.SOAdjustments.Current?.AdjdOrderType;
                //objExternalTransaction.OrigRefNbr = docgraph.SOAdjustments.Current?.AdjdOrderNbr;
                objExternalTransaction.TranNumber = docgraph.Document.Current.ExtRefNbr;
                objExternalTransaction.Completed = true;
                objExternalTransaction.Amount = docgraph.SOAdjustments.Current?.CuryAdjdAmt;
                objExternalTransaction.Active = true;
                objExternalTransaction.Direction = "D";
                docgraph.ExternalTran.Insert(objExternalTransaction);

                //Record Inserting in CCProcTran table to refund
                CCProcTran objCCProcTran = new CCProcTran();
                objCCProcTran.PMInstanceID = docgraph.Document.Current.PMInstanceID;
                objCCProcTran.ProcessingCenterID = docgraph.Document.Current.ProcessingCenterID;
                objCCProcTran.DocType = ARDocType.Payment;
                objCCProcTran.RefNbr = docgraph.Document.Current.RefNbr;
                //objCCProcTran.OrigDocType = docgraph.SOAdjustments.Current?.AdjdOrderType;
                //objCCProcTran.OrigRefNbr = docgraph.SOAdjustments.Current?.AdjdOrderNbr;
                objCCProcTran.TranType = CCTranTypeCode.PriorAuthorizedCapture;
                objCCProcTran.ProcStatus = CCProcStatus.Finalized;
                objCCProcTran.CuryID = docgraph.Document.Current.CuryID;
                objCCProcTran.TranStatus = CCTranStatusCode.Approved;
                objCCProcTran.Amount = docgraph.SOAdjustments.Current?.CuryAdjdAmt;
                objCCProcTran.PCTranNumber = docgraph.Document.Current.ExtRefNbr;
                objCCProcTran.StartTime = docgraph.Accessinfo.BusinessDate;
                objCCProcTran.PCResponseCode = Convert.ToString(1);
                objCCProcTran.PCResponseReasonText = KNMCMessages.TransactionApproved;
                docgraph.ccProcTran.Insert(objCCProcTran);

                docgraph.Actions.PressSave();
            }
        }












 

 

Best answer by alexandermakarov89

Hi, praveenpo

You can use the following example to update the ARPayment.PendingProcessing field for ARPayment to see the correct doc status (Balanced):

ARPaymentEntry docgraph = PXGraph.CreateInstance<ARPaymentEntry>();
ARPayment payment = new ARPayment();
payment.DocType = ARPaymentType.Payment;
payment = paymentGraph.Document.Insert(payment);
payment.CustomerID = ...
payment.CustomerLocationID = ...
payment.PaymentMethodID = ...
payment.CashAccountID = ...
payment.PMInstanceID = ...
payment.CuryOrigDocAmt = ...
payment.DocDesc = ...

payment = paymentGraph.Document.Update(payment);
payment.PendingProcessing = false;
payment = paymentGraph.Document.Update(payment);
paymentGraph.Save.Press();

 

The better way to add ExternalTransaction, CCProcTran and update ARPayment flags (PendingProcessing, IsCCCaptured) automaticly is to use the following code.

using PX.Objects.AR;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common

CCPaymentEntry entry = new CCPaymentEntry(paymentGraph);
paymentEntry.AfterProcessingManager = new ARPaymentAfterProcessingManager() 
{ Graph = paymentGraph };


TranRecordData tranRecord = new TranRecordData();
tranRecord.ExternalTranId = ...
tranRecord.AuthCode = ...
tranRecord.TransactionDate = ...
tranRecord.ProcessingCenterId = ...
tranRecord.TranStatus = ...
				tranRecord.Imported = ...

ICCPayment doc = paymentGraph.Document.Current;
entry.RecordPriorAuthCapture(doc, tranRecord);

 

View original
Did this topic help you find an answer to your question?

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • April 2, 2021

Hi @praveenpo,

For the Credit card payment method the default status will be “Pending Process” and the “Balanced” status will be “Cash/Check” type.

And, code looks clean to me, and observed there is no code for releasing of newly created payment.

After adding the RELEASE action code, can you please also verify with the “CASH” payment method and check.

 


Nayan Mansinha
Community Manager
Forum|alt.badge.img+2
  • Acumatica Developer Support
  • 49 replies
  • April 2, 2021
praveenpo wrote:

​Hi,

I’m creating the payment programmatically but payment status is showing Pending Processing.Even tried setting the status to balanced and it didn't worked.


 

 

The reason is because Status field is driven using SetStatus attribute. Look at its field ARRegister.Status definition in the Source Code screen.  This attribute looks for PrendingProcessing field to detemine the status. See screenshot below:

I dont see this field being set in your code. 


Hi, praveenpo

You can use the following example to update the ARPayment.PendingProcessing field for ARPayment to see the correct doc status (Balanced):

ARPaymentEntry docgraph = PXGraph.CreateInstance<ARPaymentEntry>();
ARPayment payment = new ARPayment();
payment.DocType = ARPaymentType.Payment;
payment = paymentGraph.Document.Insert(payment);
payment.CustomerID = ...
payment.CustomerLocationID = ...
payment.PaymentMethodID = ...
payment.CashAccountID = ...
payment.PMInstanceID = ...
payment.CuryOrigDocAmt = ...
payment.DocDesc = ...

payment = paymentGraph.Document.Update(payment);
payment.PendingProcessing = false;
payment = paymentGraph.Document.Update(payment);
paymentGraph.Save.Press();

 

The better way to add ExternalTransaction, CCProcTran and update ARPayment flags (PendingProcessing, IsCCCaptured) automaticly is to use the following code.

using PX.Objects.AR;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common

CCPaymentEntry entry = new CCPaymentEntry(paymentGraph);
paymentEntry.AfterProcessingManager = new ARPaymentAfterProcessingManager() 
{ Graph = paymentGraph };


TranRecordData tranRecord = new TranRecordData();
tranRecord.ExternalTranId = ...
tranRecord.AuthCode = ...
tranRecord.TransactionDate = ...
tranRecord.ProcessingCenterId = ...
tranRecord.TranStatus = ...
				tranRecord.Imported = ...

ICCPayment doc = paymentGraph.Document.Current;
entry.RecordPriorAuthCapture(doc, tranRecord);

 


  • Freshman I
  • 2 replies
  • November 11, 2024

I have found a couple ways to fix this issue.

 

  1.  As long as its the same day, you can validate the payment and it should show as balanced.  
  2. If you wait until next day you can validate the payment, then record payment (copy and paste the transaction ID  from ebiz portal).  

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings