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