private bool ProcessPayment(Order order, decimal creditAmount, Dictionary <string, object> paymentMethodData, out CustomResponse response) { var isSubscription = OrderHelper.IsSubscription(order); var transactionResult = isSubscription ? _paymentProcessor.ProcessCreateSubscription(order, creditAmount, paymentMethodData) : _paymentProcessor.ProcessPayment(order, creditAmount, paymentMethodData); if (transactionResult.Success) { response = R.Success; if (transactionResult.RequiresRedirection) { response.Redirect(transactionResult.RedirectionUrl); } else { //if we are here, payment has been done, so we can get the transaction data //create payment transaction object and save it to database _paymentAccountant.ProcessTransactionResult(transactionResult); } return(true); } else { //unlock the credits _storeCreditService.UnlockCredits(order.StoreCredits, order.UserId); } response = R.Fail.With("error", T("An error occurred while checking out")); return(false); }