Пример #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);
        }
Пример #2
0
        private Armut.Iyzipay.Options IyzicoConfig()
        {
            var iyzicoPaymentSettings =
                _settingService.LoadSetting <IyzicoPaymentSettings>(_storeContext.CurrentStore.Id);

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

            options.ApiKey    = iyzicoPaymentSettings.APIKey;
            options.SecretKey = iyzicoPaymentSettings.SecretKey;
            options.BaseUrl   = iyzicoPaymentSettings.APIUrl;
            return(options);
        }
Пример #3
0
        /// <summary>
        /// Get installment
        /// </summary>
        /// <param name="processPaymentRequest">Process Payment Request</param>
        /// <param name="paymentCard">Payment Card</param>
        /// <param name="options">Iyzipay Options</param>
        /// <returns>installment</returns>
        private Installment GetInstallment(ProcessPaymentRequest processPaymentRequest, PaymentCard paymentCard, Armut.Iyzipay.Options options)
        {
            int.TryParse((string)processPaymentRequest.CustomValues.GetValueOrDefault(_localizationService.GetResource("Plugins.Payments.Iyzico.Installment")), out int formInstallment);

            var retrieveInstallmentInfoRequest = new RetrieveInstallmentInfoRequest()
            {
                BinNumber      = paymentCard.CardNumber.ToString(),
                Locale         = Locale.TR.ToString(),
                Price          = _priceCalculationService.RoundPrice(processPaymentRequest.OrderTotal).ToString("f8", CultureInfo.InvariantCulture),
                ConversationId = string.Empty
            };
            var installmentInfo = InstallmentInfo.Retrieve(retrieveInstallmentInfoRequest, options);

            var installment = new Installment()
            {
                InstallmentNumber = 1,
                TotalPrice        = _priceCalculationService.RoundPrice(processPaymentRequest.OrderTotal).ToString("f8", CultureInfo.InvariantCulture)
            };

            if (installmentInfo.Status == "success" && installmentInfo.InstallmentDetails.Count > 0)
            {
                var installmentDetail = installmentInfo.InstallmentDetails.FirstOrDefault().InstallmentPrices.FirstOrDefault(x => x.InstallmentNumber == formInstallment);

                installment.InstallmentNumber = installmentDetail.InstallmentNumber ?? 1;
                installment.TotalPrice        = installmentDetail.TotalPrice.Replace(".", ",");
            }

            return(installment);
        }