public void MakePaymentUsingSavedTransferDetails(List<InvoiceDataHolder> invoices, decimal amount, Usr usr, Transfer previouslySavedTransfer, Transfer.FraudCheckEnum fraudCheckEnum, Guid duplicateGuid) { if (previouslySavedTransfer.UsrK != usr.K) throw new Exception("User doesn't match!"); if (!previouslySavedTransfer.CardSaved) throw new Exception("Card not saved!"); this.amount = Math.Round(amount, 2); if (this.amount <= 0) { throw new Exception("Cannot make a payment for " + this.amount.ToString("c") + ". It must be a positive amount."); } else { this.invoiceDataHolders = invoices; this.fraudCheckEnum = fraudCheckEnum; //this.SelectDSIBankAccount(invoices); this.transfer = previouslySavedTransfer.CopyThisTransfer(); // Previously saved transfer could be using different promoter account if (invoices.Count > 0) this.transfer.PromoterK = invoices[0].PromoterK; this.transfer.DuplicateGuid = duplicateGuid; this.transfer.SetUsrAndActionUsr(usr); this.transfer.CardSavedTransferK = previouslySavedTransfer.K; if (this.transfer.PromoterK == 0 && invoices.Count > 0) this.transfer.PromoterK = invoices[0].PromoterK; this.transfer.Amount = this.amount; this.transfer.Type = Transfer.TransferTypes.Payment; this.transfer.DateTimeCreated = DateTime.Now; try { response = secVpnService.repeatCardFullAddr( userName, password, previouslySavedTransfer.Guid.ToString(),// DSI created SecPay Transaction Id "tran0001" transfer.Amount.ToString(MONEY_FORMAT), // amount "50.00" password, transfer.Guid.ToString(), // DSI created SecPay Transaction Id "tran0001" DateToString(transfer.CardExpires), // User card number "4444333322221111" OrderToString(), BillingToString(), ShippingToString(), OptionsToString()); // options from Options() "name=Fred+Bloggs,company=Online+Shop+Ltd,addr_1=Dotcom+House,addr_2=London+Road,city=Townville,state=Countyshire,post_code=AB1+C23,tel=01234+567+890,fax=09876+543+210,email=somebody%40secpay.com,url=http%3A%2F%2Fwww.somedomain.com,test_status=true,dups=false,card_type=Visa,mand_cv2avs=[false|true,deferred=true]" // Log SecPay Response to transfer and save transfer details ResponseParser(this.PerformSecurityCheck); if (this.transfer.Status == Transfer.StatusEnum.Success && this.PerformSecurityCheck) { response = secVpnService.releaseCardFull( userName, password, transfer.Guid.ToString(), transfer.Amount.ToString(MONEY_FORMAT), password, transfer.Guid.ToString()); // run this through again with the new response ResponseParser(); } ProcessPaymentResults(); } catch (Exception ex) { EmailSecPayException(ex); throw new Exception("SecPay Refund failed. See transfer #" + this.transfer.K + " for details"); } } }
protected void Page_Load(object sender, EventArgs e) { ContainerPage.SslPage = true; try { if (ViewState["TransferK"] != null && (int)ViewState["TransferK"] > 0) TransferK = (int)ViewState["TransferK"]; else { if (ContainerPage.Url["K"].IsInt) { TransferK = Convert.ToInt32(ContainerPage.Url["K"].Value); ViewState["TransferK"] = TransferK; } else if (ContainerPage.Url["InvoiceK"].IsInt) { Invoice invoice = new Invoice(Convert.ToInt32(ContainerPage.Url["InvoiceK"].Value)); this.InvoiceK = invoice.K; if (!this.IsPostBack) LoadScreenFromInvoice(invoice); } else if (ContainerPage.Url["TransferRefundK"].IsInt) { Transfer transferToRefund = new Transfer(Convert.ToInt32(ContainerPage.Url["TransferRefundK"].Value)); decimal refundAmount = 0; if (!this.IsPostBack && !ContainerPage.Url["RefundAmount"].IsNull) { try { refundAmount = Convert.ToDecimal(ContainerPage.Url["RefundAmount"].Value) / 100m; } catch (Exception) { } } else if (this.AmountTextBox.Text.Length > 0 && Utilities.ConvertMoneyStringToDecimal(this.AmountTextBox.Text) != 0) { refundAmount = Utilities.ConvertMoneyStringToDecimal(this.AmountTextBox.Text); } currentTransfer = transferToRefund.RefundThisTransfer(refundAmount); // Dont set DateTimeCreated until it is saved currentTransfer.DateTimeCreated = DateTime.MinValue; loadRefundTransfer = true; } if (ContainerPage.Url["FailedTransferK"].IsInt) { Transfer failedTransfer = new Transfer(Convert.ToInt32(ContainerPage.Url["FailedTransferK"].Value)); currentTransfer = failedTransfer.CopyThisTransfer(); // Since we cant store card numbers and the SecPay transaction failed, then user must re-enter card number currentTransfer.Notes = failedTransfer.Notes; currentTransfer.CardNumberEnd = ""; currentTransfer.Status = Transfer.StatusEnum.Pending; redoFailedTransfer = true; } } if (TransferK > 0) { try { currentTransfer = new Transfer(TransferK); } catch (Exception) { // TODO: add popup error message, then redirect Response.Redirect(Transfer.UrlAdminNewTransfer()); } } } catch { // if no Transfer K, then assume we are creating a new Transfer TransferK = 0; } this.DownloadButton.Enabled = TransferK > 0; var currentTransferAmountRemaining = currentTransfer.AmountRemaining(); this.CreateCampaignCreditsButton.Visible = currentTransfer.Method == Transfer.Methods.TicketSales && currentTransferAmountRemaining > 0; if (this.CreateCampaignCreditsButton.Visible) { int numberOfCredits = CampaignCredit.CalculateTotalCreditsForMoney(currentTransferAmountRemaining / (decimal)(1 + Invoice.VATRate(Invoice.VATCodes.T1, DateTime.Now)), 0.5, currentTransfer.Promoter); CreateCampaignCreditsButton.InnerHtml = "Buy " + numberOfCredits.ToString("N0") + " campaign credits"; } if (!this.IsPostBack) { ViewState["DuplicateGuid"] = Guid.NewGuid(); this.RefundAmountTextBox.Style["text-align"] = "right"; NotesAddOnlyTextBox.ReadOnlyTextBox.CssClass = "readOnlyNotesTextBox"; NotesAddOnlyTextBox.AddTextBox.CssClass = "addNotesTextBox"; NotesAddOnlyTextBox.TimeStampFormat = "dd/MM/yy HH:mm"; NotesAddOnlyTextBox.AuthorName = Usr.Current.NickName; NotesAddOnlyTextBox.InsertOption = AddOnlyTextBox.InsertOptions.AddAtBeginning; CreateCampaignCreditsButton.Attributes["onclick"] = "if(confirm('Are you sure you want to use ticket funds to buy campaign credits?')){__doPostBack('" + CreateCampaignCreditsButton.UniqueID + "','');return false;}else{return false;};"; SetupTypeDropDownList(); if (currentTransfer != null) this.TypeDropDownList.SelectedValue = Convert.ToInt32(currentTransfer.Type).ToString(); SetupMethodDropDownList(); SetupCardTypeDropDownList(); if (currentTransfer.K > 0 || loadRefundTransfer == true || redoFailedTransfer == true) { // Setup screen rules for updating transfer only LoadScreenFromTransfer(); //if(loadRefundTransfer == true) // SetupStatusDropDownList(); } else { SetupStatusDropDownList(); this.TransferKValueLabel.Visible = false; this.TransferKLabel.Visible = false; // Setup screen for new transfer data input this.CreatedDateTextBox.Text = DateTime.Now.ToShortDateString(); if (Usr.Current != null) { this.uiActionUserAutoComplete.Value = Usr.Current.K.ToString(); this.uiActionUserAutoComplete.Text = Usr.Current.Name; this.ActionUserValueLabel.Text = Usr.Current.Link(); } } ShowHidePanels(); } SetBankDetailValidators(); }