PaymentInfo.cshtml
@{
Layout = "";
}
@model Nop.Plugin.Payments.IsBank.Models.PaymentInfoModel
@using Nop.Web.Framework;
@{
string imageUrl = "";
imageUrl = string.Format("http://www.lifereboot.com/wp-content/uploads/go-button.jpg");
}
<!-- THERE IS NO <form> TAG HTML OUTPUT OR IT'S NOT SUBMIT. (if I see with firebug there is no form tag, but right click view source then there is the form tag) -->
@using (Html.BeginRouteForm("Plugin.Payments.IsBank.SubmitButton", FormMethod.Post, new { id = "form-googlecheckout" }))
{
<img id="googleCheckoutImage" alt="" src="@Html.Raw(imageUrl)" style="cursor:pointer;" />
}
<script type="text/javascript">
$(document).ready(function () {
$('#googleCheckoutImage').click(function () {
$("#form-googlecheckout").submit();
});
});
</script>
RouteProvider.cs
using System.Web.Mvc;
using System.Web.Routing;
using Nop.Web.Framework.Mvc.Routes;
namespace Nop.Plugin.Payments.GoogleCheckout
{
public partial class RouteProvider : IRouteProvider
{
public void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("Plugin.Payments.GoogleCheckout.Configure",
"Plugins/PaymentGoogleCheckout/Configure",
new { controller = "PaymentGoogleCheckout", action = "Configure" },
new[] { "Nop.Plugin.Payments.GoogleCheckout.Controllers" }
);
routes.MapRoute("Plugin.Payments.GoogleCheckout.PaymentInfo",
"Plugins/PaymentGoogleCheckout/PaymentInfo",
new { controller = "PaymentGoogleCheckout", action = "PaymentInfo" },
new[] { "Nop.Plugin.Payments.GoogleCheckout.Controllers" }
);
//Submit Google Checkout button
routes.MapRoute("Plugin.Payments.GoogleCheckout.SubmitButton",
"Plugins/PaymentGoogleCheckout/SubmitButton",
new { controller = "PaymentGoogleCheckout", action = "SubmitButton" },
new[] { "Nop.Plugin.Payments.GoogleCheckout.Controllers" }
);
//Notification
routes.MapRoute("Plugin.Payments.GoogleCheckout.NotificationHandler",
"Plugins/PaymentGoogleCheckout/NotificationHandler",
new { controller = "PaymentGoogleCheckout", action = "NotificationHandler" },
new[] { "Nop.Plugin.Payments.GoogleCheckout.Controllers" }
);
}
public int Priority
{
get
{
return 0;
}
}
}
}
PaymentIsBankController.cs
using Nop.Plugin.Payments.IsBank.Models;
using Nop.Plugin.Payments.IsBank.Validators;
using Nop.Services.Localization;
using Nop.Web.Framework;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web.Configuration;
using System.Web.Mvc;
using Nop.Core;
using Nop.Core.Domain.Directory;
using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Payments;
using Nop.Services.Configuration;
using Nop.Services.Customers;
using Nop.Services.Directory;
using Nop.Services.Logging;
using Nop.Services.Orders;
using Nop.Services.Payments;
using Nop.Web.Framework.Controllers;
using ePayment;
namespace Nop.Plugin.Payments.IsBank.Controllers
{
public class PaymentIsBankController : BaseNopPaymentController
{
private readonly ISettingService _settingService;
private readonly ILocalizationService _localizationService;
private readonly IsBankPaymentSettings _isbankPaymentSettings;
private readonly IWorkContext _workContext;
private readonly IOrderProcessingService _orderProcessingService;
private readonly IPaymentService _paymentService;
private readonly PaymentSettings _paymentSettings;
public PaymentIsBankController(ISettingService settingService,
ILocalizationService localizationService, IsBankPaymentSettings isbankPaymentSettings,
IWorkContext workContext, IOrderProcessingService orderProcessingService,
IPaymentService paymentService, PaymentSettings paymentSettings)
{
this._settingService = settingService;
this._localizationService = localizationService;
this._isbankPaymentSettings = isbankPaymentSettings;
this._orderProcessingService = orderProcessingService;
this._paymentService = paymentService;
this._paymentSettings = paymentSettings;
this._workContext = workContext;
}
[AdminAuthorize]
[ChildActionOnly]
public ActionResult Configure()
{
var model = new ConfigurationModel();
model.TransactModeId = Convert.ToInt32(_isbankPaymentSettings.TransactMode);
model.AdditionalFee = _isbankPaymentSettings.AdditionalFee;
model.TransactModeValues = _isbankPaymentSettings.TransactMode.ToSelectList();
return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.Configure", model);
}
[HttpPost]
[AdminAuthorize]
[ChildActionOnly]
public ActionResult Configure(ConfigurationModel model)
{
if (!ModelState.IsValid)
return Configure();
//save settings
_isbankPaymentSettings.TransactMode = (TransactMode)model.TransactModeId;
_isbankPaymentSettings.AdditionalFee = model.AdditionalFee;
_settingService.SaveSetting(_isbankPaymentSettings);
model.TransactModeValues = _isbankPaymentSettings.TransactMode.ToSelectList();
return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.Configure", model);
}
[ChildActionOnly]
public ActionResult PaymentInfo()
{
var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
if (cart.Count == 0)
return Content("");
bool minOrderSubtotalAmountOk = _orderProcessingService.ValidateMinOrderSubtotalAmount(cart);
if (!minOrderSubtotalAmountOk)
return Content("");
var model = new PaymentInfoModel();
model.Bankalar.Add(new SelectListItem()
{
Text = "Akbank",
Value = "Akbank",
});
model.Bankalar.Add(new SelectListItem()
{
Text = "Garanti",
Value = "Garanti",
});
model.Bankalar.Add(new SelectListItem()
{
Text = "Isbank",
Value = "Isbank",
});
return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.PaymentInfo", model);
}
[ChildActionOnly]
public ActionResult TaksitPuan()
{
var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
if (cart.Count == 0)
return Content("");
bool minOrderSubtotalAmountOk = _orderProcessingService.ValidateMinOrderSubtotalAmount(cart);
if (!minOrderSubtotalAmountOk)
return Content("");
var model = new TaksitPuanModel();
model.Taksitler.Add(new SelectListItem()
{
Text = "3 ay",
Value = "3",
});
model.Taksitler.Add(new SelectListItem()
{
Text = "6 ay",
Value = "6",
});
model.Taksitler.Add(new SelectListItem()
{
Text = "9 ay",
Value = "9",
});
return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.TaksitPuan", model);
}
//KartBilgileri
//[HttpPost]
//[AdminAuthorize]
//[ChildActionOnly]
public ActionResult SubmitButton(PaymentInfoModel model)
{
//if (!ModelState.IsValid)
// return Configure();
//var _model = new TaksitPuanModel();
//_model.CardCode = model.CardCode;
//_model.CardholderName = model.CardholderName;
//_model.CardNumber = model.CardNumber;
//_model.CreditCardType = model.CreditCardType;
//_model.ExpireMonth = model.ExpireMonth;
//_model.ExpireYear = model.ExpireYear;
//_model.Taksitler.Add(new SelectListItem()
//{
// Text = "3 ay",
// Value = "3",
//});
//_model.Taksitler.Add(new SelectListItem()
//{
// Text = "6 ay",
// Value = "6",
//});
//_model.Taksitler.Add(new SelectListItem()
//{
// Text = "9 ay",
// Value = "9",
//});
//_model.PuanKullanim = "testPuanKullanim";
//return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.TaksitPuan", _model);
return Content("bla bla");
}
[ChildActionOnly]
public ActionResult CheckOutConfirm()
{
var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
if (cart.Count == 0)
return Content("");
bool minOrderSubtotalAmountOk = _orderProcessingService.ValidateMinOrderSubtotalAmount(cart);
if (!minOrderSubtotalAmountOk)
return Content("");
var model = new CheckOutConfirmModel();
model.TaksitListeleri.Add(new SelectListItem()
{
Text = "3 ay",
Value = "3",
});
model.TaksitListeleri.Add(new SelectListItem()
{
Text = "6 ay",
Value = "6",
});
model.TaksitListeleri.Add(new SelectListItem()
{
Text = "9 ay",
Value = "9",
});
return View("Nop.Plugin.Payments.IsBank.Views.PaymentIsBank.CheckOutConfirm", model);
}
[NonAction]
public override IList<string> ValidatePaymentForm(FormCollection form)
{
var warnings = new List<string>();
//validate
var validator = new PaymentInfoValidator(_localizationService);
var model = new PaymentInfoModel()
{
CardholderName = form["CardholderName"],
CardNumber = form["CardNumber"],
CardCode = form["CardCode"],
};
var validationResult = validator.Validate(model);
if (!validationResult.IsValid)
foreach (var error in validationResult.Errors)
warnings.Add(error.ErrorMessage);
var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.IsBank") as IsBankPaymentProcessor;
if (processor == null ||
!processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed)
throw new NopException("IsBank Payment module cannot be loaded");
return warnings;
}
[NonAction]
public override ProcessPaymentRequest GetPaymentInfo(FormCollection form)
{
var paymentInfo = new ProcessPaymentRequest();
paymentInfo.CreditCardType = form["CreditCardType"];
paymentInfo.CreditCardName = form["CardholderName"];
paymentInfo.CreditCardNumber = form["CardNumber"];
paymentInfo.CreditCardExpireMonth = int.Parse(form["ExpireMonth"]);
paymentInfo.CreditCardExpireYear = int.Parse(form["ExpireYear"]);
paymentInfo.CreditCardCvv2 = form["CardCode"];
paymentInfo.RecurringTotalCycles = int.Parse(form["TaksitListesi"]); // installment
return paymentInfo;
}
}
}