protected void gvPaymentMethods_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var method = (PaymentMethod)e.Row.DataItem; var chkEnabled = e.Row.FindControl("chkEnabled") as CheckBox; var lblMethodName = e.Row.FindControl("lblMethodName") as Label; var btnEdit = e.Row.FindControl("btnEdit") as LinkButton; var contains = HccApp.CurrentStore.Settings.PaymentMethodsEnabled.Contains(method.MethodId); chkEnabled.Checked = contains; if (string.IsNullOrEmpty(LocalizationUtils.GetPaymentMethodFriendlyName(method.MethodName))) { lblMethodName.Text = method.MethodName; } else { lblMethodName.Text = LocalizationUtils.GetPaymentMethodFriendlyName(method.MethodName); } var editor = HccPartController.LoadPaymentMethodEditor(method.MethodName, Page) as HccPart; var editorExists = editor != null; btnEdit.Visible = editorExists; } }
private void LoadPaymentMethods() { // Hide all first var divs = new List <Control> { divNoPaymentNeeded, divCreditCard, divPurchaseOrder, divCompanyAccount, divCheck, divTelephone, divCashOnDelivery }; divs.ForEach(d => d.Visible = false); // Show enabled only var enabledMethods = PaymentMethods.EnabledMethods(HccApp.CurrentStore, CurrentOrder.IsRecurring); foreach (var method in enabledMethods) { var divWrapper = upMain.FindControl("div" + method.MethodName) as HtmlGenericControl; var radioButton = upMain.FindControl("rb" + method.MethodName) as RadioButton; if (divWrapper != null) { divWrapper.Visible = true; } if (radioButton != null) { radioButton.Text = LocalizationUtils.GetPaymentMethodFriendlyName(method.MethodName); } } // Select first one var firstMethod = enabledMethods.FirstOrDefault(); if (firstMethod != null) { var radioButton = upMain.FindControl("rb" + firstMethod.MethodName) as RadioButton; if (radioButton != null) { radioButton.Checked = true; } } }
private string GetPaymentMethodName(OrderTransaction transaction) { switch (transaction.Action) { case ActionType.CashReceived: case ActionType.CashReturned: return(LocalizationUtils.GetQuickbooksExportString("PayMethCash")); case ActionType.CheckReceived: case ActionType.CheckReturned: return(LocalizationUtils.GetQuickbooksExportString("PayMethCheck")); case ActionType.CompanyAccountAccepted: return(LocalizationUtils.GetQuickbooksExportString("PayMethCompanyAccount")); case ActionType.PurchaseOrderAccepted: return(LocalizationUtils.GetQuickbooksExportString("PayMethPurchaseOrder")); case ActionType.CreditCardCapture: case ActionType.CreditCardCharge: case ActionType.CreditCardRefund: return(LocalizationUtils.GetQuickbooksExportString("PayMethCreditCard")); case ActionType.PayPalCapture: case ActionType.PayPalCharge: case ActionType.PayPalRefund: return(LocalizationUtils.GetQuickbooksExportString("PayMethPayPal")); case ActionType.ThirdPartyPayMethodCapture: case ActionType.ThirdPartyPayMethodCharge: case ActionType.ThirdPartyPayMethodRefund: var payMeth = PaymentMethods.Find(transaction.MethodId); return(LocalizationUtils.GetPaymentMethodFriendlyName(payMeth.MethodName)); default: return(LocalizationUtils.GetQuickbooksExportString("PayMethUnknown")); } }