Exemplo n.º 1
0
        public void Report()
        {
            var iDealTransactionId = Request["transaction_id"];
            var payment = _paymentService.Query().ByThirdPartyTransactionId(iDealTransactionId, "iDeal");

            var paymentMethod = _paymentMethodService.Find(payment.PaymentMethodId);
            var settings = paymentMethod.LoadProcessorConfig<IDealConfig>();
            var idealCheck = new IdealCheck(settings.PartnerId, settings.TestMode, iDealTransactionId);

            ProcessPaymentResult result = null;

            if (idealCheck.Error)
            {
                result = ProcessPaymentResult.Failed(idealCheck.ErrorMessage, iDealTransactionId);
            }
            else if (idealCheck.Payed)
            {
                result = ProcessPaymentResult.Success(iDealTransactionId);
            }

            if (result != null)
            {
                _paymentService.AcceptProcessResult(payment, result);
            }
        }
Exemplo n.º 2
0
        public void Report()
        {
            var iDealTransactionId = Request["transaction_id"];
            var payment            = _paymentService.Query().ByThirdPartyTransactionId(iDealTransactionId, "iDeal");

            var paymentMethod = _paymentMethodService.Find(payment.PaymentMethodId);
            var settings      = paymentMethod.LoadProcessorConfig <IDealConfig>();
            var idealCheck    = new IdealCheck(settings.PartnerId, settings.TestMode, iDealTransactionId);

            ProcessPaymentResult result = null;

            if (idealCheck.Error)
            {
                result = ProcessPaymentResult.Failed(idealCheck.ErrorMessage, iDealTransactionId);
            }
            else if (idealCheck.Payed)
            {
                result = ProcessPaymentResult.Success(iDealTransactionId);
            }

            if (result != null)
            {
                _paymentService.AcceptProcessResult(payment, result);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Processes the callback.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="request">The request.</param>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        public override CallbackInfo ProcessCallback(Api.Models.Order order, System.Web.HttpRequest request, IDictionary <string, string> settings)
        {
            CallbackInfo callbackInfo = null;

            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("PartnerId", "settings");
                settings.MustContainKey("RoundingMode", "settings");

                // Call the validation URL to check this order
                IdealCheck idealCheck = new IdealCheck(settings["PartnerId"], settings["TestMode"] == "1", request["transaction_id"]);

                decimal orderAmount = order.TotalPrice.Value.WithVat;
                if (idealCheck.Payed)
                {
                    decimal mollieAmount = idealCheck.Amount;

                    // Check if amount that mollie received is equal to the orders amount
                    if (Math.Round(mollieAmount, 0) == Math.Round(orderAmount, Convert.ToInt32(settings["RoundingMode"])))
                    {
                        callbackInfo = new CallbackInfo(orderAmount, request["transaction_id"], PaymentState.Captured);
                        LoggingService.Instance.Info <MollieiDeal>(string.Format("Mollie: Saved and finalized orderId {0}", order.Id));
                    }
                    else
                    {
                        callbackInfo = new CallbackInfo(orderAmount, request["transaction_id"], PaymentState.Error);
                        LoggingService.Instance.Info <MollieiDeal>(string.Format("Mollie: Controle: MollieAmount:{0} OrderAmount: {1} do not match!", mollieAmount, orderAmount));
                    }
                }
                else
                {
                    LoggingService.Instance.Info <MollieiDeal>(string.Format("Mollie: Controle: iDeal status not payed, for cartId {0}!", order.Id));
                }
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <MollieiDeal>("ProcessCallback exception", exp);
            }

            return(callbackInfo);
        }
Exemplo n.º 4
0
 public static bool IsTransactionPayed(string transactionId, string mollieClientNumber, bool testMode)
 {
     IdealCheck idealCheck = new IdealCheck(mollieClientNumber, testMode, transactionId);
     return idealCheck.Payed;
 }
        private bool Handle(string transactionId)
        {
            var targetPayId = ConfigurationManager.AppSettings["TargetPayId"];
            //var targetPayId = Session["TargetPayId"] as string;
            var targetPayReturn = ConfigurationManager.AppSettings["TargetPayReturn"];
            //Check the payment (in testmode)
            IdealCheck idealCheck = new IdealCheck(targetPayId, transactionId);

            if (!idealCheck.IsOk)
            {
                //show error
                var error = "Error code: " + idealCheck.Error.Code + ", message: " + idealCheck.Error.Message;
                throw new Exception(error);

            }
            if (idealCheck.Payed)
            {
                /*************
                 * Payment succeeded, handle appropriately
                 ************/
                return true;
            }
            return false;
        }
Exemplo n.º 6
0
        public OrderInfo HandlePaymentResponse(PaymentProvider paymentProvider, OrderInfo orderInfo)
        {
            try
            {
                var transactionId = HttpContext.Current.Request["transaction_id"];

                Log.Instance.LogDebug("Mollie Transaction Id: " + transactionId);

                if (string.IsNullOrEmpty(transactionId))
                {
                    Log.Instance.LogError("Mollie: TransactionId IsNullOrEmpty");
                    return(null);
                }

                orderInfo = OrderHelper.GetOrder(transactionId);

                if (orderInfo == null)
                {
                    Log.Instance.LogError("Mollie: Order Not Found For TransactionId: " + transactionId);
                    return(null);
                }

                if (orderInfo.Paid != false)
                {
                    Log.Instance.LogDebug("Mollie: Order already paid! TransactionId: " + transactionId);
                    return(null);
                }

                var partnerId = paymentProvider.GetSetting("PartnerId");
                var testMode  = paymentProvider.TestMode;

                var idealCheck = new IdealCheck(partnerId, testMode, transactionId);

                if (idealCheck.Error)
                {
                    if (idealCheck.Message != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Error Error! idealCheck.Message: {0}", idealCheck.Message));
                    }
                    if (idealCheck.ErrorMessage != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Error Error! idealCheck.ErrorMessage: {0}", idealCheck.ErrorMessage));
                    }

                    if (orderInfo.Status == OrderStatus.ReadyForDispatch)
                    {
                        return(null);
                    }
                    orderInfo.Paid   = false;
                    orderInfo.Status = OrderStatus.PaymentFailed;

                    if (idealCheck.ErrorMessage != null)
                    {
                        orderInfo.PaymentInfo.ErrorMessage = idealCheck.ErrorMessage;
                    }
                }

                if (idealCheck.Payed)
                {
                    orderInfo.Paid   = true;
                    orderInfo.Status = OrderStatus.ReadyForDispatch;
                }
                else
                {
                    if (idealCheck.Message != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Payed Error! idealCheck.Message: {0}", idealCheck.Message));
                    }
                    if (idealCheck.ErrorMessage != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Payed Error! idealCheck.ErrorMessage: {0}", idealCheck.ErrorMessage));
                    }

                    orderInfo.Paid   = false;
                    orderInfo.Status = OrderStatus.PaymentFailed;
                    orderInfo.PaymentInfo.ErrorMessage = idealCheck.ErrorMessage;
                }

                orderInfo.Save();
            }
            catch (Exception ex)
            {
                Log.Instance.LogError("MolliePaymentResponseHandler.HandlePaymentResponse: " + ex);
            }

            return(null);
        }
        public OrderInfo HandlePaymentResponse(PaymentProvider paymentProvider, OrderInfo orderInfo)
        {
            try
            {
                var transactionId = HttpContext.Current.Request["transaction_id"];

                Log.Instance.LogDebug("Mollie Transaction Id: " + transactionId);

                if (string.IsNullOrEmpty(transactionId))
                {
                    Log.Instance.LogError("Mollie: TransactionId IsNullOrEmpty");
                    return null;
                }

                orderInfo = OrderHelper.GetOrder(transactionId);

                if (orderInfo == null)
                {
                    Log.Instance.LogError("Mollie: Order Not Found For TransactionId: " + transactionId);
                    return null;
                }

                if (orderInfo.Paid != false)
                {
                    Log.Instance.LogDebug("Mollie: Order already paid! TransactionId: " + transactionId);
                    return null;
                }

                var partnerId = paymentProvider.GetSetting("PartnerId");
                var testMode = paymentProvider.TestMode;

                var idealCheck = new IdealCheck(partnerId, testMode, transactionId);

                if (idealCheck.Error)
                {
                    if (idealCheck.Message != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Error Error! idealCheck.Message: {0}", idealCheck.Message));
                    }
                    if (idealCheck.ErrorMessage != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Error Error! idealCheck.ErrorMessage: {0}", idealCheck.ErrorMessage));
                    }

                    if (orderInfo.Status == OrderStatus.ReadyForDispatch)
                    {
                        return null;
                    }
                    orderInfo.Paid = false;
                    orderInfo.Status = OrderStatus.PaymentFailed;

                    if (idealCheck.ErrorMessage != null)
                    {
                        orderInfo.PaymentInfo.ErrorMessage = idealCheck.ErrorMessage;
                    }
                }

                if (idealCheck.Payed)
                {
                    orderInfo.Paid = true;
                    orderInfo.Status = OrderStatus.ReadyForDispatch;
                }
                else
                {
                    if (idealCheck.Message != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Payed Error! idealCheck.Message: {0}", idealCheck.Message));
                    }
                    if (idealCheck.ErrorMessage != null)
                    {
                        Log.Instance.LogError(string.Format("Mollie idealCheck.Payed Error! idealCheck.ErrorMessage: {0}", idealCheck.ErrorMessage));
                    }

                    orderInfo.Paid = false;
                    orderInfo.Status = OrderStatus.PaymentFailed;
                    orderInfo.PaymentInfo.ErrorMessage = idealCheck.ErrorMessage;
                }

                orderInfo.Save();
            }
            catch (Exception ex)
            {
                Log.Instance.LogError("MolliePaymentResponseHandler.HandlePaymentResponse: " + ex);
            }

            return null;
        }