Giter Club home page Giter Club logo

payjs-csharp-sdk's Introduction

PAYJS-CSharp-SDK

本项目为PAYJS API接口的C#封装。关于payjs,可以在这里了解更多:https://help.payjs.cn/

说明

为了简化sdk,本项目仅有一个cs类文件,封装了payjs常用接口的调用、生成sign、验sign、发送请求等功能。

不包含响应结果的格式化功能,需要自行处理json字符串,推荐使用https://github.com/JamesNK/Newtonsoft.Json

src目录为类库源文件,可以引入自己的项目中,支持ASP.NET、ASP.NET Core、NetCore WebAPI等环境

快速使用

1、初始化

Payjs pay = new Payjs("YOUR MCHID", "YOUR KEY");

2、二维码

Dictionary<string, string> param = new Dictionary<string, string>();
param["total_fee"] = "1";
param["out_trade_no"] = DateTime.Now.Ticks.ToString();
param["body"] = "test";
param["attch"] = "user id";
param["notify_url"] = "YOUR notify_url";

//返回原始json字符串
string jsonString = pay.native(param);

3、收银台

Dictionary<string, string> param = new Dictionary<string, string>();
param["total_fee"] = "1";
param["out_trade_no"] = DateTime.Now.Ticks.ToString();
param["body"] = "test";
param["attch"] = "user id";
param["notify_url"] = "YOUR notify_url";
param["callback_url"] = "YOUR callback_url";

//返回收银台地址,直接跳转到此地址即可
string url = pay.cashier(param);

4、JSAPI

Dictionary<string, string> param = new Dictionary<string, string>();
param["total_fee"] = "1";
param["out_trade_no"] = DateTime.Now.Ticks.ToString();
param["body"] = "test";
param["attch"] = "user id";
param["notify_url"] = "YOUR notify_url";
param["openid"] = "user's openid";//获取用户openid:https://help.payjs.cn/api-lie-biao/huo-qu-openid.html

//返回原始json字符串
string jsonString = pay.jsapi(param);

5、刷卡支付

Dictionary<string, string> param = new Dictionary<string, string>();
param["total_fee"] = "1";
param["out_trade_no"] = DateTime.Now.Ticks.ToString();
param["body"] = "test";
param["attch"] = "user id";
param["auth_code"] = "YOUR auth_code";


//返回原始json字符串
string jsonString = pay.micropay(param);

6、订单查询

Dictionary<string, string> param = new Dictionary<string, string>();
param["payjs_order_id"] = "2018xxxxxxx";

//返回原始json字符串
string jsonString = pay.check(param);

7、关闭订单

Dictionary<string, string> param = new Dictionary<string, string>();
param["payjs_order_id"] = "2018xxxxxxx";

//返回原始json字符串
string jsonString = pay.close(param);

8、退款

Dictionary<string, string> param = new Dictionary<string, string>();
param["payjs_order_id"] = "2018xxxxxxx";

//返回原始json字符串
string jsonString = pay.refund(param);

9、获取用户资料

Dictionary<string, string> param = new Dictionary<string, string>();
param["openid"] = "xxxxxxxxxxx";

//返回原始json字符串
string jsonString = pay.user(param);

10、获取商户资料

//返回原始json字符串
string jsonString = pay.info(new Dictionary<string, string>());

11、PAYJS回调请求的验签

//param参数为PAYJS服务器POST过来的数据,根据自己项目中所用的框架获取POST数据后,转为Dictionary<string,string>类型传入notifyCheck方法

//返回是否验证成功
bool issuccess = pay.notifyCheck(param);

12、人脸支付

Dictionary<string, string> param = new Dictionary<string, string>();
param["total_fee"] = "1";
param["out_trade_no"] = DateTime.Now.Ticks.ToString();
param["body"] = "test";
param["attch"] = "user id";
param["face_code"] = "YOUR face_code";
param["openid"] = "user's openid";

string jsonString = pay.facepay(param);

payjs-csharp-sdk's People

Watchers

James Cloos 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.