All Projects → milanyangbo → Icanpay.donet

milanyangbo / Icanpay.donet

统一支付网关。支持NET46和NETSTANDARD2_0。支持支付宝,微信,银联支付渠道通过Web,App,Wap,QRCode方式支付。简化订单的创建、查询、退款跟接收网关返回的支付通知等功能

Projects that are alternatives of or similar to Icanpay.donet

laravel-payment
Omnipay ServiceProvider for Laravel.
Stars: ✭ 89 (+43.55%)
Mutual labels:  alipay, payment-gateway
Omnipay Pingpp
A Ping++ driver for the Omnipay PHP payment processing library. 一个聚合了支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关(Ping++, also known as Pingpp/Pingxx/Pingplusplus)
Stars: ✭ 227 (+266.13%)
Mutual labels:  alipay, payment-gateway
Vdonate
💰 为你的网站增加个微信、支付宝二维码,方便读者打赏
Stars: ✭ 55 (-11.29%)
Mutual labels:  alipay
Dotnet Bundle
MSBuild task and CLI tools for bundling .NET Core projects into MacOS applications (.app)
Stars: ✭ 59 (-4.84%)
Mutual labels:  dotnet-core
Dotnetworkqueue
A work queue for dot.net with SQL server, SQLite, Redis and PostGreSQL backends
Stars: ✭ 58 (-6.45%)
Mutual labels:  dotnet-core
React Native Midtrans
Midtrans Mobile SDK for React Native
Stars: ✭ 57 (-8.06%)
Mutual labels:  payment-gateway
Community Cluster
OpenFaaS Cloud Cluster for Community
Stars: ✭ 59 (-4.84%)
Mutual labels:  dotnet-core
Subloader
Subloader is a simple and minimalistic subtitle downloader that enables you to quickly find and download subtitles for your video files.
Stars: ✭ 53 (-14.52%)
Mutual labels:  dotnet-core
Aspnetboilerplate Core Ng
Tutorial for ASP.NET Boilerplate Core + Angular
Stars: ✭ 61 (-1.61%)
Mutual labels:  dotnet-core
Laravel Paytm Wallet
Integrate paytm wallet in your laravel application easily with this package. This package uses official Paytm PHP SDK's.
Stars: ✭ 58 (-6.45%)
Mutual labels:  payment-gateway
Aspnet Core Clean Arch
It is a clean architecture project template which is based on hexagonal-architecture principles built with .Net core.
Stars: ✭ 60 (-3.23%)
Mutual labels:  dotnet-core
Fakeiteasy
The easy mocking library for .NET
Stars: ✭ 1,092 (+1661.29%)
Mutual labels:  dotnet-core
Yarn.msbuild
MSBuild integration for the Yarn package manager.
Stars: ✭ 57 (-8.06%)
Mutual labels:  dotnet-core
Developing Solutions Azure Exam
This repository contains resources for the Exam AZ-203: Developing Solutions for Microsoft Azure. You can find direct links to resources and and practice resources to test yourself ☁️🎓📚
Stars: ✭ 59 (-4.84%)
Mutual labels:  dotnet-core
Alipay
支付宝 AliPay SDK for Go, 集成简单,功能完善,持续更新,支持公钥证书和普通公钥进行签名和验签。
Stars: ✭ 1,090 (+1658.06%)
Mutual labels:  alipay
Pioneer Console Boilerplate
Dependency injection, logging and configuration in a .NET Core console application.
Stars: ✭ 60 (-3.23%)
Mutual labels:  dotnet-core
Electron.net Musicplayer Sample
Stars: ✭ 55 (-11.29%)
Mutual labels:  dotnet-core
Golang Payu
Golang Payu Integration
Stars: ✭ 58 (-6.45%)
Mutual labels:  payment-gateway
Virtualizingwrappanel
Implementation of a VirtualizingWrapPanel for WPF running .NET Framework 4.5+ or .NET Core 3.0+
Stars: ✭ 59 (-4.84%)
Mutual labels:  dotnet-core
Ionic Example App
A Ionic Example App (previously known as ionic 2 examples). Contains different examples on how to use the Ionic Framework
Stars: ✭ 61 (-1.61%)
Mutual labels:  dotnet-core

ICanPay

https://github.com/hiihellox10/ICanPay 统一支付网关。对原代码优化。支持NET46和NETSTANDARD2_0。支持支付宝,微信,银联支付渠道通过Web,App,Wap,QRCode方式支付。简化订单的创建、查询、退款跟接收网关返回的支付通知等功能

初始网关信息

NET46,需依赖AuotoFac组件

    var builder = new ContainerBuilder();
	builder.RegisterControllers(typeof(MvcApplication).Assembly);
	builder.Register(c =>
	{
		var gateways = new Gateways();
		gateways.Add(new AlipayGateway()
		{
			Merchant = new Merchant()
			{
				AppId = ConfigurationManager.AppSettings["alipay.appid"],
				Partner = ConfigurationManager.AppSettings["alipay.partner"],
				Email = ConfigurationManager.AppSettings["alipay.seller_email"],
				Key = ConfigurationManager.AppSettings["alipay.key"],
				PublicKey = ConfigurationManager.AppSettings["alipay.publicKey"],
				PrivateKey = ConfigurationManager.AppSettings["alipay.privateKey"],
				NotifyUrl = new Uri(ConfigurationManager.AppSettings["alipay.notify_url"]),
				ReturnUrl = new Uri(ConfigurationManager.AppSettings["alipay.return_url"]),
			}
		});               
	   return gateways;
	}).As<IGateways>().InstancePerDependency();
	
	builder.Register(c => new PaymentNotify(c.Resolve<IGateways>().Merchants)).As<PaymentNotify>().InstancePerDependency();
	
	//autofac 注册依赖
	IContainer container = builder.Build();
	DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

