The project “LMS” is a responsive website
_implementation of ZarinPal payment gateway
_Panel for website (Login System with Session handling)
_with Database file
Github URL: Project Link
Steps:
1. Restore DB in SQL Server from the DB file(lmspricingDB.sql) in root of repository
2. Open LMS Solution in Visual Studio and build the project
3. Execute (F5) to run. Browser will throw Home page of website
4. Open hamidiabetSite Solution in Visual Studio and build the project
3. Execute (F5) to run. Browser will show Homepage of website (the picture of homepage is end of this readme)
4. you can go to panel ( add to url /admin) in Login form enter username and password as admin
Admin Url: ./admin
Admin Username: "username"
Password : "password"
About implementation Zarin Pal payment gateway:
_Download and install zarinpal package from NuGet.
_controller for handling this scenario in Homecontroller:
code
_create and send request
_Catch Authority
_save factor and Authority in DB
_redirect user to zarinpal StartPay page with authority
description = "Buying a bronze package";
mobile = "+989121212121" ;
email = "soheila.sadeghian89@gmail.com";
price = 1000;
string merchant = ConfigurationManager.AppSettings["merchant"];
string Authority = "";
zarinpal.PaymentGatewayImplementationServicePortTypeClient zp = new zarinpal.PaymentGatewayImplementationServicePortTypeClient();
int Status = zp.PaymentRequest(merchant, price, description, email, mobile, "http://our_website_name/result", out Authority);
if (Status == 100)
{
var db = new DataAccessDataContext();
var dt = new DateTime();
dt = DateTime.Now;
var factor = new factorTbl();
factor.Authority = Authority;
factor.description = explain;
factor.email = email;
factor.fullName = fullName;
factor.hostDomain = hostDomain;
factor.mobile = mobile;
factor.packetTitle = description;
factor.regDate = dt;
factor.price = price;
db.factorTbls.InsertOnSubmit(factor);
db.SubmitChanges();
Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority);
_after payment by user, zarinpal send authority and payment status to server(call OrderResult in Homecontroller)
_server send request to zarinpal to get RefID(validate transaction)
_save RefID in DB
public ActionResult OrderResult()
{
if (Request.QueryString["Status"].ToString().Equals("OK"))
{
long RefID;
System.Net.ServicePointManager.Expect100Continue = false;
zarinpal.PaymentGatewayImplementationServicePortTypeClient zp = new zarinpal.PaymentGatewayImplementationServicePortTypeClient();
string merchant = ConfigurationManager.AppSettings["merchant"];
var Authority = Request.QueryString["Authority"].ToString();
var db = new DataAccessDataContext();
var fac = db.factorTbls.Single(c => c.Authority == Authority);
int Status = zp.PaymentVerification(merchant, Authority, fac.price, out RefID);
if (Status == 100)
{
model.Result.isError = false;
model.Result.message = "عملیات پرداخت با موفقیت انجام شد";
model.Result.value = RefID + "";
fac.RefID = RefID + "";
db.SubmitChanges();
return View("OrderResult", model as object);
}
}
}
LMS Website: