Skip to main content
Solved

Status of the payment record showing pending processing

  • 31 March 2021
  • 3 replies
  • 820 views

​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();
            }
        }












 

 

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.

 


​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);

 


Reply