public static Transaction ChargeOrder(GoogleCheckout instance, CaptureTransactionRequest captureRequest) { string env = instance.UseTestMode ? "Sandbox" : "Production"; string merchantId = instance.MerchantID; string merchantKey = instance.MerchantKey; string orderNum = captureRequest.Payment.Order.GoogleOrderNumber; string currency = captureRequest.Payment.CurrencyCode; if (currency == null || currency.Length == 0) { currency = "USD"; } LSDecimal amount = captureRequest.Amount; LSDecimal remainingCapture = captureRequest.Payment.Transactions.GetTotalAuthorized() - captureRequest.Payment.Transactions.GetTotalCaptured(); ChargeOrderRequest request = new ChargeOrderRequest(merchantId, merchantKey, env, orderNum, currency, amount); Util.GCheckoutResponse response = request.Send(); Transaction transaction = new Transaction(); transaction.Amount = captureRequest.Amount; transaction.ProviderTransactionId = orderNum; transaction.PaymentGatewayId = instance.PaymentGatewayId; if (remainingCapture > amount) { transaction.TransactionType = TransactionType.PartialCapture; } else { transaction.TransactionType = TransactionType.Capture; } if (response.IsGood) { transaction.TransactionStatus = TransactionStatus.Pending; } else { transaction.TransactionStatus = TransactionStatus.Failed; transaction.ResponseMessage = response.ErrorMessage; } return(transaction); }
private static void HandleOrderStateChangeNotification(GCheckout.AutoGen.OrderStateChangeNotification notification) { // Charge Order If Chargeable if ((notification.previousfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.REVIEWING) && (notification.newfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGEABLE)) { ChargeOrderRequest oneChargeOrderRequest = new ChargeOrderRequest(notification.googleordernumber); GCheckout.Util.GCheckoutResponse oneGCheckoutResponse = oneChargeOrderRequest.Send(); } // Update License If Charged if ((notification.previousfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGING) && (notification.newfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGED)) { // TODO: For each shopping cart item received in the NewOrderNotification, authorize the license } // TODO: Add custom processing for this notification type }