Exemplo n.º 1
0
        private bool ProcessThePayment(Order order, Secure3DHandler model)
        {
            var result = false;
            var iyzicoPaymentSettings = _settingService.LoadSetting <IyzicoPaymentSettings>(_storeContext.CurrentStore.Id);

            Armut.Iyzipay.Options options = new Armut.Iyzipay.Options();

            options.ApiKey    = iyzicoPaymentSettings.APIKey;
            options.SecretKey = iyzicoPaymentSettings.SecretKey;
            options.BaseUrl   = iyzicoPaymentSettings.APIUrl;

            if (model.status.Equals("success"))
            {
                CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest();
                // request.Locale = Locale.TR.ToString();
                request.ConversationId   = model.conversationId;
                request.PaymentId        = model.paymentId;
                request.ConversationData = model.conversationData;
                // complete the 3DS
                ThreedsPayment threedsPayment = ThreedsPayment.Create(request, options);

                if (threedsPayment.Status.Equals("success"))
                {
                    result              = true;
                    order.OrderStatus   = OrderStatus.Processing;
                    order.PaymentStatus = PaymentStatus.Paid;
                }
                else
                {
                    order.OrderStatus   = OrderStatus.Cancelled;
                    order.PaymentStatus = PaymentStatus.Voided;
                    OrderError(threedsPayment.ErrorMessage, order);
                }
            }
            else
            {
                order.OrderStatus   = OrderStatus.Cancelled;
                order.PaymentStatus = PaymentStatus.Voided;
                OrderError($"Error mdStatus:{model.mdStatus}", order);
            }

            // clear card informations
            // if you want to keep that informations ignore the below part
            order.CardCvv2                     = string.Empty;
            order.CardName                     = string.Empty;
            order.CardNumber                   = string.Empty;
            order.CardExpirationYear           = string.Empty;
            order.CardExpirationMonth          = string.Empty;
            order.CardType                     = string.Empty;
            order.MaskedCreditCardNumber       = string.Empty;
            order.AllowStoringCreditCardNumber = false;

            _orderService.UpdateOrder(order);

            return(result);
        }
Exemplo n.º 2
0
        public void Should_Auth_Threeds()
        {
            CreateThreedsPaymentRequest createThreedsPaymentRequest = new CreateThreedsPaymentRequest();

            createThreedsPaymentRequest.ConversationData = "conversion data";
            createThreedsPaymentRequest.PaymentId        = "1";
            createThreedsPaymentRequest.Locale           = Locale.TR.ToString();
            createThreedsPaymentRequest.ConversationId   = "123456789";

            ThreedsPayment threedsPayment = ThreedsPayment.Create(createThreedsPaymentRequest, _options);

            PrintResponse(threedsPayment);
        }
Exemplo n.º 3
0
        public async Task Should_Auth_Threeds()
        {
            CreateThreedsPaymentRequest createThreedsPaymentRequest = new CreateThreedsPaymentRequest
            {
                ConversationData = "conversion data",
                PaymentId        = "1",
                Locale           = Locale.TR.ToString(),
                ConversationId   = "123456789"
            };

            ThreedsPayment threedsPayment = await ThreedsPayment.CreateAsync(createThreedsPaymentRequest, Options);

            PrintResponse(threedsPayment);
        }
Exemplo n.º 4
0
        public void Should_Create_Threeds_Payment()
        {
            CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest();

            request.Locale           = Locale.TR.ToString();
            request.ConversationId   = "123456789";
            request.PaymentId        = "1";
            request.ConversationData = "conversation data";

            ThreedsPayment threedsPayment = ThreedsPayment.Create(request, options);

            PrintResponse <ThreedsPayment>(threedsPayment);

            Assert.AreEqual(Status.SUCCESS.ToString(), threedsPayment.Status);
            Assert.AreEqual(Locale.TR.ToString(), threedsPayment.Locale);
            Assert.AreEqual("123456789", threedsPayment.ConversationId);
            Assert.IsNotNull(threedsPayment.SystemTime);
            Assert.IsNull(threedsPayment.ErrorCode);
            Assert.IsNull(threedsPayment.ErrorMessage);
            Assert.IsNull(threedsPayment.ErrorGroup);
        }
