protected void btnSubmit_Click(object sender, EventArgs e) { Payment pay = new Payment(); CreditCardForm.SetCustomerInfo(pay); Payment.CustomerInfo customer = pay.customer; if (customer.customer_profile_id != 0) { try { customer.payment_profile_id = pay.SetCustomerPaymentProfile(customer.customer_profile_id); lblResult.Text = "Thank you, your credit card info has been updated."; CreditCardForm.Visible = false; mainsection.Visible = false; } catch (System.Exception ex) { lblResult.Style["color"] = "white"; lblResult.Text = "ERROR: We are sorry, our payment processor is down, please try again in a few minutes. Error=" + ex.Message; heading.Attributes["style"] = "background-color:#c00"; MyUtils.LogError(ex); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { double amount = 0; int credits = 0; if (MyUtils.MONTHLY_CHARGE_PLAN) { amount = MyUtils.MonthlyFee; } else { GetPackageAmounts(ref amount, ref credits); } bool isPaymSuccess = false; paym.customer = new Payment.CustomerInfo(); paym.customer.id_user = MyUtils.ID_USER; if (hiddenCardSelect.Value == "1" && customer_profile_id > 0 && payment_profile_id > 0) { //use old card paym.customer.customer_profile_id = customer_profile_id; paym.customer.payment_profile_id = payment_profile_id; } else { CreditCardForm.SetCustomerInfo(paym); } string description = "Credit package " + credits; if (MyUtils.MONTHLY_CHARGE_PLAN) { description = "Monthly Service Plan"; } string response = paym.Pay(paym.customer, (decimal)amount, description); isPaymSuccess = (response == "OK"); if (isPaymSuccess) { if (MyUtils.MONTHLY_CHARGE_PLAN) { SetupBillingAndUpgradeMembership(amount); lblResult.Text = string.Format("Your card was charged {0} and your account was upgraded to VIP membership.", amount.ToString("c")); } else { BuyCreditsDB(amount, credits, MyUtils.ID_USER); lblResult.Text = string.Format("Your card was charged {0} and {1} credits were added to your account.", amount.ToString("c"), credits); } divForm.Visible = false; Session["success_text"] = lblResult.Text; Response.Redirect("/Account/Upgrade?ok=1"); return; } else { lblResult.Text = "Your card was not charged. ERROR: " + paym.error; heading.Attributes["style"] = "background-color:#c00"; } pnlMessage.Visible = true; }