All Projects → tvrcgo → Weixin Pay

tvrcgo / Weixin Pay

Licence: mit
微信支付

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Weixin Pay

Node Tenpay
微信支付 for nodejs
Stars: ✭ 947 (+9.73%)
Mutual labels:  payment, wechat, weixin
Sdk3rd
第三方SDK集成库,授权/分享/支付
Stars: ✭ 249 (-71.15%)
Mutual labels:  payment, wechat, weixin
Pay
可能是我用过的最优雅的 Alipay 和 WeChat 的支付 SDK 扩展包了
Stars: ✭ 4,176 (+383.89%)
Mutual labels:  payment, wechat, weixin
Weixin Platform History Article Api
微信公众号历史文章爬取api
Stars: ✭ 27 (-96.87%)
Mutual labels:  wechat, weixin
Wechat Jssdk
🐧WeChat JS-SDK integration with NodeJS
Stars: ✭ 571 (-33.84%)
Mutual labels:  wechat, weixin
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 589 (-31.75%)
Mutual labels:  wechat, weixin
Planmaster
套餐助手:手机套餐对比选购小程序
Stars: ✭ 487 (-43.57%)
Mutual labels:  wechat, weixin
Taro scaffold
基于 Taro / dva / redux-saga / react 的微信小程序脚手架,同时集成了 sprite 。
Stars: ✭ 24 (-97.22%)
Mutual labels:  wechat, weixin
Wechat Miniprogram Examples
WeChat mini program examples. 微信小程序示例
Stars: ✭ 634 (-26.54%)
Mutual labels:  wechat, weixin
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+722.48%)
Mutual labels:  wechat, weixin
Juejin
💰 Unofficial JueJin wechat mini program application - 掘金非官方微信小程序
Stars: ✭ 771 (-10.66%)
Mutual labels:  wechat, weixin
Pay
个人网站即时到账收款解决方案 / Personal website instant payment solution
Stars: ✭ 558 (-35.34%)
Mutual labels:  payment, wechat
Wecron
✔️ 微信上的定时提醒 - Cron on WeChat
Stars: ✭ 537 (-37.78%)
Mutual labels:  wechat, weixin
Wechattweak Macos
A dynamic library tweak for WeChat macOS - 首款微信 macOS 客户端撤回拦截与多开
Stars: ✭ 6,505 (+653.77%)
Mutual labels:  wechat, weixin
Sns auth
通用第三方登录SDK,支持微信,微信扫码,QQ,微博登录,支付宝登录,Facebook,Line,Twitter,Google
Stars: ✭ 520 (-39.75%)
Mutual labels:  wechat, weixin
Quietweather
☀️ Develop a weather wechat mini program application in two days - 两天撸一个天气应用微信小程序
Stars: ✭ 677 (-21.55%)
Mutual labels:  wechat, weixin
Python Weixin
微信(weixin|wechat) Python SDK 支持开放平台和公众平台 支持微信小程序云开发
Stars: ✭ 746 (-13.56%)
Mutual labels:  wechat, weixin
Weixin Java Miniapp Demo
基于Spring Boot 和 WxJava 实现的微信小程序Java后端Demo
Stars: ✭ 779 (-9.73%)
Mutual labels:  wechat, weixin
Xiaochengxu demos
小程序优秀项目源码汇总,每个项目都有图有源码,零基础学微信小程序,小程序表格,小程序视频,小程序视频弹幕,小程序仿天猫大转盘抽奖等源码,小程序云开发,小程序发邮件,小程序支付,微信支付,持续更新。。。
Stars: ✭ 855 (-0.93%)
Mutual labels:  wechat, weixin
Weindex
微信相关资源汇总索引
Stars: ✭ 466 (-46%)
Mutual labels:  wechat, weixin

weixin-pay

微信支付 for node.js

npm version

Installation

npm install weixin-pay

Usage

创建统一支付订单

var WXPay = require('weixin-pay');

var wxpay = WXPay({
	appid: 'xxxxxxxx',
	mch_id: '1234567890',
	partner_key: 'xxxxxxxxxxxxxxxxx', //微信商户平台API密钥
	pfx: fs.readFileSync('./wxpay_cert.p12'), //微信商户平台证书
});

wxpay.createUnifiedOrder({
	body: '扫码支付测试',
	out_trade_no: '20140703'+Math.random().toString().substr(2, 10),
	total_fee: 1,
	spbill_create_ip: '192.168.2.210',
	notify_url: 'http://wxpay_notify_url',
	trade_type: 'NATIVE',
	product_id: '1234567890'
}, function(err, result){
	console.log(result);
});

查询订单

// 通过微信订单号查
wxpay.queryOrder({ transaction_id:"xxxxxx" }, function(err, order){
	console.log(order);
});

// 通过商户订单号查
wxpay.queryOrder({ out_trade_no:"xxxxxx" }, function(err, order){
	console.log(order);
});

关闭订单

wxpay.closeOrder({ out_trade_no:"xxxxxx"}, function(err, result){
	console.log(result);
});

退款接口

var params = {
	appid: 'xxxxxxxx',
	mch_id: '1234567890',
    op_user_id: '商户号即可',
    out_refund_no: '20140703'+Math.random().toString().substr(2, 10),
    total_fee: '1', //原支付金额
    refund_fee: '1', //退款金额
    transaction_id: '微信订单号'
};

wxpay.refund(params, function(err, result){
    console.log('refund', arguments);
});

原生支付 (NATIVE)

模式一

提供一个生成支付二维码链接的函数,把url生成二维码给用户扫。

var url = wxpay.createMerchantPrepayUrl({ product_id: '123456' });

商户后台收到微信的回调之后,调用 createUnifiedOrder() 生成预支付交易单,将结果的XML数据返回给微信。

什么是模式一?

模式二

直接调用 createUnifiedOrder() 函数生成预支付交易单,将结果中的 code_url 生成二维码给用户扫。

什么是模式二?

公众号支付 (JS API)

生成JS API支付参数,发给页面

wxpay.getBrandWCPayRequestParams({
	openid: '微信用户 openid',
	body: '公众号支付测试',
    detail: '公众号支付测试',
	out_trade_no: '20150331'+Math.random().toString().substr(2, 10),
	total_fee: 1,
	spbill_create_ip: '192.168.2.210',
	notify_url: 'http://wxpay_notify_url'
}, function(err, result){
	// in express
    res.render('wxpay/jsapi', { payargs:result })
});

网页调用参数(以ejs为例)

WeixinJSBridge.invoke(
	"getBrandWCPayRequest", <%-JSON.stringify(payargs)%>, function(res){
		if(res.err_msg == "get_brand_wcpay_request:ok" ) {
    		// success
    	}
});

中间件

商户服务端处理微信的回调(express为例)

// 原生支付回调
router.use('/wxpay/native/callback', wxpay.useWXCallback(function(msg, req, res, next){
	// msg: 微信回调发送的数据
}));

// 支付结果异步通知
router.use('/wxpay/notify', wxpay.useWXCallback(function(msg, req, res, next){
	// 处理商户业务逻辑

    // res.success() 向微信返回处理成功信息,res.fail()返回失败信息。
    res.success();
}));
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].