Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Soghandi/BankPayment
Persian Bank Payment Server
https://github.com/Soghandi/BankPayment
banking behpardakht gateways mellat parsian persian saman saman-bank
Last synced: about 2 months ago
JSON representation
Persian Bank Payment Server
- Host: GitHub
- URL: https://github.com/Soghandi/BankPayment
- Owner: Soghandi
- License: lgpl-2.1
- Created: 2018-08-01T09:32:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-19T10:18:11.000Z (5 months ago)
- Last Synced: 2024-08-19T12:12:13.850Z (5 months ago)
- Topics: banking, behpardakht, gateways, mellat, parsian, persian, saman, saman-bank
- Language: C#
- Homepage:
- Size: 2.09 MB
- Stars: 42
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: Security/Adin.BankPayment.TokenProvider/Adin.BankPayment.TokenProvider.csproj
Awesome Lists containing this project
README
# BankPayment
Persian Bank Payment Gateway
Easily connect to Iranian bank gateways without getting involved with their contractual protocol.
Supported Banks:
- Saman
- Mellat (behpardakht)
- Efarda (Ertebat Farda - efarda.ir)
- Parsian
- Pasargad
How to setup server:
clone project, build and run Adin.BankPayment in your server (Windows, Linux, Mac)
build command:
```
dotnet build Adin.BankPayment
```
add connectionstring to appsettings in Adin.Bankpayment project
```
{
"ConnectionString": "Server=SERVERNAME;Database=DATABASENAME;User Id=DATABASEUSER;Password=PASSWORD;MultipleActiveResultSets=True"
}
```
run below command to create tables with default values:
```
dotnet ef database update -p .\Adin.BankPayment.Domain\Adin.BankPayment.Domain.csproj -s .\Adin.BankPayment\Adin.BankPayment.csproj
```
publish command:
```
dotnet publish .\Adin.BankPayment\Adin.BankPayment.csproj
```
run command:
```
dotnet .\Adin.BankPayment\bin\Debug\netcoreapp2.1\publish\Adin.BankPayment.dll
```
after project started successfully you can easily add various applications with multiple bank gateways from swagger url:
http://localhost:5000/api-docs/index.html
server configuration finish!
How to setup client:
First add connector dll to client project
```
Install-Package Adin.BankPayment.Connector
```
use it in your project (like sample project)
send request:
```
public async Task GotoBankPage()
{
var currentBaseUrl = string.Format("{0}://{1}", Request.Scheme, Request.Host);
var model = new Connector.Model.PayInfoModel
{
Amount = 1000,
BankCode = BankCodeEnum.Saman,
CallbackUrl = currentBaseUrl + "/Home/Callback",
Mobile = 989354762696,
PriceUnit = Connector.Enum.PriceUnitEnum.Rial,
TrackCode = DateTime.Now.ToString("hhmmssfff")
};
var response = await client.RequestPay(model);
if (response.Status == Connector.Enum.ApiStatusCodeEnum.Success)
{
return Redirect(response.Body.Url);
}
else
{
throw new Exception(response.Status + ":" + response.Body);
}
}
```
callback:
```
public async Task CallBack()
{
Guid payId = Guid.Parse(Request.Query["id"]);
string trackCode = Request.Query["trackCode"];
bool status = bool.Parse(Request.Query["status"]);
string message = Request.Query["message"];
if (status == false)
{
int errorCode = int.Parse(Request.Query["errorCode"]);
BankErrorCodeEnum errCode = (BankErrorCodeEnum)errorCode;
ViewBag.Result = message;
}
else
{
try
{
//Todo: deliver product to customer here
var res = await client.Verify(payId);
if (res.Status == Connector.Enum.ApiStatusCodeEnum.Success && res.Body.Status)
{
//Transaction Done
ViewBag.Result = res.Body.Message;
}
else
{
//Transaction Failed
ViewBag.Result = res.Body.Message + "
" + "تا 24 ساعت دیگر مبلغ به حساب شما بازگردانده خواهد شد";
}
}
catch
{
//Reverse Transaction
}
}
return View();
}
```
enjoy it.