public async Task <ActionResult <PaymentProcessExtModel> > PostPaymentProcess(PaymentProcessModel paymentProcess)
        {
            try
            {
                // Request validation
                PaymentProcessValidator _validator = new PaymentProcessValidator();
                ValidationResult        result     = _validator.Validate(paymentProcess);
                if (!result.IsValid)
                {
                    return(BadRequest(result.Errors));
                }

                PaymentProcess _paymentProcess = _mapper.Map <PaymentProcess>(paymentProcess);
                _paymentProcess.Id     = Guid.NewGuid().ToString();
                _paymentProcess.Status = PaymentStatus.PENDING;
                _paymentProcess.Tries  = 0;

                _ = _unitOfWork.PaymentProcesses.InsertAsync(_paymentProcess);

                await _unitOfWork.CompleteAsync();

                return(Ok(_paymentProcess));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
        private void payWithMobileWallet(object sender, EventArgs eventArgs)
        {
            /* Vipps Payment
             *
             * isTestMode - true if Test environment and false for Production.
             */
            //PaymentProcess.WalletPayment walletProcess = PaymentProcess.Vipps(true, this);


            /*
             * Swish Payment
             */
            //PaymentProcess.WalletPayment walletProcess = PaymentProcess.Swish(this);


            /*
             * MobilePay Payment
             */
            PaymentProcess.WalletPayment walletProcess = PaymentProcess.MobilePay(this);

            bool canLaunch = PiaSDK.InitiateMobileWallet(walletProcess, this);

            if (!canLaunch)
            {
                Toast.MakeText(this, "Wallet is not installed", ToastLength.Short).Show();
                return;
            }
        }
        public async Task <bool> InsertPayment(PaymentProcess paymentprocess)
        {
            PaymentProcess _paymentProcess = new PaymentProcess();

            _paymentProcess = context.PaymentProcesses.Where(x => x.CreditCardNumber == paymentprocess.CreditCardNumber).FirstOrDefault();

            if (_paymentProcess != null)
            {
                _paymentProcess.ExpirationDate = paymentprocess.ExpirationDate;
                _paymentProcess.Amount         = paymentprocess.Amount;
            }
            else
            {
                context.PaymentProcesses.Add(new PaymentProcess
                {
                    CardHolder       = paymentprocess.CardHolder,
                    CreditCardNumber = paymentprocess.CreditCardNumber,
                    Amount           = paymentprocess.Amount,
                    ExpirationDate   = paymentprocess.ExpirationDate,
                    SecurityCode     = paymentprocess.SecurityCode,
                    IsDeleted        = false,
                    CreatedBy        = "Super Admin"
                });
            }

            return(await context.Instance.SaveChangesAsync() > 0);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            PaymentProcess payment = new PaymentProcess();

            payment.Pay("ABC123");

            Console.ReadLine();
        }
        public void ProcessPayment(PaymentProcess payment)
        {
            var response = _bankservice.ProcessPayment(payment);

            payment.Status       = response.ResponseStatus.ToString();
            payment.Guid         = response.Guid.ToString();
            payment.MaskedNumber = MaskingCardNumber.Mask(payment.CardNumber.ToString(), 0, 12);

            _repository.ProcessPayment(payment);
        }
Exemple #6
0
        public ActionResult ProcessPayment([FromBody] PaymentProcess payment)
        {
            if (payment == null || _validationService.ValidateProcess(payment) == false)
            {
                return(NotFound());
            }

            _customerService.ProcessPayment(payment);

            return(Ok(payment));
        }
Exemple #7
0
        /// <summary>
        /// To save the details of the payment process
        /// </summary>
        /// <param name="paymentProcessData"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public bool AddPaymentProcessData(PaymentProcess paymentProcessData, out string errorMessage)
        {
            errorMessage = string.Empty;
            try
            {
                var entity = context.PaymentProcess.Add(paymentProcessData);
                entity.State = EntityState.Added;
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                errorMessage = ex.ToString();
                return(false);
            }

            return(true);
        }
Exemple #8
0
        public void ShouldCreateRealStepsForProvidedListOfReservationStepTypes()
        {
            var dummyStepTypes = new List <ReservationStepType> {
                ReservationStepType.PaymentProcess, ReservationStepType.ReservationProcess
            };

            var firstStepDouble  = new PaymentProcess();
            var secondStepDouble = new ReservationStartProcess();

            A.CallTo(() => _stepFactoryDouble.CreateInstance(ReservationStepType.PaymentProcess)).Returns(firstStepDouble);
            A.CallTo(() => _stepFactoryDouble.CreateInstance(ReservationStepType.ReservationProcess)).Returns(secondStepDouble);

            var expectedStepsInstances = new List <IReservationStep> {
                firstStepDouble, secondStepDouble
            };

            _subject.Execute(dummyStepTypes).Should().Equal(expectedStepsInstances);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            //DIP - Principio da inversão da dependência
            //Criar modulos que não estão ligados
            //Um modulo de alto nivel nao pode depender de um modulo de baixo nivel
            //Ambos precisam depender apenas de abstrações

            //Modulos de alto nivel, é o lugar onde estão as regras de negocio.
            //Modulos de baixo nivel, são as tarefas realizadas pela nossa aplicação. São os detalhes. Data access SQL, Auteticação...

            //Nesse exemplo vamos dizer que precisam usar banco de dados MongoDB e MYSQL

            PaymentProcess payment = new PaymentProcess();

            payment.Pay("ABC123");

            Console.ReadLine();
        }
        public int InsertPaymentTransactionWithSuccess(PaymentProcess objpp)
        {
            string        connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringId].ToString();
            SqlConnection CN = new SqlConnection(connectionString);
            int           status;

            try
            {
                using (SqlCommand CMD = new SqlCommand())
                {
                    CN.Open();
                    CMD.Connection = CN;

                    CMD.CommandType = System.Data.CommandType.StoredProcedure;
                    CMD.CommandText = "sptPaymentProcess";
                    CMD.Parameters.Add(new SqlParameter("@StudentNo", objpp.StudentNo));
                    CMD.Parameters.Add(new SqlParameter("@ssl_txn_id", objpp.ssl_txn_id));
                    CMD.Parameters.Add(new SqlParameter("@ssl_txn_time", objpp.ssl_txn_time));
                    CMD.Parameters.Add(new SqlParameter("@ssl_token", objpp.ssl_token));
                    CMD.Parameters.Add(new SqlParameter("@ssl_token_response", objpp.ssl_token_response));
                    CMD.Parameters.Add(new SqlParameter("@ssl_result", objpp.ssl_result));
                    CMD.Parameters.Add(new SqlParameter("@ssl_result_message", objpp.ssl_result_message));
                    CMD.Parameters.Add(new SqlParameter("@ssl_approval_code", objpp.ssl_approval_code));
                    CMD.Parameters.Add(new SqlParameter("@ssl_amount", objpp.ssl_amount));
                    CMD.Parameters.Add(new SqlParameter("@errorCode", DBNull.Value));
                    CMD.Parameters.Add(new SqlParameter("@errorName", DBNull.Value));
                    CMD.Parameters.Add(new SqlParameter("@errorMsg", DBNull.Value));
                    CMD.Parameters.Add(new SqlParameter("@PaymentSource", objpp.PaymentSource));
                    CMD.Parameters.Add(new SqlParameter("@MiscID", objpp.MiscID));
                    CMD.Parameters.Add(new SqlParameter("@LeadsID", objpp.LeadsID));
                    CMD.Parameters.Add(new SqlParameter("@PaymentType", objpp.PaymentType));
                    status = CMD.ExecuteNonQuery();
                    CN.Close();

                    return(status);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Exemple #11
0
        public void ProcessPayment(PaymentProcess payment)
        {
            var commandProcessPayment = RepositoryCommands.ProcessPayment;
            var args = new
            {
                CardN       = payment.CardName,
                MaskedNumb  = payment.MaskedNumber,
                ExpiryDat   = payment.ExpiryDate,
                AmountPay   = payment.Amount,
                Cur         = payment.Currency,
                Cvv         = payment.CVV,
                GeneratedId = payment.Guid,
                Stat        = payment.Status
            };

            using (var connection = _connectionFactory.Create())
            {
                connection.Query <string>(commandProcessPayment, args);
            }
        }
 public ResponseModel ProcessPayment(PaymentProcess payment)
 {
     return(_responseFactory.create());
 }
Exemple #13
0
 public async Task <bool> InsertPayment(PaymentProcess paymentprocess)
 {
     return(await paymentRepository.InsertPayment(paymentprocess));
 }
 /// <summary>
 /// Not allow negative amounts and expiry dates longer than actual time
 /// </summary>
 /// <param name="payment"></param>
 /// <returns></returns>
 public bool ValidateProcess(PaymentProcess payment)
 {
     return(payment.Amount < 0 || payment.ExpiryDate < DateTime.UtcNow ? false : true);
 }
        public async Task <System.Web.Http.IHttpActionResult> InsertPaymentProcessData(PaymentProcess paymentprocess)
        {
            bool inserted = false;

            if (ValidateCreditCard(paymentprocess.CreditCardNumber))
            {
                if (IsCreditCardInfoValid(paymentprocess.ExpirationDate, paymentprocess.SecurityCode))
                {
                    if (paymentprocess.Amount > 0)
                    {
                        inserted = await paymentService.InsertPayment(paymentprocess);

                        if (inserted)
                        {
                            if (paymentprocess.Amount <= 20)
                            {
                                if (await cheapPaymentGatewayService.AnalysisPaymentByThisGatewayProcessed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await cheapPaymentGatewayService.AnalysisPaymentByThisGatewayPending(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await cheapPaymentGatewayService.AnalysisPaymentByThisGatewayFailed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                            }
                            else if (paymentprocess.Amount >= 21 && paymentprocess.Amount <= 500)
                            {
                                if (await expensivePaymentGatewayService.AnalysisPaymentByThisGatewayProcessed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await expensivePaymentGatewayService.AnalysisPaymentByThisGatewayPending(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await expensivePaymentGatewayService.AnalysisPaymentByThisGatewayFailed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                            }
                            else if (paymentprocess.Amount > 500)
                            {
                                if (await premiumPaymentService.AnalysisPaymentByThisGatewayProcessed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await premiumPaymentService.AnalysisPaymentByThisGatewayPending(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                                else if (await premiumPaymentService.AnalysisPaymentByThisGatewayFailed(paymentprocess.Amount, paymentprocess.CreditCardNumber))
                                {
                                    return((System.Web.Http.IHttpActionResult)Ok());
                                }
                            }

                            return((System.Web.Http.IHttpActionResult)Ok());
                        }
                        else if (!inserted)
                        {
                            return((System.Web.Http.IHttpActionResult)BadRequest());
                        }
                        else
                        {
                            return((System.Web.Http.IHttpActionResult)StatusCode(500));
                        }
                    }
                    else
                    {
                        return((System.Web.Http.IHttpActionResult)BadRequest("Amount can never be negative or zero"));
                    }
                }
                else
                {
                    return((System.Web.Http.IHttpActionResult)BadRequest("Expiry Date or CVV no is invalid"));
                }
            }
            else
            {
                return((System.Web.Http.IHttpActionResult)BadRequest("Credit card is invalid"));
            }
        }
 public void BeforeTest()
 {
     _subject = new PaymentProcess();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIButton payWithCard = new UIButton();
            float    buttonWidth = (float)UIScreen.MainScreen.Bounds.Width - 80f;

            payWithCard.Frame = new CGRect(40f, 40f, buttonWidth, 40f);
            payWithCard.SetTitle("Pay 10 EUR with Card", UIControlState.Normal);
            payWithCard.BackgroundColor = UIColor.LightGray;

            payWithCard.TouchUpInside += (sender, e) =>
            {
                var merchantInfo = MerchantDetails.MerchantWithID("YOUR_MERCHANT_ID", true);

                CardPaymentProcess cardPayment = PaymentProcess.CardPaymentWithMerchant(merchantInfo, 1000, @"EUR");


                var controller = PiaSDK.ControllerForCardPaymentProcess(cardPayment, true,
                                                                        transactionCallback: (savecard, callback) => {
                    registerCardPaymnet(false, completionHandler: () => {
                        if (transactionInfo != null)
                        {
                            callback(CardRegistrationResponse.SuccessWithTransactionID(transactionInfo.TransactionID, transactionInfo.redirectUrl));
                        }
                        else
                        {
                            callback(CardRegistrationResponse.Failure(registrationError));
                        }
                    });;
                },
                                                                        success: (piaController) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert("Payment is successfull");
                        });
                    });
                },
                                                                        cancellation: (piaController) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert("transaction cancelled");
                        });
                    });
                },
                                                                        failure: (piaController, error) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert(error.LocalizedDescription);
                        });
                    });
                });

                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCard = new UIButton();

            payWithSavedCard.Frame = new CGRect(40f, 120f, buttonWidth, 40f);
            payWithSavedCard.SetTitle("Pay 10 EUR with Saved Card", UIControlState.Normal);
            payWithSavedCard.BackgroundColor = UIColor.LightGray;

            payWithSavedCard.TouchUpInside += (sender, e) =>
            {
                var merchantId = "YOUR_MERCHANT_ID";

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(true, tokenCardInfo, merchantId, orderInfo, true);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCardSkipConfirmation = new UIButton();

            payWithSavedCardSkipConfirmation.Frame = new CGRect(40f, 200f, buttonWidth, 80f);
            payWithSavedCardSkipConfirmation.SetTitle("Pay 10 EUR - Saved Card(Skip confirmation)", UIControlState.Normal);
            payWithSavedCardSkipConfirmation.LineBreakMode   = UILineBreakMode.WordWrap;
            payWithSavedCardSkipConfirmation.BackgroundColor = UIColor.LightGray;

            payWithSavedCardSkipConfirmation.TouchUpInside += (sender, e) =>
            {
                var merchantInfo = new NPIMerchantInfo("YOUR_MERCHANT_ID", true, true);

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(tokenCardInfo, merchantInfo, orderInfo);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithMobilePay = new UIButton();

            payWithMobilePay.Frame = new CGRect(40f, 320f, buttonWidth, 40f);
            payWithMobilePay.SetTitle("Pay 10 EUR with MobilePay", UIControlState.Normal);
            payWithMobilePay.BackgroundColor = UIColor.LightGray;
            payWithMobilePay.TouchUpInside  += (sender, e) =>
            {
                if (!PiaSDK.LaunchWalletAppForWalletPaymentProcess(PaymentProcess.WalletPaymentForWallet(Wallet.MobilePayTest),
                                                                   (callback) => {
                    registerCallForWallets(MobileWallet.MobilePay, callback);
                },
                                                                   (redirectWithoutInterruption) => {
                    InvokeOnMainThread(() => {
                        PiaSDK.RemoveTransitionView();
                        if (redirectWithoutInterruption)
                        {
                            showAlert(@"Wallet redirected sucessfully, Please check transaction status from your backend");
                        }
                        else
                        {
                            showAlert(@"wallet redirected interrupt");
                        }
                    });
                }, (error) => {
                    InvokeOnMainThread(() =>
                    {
                        showAlert(error.LocalizedDescription);
                    });
                }))
                {
                    showAlert(@"failed to launch wallet app");
                }
                ;
            };


            UIButton payWithPaytrail = new UIButton();

            payWithPaytrail.Frame = new CGRect(40f, 400f, buttonWidth, 40f);
            payWithPaytrail.SetTitle("Pay 10 EUR with Paytrail", UIControlState.Normal);
            payWithPaytrail.BackgroundColor = UIColor.LightGray;
            payWithPaytrail.TouchUpInside  += (sender, e) =>
            {
                var merchantId = "YOUR_MERCHANT_ID";
                isPaytrail = true;

                PiaSDK.AddTransitionViewIn(this.View);

                registerCardPaymnet(false, completionHandler: () =>
                {
                    var controller          = new PiaSDKController(merchantId, transactionInfo, true);
                    PiaDelegate newDelegate = new PiaDelegate();
                    controller.PiaDelegate  = newDelegate;
                    newDelegate.vc          = this;
                    InvokeOnMainThread(() => {
                        PiaSDK.RemoveTransitionView();
                        this.PresentViewController(controller, true, null);
                    });
                });
            };

            this.View.AddSubview(payWithCard);
            this.View.AddSubview(payWithSavedCard);
            this.View.AddSubview(payWithSavedCardSkipConfirmation);
            this.View.AddSubview(payWithMobilePay);
            this.View.AddSubview(payWithPaytrail);
        }
Exemple #18
0
        public ActionResult PaymentProcess()
        {
            var model = new PaymentProcess(base.BasketCount);

            return(View(model));
        }