protected void PaymentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Capture") { // INIT VARS int paymentId = AlwaysConvert.ToInt(e.CommandArgument); Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { CaptureDialogCaption.Text = string.Format(CaptureDialogCaption.Text, paymentId, payment.ReferenceNumber); CurrentPaymentStatus.Text = StringHelper.SpaceName(payment.PaymentStatus.ToString()).ToUpperInvariant(); CurrentPaymentStatus.CssClass = AbleCommerce.Code.CssHelper.GetPaymentStatusCssClass(payment.PaymentStatus); PaymentDate.Text = string.Format("{0:g}", payment.PaymentDate); Amount.Text = payment.Amount.LSCurrencyFormat("lc"); PaymentMethod.Text = payment.PaymentMethodName; decimal orig = payment.Transactions.GetTotalAuthorized(); decimal rem = payment.Transactions.GetRemainingAuthorized(); decimal bal = payment.Order.GetBalance(false); OriginalAuthorization.Text = orig.LSCurrencyFormat("lc"); RemainingAuthorization.Text = rem.LSCurrencyFormat("lc"); trRemainingAuthorization.Visible = (orig != rem); CaptureAmount.Text = string.Format("{0:F2}", bal); OrderBalance.Text = bal.LSCurrencyFormat("lc"); trAdditionalCapture.Visible = IsPartialCaptureSupported(payment); AccountDataViewport.PaymentId = paymentId; HiddenPaymentId.Value = paymentId.ToString(); CapturePopup.Show(); } } }
protected void SubmitCaptureButton_Click(object sender, EventArgs e) { int paymentId = AlwaysConvert.ToInt(HiddenPaymentId.Value); Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { //GET THE CAPTURE AMOUNT decimal captureAmount = AlwaysConvert.ToDecimal(CaptureAmount.Text); bool finalCapture = NoAdditionalCapture.Checked; if (captureAmount > 0) { payment.Capture(captureAmount, finalCapture, false); if (!string.IsNullOrEmpty(CustomerNote.Text)) { OrderNote note = new OrderNote(payment.Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public); note.Save(); } } // UPDATE THE GRID CapturePopup.Hide(); PaymentGrid.DataBind(); SearchResultAjax.Update(); } }
protected void Page_PreRender(object sender, EventArgs e) { // INITIALIZE THE ACCOUNT DATA VIEWPORT Payment payment = PaymentDataSource.Load(this.PaymentId); if (!IsAccountDataAvailable(payment)) { // ACCOUNT DATA NOT PRESENT OR USER IS NOT PERMITTED ShowAccountData.Visible = false; SSLRequiredMessage.Visible = false; UnavailableMessage.Visible = true; } else { //ACCOUNT DATA IS PRESENT AND USER HAS PERMISSION if (Request.IsSecureConnection) { // FOR PAYMENT TYPES OTHER THAN CREDIT CARD // WE CAN BIND THE ACCOUNT DETAILS RIGHT AWAY if (payment.PaymentMethod != null && !payment.PaymentMethod.IsCreditOrDebitCard()) { BindAccountData(payment); } } else { //SECURE CONNECTION NOT AVAILABLE SSLRequiredMessage.Visible = true; ShowAccountData.Visible = false; UnavailableMessage.Visible = false; } } }
private Order LoadOrder() { // FIRST CHECK FOR ORDER Order order = AbleCommerce.Code.OrderHelper.GetOrderFromContext(); if (order == null) { // NEXT CHECK FOR PAYMENT int paymentId = AlwaysConvert.ToInt(Request.QueryString["PaymentId"]); Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { order = payment.Order; } else { // NEXT CHECK FOR SHIPMENT int orderShipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); OrderShipment orderShipment = OrderShipmentDataSource.Load(orderShipmentId); if (orderShipment != null) { order = orderShipment.Order; } } } return(order); }
protected void Page_Init(object sender, EventArgs e) { _PaymentId = AlwaysConvert.ToInt(Request.QueryString["PaymentId"]); _Payment = PaymentDataSource.Load(_PaymentId); if (_Payment == null) { Response.Redirect("../Default.aspx"); } _OrderId = _Payment.OrderId; _Order = _Payment.Order; Caption.Text = string.Format(Caption.Text, (_Order.Payments.IndexOf(_PaymentId) + 1), _Payment.ReferenceNumber); PaymentReference.Text = _Payment.PaymentMethodName + " - " + _Payment.ReferenceNumber; PaymentAmount.Text = _Payment.Amount.LSCurrencyFormat("lc"); if (!Page.IsPostBack) { RefundAmount.Text = string.Format("{0:F2}", _Payment.Amount); } _PaymentProvider = GetPaymentProvider(_Payment); if (_PaymentProvider != null && (_PaymentProvider.RefundRequiresAccountData || (_PaymentProvider.Name == "Authorize.NET CIM" && _Payment.PaymentProfile == null))) { // INITIALIZE FIELDS FOR COLLECTING REFUND ACCOUNT DATA _AccountData = new AccountDataDictionary(_Payment.AccountData); bool isCheckPayment = (_Payment.PaymentMethod != null && _Payment.PaymentMethod.PaymentInstrumentType == PaymentInstrumentType.Check); if (isCheckPayment) { CheckFields.Visible = true; CreditCardFields.Visible = false; DebitCardFields.Visible = false; InitializeCheckFields(); } else { CheckFields.Visible = false; CreditCardFields.Visible = true; bool isAuthNet = (_PaymentProvider.Name == "Authorize.Net"); if (isAuthNet) { trCreditCardExpiration.Visible = false; CreditCardNumberLiteral.Text = " (last 4 digits or whole number)"; CreditCardNumberValidator.ValidationExpression = "^(\\d{4}|\\d{13,19})$"; CreditCardNumberValidator.ErrorMessage = "Enter the last 4 digits or the whole number between 13 and 19 digits long."; } DebitCardFields.Visible = _Payment.PaymentMethod != null && _Payment.PaymentMethod.IsIntlDebitCard(); InitializeCreditCardFields(); } } else { CheckFields.Visible = false; CreditCardFields.Visible = false; DebitCardFields.Visible = false; } }
protected void InitVars() { _PaymentId = AlwaysConvert.ToInt(Request.QueryString["PaymentId"]); _Payment = PaymentDataSource.Load(_PaymentId); if (_Payment == null) { Response.Redirect("../Default.aspx"); } _OrderId = _Payment.OrderId; _Order = _Payment.Order; }
protected void ShowAccountData_Click(object sender, EventArgs e) { Payment payment = PaymentDataSource.Load(this.PaymentId); if (IsAccountDataAvailable(payment)) { // ACCOUNT DATA IS PRESENT AND USER HAS PERMISSION Logger.Audit(AuditEventType.ViewCardData, true, string.Empty, AbleContext.Current.User, payment.Order.Id); BindAccountData(payment); } }
protected void Page_Load(object sender, EventArgs e) { _PaymentId = AlwaysConvert.ToInt(Request.QueryString["PaymentId"]); _Payment = PaymentDataSource.Load(_PaymentId); if (_Payment == null) { Response.Redirect("../Default.aspx"); } if (!Page.IsPostBack) { PaymentMethod paymentMethod = _Payment.PaymentMethod; if ((paymentMethod != null) && (paymentMethod.IsCreditOrDebitCard() || paymentMethod.PaymentInstrumentType == PaymentInstrumentType.PayPal)) { foreach (PaymentStatus s in Enum.GetValues(typeof(PaymentStatus))) { ListItem item = new ListItem(StringHelper.SpaceName(s.ToString()), ((int)s).ToString()); if (s == _Payment.PaymentStatus) { item.Selected = true; } CurrentPaymentStatus.Items.Add(item); } } else { ListItem item = new ListItem(StringHelper.SpaceName(PaymentStatus.Unprocessed.ToString()), ((int)PaymentStatus.Unprocessed).ToString()); if (PaymentStatus.Unprocessed == _Payment.PaymentStatus) { item.Selected = true; } CurrentPaymentStatus.Items.Add(item); item = new ListItem(StringHelper.SpaceName(PaymentStatus.Completed.ToString()), ((int)PaymentStatus.Completed).ToString()); if (PaymentStatus.Completed == _Payment.PaymentStatus) { item.Selected = true; } CurrentPaymentStatus.Items.Add(item); item = new ListItem(StringHelper.SpaceName(PaymentStatus.Void.ToString()), ((int)PaymentStatus.Void).ToString()); if (PaymentStatus.Void == _Payment.PaymentStatus) { item.Selected = true; } CurrentPaymentStatus.Items.Add(item); } PaymentDate.Text = string.Format("{0:g}", _Payment.PaymentDate); Amount.Text = string.Format("{0:F2}", _Payment.Amount); PaymentMethod.Text = _Payment.PaymentMethodName; Caption.Text = string.Format(Caption.Text, _Payment.PaymentMethodName, _Payment.ReferenceNumber); } }
/// <summary> /// Creates a clone of this CaptureTransactionRequest object /// </summary> /// <returns>A clone of this CaptureTransactionRequest object</returns> public CaptureTransactionRequest Clone() { Payment payment = PaymentDataSource.Load(this.Payment.PaymentId); CaptureTransactionRequest clone = new CaptureTransactionRequest(payment, this.RemoteIP); clone.Amount = this.Amount; clone.CurrencyCode = this.CurrencyCode; clone.IsFinal = this.IsFinal; foreach (string key in this.ExtendedProperties.Keys) { clone.ExtendedProperties[key] = this.ExtendedProperties[key]; } return(clone); }
protected void Page_Load(object sender, EventArgs e) { Payment payment = PaymentDataSource.Load(this.PaymentId); if (payment != null && IsUnprocessedAmazonPayment(payment)) { IPaymentProvider amazonProvider = GetAmazonProvider(); if (amazonProvider != null) { MethodInfo buttonMethod = amazonProvider.GetType().GetMethod("GetPaymentButton"); object[] parameters = new object[] { payment }; ImageButton paymentButton = (ImageButton)buttonMethod.Invoke(amazonProvider, parameters); this.ButtonPanel.Controls.Add(paymentButton); } } }
/// <summary> /// Determines the order context for the current request. /// </summary> /// <returns>The order context for the current request.</returns> public static int GetOrderId() { HttpContext context = HttpContext.Current; if (context == null) { return(0); } //CHECK FOR ORDER # IN QUERY STRING int orderNumber = AlwaysConvert.ToInt(context.Request.QueryString["OrderNumber"]); if (orderNumber != 0) { // GET ORDER NUMBER FOR ID return(OrderDataSource.LookupOrderId(orderNumber)); } int orderId = AlwaysConvert.ToInt(context.Request.QueryString["OrderId"]); if (orderId != 0) { return(orderId); } int paymentId = AlwaysConvert.ToInt(context.Request.QueryString["PaymentId"]); if (paymentId != 0) { Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { return(payment.OrderId); } } int shipmentId = AlwaysConvert.ToInt(context.Request.QueryString["OrderShipmentId"]); if (shipmentId != 0) { OrderShipment shipment = OrderShipmentDataSource.Load(shipmentId); if (shipment != null) { return(shipment.OrderId); } } return(0); }
protected void CaptureAllButton_Click(object sender, EventArgs e) { foreach (GridViewRow row in PaymentGrid.Rows) { CheckBox checkbox = (CheckBox)row.FindControl("SelectPaymentCheckBox"); if ((checkbox != null) && (checkbox.Checked)) { int paymentId = Convert.ToInt32(PaymentGrid.DataKeys[row.RowIndex].Value); Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { if (payment.Amount > 0) { payment.Capture(payment.Amount, true, false); } } } } PaymentGrid.DataBind(); SearchResultAjax.Update(); }