Coder Social home page Coder Social logo

ttgzs / alipay.aopsdk.core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotnetcore/alipay.aopsdk.core

0.0 2.0 0.0 2.18 MB

支付宝(Alipay)服务端SDK,采用.NET Standard 2.0,支持.NET Core >=2.0,与官方SDK接口完全相同。完全可以按照官方文档进行开发。除了支持支付以外,官方SDK支持的功能本SDK全部支持,比如生活号、服务窗、行业合作等,且用法几乎一样,代码都可参考官方文档代码。

License: MIT License

C# 100.00% Batchfile 0.01%

alipay.aopsdk.core's Introduction

Member project of .NET Core Community Jenkins

Alipay.AopSdk.Core

近期工作

重构:因为原项目采用移植.NET Framework的代码,所以有些地方有些小问题,打算有时间慢慢重构了,先从支付开始。

一.各个组件说明

组件名 说明 版本号
Alipay.AopSdk.Core ASP.NET 项目可以单独安装此组件。服务端SDK,封装了支付宝开放平台的所有API Latest version
Alipay.AopSdk.AspnetCore ASP.NET Core 项目可以单独安装此组件。服务端SDK的ASP.NET Core组件,为了能更好配合ASP.NET Core 使用 Latest version

Alipay.AopSdk.F2FPay.AspnetCore、Alipay.AopSdk.F2FPay 在2.3版本已被合并。

支付宝(Alipay)服务端SDK,采用.NET Standard 2.0,支持.NET Core >= 2.0,与官方SDK接口完全相同。完全可以按照官方文档进行开发。除了支持支付以外,官方SDK支持的功能本SDK全部支持,且用法几乎一样,代码都可参考官方文档代码。。由于精力有限,所以只做了几个Demo,但是其他功能可以参照官方的Demo来使用。可以使用官方文档中的示例代码。如有问题请加QQ群4656606。

本项目代码基于官方.NET Framework 代码重构而来以及加入了ASP.NET Core的扩展支持。

二.ASP.NET Core 使用

1.安装程序包

Install-Package Install-Package Alipay.AopSdk.AspnetCore

2.添加配置

public void ConfigureServices(IServiceCollection services)
{
    services.AddAlipay(options =>
	        {
		        options.AlipayPublicKey = "支付宝公钥";
		        options.AppId = "应用ID";
		        options.CharSet = "密钥编码";
		        options.Gatewayurl = "支付网关";
		        options.PrivateKey = "商家私钥";
		        options.SignType = "签名方式 RSA/RSA2";
		        options.Uid = "商户ID";
	        });
}

3.在Controller中使用

//通过di注入
private readonly AlipayService  _alipayService;

public xxxController(AlipayService alipayService)
{
	_alipayService = alipayService;

}

_alipayService.Execute();

三.使用当面付(条码支付/扫描支付)

private readonly AlipayF2FService _alipayF2FService;

public xxxController(AlipayF2FService alipayF2FService)
{
	_alipayF2FService = alipayF2FService;

}

_alipayF2FService.Execute();

四.配置

1.快捷添加配置的方法

appsettings.json里添加如下信息

 "Alipay": {
    "AlipayPublicKey": "",
    "AppId": "",
    "CharSet": "UTF-8",
    "Gatewayurl": "https://openapi.alipaydev.com/gateway.do",
    "PrivateKey": "",
    "SignType": "RSA2",
    "Uid": ""
  }

添加配置代码可改为如下:

public void ConfigureServices(IServiceCollection services)
{
    services.AddAlipay(Configuration.GetSection("Alipay"));
    
}

2.密钥生成的方法

解压tool文件夹下keygen.zip压缩包,运行start.bat即可在keys目录下生成公钥和私钥,长度为2048。

这里生成的公钥和私钥,只需将私钥配置到配置文件文件中,公钥需要设置到支付宝后台。然后设置SignTypeRSA2。配置文件中的公钥配置,不是我们自己生成的这个,需要到支付宝后台获取,这里需要注意一下。

1526457521967

五.文档信息

官方文档:

1.演示Demo

实现支付、支付同步回调、支付异步通知、订单查询、退款、退款查询、订单关闭、扫码支付功能

2.教程

3.使用问题集锦

常见问题解答

alipay.aopsdk.core's People

Contributors

alexinea avatar icebeans avatar stulzq avatar xland avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.