Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static void UnarchiveOrder(GoogleCheckout instance, string googleOrderNumber)
        {
            string env         = instance.UseTestMode ? "Sandbox" : "Production";
            string merchantId  = instance.MerchantID;
            string merchantKey = instance.MerchantKey;

            UnarchiveOrderRequest request = new UnarchiveOrderRequest(merchantId, merchantKey, env, googleOrderNumber);

            Util.GCheckoutResponse response = request.Send();

            if (response.IsGood)
            {
                Utility.Logger.Debug("Unarchive Order Request initiated successfuly. GoogleOrderNumber=" + googleOrderNumber);
            }
            else
            {
                Utility.Logger.Debug("Unarchive Order Request could not be initiated. ErrorMessage=" + response.ErrorMessage);
            }
        }
Esempio n. 3
0
        public static void AddTrackingData(GoogleCheckout instance, string googleOrderNumber, string carrier, string trackingNo)
        {
            string env         = instance.UseTestMode ? "Sandbox" : "Production";
            string merchantId  = instance.MerchantID;
            string merchantKey = instance.MerchantKey;

            AddTrackingDataRequest request = new AddTrackingDataRequest(merchantId, merchantKey, env, googleOrderNumber, carrier, trackingNo);

            Util.GCheckoutResponse response = request.Send();

            if (response.IsGood)
            {
                Utility.Logger.Debug("Add Tracking Data Request initiated successfuly. GoogleOrderNumber=" + googleOrderNumber);
            }
            else
            {
                Utility.Logger.Warn("Add Tracking Data Request could not be initiated. ErrorMessage=" + response.ErrorMessage);
            }
        }
Esempio n. 4
0
        public static void AddMerchantOrderNumber(GoogleCheckout instance, string googleOrderNumber, string acOrderNumber)
        {
            string env         = instance.UseTestMode ? "Sandbox" : "Production";
            string merchantId  = instance.MerchantID;
            string merchantKey = instance.MerchantKey;

            AddMerchantOrderNumberRequest onReq =
                new AddMerchantOrderNumberRequest(merchantId, merchantKey, env, googleOrderNumber, acOrderNumber);

            Util.GCheckoutResponse resp = onReq.Send();

            if (resp.IsGood)
            {
                Utility.Logger.Debug("Add Merchant Order Number Request initiated successfuly. GoogleOrderNumber=" + googleOrderNumber
                                     + " AC OrderNumber=" + acOrderNumber);
            }
            else
            {
                Utility.Logger.Debug("Add Merchant Order Number Request could not be initiated. ErrorMessage=" + resp.ErrorMessage);
            }
        }