/// <summary> /// Identifies the card if a match with pre-configured card types in not found by the application. /// </summary> /// <param name="cardInfo">Reference to an EftInfo object.</param> /// <param name="eftInfo">Reference to an eftInfo object.</param> public void IdentifyCard(ref ICardInfo cardInfo, ref IEFTInfo eftInfo) { //if (cardInfo != null) //{ // cardInfo.CardType = CardTypes.Unknown; //} if (cardInfo != null) { // This API is exposed for ISVs to identify card types not known internally. // // Normally, the card type should be determined by matching a number mask set up // in AX for Retail Headquarters. However, if there are other means to // identify a card, create the logic here and set the TenderTypeID property. // The TenderTypeID should match a CARDID in the RETAILSTORETENDERTYPECARDTABLE table. cardInfo.CardType = CardTypes.Unknown; // InternationalCreditCard = 0, InternationalDebitCard = 1, etc. cardInfo.TenderTypeId = String.Empty; // At least one of the following two fields needs to be set. If cardInfo.CardTypeId has a value, it will be saved to // the CARDTYPEID column of the RetailTransactionPaymentTrans table. Otherwise, the eftInfo.IssuerNumber // will be saved there. If a NULL is saved to that table, there will be problems down the road. //cardInfo.CardTypeId = String.Empty; //eftInfo.IssuerNumber = string.Empty; } }
/// <summary> /// Get transaction token for authorized transaction (Secure card storage). /// </summary> /// <param name="eftInfo">EftInfo object.</param> /// <param name="posTransaction">Reference to an IPosTransaction object.</param> public void GetTransactionToken(IEFTInfo eftInfo, IPosTransaction posTransaction) { // call payment processor's credit card tokenization // This token can sent to HQ via Transaction Service for Sales Order processing string token = string.Empty; eftInfo.TransactionToken = token; }
/// <summary> /// Captures the card payment by establishing a connection with the configured payment processor. /// </summary> /// <param name="eftInfo">Reference to an EftInfo object.</param> /// <param name="posTransaction">Current transaction.</param> public void CapturePayment(IEFTInfo eftInfo, IPosTransaction posTransaction) { // Similar logic to ProcessCardPayment(): send a previously-authorized payment to the processor for capture // This will ONLY get called at the end of a transaction if the IsPendingCapture property is set to true. // Unless the transaction is split tender (two or more card payments) this will normally get called shortly // after the call to ProcessCardPayment(). Any information needed to match up an authorization to the capture // request will be stored in the eftInfo object // ToDO: Add code to call the processer's API }
public static void PrintDeclineReceipt(IEFTInfo eftInfo) { //Prints Simple decline receipt for Merchant and Customer // This is is just simple text, so you can build it any way you want with eftInfo values StringBuilder recLayout = new StringBuilder(); recLayout.AppendLine("--------------------"); recLayout.AppendLine(eftInfo.CardName); recLayout.AppendLine(EFT.InternalApplication.BusinessLogic.Utility.MaskCardNumber(eftInfo.CardNumber)); recLayout.AppendLine(eftInfo.ProviderResponseCode); recLayout.AppendLine("--------------------"); string receipt = recLayout.ToString(); EFT.InternalApplication.Services.Peripherals.Printer.PrintReceipt( string.Format(receipt, ApplicationLocalizer.Language.Translate(50078))); //Merchant Copy EFT.InternalApplication.Services.Peripherals.Printer.PrintReceipt( string.Format(receipt, ApplicationLocalizer.Language.Translate(50077))); //Customer Copy }
/// <summary> /// Voids the card payment by establishing a connection with the configured payment processor. /// </summary> /// <param name="eftInfo">Reference to an EftInfo object.</param> /// <param name="posTransaction">Current transaction.</param> /// <returns>True if the processing succeeded.</returns> public bool VoidTransaction(ref IEFTInfo eftInfo, IPosTransaction posTransaction) { //eftInfo.CardNumberHidden = true; //eftInfo.Authorized = true; //return eftInfo.Authorized; //VoidTransaction() is only called in two very specific scenarios. The second one is quite rare. // 1. If a partial payment is manually voided before the entire transaction is // completed (by using the "Void Payment" button in the POS). This will only happen // in partial card payment (split tender) scenarios. // 2. If a card payment is made against a Sales Order or Sales Invoice and the // Retail Transaction Service becomes unavailable before the Sales Order or Sales // Invoice can be marked as "Paid" at Headquarters. In this case, an error will be thrown // and the card payment or authorization must be rolled back. // All other negative (refund) card transactions will flow through the standard ProcessCardPayment() method // TODO: Add code to call to the processer's API eftInfo.Authorized = true; // Set to true if Void was successful return(eftInfo.Authorized); }
internal static CustomerOrderInfo GetInfoFromTransaction(CustomerOrderTransaction customerOrder) { CustomerOrderInfo parameters = new CustomerOrderInfo(); //GRW DAC odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection); DataTable dt = odac.GetContactData(customerOrder.TransactionId, customerOrder.TerminalId, customerOrder.StoreId); if (dt.Rows.Count > 0) { parameters.CustName = dt.Rows[0]["NAME"].ToString(); parameters.CustPhone = dt.Rows[0]["PHONE"].ToString(); parameters.Email = dt.Rows[0]["EMAIL"].ToString(); } //GRW parameters.OrderType = customerOrder.OrderType; parameters.Id = customerOrder.OrderId; parameters.TransactionId = customerOrder.TransactionId; parameters.QuotationId = customerOrder.OrderId; parameters.AutoPickOrder = false; parameters.WarehouseId = customerOrder.WarehouseId; parameters.CurrencyCode = customerOrder.StoreCurrencyCode; parameters.StoreId = customerOrder.StoreId; parameters.TerminalId = customerOrder.TerminalId; parameters.LocalHourOfDay = customerOrder.LocalHourOfDay; parameters.AddressRecordId = (customerOrder.ShippingAddress != null) ? customerOrder.ShippingAddress.AddressRecId : string.Empty; parameters.CustomerAccount = (customerOrder.Customer != null) ? customerOrder.Customer.CustomerId : string.Empty; parameters.SalespersonStaffId = (customerOrder.SalesPersonId) ?? string.Empty; // The format must match the expected format in AX RetailTransactionService.CreateCustomerOrder: "dd/MM/yyyy" parameters.ExpiryDateString = customerOrder.ExpirationDate.ToString(FixedDateFormat); parameters.RequestedDeliveryDateString = customerOrder.RequestedDeliveryDate.ToString(FixedDateFormat); parameters.DeliveryMode = customerOrder.DeliveryMode != null ? customerOrder.DeliveryMode.Code : string.Empty; parameters.PrepaymentAmountOverridden = customerOrder.PrepaymentAmountOverridden; parameters.PrepaymentAmountApplied = customerOrder.NetAmountWithTaxAndCharges - customerOrder.AmountDue; parameters.TotalManualDiscountAmount = customerOrder.TotalManualDiscountAmount; parameters.TotalManualDiscountPercentage = customerOrder.TotalManualPctDiscount; //parameters.Email = customerOrder.ReceiptEmailAddress; parameters.Comment = ((IPosTransactionV1)customerOrder).Comment; parameters.ReturnReasonCodeId = customerOrder.ReturnReasonCodeId; parameters.LoyaltyCardId = (customerOrder.LoyaltyItem != null) ? customerOrder.LoyaltyItem.LoyaltyCardNumber : string.Empty; // If we do not have the channel reference identifier, we create a new receipt identifier instead. parameters.ChannelReferenceId = customerOrder.ChannelReferenceId; parameters.CreditCardToken = customerOrder.CreditCardToken; // Discount codes parameters.DiscountCodes = new Collection <string>(); foreach (string code in customerOrder.DiscountCodes) { parameters.DiscountCodes.Add(code); } // Line Items parameters.Items = new Collection <ItemInfo>(); foreach (SaleLineItem item in customerOrder.SaleItems) { if (!item.Voided) { string deliveryMode = parameters.DeliveryMode; if (item.DeliveryMode != null) { deliveryMode = item.DeliveryMode.Code; } string deliveryDateString = parameters.RequestedDeliveryDateString; if (item.DeliveryDate.HasValue) { deliveryDateString = item.DeliveryDate.Value.ToString(FixedDateFormat); } Collection <ChargeInfo> lineChargeInfo = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in item.MiscellaneousCharges) { lineChargeInfo.Add(new ChargeInfo() { Amount = charge.Amount, Code = charge.ChargeCode, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } // If no line-level warehouse is specified, fall back to the header warehouse string inventLocationId = string.IsNullOrWhiteSpace(item.DeliveryWarehouse) ? customerOrder.WarehouseId : item.DeliveryWarehouse; // AX SO line stores discount amount per item, POS stores for whole line, calculate per item discount amount decimal lineDiscount = (item.Quantity == 0M ? 0M : (item.TotalDiscount + item.LineDiscount + item.PeriodicDiscount) / (item.Quantity)); // Save all discount lines per sales line Collection <DiscountInfo> lineDiscountInfo = new Collection <DiscountInfo>(); foreach (DiscountItem discountLine in item.DiscountLines) { DiscountInfo discountInfo = new DiscountInfo(); discountInfo.DiscountCode = string.Empty; discountInfo.PeriodicDiscountOfferId = string.Empty; discountInfo.EffectiveAmount = discountLine.EffectiveAmount; discountInfo.DealPrice = discountLine.DealPrice; discountInfo.Percentage = discountLine.Percentage; discountInfo.DiscountAmount = discountLine.Amount; LineDiscountItem lineDiscountItem; PeriodicDiscountItem periodicDiscountItem; CustomerDiscountItem customerDiscountItem; if ((lineDiscountItem = discountLine as LineDiscountItem) != null) { discountInfo.DiscountOriginType = (int)lineDiscountItem.LineDiscountType; if ((periodicDiscountItem = discountLine as PeriodicDiscountItem) != null) { discountInfo.PeriodicDiscountOfferId = periodicDiscountItem.OfferId; discountInfo.DiscountCode = periodicDiscountItem.DiscountCode; } else if ((customerDiscountItem = discountLine as CustomerDiscountItem) != null) { discountInfo.CustomerDiscountType = (int)customerDiscountItem.CustomerDiscountType; } else { discountInfo.DiscountOriginType = (int)LineDiscountItem.DiscountTypes.Manual; discountInfo.ManualDiscountType = (int)discountLine.GetManualDiscountType(); } } if (discountLine is TotalDiscountItem) { discountInfo.DiscountOriginType = (int)LineDiscountItem.DiscountTypes.Manual; discountInfo.ManualDiscountType = (int)discountLine.GetManualDiscountType(); } lineDiscountInfo.Add(discountInfo); } parameters.Items.Add(new ItemInfo() { RecId = item.OrderLineRecordId, //quantity ItemId = item.ItemId, Quantity = item.Quantity, Unit = item.SalesOrderUnitOfMeasure, //pricing Price = item.Price, Discount = lineDiscount, NetAmount = item.NetAmount, ItemTaxGroup = item.TaxGroupId, SalesTaxGroup = item.SalesTaxGroupId, SalesMarkup = item.SalesMarkup, PeriodicDiscount = item.PeriodicDiscount, LineDscAmount = item.LineDiscount, LineManualDiscountAmount = item.LineManualDiscountAmount, LineManualDiscountPercentage = item.LineManualDiscountPercentage, TotalDiscount = item.TotalDiscount, TotalPctDiscount = item.TotalPctDiscount, PeriodicPercentageDiscount = item.PeriodicPctDiscount, //Comment Comment = item.Comment, //delivery WarehouseId = inventLocationId, AddressRecordId = item.ShippingAddress != null ? item.ShippingAddress.AddressRecId : null, DeliveryMode = deliveryMode, RequestedDeliveryDateString = deliveryDateString, //inventDim BatchId = item.BatchId, SerialId = item.SerialId, VariantId = item.Dimension.VariantId, ColorId = item.Dimension.ColorId, SizeId = item.Dimension.SizeId, StyleId = item.Dimension.StyleId, ConfigId = item.Dimension.ConfigId, //Return InvoiceId = item.ReturnInvoiceId, InventTransId = item.ReturnInvoiceInventTransId, //line-level misc. charges Charges = lineChargeInfo, //line-level discounts Discounts = lineDiscountInfo, }); } } // Header level Misc Charges parameters.Charges = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in customerOrder.MiscellaneousCharges) { parameters.Charges.Add(new ChargeInfo() { Code = charge.ChargeCode, Amount = charge.Amount, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } string CardType = ""; // Payments parameters.Payments = new Collection <PaymentInfo>(); foreach (ITenderLineItem tender in customerOrder.TenderLines) { CardType = ""; if (!tender.Voided) { ICardTenderLineItem cardTender = tender as ICardTenderLineItem; if (cardTender != null && cardTender.EFTInfo.IsAuthOnly) { // This is a Pre-Authorization record. IEFTInfo eft = cardTender.EFTInfo; parameters.Preauthorization = new Preauthorization() { PaymentPropertiesBlob = eft.PaymentProviderPropertiesXML }; } else if (tender.Amount != decimal.Zero) { // This is an actual payment record. DAC odac2 = new DAC(ApplicationSettings.Database.LocalConnection); CardType = odac2.getCardType(customerOrder.TransactionId, customerOrder.TerminalId, customerOrder.StoreId, tender.LineId, tender.TenderTypeId); parameters.Payments.Add(new PaymentInfo() { PaymentType = tender.TenderTypeId, Amount = string.IsNullOrEmpty(tender.CurrencyCode) ? tender.Amount : tender.ForeignCurrencyAmount, Currency = (tender.CurrencyCode) ?? string.Empty, CardType = string.IsNullOrEmpty(CardType) ? "":CardType }); } } } // Affiliations parameters.Affiliations = new Collection <AffiliationInfo>(); foreach (IAffiliation affiliation in customerOrder.AffiliationLines) { parameters.Affiliations.Add(new AffiliationInfo() { AffiliationId = affiliation.RecId, LoyaltyTierId = affiliation.LoyaltyTier }); } return(parameters); }
/// <summary> /// Processes the card payment by establishing a connection with the configured payment processor. /// </summary> /// <param name="eftInfo">Reference to an EftInfo object.</param> /// <param name="posTransaction">Current transaction.</param> /// <returns>True if the processing succeeded.</returns> public bool ProcessCardPayment(ref IEFTInfo eftInfo, IPosTransaction posTransaction) { //eftInfo.Authorized = true; //eftInfo.IsPendingCapture = true; //return eftInfo.Authorized; // This is the main entry point for the actual card processing. All card information that was // gathered by GetCardInfoAndAmount() has been copied to similar fields in the "eftInfo" object. // Use this information when calling your provider's service. // Our example will simulate successful authorization (or refund) randomly based on whether // this method gets hit on an odd or even second. In a real scenario, this is where you // would call your payment provider directly (web service, direct sockets, etc.) or call // out to a DLL with the necessary parameters. // All information is stored back to the eftInfo object which is used for printing the receipt, // storing information to the database (RetailTransactionPaymentTrans table), statement posting, etc. // In this example, we are simulating a 1-step Auth/Capture process, so we will // always leave "IsPendingCapture" as false. // The eftInfo class has many properties; most of them are used only for printing on the receipt. // See the EFT_NewSample2012_Readme.docx file for a mapping. // // Only a few are stored to the RetailTransactionPaymentTrans table: // eftInfo.BatchCode = BATCHID // eftInfo.AuthCode = EFTAUTHENTICATIONCODE // eftInfo.IssuerNumber = CARDTYPEID ** Only used if cardInfo.CardTypeId was blank after ID'ing the card // In addition, the cardInfo.CardNumber (masked) is stored to the CARDORACCOUNT column. // You may wish to save additional information to your own table. // Note: Both a SALE and a REFUND process will end up here. To determine if we're charging the card // or refunding money to the card, simply look at eftInfo.Amount. If the amount is negative, send a refund request. //if (DateTime.Now.Second % 2 == 1) //Uncomment this line to RANDOMLY succeed (odd or even second) ////if (true) //Uncomment this line to ALWAYS succeed //{ // //Auth was successful // eftInfo.Authorized = true; // //Authorization code returned from processor. // eftInfo.AuthCode = "123456"; // // Some fields only for printing on the receipt (see note above) // eftInfo.TransactionDateTime = DateTime.Now; // eftInfo.Message = String.Empty; // eftInfo.SequenceCode = String.Empty; // eftInfo.EntrySourceCode = String.Empty; // eftInfo.RetrievalReferenceNumber = String.Empty; // eftInfo.AccountType = "Checking"; // eftInfo.ResponseCode = String.Empty; // eftInfo.AuthorizedText = "Success"; // Printed on receipt as "EFT Info Message" field // // If performing a two-step Auth/Capture process, would set this to true in order // // to be caught by the Capture process at the end of the transaction. Otherwise, // // the Authorization process must send a Capture request at the same time as the Auth request. // eftInfo.IsPendingCapture = false; //} //else //{ // //Authorization failed // eftInfo.Authorized = false; // eftInfo.TransactionDateTime = DateTime.Now; // eftInfo.ProviderResponseCode = "99"; // eftInfo.NotAuthorizedText = "Not Approved"; // //Error Code and Error Message are shown to the user in pop-up window. // eftInfo.ErrorCode = "99999"; // eftInfo.ErrorMessage = "This is why the auth failed."; //} //if (!eftInfo.Authorized) //{ // // May want to print decline receipt if authorization failed. // PrintDeclineReceipt(eftInfo); // // Otherwise, set ErrorCode and ErrorMessage will be shown on the screen if Authorized = false // // Note: If authorization was successful, by default no message is given. You can add functionality // // to notify user of success. //} /* Blocked on 29.07.2013 // * * string sReqXML = "22,0,<?xml version='1.0' encoding='UTF-8' ?><purchase-request><TransactionInput ID='ID000001'><Card><IsManualEntry>false</IsManualEntry><Track1>4550381512383001^SUBHANKAR KUNDU ^1012101154730000000000774000000</Track1><Track2>5566204200063157=10031010019400</Track2></Card><Amount><BaseAmount>100</BaseAmount><CurrencyCode>INR</CurrencyCode></Amount><POS><POSReferenceNumber>TL993812</POSReferenceNumber><TransactionTime>2008-09-17T09:30:47.0Z</TransactionTime><Product><Code>SK9881277736</Code><Name>NOKIA 6610</Name><Description>Nokia mobile phone</Description><Category>MBL</Category></Product><Product><Code>SK9881277788</Code><Name>NOKIA 78GL ADPTR</Name><Description>Nokia travel adaptor</Description><Category>MBA</Category></Product><User><ID>16</ID><Name>AMITKUMAR</Name></User><TrackingNumber>818</TrackingNumber></POS></TransactionInput></purchase-request>"; * Project1.Class1 oEFTClass = new Project1.Class1(); * String sResponseXML = oEFTClass.Inno(sReqXML); * * DataSet ds = new DataSet(); * using (StringReader stringReader = new StringReader(sResponseXML)) * { * ds = new DataSet(); * ds.ReadXml(stringReader); * } * * DataTable dt = new DataTable(); * if (ds != null && ds.Tables.Count > 0) * { * dt = ds.Tables["HostResponse"]; * } * * if (dt != null && dt.Rows.Count > 0) * { * string code = Convert.ToString(dt.Rows[0]["ResponseCode"]); * string message = Convert.ToString(dt.Rows[0]["ResponseMessage"]); * string approvalcode = Convert.ToString(dt.Rows[0]["ApprovalCode"]); * if (string.IsNullOrEmpty(approvalcode)) * { * eftInfo.Authorized = false; * eftInfo.ErrorCode = code; * eftInfo.ErrorMessage = message; * } * } * else * { * eftInfo.Authorized = false; * eftInfo.ErrorCode = "99999"; * eftInfo.ErrorMessage = "No Connection Available to authorize the connection."; * } */ //using (LSRetailPosis.POSProcesses.frmMessage dialog = new frmMessage(sResponseXML, MessageBoxButtons.OK, MessageBoxIcon.Information)) //{ // Application.ApplicationFramework.POSShowForm(dialog); //} // eftInfo.Authorized = true; eftInfo.Authorized = true; string sTblName = "EXTNDCARDINFO" + ApplicationSettings.Terminal.TerminalId; string sCardNo = EFT.InternalApplication.BusinessLogic.Utility.MaskCardNumber(eftInfo.CardNumber); RetailTransaction retailTrans = posTransaction as RetailTransaction; if (retailTrans != null) { retailTrans.PartnerData.EFTCardNo = eftInfo.CardNumber; UpdateCardIfo(sTblName, retailTrans.TransactionId, sCardNo, sEFTApprovalCode, sCExpMonth, sCExpYear); } LSRetailPosis.Transaction.CustomerPaymentTransaction custTrans = posTransaction as LSRetailPosis.Transaction.CustomerPaymentTransaction; if (custTrans != null) { custTrans.PartnerData.EFTCardNo = eftInfo.CardNumber; UpdateCardIfo(sTblName, custTrans.TransactionId, sCardNo, sEFTApprovalCode, sCExpMonth, sCExpYear); } return(eftInfo.Authorized); }
internal static CustomerOrderInfo GetInfoFromTransaction(CustomerOrderTransaction customerOrder) { CustomerOrderInfo parameters = new CustomerOrderInfo(); parameters.OrderType = customerOrder.OrderType; parameters.Id = customerOrder.OrderId; parameters.QuotationId = customerOrder.OrderId; parameters.AutoPickOrder = false; parameters.WarehouseId = customerOrder.WarehouseId; parameters.CurrencyCode = customerOrder.StoreCurrencyCode; parameters.StoreId = customerOrder.StoreId; parameters.TerminalId = customerOrder.TerminalId; parameters.LocalHourOfDay = customerOrder.LocalHourOfDay; parameters.AddressRecordId = (customerOrder.ShippingAddress != null) ? customerOrder.ShippingAddress.AddressRecId : string.Empty; parameters.CustomerAccount = (customerOrder.Customer != null) ? customerOrder.Customer.CustomerId : string.Empty; parameters.SalespersonStaffId = (customerOrder.SalesPersonId) ?? string.Empty; // The format must match the expected format in AX RetailTransactionService.CreateCustomerOrder: "dd/MM/yyyy" parameters.ExpiryDateString = customerOrder.ExpirationDate.ToString(FixedDateFormat); parameters.RequestedDeliveryDateString = customerOrder.RequestedDeliveryDate.ToString(FixedDateFormat); parameters.DeliveryMode = customerOrder.DeliveryMode != null ? customerOrder.DeliveryMode.Code : string.Empty; parameters.PrepaymentAmountOverridden = customerOrder.PrepaymentAmountOverridden; parameters.Email = customerOrder.ReceiptEmailAddress; parameters.Comment = ((IPosTransactionV1)customerOrder).Comment; parameters.ReturnReasonCodeId = customerOrder.ReturnReasonCodeId; parameters.LoyaltyCardId = (customerOrder.LoyaltyItem != null && customerOrder.LoyaltyItem.UsageType == LSRetailPosis.Transaction.Line.LoyaltyItem.LoyaltyItemUsageType.UsedForLoyaltyRequest) ? customerOrder.LoyaltyItem.LoyaltyCardNumber : string.Empty; // If we do not have the channel reference identifier, we create a new receipt identifier instead. parameters.ChannelReferenceId = !string.IsNullOrWhiteSpace(customerOrder.ChannelReferenceId) ? customerOrder.ChannelReferenceId : SalesOrder.InternalApplication.Services.ApplicationService.GetNextReceiptId(customerOrder); parameters.CreditCardToken = customerOrder.CreditCardToken; // Discount codes parameters.DiscountCodes = new Collection <string>(); foreach (string code in customerOrder.DiscountCodes) { parameters.DiscountCodes.Add(code); } // Line Items parameters.Items = new Collection <ItemInfo>(); foreach (SaleLineItem item in customerOrder.SaleItems) { if (!item.Voided) { string deliveryMode = parameters.DeliveryMode; if (item.DeliveryMode != null) { deliveryMode = item.DeliveryMode.Code; } string deliveryDateString = parameters.RequestedDeliveryDateString; if (item.DeliveryDate.HasValue) { deliveryDateString = item.DeliveryDate.Value.ToString(FixedDateFormat); } Collection <ChargeInfo> lineChargeInfo = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in item.MiscellaneousCharges) { lineChargeInfo.Add(new ChargeInfo() { Amount = charge.Amount, Code = charge.ChargeCode, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } // If no line-level warehouse is specified, fall back to the header warehouse string inventLocationId = string.IsNullOrWhiteSpace(item.DeliveryWarehouse) ? customerOrder.WarehouseId : item.DeliveryWarehouse; //AX SO line stores discount amount per item, POS stores for whole line, calculate per item discount amount decimal lineDiscount = (item.Quantity == 0M ? 0M : (item.TotalDiscount + item.LineDiscount + item.PeriodicDiscount) / (item.Quantity)); parameters.Items.Add(new ItemInfo() { RecId = item.OrderLineRecordId, //quantity ItemId = item.ItemId, Quantity = item.Quantity, Unit = item.SalesOrderUnitOfMeasure, //pricing Price = item.Price, Discount = lineDiscount, NetAmount = item.NetAmount, ItemTaxGroup = item.TaxGroupId, SalesTaxGroup = item.SalesTaxGroupId, SalesMarkup = item.SalesMarkup, //delivery WarehouseId = inventLocationId, AddressRecordId = item.ShippingAddress != null ? item.ShippingAddress.AddressRecId : null, DeliveryMode = deliveryMode, RequestedDeliveryDateString = deliveryDateString, //inventDim BatchId = item.BatchId, SerialId = item.SerialId, VariantId = item.Dimension.VariantId, ColorId = item.Dimension.ColorId, SizeId = item.Dimension.SizeId, StyleId = item.Dimension.StyleId, ConfigId = item.Dimension.ConfigId, //Return InvoiceId = item.ReturnInvoiceId, InventTransId = item.ReturnInvoiceInventTransId, //line-level misc. charges Charges = lineChargeInfo, }); } } // Header level Misc Charges parameters.Charges = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in customerOrder.MiscellaneousCharges) { parameters.Charges.Add(new ChargeInfo() { Code = charge.ChargeCode, Amount = charge.Amount, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } // Payments parameters.Payments = new Collection <PaymentInfo>(); foreach (ITenderLineItem tender in customerOrder.TenderLines) { if (!tender.Voided) { ICardTenderLineItem cardTender = tender as ICardTenderLineItem; if (cardTender != null && cardTender.EFTInfo.IsAuthOnly) { // This is a Pre-Authorization record. IEFTInfo eft = cardTender.EFTInfo; parameters.Preauthorization = new Preauthorization() { PaymentPropertiesBlob = eft.PaymentProviderPropertiesXML }; } else if (tender.Amount != decimal.Zero) { // This is an actual payment record. parameters.Payments.Add(new PaymentInfo() { PaymentType = tender.TenderTypeId, Amount = tender.Amount, Currency = (tender.CurrencyCode) ?? string.Empty }); } } } return(parameters); }
private void btnOk_Click(object sender, EventArgs e) { string errorMessage = string.Empty; //------ if (string.IsNullOrEmpty(txtApprovalCode.Text)) { using (LSRetailPosis.POSProcesses.frmMessage dialog = new frmMessage("Please enter approval code.", MessageBoxButtons.OK, MessageBoxIcon.Information)) { // Application.ApplicationFramework.POSShowForm(dialog); LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); } return; } //---------- if (!string.IsNullOrEmpty(txtExpMonth.Text) && !string.IsNullOrEmpty(txtExpYear.Text)) { int iCurMonth = Convert.ToInt32(Convert.ToString(DateTime.Now.Month)); int iCurYear = Convert.ToInt32(Convert.ToString(DateTime.Now.Year).Substring(2)); if ((iCurYear == Convert.ToInt32(txtExpYear.Text.Trim())) && (iCurMonth > Convert.ToInt32(txtExpMonth.Text.Trim()))) { using (LSRetailPosis.POSProcesses.frmMessage dialog = new frmMessage("Please enter valid month", MessageBoxButtons.OK, MessageBoxIcon.Information)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); } return; } } //------------- //Perform some basic validation on entered values. Only set // everythingValid to true if everything is good. try { everythingValid = true; // Start by assuming true if (!getAmountOnly) { // If a card was manually entered, we need to make sure it is a valid card as defined in HQ // We will also set some additional CardInfo fields (they would have been set automatically when swiping) // We will set these values in the local CardInfo object and then return a new copy. localCardInfo.CardNumber = cardNumber.Text.Trim(); // This call will do most of the work for us. It will attempt to match to a known card type and // fill in the fields from the RETAILSTORETENDERTYPECARDTABLE and RETAILTENDERTYPECARDTABLE tables. // If more than one possible match is found, it will prompt for the correct card type. // All of this code is in the Card service (Services\Card\Card.cs) EFT.InternalApplication.Services.Card.GetCardType(ref localCardInfo); // Important fields for Statement Posting: CardTypeId, TenderTypeId // Other fields that can be used to determine if further validations are needed: // ModulusCheck, CardFee, ExpDateCheck, ProcessLocally, AllowManualInput, // Other informational fields: Issuer, EnterFleetInfo, CardFee, CashBackLimit // And the CardType field tells what card type it is (not the same as CardTypeID): // 0 = InternationalCreditCard, 1 = InternationalDebitCard, 2 = LoyaltyCard, 3 = CorporateCard // 4 = CustomerCard, 5 = EmployeeCard, 6 = SalespersonCard, 7 = GiftCard, 500 = Unknown // The EFT plugin is mainly concerned with the first two (Credit and Debit cards). } if (localCardInfo.CardType == CardTypes.Unknown) { // Card number was not recognized by the POS system. Two options here: // A) Write own logic to identify the card // This logic would be written in the IdentifyCard() method in EFT.cs and // called from here. IEFTInfo eftInfo = EFT.InternalApplication.BusinessLogic.Utility.CreateEFTInfo(); EFT.InternalApplication.Services.EFT.IdentifyCard(ref localCardInfo, ref eftInfo); // or B) stop processing and notify user that the card number entered is invalid //errorMessage = ApplicationLocalizer.Language.Translate(1370); // "Broker did not identify the card" //everythingValid = false; } //Amount paid has to be a non-zero amountPaid = decimal.Parse(AmountPaid.Text.Trim()); localCardInfo.Amount = amountPaid; // Added By Nimbus localCardInfo.CardNumber = cardNumber.Text.Trim(); //localCardInfo. sApprovalCode = txtApprovalCode.Text.Trim(); // Approval Code sCardExpMonth = txtExpMonth.Text.Trim(); sCardExpYear = txtExpYear.Text.Trim(); if (everythingValid && amountPaid == 0) { errorMessage = ApplicationLocalizer.Language.Translate(50041); // "The amount cannot be zero" everythingValid = false; } // Add other validations here if needed - set the errorMessage to give feedback to user. // Here are a few that the standard product does: // Expiration Date: 5366 = "The expiration date is not valid." // Manual card not allowed: 1369 = "The card number for this card type cannot be manually entered." // Card length: 1371 = "The card number's number of digits is not valid." // Debit cards: Cashback amount: 50027 = "The cashback amount that the customer has requested exceeds the store's cashback limit." // Debit cards: 50090 = "The cashback amount must be a positive value." // Of course you can add your own as well... } catch (System.Exception) { // Give a generic error message here and log the exception errorMessage = ApplicationLocalizer.Language.Translate(1000); // "An error occurred performing the action" everythingValid = false; } if (!everythingValid) { //Report the error message EFT.InternalApplication.Services.Dialog.ShowMessage(errorMessage, MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { this.Close(); } }
public void PrintCardReceipt(FormType formType, IPosTransaction posTransaction, IEFTInfo eftInfo, bool copyReceipt) { //PrintingActions.Print(formType, copyReceipt, true, // delegate(FormModulation formMod, FormInfo formInfo) // { // return formMod.GetTransformedCardTender(formInfo, eftInfo, (RetailTransaction)posTransaction); // }); }