Exemplo n.º 5
0
        public async Task Should_Create_Threeds_Payment()
        {
            CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest
            {
                Locale           = Locale.TR.ToString(),
                ConversationId   = "123456789",
                PaymentId        = "1",
                ConversationData = "conversation data"
            };

            ThreedsPayment threedsPayment = await ThreedsPayment.CreateAsync(request, Options);

            PrintResponse(threedsPayment);

            Assert.AreEqual(Status.SUCCESS.ToString(), threedsPayment.Status);
            Assert.AreEqual(Locale.TR.ToString(), threedsPayment.Locale);
            Assert.AreEqual("123456789", threedsPayment.ConversationId);
            Assert.IsNotNull(threedsPayment.SystemTime);
            Assert.IsNull(threedsPayment.ErrorCode);
            Assert.IsNull(threedsPayment.ErrorMessage);
            Assert.IsNull(threedsPayment.ErrorGroup);
        }
Exemplo n.º 6
0
 // sync
 public static ThreedsPayment Create(CreateThreedsPaymentRequest request, Options options)
 {
     return(RestHttpClient.Create().Post <ThreedsPayment>(options.BaseUrl + "/payment/3dsecure/auth", GetHttpHeaders(request, options), request));
 }
Exemplo n.º 7
0
 // Async
 public static async Task <ThreedsPayment> CreateAsync(CreateThreedsPaymentRequest request, Options options)
 {
     return(await RestHttpClient.Create().PostAsync <ThreedsPayment>(options.BaseUrl + "/payment/3dsecure/auth", GetHttpHeaders(request, options), request));
 }