NETSTANDARD2_0,在Startup初始化

    public void ConfigureServices(IServiceCollection services)
	{
		 services.AddMvc();

		services.AddSingleton<IConfiguration>(Configuration);

		services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

		services.AddTransient(c => {
			IGateways gateways = new Gateways();
			gateways.Add(new AlipayGateway()
			{
				Merchant = new Merchant()
				{
					AppId = Configuration["alipay:appid"],
					Partner = Configuration["alipay:partner"],
					Email = Configuration["alipay:seller_email"],
					Key = Configuration["alipay:key"],
					PublicKey = Configuration["alipay:publicKey"],
					PrivateKey = Configuration["alipay:privateKey"],
					NotifyUrl = new Uri(Configuration["alipay:notifyurl"]),
					ReturnUrl = new Uri(Configuration["alipay:returnurl"]),
				}
			});
			return gateways;
		});

		services.AddTransient(c=>new PaymentNotify(c.GetService<IGateways>().Merchants));
	}

WebPayment(网站支付)

    public void CreateOrder(GatewayType gatewayType)
	{
		var gateway = gateways.Get(gatewayType, GatewayTradeType.Web);
		var paymentSetting = new PaymentSetting(gateway);
		paymentSetting.Order = new Order()
		{
			OrderAmount = 0.01,
			OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"),
			Subject = "WebPayment",
			PaymentDate = DateTime.Now
		};
		paymentSetting.Payment();
	}

WapPayment(手机网站支付)

    public void CreateOrder(GatewayType gatewayType)
	{
		var gateway = gateways.Get(gatewayType, GatewayTradeType.Wap);
		var paymentSetting = new PaymentSetting(gateway);
		paymentSetting.Order = new Order()
		{
			OrderAmount = 0.01,
			OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"),
			Subject = "WapPayment",
			PaymentDate = DateTime.Now
		};
		paymentSetting.Payment();
	}

QRCodePayment(二维码支付)

	public void CreateOrder(GatewayType gatewayType)
	{
		var gateway = gateways.Get(gatewayType, GatewayTradeType.QRCode);
		var paymentSetting = new PaymentSetting(gateway);
		paymentSetting.Order = new Order()
		{
			OrderAmount = 0.01,
			OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"),
			Subject = "QRCodePayment",
			PaymentDate = DateTime.Now
		};
		paymentSetting.Payment();
	}

AppPayment(手机APP支付)

	public JsonResult CreateOrder(GatewayType gatewayType)
	{
		var gateway = gateways.Get(gatewayType, GatewayTradeType.APP);
		var paymentSetting = new PaymentSetting(gateway);
		paymentSetting.Order = new Order()
		{
			OrderAmount = 0.01,
			OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"),
			Subject = "AppPayment",
			PaymentDate = DateTime.Now
		};
		return Json(paymentSetting.Payment());
	}

QueryPayment(查询订单)

    public void QueryOrder(GatewayType gatewayType)
    {
		var gateway = gateways.Get(gatewayType);
		var querySetting = new PaymentSetting(gateway);

		// 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。
		querySetting.Order.OrderNo = "20";
		querySetting.Order.OrderAmount = 0.01;

		if (querySetting.QueryNow())
		{
			// 订单已支付
		}
    }

Refund(退款和退款查询)

    public void CreateRefund(GatewayType gatewayType)
	{
		var gateway = gateways.Get(gatewayType);
		var paymentSetting = new PaymentSetting(gateway);

		var refund = new Refund();
		refund.OutRefundNo = "000000000000000";
		paymentSetting.BuildRefund(refund);
		paymentSetting.BuildRefundQuery(refund);
	}

Notify(异步通知)

	private readonly PaymentNotify paymentNotify;

	public NotifyController(PaymentNotify paymentNotify)
	{
		this.paymentNotify = paymentNotify;
		paymentNotify.PaymentSucceed += @event => {
			//支付成功时时的处理代码
			if (@event.PaymentNotifyMethod == PaymentNotifyMethod.AutoReturn)
			{
				//当前是用户的浏览器自动返回时显示充值成功页面
			}
			else
			{
				//支付结果的发送方式,以服务端接收为准

			}
		};

		paymentNotify.PaymentFailed += @event=> {
			//支付失败时的处理代码
		};

		paymentNotify.UnknownGateway += @event => {
			//无法识别支付网关时的处理代码
		};
	}


	public void ServerNotify()
	{          
		//接收并处理支付通知
		paymentNotify.Received(PaymentNotifyMethod.ServerNotify);
	}

	public void AutoReturn()
	{
		//接收并处理支付通知
		paymentNotify.Received(PaymentNotifyMethod.AutoReturn);
	}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].