/// <summary> /// Create a Request object from transaction data /// </summary> /// <param name="voidItem"></param> /// <returns></returns> public CSPaymentProvider.Request GetVoidRequestFromOrderRow(CSMasterDataSet.VoidQueueRow voidItem) { CSPaymentProvider.Request request = new CSPaymentProvider.Request(); request.TransactionID = voidItem.TransactionNumber; request.AuthCode = voidItem.TransactionID; request.InvoiceNumber = voidItem.OrderID.ToString(); return(request); }
/// <summary> /// Process all transactions /// </summary> /// <returns></returns> public bool DoBatch() { bool _breturn = false; CSMasterDataSet.VoidQueueDataTable tblVoidQueue = new CSMasterDataSet.VoidQueueDataTable(); CSMasterDataSetTableAdapters.VoidQueueTableAdapter adpVoidQueue = new CSMasterDataSetTableAdapters.VoidQueueTableAdapter(); IPaymentProvider pProvider = VOIDBatch.Application_Code.DataAccess.ClientDAL.GetDefaultProvider(); //try //{ adpVoidQueue.Fill(tblVoidQueue); foreach (var item in tblVoidQueue.Rows) { CSMasterDataSet.VoidQueueRow voidItem = (CSMasterDataSet.VoidQueueRow)item; CSPaymentProvider.Request request = GetVoidRequestFromOrderRow(voidItem); CSPaymentProvider.Response response = pProvider.PerformVoidRequest(request); voidItem.Request = response.GatewayRequestRaw; if (voidItem.IsRequestNull()) { voidItem.Request = "NULL"; } voidItem.Response = response.GatewayResponseRaw; switch (response.ResponseType) { case CSPaymentProvider.TransactionResponseType.Approved: SetOrderAsRejected(voidItem.OrderID); voidItem.Succeeded = true; break; case CSPaymentProvider.TransactionResponseType.Denied: voidItem.Succeeded = false; break; case CSPaymentProvider.TransactionResponseType.Error: voidItem.Succeeded = false; //if (voidItem.IsCommentsNull()) voidItem.Comments = string.Empty; //voidItem.Comments = string.Format("{0} --- {1} : {2}", voidItem.Comments, DateTime.Now.ToString(), response.ReasonText); break; } SaveTransaction(voidItem); } //} //catch (Exception e) //{ // Console.WriteLine(e.Message + " ----- " + e.InnerException.Message); // return _breturn; //} return(_breturn); }