Exemplo n.º 8
0
        public override void DoOperation()
        {
            try
            {
                //Validate Reques Header / Constants
                this.baseResponseMessage = ValidateInput();
                if (!this.baseResponseMessage.header.IsSuccess)
                {
                    throw new Exception(this.baseResponseMessage.header.ResponseMessage);
                }

                Options baseHeader = null;
                string  errMsg     = "";
                string  errCode    = "";
                bool    result     = true;

                //Operation
                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region PAYMENT

                    //Create payments
                    Iyzipay.Request.CreatePaymentRequest paymentRequest = PrepareRequest(ref result, ref errMsg, ref baseHeader, ref errCode);
                    Payment payment = Payment.Create(paymentRequest, baseHeader);

                    RetrievePaymentRequest request = new RetrievePaymentRequest();
                    request.Locale                = Locale.TR.ToString();
                    request.ConversationId        = payment.ConversationId;
                    request.PaymentId             = payment.PaymentId;
                    request.PaymentConversationId = payment.ConversationId;

                    //check payments
                    Payment Checkpayments = Payment.Retrieve(request, baseHeader);
                    if (Checkpayments.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    bool checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = paymentRequest.CallbackUrl,
                        CARD_HOLDER_NAME = paymentRequest.PaymentCard.CardHolderName,
                        CARD_REF_NUMBER  = paymentRequest.PaymentCard.CardNumber,
                        CONVERSATION_ID  = payment.ConversationId,
                        CURRENCY         = payment.Currency,
                        CUSTOMER_NUMBER  = Convert.ToInt64(paymentRequest.Buyer.Id),
                        IP              = paymentRequest.Buyer.Ip,
                        PAID_PRICE      = payment.PaidPrice,
                        PRICE           = payment.Price,
                        PAYMENT_CHANNEL = paymentRequest.PaymentChannel,
                        PAYMENT_ID      = Checkpayments.PaymentId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region REFUND

                    //Create ReFund
                    FillOptionHeader(ref baseHeader);
                    CreateRefundRequest refundRequest = new CreateRefundRequest();
                    refundRequest.ConversationId       = this.request.CONVERSATION_ID;
                    refundRequest.Locale               = Locale.TR.ToString();
                    refundRequest.PaymentTransactionId = this.request.PAYMENT_ID;
                    refundRequest.Price    = this.request.PRICE;
                    refundRequest.Ip       = this.request.IP;
                    refundRequest.Currency = this.request.CURRENCY;

                    //check refund
                    Refund refund = Refund.Create(refundRequest, baseHeader);
                    if (refund.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception(" Geri ödeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);

                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = this.request.CALLBACK_URL,
                        CARD_HOLDER_NAME = this.request.CARD_HOLDER_NAME,
                        CARD_REF_NUMBER  = this.request.CARD_REF_NUMBER,
                        CONVERSATION_ID  = refundRequest.ConversationId,
                        CURRENCY         = refundRequest.Currency,
                        CUSTOMER_NUMBER  = this.request.CUSTOMER_NUMBER,
                        IP              = refundRequest.Ip,
                        PAID_PRICE      = refundRequest.Price,
                        PRICE           = refundRequest.Price,
                        PAYMENT_CHANNEL = this.request.PAYMENT_CHANNEL,
                        PAYMENT_ID      = refundRequest.PaymentTransactionId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region BKM PAYMENT

                    CreateBkmInitializeRequest requestBKM = PrepareBkmRequest(ref baseHeader);
                    BkmInitialize bkmInitialize           = BkmInitialize.Create(requestBKM, baseHeader);

                    RetrieveBkmRequest retrieveBKM = new RetrieveBkmRequest();
                    retrieveBKM.Locale         = Locale.TR.ToString();
                    retrieveBKM.ConversationId = "123456789";
                    retrieveBKM.Token          = "token";

                    Bkm bkm = Bkm.Retrieve(retrieveBKM, baseHeader);
                    if (bkm.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = requestBKM.CallbackUrl,
                        CARD_HOLDER_NAME = "",
                        CARD_REF_NUMBER  = "",
                        CONVERSATION_ID  = requestBKM.ConversationId,
                        CURRENCY         = "",
                        CUSTOMER_NUMBER  = Convert.ToInt64(requestBKM.Buyer.Id),
                        IP              = requestBKM.Buyer.Ip,
                        PAID_PRICE      = requestBKM.Price,
                        PRICE           = requestBKM.Price,
                        PAYMENT_CHANNEL = requestBKM.PaymentSource,
                        PAYMENT_ID      = requestBKM.BasketId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region 3D PAYMENT
                    //Initialize 3D Payment
                    Iyzipay.Request.CreatePaymentRequest payment3DRequest = Prepare3DRequest(ref baseHeader);
                    ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(payment3DRequest, baseHeader);
                    if (threedsInitialize.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }
                    //Create 3D Payment
                    CreateThreedsPaymentRequest create3Drequestpayment = new CreateThreedsPaymentRequest();
                    create3Drequestpayment.Locale           = Locale.TR.ToString();
                    create3Drequestpayment.ConversationId   = payment3DRequest.ConversationId;
                    create3Drequestpayment.PaymentId        = this.request.PAYMENT_ID;
                    create3Drequestpayment.ConversationData = "conversation data";    // ?????

                    ThreedsPayment threedsPayment = ThreedsPayment.Create(create3Drequestpayment, baseHeader);
                    if (threedsPayment.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = payment3DRequest.CallbackUrl,
                        CARD_HOLDER_NAME = payment3DRequest.PaymentCard.CardHolderName,
                        CARD_REF_NUMBER  = payment3DRequest.PaymentCard.CardNumber,
                        CONVERSATION_ID  = payment3DRequest.ConversationId,
                        CURRENCY         = payment3DRequest.Currency,
                        CUSTOMER_NUMBER  = Convert.ToInt64(payment3DRequest.Buyer.Id),
                        IP              = payment3DRequest.Buyer.Ip,
                        PAID_PRICE      = payment3DRequest.PaidPrice,
                        PRICE           = payment3DRequest.Price,
                        PAYMENT_CHANNEL = payment3DRequest.PaymentChannel,
                        PAYMENT_ID      = create3Drequestpayment.PaymentId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error("Payment Operation has an ERROR: [ERROR : " + ex.Message + "]");
                throw new Exception("Ödeme sirasinda hata oluştu.");
            }
        }
Exemplo n.º 9
0
 public static BasicThreedsPayment Create(CreateThreedsPaymentRequest request, Options options)
 {
     return(RestHttpClient.Instance.Post <BasicThreedsPayment>(options.BaseUrl + BasicThreedsPaymentUrl, GetHttpHeaders(request, options), request));
 }
Exemplo n.º 10
0
 public static async Task <BasicThreedsPayment> CreateAsync(CreateThreedsPaymentRequest request, Options options)
 {
     return(await RestHttpClient.Instance.PostAsync <BasicThreedsPayment>(options.BaseUrl + BasicThreedsPaymentUrl, GetHttpHeaders(request, options), request));
 }
Exemplo n.º 11
0
        public ActionResult IyziReturn()
        {
            var result           = Request.Form;
            var conversationId   = result["conversationId"].ToString();
            var conversationData = result["conversationData"].ToString();
            var paymentId        = result["paymentId"].ToString();
            var order            = db.Orders.Where(x => x.ConversationId == conversationId).FirstOrDefault();

            if (order != null)
            {
                if (order.Paid == false)
                {
                    if (result["status"] == "success" && result["mdStatus"] == "1")
                    {
                        Options options = new Options();
                        options.ApiKey    = ConfigurationManager.AppSettings["IyziApiKey"].ToString();
                        options.SecretKey = ConfigurationManager.AppSettings["IyziSecretKey"].ToString();
                        options.BaseUrl   = "https://sandbox-api.iyzipay.com";

                        CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest();
                        request.Locale           = Locale.TR.ToString();
                        request.ConversationId   = conversationId;
                        request.PaymentId        = paymentId;
                        request.ConversationData = conversationData;

                        ThreedsPayment threedsPayment = ThreedsPayment.Create(request, options);
                        if (threedsPayment.Status == "success")
                        {
                            order.Paid = true;
                        }
                        else
                        {
                            order.PaymentError = threedsPayment.ErrorMessage;
                        }
                    }
                    else
                    {
                        switch (result["mdStatus"])
                        {
                        case "0":
                            order.PaymentError = "3-D Secure imzası geçersiz veya doğrulama";
                            break;

                        case "2":
                            order.PaymentError = "Kart sahibi veya bankası sisteme kayıtlı değil";
                            break;

                        case "3":
                            order.PaymentError = "Kartın bankası sisteme kayıtlı değil";
                            break;

                        case "4":
                            order.PaymentError = "Doğrulama denemesi, kart sahibi sisteme daha sonra kayıt olmayı seçmiş";
                            break;

                        case "5":
                            order.PaymentError = "Doğrulama yapılamıyor";
                            break;

                        case "6":
                            order.PaymentError = "3-D Secure hatası";
                            break;

                        case "7":
                            order.PaymentError = "Sistem hatası";
                            break;

                        case "8":
                            order.PaymentError = "Bilinmeyen kart no";
                            break;

                        default:
                            break;
                        }
                    }
                    db.SaveChanges();
                }
            }


            return(RedirectToAction("Order", "MyOrders", new { id = order.OrderId }));
        }
Exemplo n.º 12
0
        public void Callback(string status, string paymentId, string conversationData, string conversationId, string mdStatus)
        {
            try
            {
                if (status == "success")
                {
                    if (mdStatus == "1")
                    {
                        Options options = new Options();
                        options.ApiKey    = "sandbox-OPMmAWhaJiQntmjPPVrolCuJ8XLWITGd";
                        options.SecretKey = "sandbox-wPykKvg4r9BZUGAlvFP08eOf90iYY9oS";
                        options.BaseUrl   = "https://sandbox-api.iyzipay.com";

                        CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest();
                        request.Locale           = Locale.TR.ToString();
                        request.ConversationId   = conversationId;
                        request.PaymentId        = paymentId;
                        request.ConversationData = conversationData;

                        ThreedsPayment threedsPayment = ThreedsPayment.Create(request, options);

                        if (threedsPayment.Status == "success")
                        {
                            OperationResult operationResult_order = _uow.Orders.Get(int.Parse(conversationId));
                            if (operationResult_order.IsSuccess)
                            {
                                Order order = (Order)operationResult_order.ReturnObject;
                                if (order != null)
                                {
                                    OperationResult operationResult_carts = _uow.Carts.GetMyCartsWithUserId(order.UserId);
                                    if (operationResult_carts.IsSuccess)
                                    {
                                        List <Cart> carts = (List <Cart>)operationResult_carts.ReturnObject;
                                        if (carts != null)
                                        {
                                            List <OrderDetail> orderDetails = new List <OrderDetail>();
                                            foreach (var cart in carts)
                                            {
                                                OrderDetail orderDetail2 = new OrderDetail()
                                                {
                                                    Order               = order,
                                                    OrderStatus         = OrderStatus.Approved,
                                                    Quantity            = cart.Quantity,
                                                    ProductAmountTypeId = cart.ProductAmountType.Id,
                                                    TotalPrice          = cart.ProductAmountType.Price * cart.Quantity,
                                                };

                                                orderDetails.Add(orderDetail2);
                                            }

                                            OperationResult operationResult_orderDetails = _uow.OrderDetails.AddRange(orderDetails);
                                            if (operationResult_orderDetails.IsSuccess)
                                            {
                                                _hubContext.Clients.All.checkoutNav();

                                                foreach (var cart in carts)
                                                {
                                                    _uow.Carts.Delete(cart);
                                                }


                                                order.OrderStatus = OrderStatus.Approved;
                                                _uow.SaveChanges();

                                                PaymentResult paymentResult = new PaymentResult()
                                                {
                                                    AuthCode                     = threedsPayment.AuthCode,
                                                    BasketId                     = threedsPayment.BasketId,
                                                    BinNumber                    = threedsPayment.BinNumber,
                                                    CardAssociation              = threedsPayment.CardAssociation,
                                                    CardFamily                   = threedsPayment.CardFamily,
                                                    CardToken                    = threedsPayment.CardToken,
                                                    CardType                     = threedsPayment.CardType,
                                                    CardUserKey                  = threedsPayment.CardUserKey,
                                                    ConnectorName                = threedsPayment.ConnectorName,
                                                    IyziCommissionRateAmount     = threedsPayment.IyziCommissionRateAmount,
                                                    Currency                     = threedsPayment.Currency,
                                                    FraudStatus                  = threedsPayment.FraudStatus,
                                                    Installment                  = threedsPayment.Installment,
                                                    IyziCommissionFee            = threedsPayment.IyziCommissionFee,
                                                    MerchantCommissionRate       = threedsPayment.IyziCommissionFee,
                                                    MerchantCommissionRateAmount = threedsPayment.MerchantCommissionRateAmount,
                                                    PaidPrice                    = threedsPayment.PaidPrice,
                                                    PaymentId                    = threedsPayment.PaymentId,
                                                    PaymentStatus                = threedsPayment.PaymentStatus,
                                                    Phase        = threedsPayment.Phase,
                                                    Price        = threedsPayment.Price,
                                                    PaymentItems = threedsPayment.PaymentItems.Select(x => new Entities.DbModels.PaymentItem()
                                                    {
                                                        BlockageRate = x.BlockageRate,
                                                        BlockageRateAmountMerchant    = x.BlockageRateAmountMerchant,
                                                        BlockageRateAmountSubMerchant = x.BlockageRateAmountSubMerchant,
                                                        BlockageResolvedDate          = x.BlockageResolvedDate,
                                                        ItemId            = x.ItemId,
                                                        IyziCommissionFee = x.IyziCommissionFee,
                                                        ConvertedPayout   = new Entities.DbModels.ConvertedPayout()
                                                        {
                                                            BlockageRateAmountMerchant    = x.ConvertedPayout.BlockageRateAmountMerchant,
                                                            BlockageRateAmountSubMerchant = x.ConvertedPayout.BlockageRateAmountSubMerchant,
                                                            Currency                 = x.ConvertedPayout.Currency,
                                                            IyziCommissionFee        = x.ConvertedPayout.IyziCommissionFee,
                                                            IyziCommissionRateAmount = x.ConvertedPayout.IyziCommissionRateAmount,
                                                            IyziConversionRate       = x.ConvertedPayout.IyziConversionRate,
                                                            IyziConversionRateAmount = x.ConvertedPayout.IyziConversionRateAmount,
                                                            MerchantPayoutAmount     = x.ConvertedPayout.MerchantPayoutAmount,
                                                            PaidPrice                = x.ConvertedPayout.PaidPrice,
                                                            SubMerchantPayoutAmount  = x.ConvertedPayout.SubMerchantPayoutAmount
                                                        },
                                                        IyziCommissionRateAmount     = x.IyziCommissionRateAmount,
                                                        MerchantCommissionRate       = x.MerchantCommissionRate,
                                                        MerchantCommissionRateAmount = x.MerchantCommissionRateAmount,
                                                        MerchantPayoutAmount         = x.MerchantPayoutAmount,
                                                        PaidPrice            = x.PaidPrice,
                                                        PaymentTransactionId = x.PaymentTransactionId,
                                                        Price                   = x.Price,
                                                        SubMerchantKey          = x.SubMerchantKey,
                                                        SubMerchantPayoutAmount = x.SubMerchantPayoutAmount,
                                                        SubMerchantPayoutRate   = x.SubMerchantPayoutRate,
                                                        SubMerchantPrice        = x.SubMerchantPrice,
                                                        TransactionStatus       = x.TransactionStatus
                                                    }).ToList(),
                                                    OrderId = order.Id,
                                                    UserId  = order.UserId
                                                };

                                                _uow.PaymentResults.Add(paymentResult);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        else
                                        {
                                        }
                                    }
                                    else
                                    {
                                    }
                                }
                                else
                                {
                                }
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 13
0
        public IActionResult Success(IFormCollection form)
        {
            var processor = _paymentService.LoadPaymentMethodBySystemName(IyzicoPayPaymentDefaults.SystemName) as IyzicoPayPaymentProcessor;

            if (processor == null || !_paymentService.IsPaymentMethodActive(processor) || !processor.PluginDescriptor.Installed)
            {
                throw new NopException("Iyzico  module cannot be loaded");
            }
            var model = new SuccessModel();
            CreateThreedsPaymentRequest threquest = new CreateThreedsPaymentRequest();

            threquest.Locale           = Locale.TR.ToString();
            threquest.PaymentId        = form["paymentId"];
            threquest.ConversationData = form["conversationData"];
            threquest.ConversationId   = form["conversationId"];
            ThreedsPayment threedsPayment = ThreedsPayment.Create(threquest,
                                                                  HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings));

            if (threedsPayment.Status == "success")
            {
                if (form["mdStatus"] == "1")
                {
                    var customer = _customerService.GetCustomerByGuid(new Guid(threedsPayment.ConversationId));
                    var query    = _orderService.SearchOrders(customerId: customer.Id).ToList();
                    var order    = query.FirstOrDefault();
                    order.PaymentStatus = threedsPayment.FraudStatus == 1 ? PaymentStatus.Paid : PaymentStatus.Pending;
                    order.OrderStatus   = OrderStatus.Processing;
                    order.AuthorizationTransactionId   = threedsPayment.PaymentId;
                    order.AuthorizationTransactionCode = threedsPayment.AuthCode;
                    order.PaidDateUtc = DateTime.UtcNow;
                    var paymentrequest = new ProcessPaymentRequest();
                    var ordernote      = new OrderNote();
                    ordernote.DisplayToCustomer = false;
                    ordernote.CreatedOnUtc      = DateTime.UtcNow;
                    ordernote.Note = "Fraud:" + threedsPayment.FraudStatus;

                    paymentrequest.CustomValues.Add("fraudstatus", threedsPayment.FraudStatus);
                    foreach (var item in threedsPayment.PaymentItems)
                    {
                        ordernote.Note += string.Format("{0}{1}", item.ItemId, item.PaymentTransactionId);
                    }
                    order.OrderNotes.Add(ordernote);
                    _orderService.UpdateOrder(order);;
                    _orderService.UpdateOrder(order);
                    if (_orderSettings.OnePageCheckoutEnabled)
                    {
                        return(RedirectToRoute("HomePage"));
                    }
                    return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }));
                }
                else
                {
                    switch (form["mdStatus"])
                    {
                    case "0": model.Errorr = "3-D Secure imzası geçersiz veya doğrulama"; break;

                    case "2": model.Errorr = "Kart sahibi veya bankası sisteme kayıtlı değil"; break;

                    case "3": model.Errorr = "Kartın bankası sisteme kayıtlı değil"; break;

                    case "4": model.Errorr = "Doğrulama denemesi, kart sahibi sisteme daha sonra kayıt olmayı seçmiş"; break;

                    case "5": model.Errorr = "Doğrulama yapılamıyor"; break;

                    case "6": model.Errorr = "3-D Secure hatası"; break;

                    case "7": model.Errorr = "Sistem hatası"; break;

                    case "8": model.Errorr = "Bilinmeyen kart no"; break;

                    default: model.Errorr = "Hata Oluştu"; break;
                    }
                    return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model));
                }
            }
            else
            {
                model.Errorr = threedsPayment.ErrorMessage;
                return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model));
            }
        }
Exemplo n.º 14
0
 public static BasicThreedsPayment Create(CreateThreedsPaymentRequest request, Options options)
 {
     return(RestHttpClient.Create().Post <BasicThreedsPayment>(options.BaseUrl + "/payment/3dsecure/auth/basic", request, options));
 }