Skip to content

Commit

Permalink
zarinPal files
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdirln authored Mar 16, 2019
1 parent f165f8b commit 967f86d
Show file tree
Hide file tree
Showing 13 changed files with 1,121 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Models/ConfigurationModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Web.Mvc;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc;

namespace Nop.Plugin.Payments.ZarinPal.Models
{
public class ConfigurationModel : BaseNopModel
{
public ConfigurationModel()
{
AvailableCurency = new List<SelectListItem>();
}

public IList<SelectListItem> AvailableCurency { get; set; }

public int ActiveStoreScopeConfiguration { get; set; }

[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.Currency")]
public int CurrencyId { get; set; }

public bool CurrencyId_OverrideForStore { get; set; }


[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.Description")]
public string Description { get; set; }

public bool Description_OverrideForStore { get; set; }


[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.MerchantCode")]
public string MerchantCode { get; set; }

public bool MerchantCode_OverrideForStore { get; set; }


[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.UseSsl")]
public bool UseSsl { get; set; }

public bool UseSsl_OverrideForStore { get; set; }

}
}
21 changes: 21 additions & 0 deletions Models/PaymentInfoModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc;

namespace Nop.Plugin.Payments.ZarinPal.Models
{
public class PaymentInfoModel : BaseNopModel
{

[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.EMail")]
public string EMail { get; set; }

[NopResourceDisplayName("Plugins.Payments.ZarinPal.Fields.Phonenumber")]
public string Phonenumber { get; set; }

}
}
17 changes: 17 additions & 0 deletions Models/ResultModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nop.Plugin.Payments.ZarinPal.Models
{
public class ResultModel
{
public long RefId { get; set; }

public int Status { get; set; }

public string Message { get; set; }
}
}
36 changes: 36 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Nop.Plugin.Payments.ZarinPal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Nop.Plugin.Payments.ZarinPal")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("59aaed07-8c3f-4804-b10d-5bbad0a01eac")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
37 changes: 37 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nop.Plugin.Payments.ZarinPal.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Nop_Plugin_Payments_ZarinPal_ZarinPalWebService_PaymentGatewayImplementationService" Type="(Web Service URL)" Scope="Application">
<Value Profile="(Default)">https://www.zarinpal.com/pg/services/WebGate/service</Value>
</Setting>
</Settings>
</SettingsFile>
57 changes: 57 additions & 0 deletions Validator/PaymentInfoValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentValidation;
using Nop.Plugin.Payments.ZarinPal.Models;
using Nop.Services.Localization;
using Nop.Web.Framework.Validators;

namespace Nop.Plugin.Payments.ZarinPal.Validator
{
public class PaymentInfoValidator : BaseNopValidator<PaymentInfoModel>
{
public PaymentInfoValidator(ILocalizationService localizationService)
{
string _emailPattern =
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

//RuleFor(x => x.EMail).Matches(_emailPattern)
// .WithMessage(localizationService.GetResource("Plugins.Payments.ZarinPal.Fields.EMail.IsWrong"));

RuleFor(p => p.EMail)
.EmailAddress()
.WithMessage(localizationService.GetResource("Plugins.Payments.ZarinPal.Fields.EMail.IsWrong"))
.When(CheckEmptyEmail);

RuleFor(p => p.Phonenumber)
.Must(CheckPhonenumberType)
.WithMessage(localizationService.GetResource("Plugins.Payments.ZarinPal.Fields.Phonenumber.TypeIsNotValid"));

}

private bool CheckEmptyEmail(PaymentInfoModel model)
{
return !string.IsNullOrEmpty(model.EMail);
}

private bool CheckPhonenumberType(string phonenumber)
{
if (phonenumber.Length == 0)
return true;

try
{
var temp = Convert.ToDouble(phonenumber);

return true;
}
catch (Exception)
{
return false;
}
}
}
}
62 changes: 62 additions & 0 deletions Views/Configure.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@{
Layout = "";
}
@model Nop.Plugin.Payments.ZarinPal.Models.ConfigurationModel
@using Nop.Web.Framework;

@Html.Action("StoreScopeConfiguration", "Setting", new { area = "Admin" })

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<div class="col-md-3">
@Html.OverrideStoreCheckboxFor(model => model.Description_OverrideForStore, model => model.Description, Model.ActiveStoreScopeConfiguration)
@Html.NopLabelFor(model => model.Description)
</div>
<div class="col-md-9">
@Html.NopEditorFor(model => model.Description)
</div>
</div>
<div class="form-group">
<div class="col-md-3">
@Html.OverrideStoreCheckboxFor(model => model.MerchantCode_OverrideForStore, model => model.MerchantCode, Model.ActiveStoreScopeConfiguration)
@Html.NopLabelFor(model => model.MerchantCode)
</div>
<div class="col-md-9">
@Html.NopEditorFor(model => model.MerchantCode)
</div>
</div>
<div class="form-group">
<div class="col-md-3">
@Html.OverrideStoreCheckboxFor(model => model.UseSsl_OverrideForStore, model => model.UseSsl, Model.ActiveStoreScopeConfiguration)
@Html.NopLabelFor(model => model.UseSsl)
</div>
<div class="col-md-9">
@Html.NopEditorFor(model => model.UseSsl)
</div>
</div>
<div class="form-group">
<div class="col-md-3">
@Html.OverrideStoreCheckboxFor(model => model.CurrencyId_OverrideForStore, model => model.CurrencyId, Model.ActiveStoreScopeConfiguration)
@Html.NopLabelFor(model => model.CurrencyId)
</div>
<div class="col-md-9">
@Html.DropDownListFor(model => model.CurrencyId, Model.AvailableCurency)
</div>
</div>
<div class="form-group">
<div class="col-md-3">
&nbsp;
</div>
<div class="col-md-9">
<input type="submit" name="save" class="btn bg-blue" value="@T("Admin.Common.Save")" />
</div>
</div>
</div>
</div>
</div>
}
31 changes: 31 additions & 0 deletions Views/PaymentInfo.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@{
Layout = "";
}
@model Nop.Plugin.Payments.ZarinPal.Models.PaymentInfoModel

<table width="100%" cellspacing="2" cellpadding="1" border="0">
<tr>
<td>
<p>
<b>@T("Plugins.Payments.ZarinPal.Fields.RedirectionTip")</b>
</p>
</td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.EMail):
</td>
<td>
@Html.TextBoxFor(model => model.EMail)
@Html.ValidationMessageFor(model => model.EMail)
</td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.Phonenumber):
</td>
<td>
@Html.TextBoxFor(model => model.Phonenumber)
</td>
</tr>
</table>
14 changes: 14 additions & 0 deletions Views/Result.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@model Nop.Plugin.Payments.ZarinPal.Models.ResultModel
@{
Layout = "~/Views/Shared/_ColumnsOne.cshtml";
}

<div class="page checkout-page order-completed-page">
<div class="page-body checkout-data">
<div class="section order-completed">
<div class="title">
<strong>@T("Plugins.Payments.ZarinPal.Failed")</strong>
</div>
</div>
</div>
</div>
Loading

0 comments on commit 967f86d

Please sign in to comment.