/// <summary> /// Handles the Click event of the ChargeButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ChargeButton_Click(object sender, EventArgs e) { Label orderNumberLbl = (Label)LoginView.FindControl("GoogleOrderNumberLabel"); GCheckout.OrderProcessing.ChargeOrderRequest chargeReq = new GCheckout.OrderProcessing.ChargeOrderRequest(orderNumberLbl.Text); chargeReq.Send(); }
private void GoogleChargeOrder(string gatewayOrderID) { string orderID = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID); Order order = DataAccessContext.OrderRepository.GetOne(orderID); Log.Debug("Start Auto Charge for Google"); GCheckout.OrderProcessing.ChargeOrderRequest Req = new GCheckout.OrderProcessing.ChargeOrderRequest( WebConfiguration.GoogleMerchantID, WebConfiguration.GoogleMerchantKey, WebConfiguration.GoogleEnvironment, order.GatewayOrderID, DataAccessContext.Configurations.GetValue("PaymentCurrency"), order.Total); GCheckoutResponse R = Req.Send(); if (!R.IsGood) { Log.Debug("Can not charge - Response: " + R.ResponseXml + "\n"); Log.Debug("Can not charge - RedirectUrl: " + R.RedirectUrl + "\n"); Log.Debug("Can not charge - IsGood: " + R.IsGood + "\n"); Log.Debug("Can not charge - ErrorMessage: " + R.ErrorMessage + "\n"); SendChargeFailureEmail(order); } Log.Debug("End Auto Charge for Google"); }
private static void HandleOrderStateChangeNotification(GCheckout.AutoGen.OrderStateChangeNotification inputOrderStateChangeNotification) { // Charge Order If Chargeable if ((inputOrderStateChangeNotification.previousfinancialorderstate.ToString().Equals("REVIEWING")) && (inputOrderStateChangeNotification.newfinancialorderstate.ToString().Equals("CHARGEABLE"))) { GCheckout.OrderProcessing.ChargeOrderRequest oneChargeOrderRequest = new GCheckout.OrderProcessing.ChargeOrderRequest(inputOrderStateChangeNotification.googleordernumber); GCheckout.Util.GCheckoutResponse oneGCheckoutResponse = oneChargeOrderRequest.Send(); } // Update License If Charged if ((inputOrderStateChangeNotification.previousfinancialorderstate.ToString().Equals("CHARGING")) && (inputOrderStateChangeNotification.newfinancialorderstate.ToString().Equals("CHARGED"))) { // TODO: For each shopping cart item received in the NewOrderNotification, authorize the license } // TODO: Add custom processing for this notification type }
/// <summary> /// Handles the Click event of the ChargePartialButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ChargePartialButton_Click(object sender, EventArgs e) { Label orderNumberLbl = (Label)LoginView.FindControl("GoogleOrderNumberLabel"); TextBox partialAmountTB = (TextBox)LoginView.FindControl("PartialAmountTextBox"); Label totalAmountLbl = (Label)LoginView.FindControl("TotalAmountLabel"); Label statusLabel = (Label)LoginView.FindControl("StatusLabel"); Panel partialChargingPanel = (Panel)LoginView.FindControl("PartialChargingPanel"); RangeValidator validator = (RangeValidator)LoginView.FindControl("PartialAmountRangeValidator"); decimal total = decimal.Parse(totalAmountLbl.Text); decimal amount = 0; validator.MaximumValue = total.ToString(); if (decimal.TryParse(partialAmountTB.Text, out amount) && amount != 0 && amount <= total) { GCheckout.OrderProcessing.ChargeOrderRequest chargeReq = new GCheckout.OrderProcessing.ChargeOrderRequest(orderNumberLbl.Text, "USD", amount); chargeReq.Send(); statusLabel.Text = ""; partialChargingPanel.Visible = false; } else { statusLabel.Text = "The entered amount is not correct!"; } }
public void ChargeOrderRequest() { ChargeOrderRequest Req; AutoGen.ChargeOrderRequest D; // Test the first constructor. Req = new ChargeOrderRequest(MERCHANT_ID, MERCHANT_KEY, "Sandbox", ORDER_NUMBER); D = (AutoGen.ChargeOrderRequest)EncodeHelper.Deserialize(Req.GetXml()); Assert.AreEqual(ORDER_NUMBER, D.googleordernumber); Assert.AreEqual(null, D.amount); // Test the second constructor. Req = new ChargeOrderRequest(MERCHANT_ID, MERCHANT_KEY, "Sandbox", ORDER_NUMBER, "GBP", 10.2m); D = (AutoGen.ChargeOrderRequest)EncodeHelper.Deserialize(Req.GetXml()); Assert.AreEqual(ORDER_NUMBER, D.googleordernumber); Assert.AreEqual("GBP", D.amount.currency); Assert.AreEqual(10.2m, D.amount.Value); Req = new ChargeOrderRequest(ORDER_NUMBER); D = (AutoGen.ChargeOrderRequest)EncodeHelper.Deserialize(Req.GetXml()); Assert.AreEqual(Req.GoogleOrderNumber, D.googleordernumber); Req = new ChargeOrderRequest(ORDER_NUMBER, "USD", 12.975m); D = (AutoGen.ChargeOrderRequest)EncodeHelper.Deserialize(Req.GetXml()); Assert.AreEqual(Req.GoogleOrderNumber, D.googleordernumber); Assert.AreEqual(Req.Amount, 12.98m); }