All Projects → yangfuhe → node-wxpay

yangfuhe / node-wxpay

Licence: other
微信支付APIv3 for nodejs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-wxpay

wechatpay-go
微信支付 APIv3 的 Go Library
Stars: ✭ 553 (+494.62%)
Mutual labels:  wechatpay
yara-exporter
Exporting MISP event attributes to yara rules usable with Thor apt scanner
Stars: ✭ 22 (-76.34%)
Mutual labels:  cert
anvil
Tools for distributing ssl certificates
Stars: ✭ 29 (-68.82%)
Mutual labels:  cert
qiniu-auto-cert
七牛 CDN 证书自动化工具
Stars: ✭ 20 (-78.49%)
Mutual labels:  cert
Coursera-Certifications
A repository to showcase my completed courses on the Coursera platform.
Stars: ✭ 20 (-78.49%)
Mutual labels:  cert
training-materials
No description or website provided.
Stars: ✭ 47 (-49.46%)
Mutual labels:  cert
Simple-TLS-Client-Server-with-Node.js
Simple TLS Client/Server with Node.js
Stars: ✭ 22 (-76.34%)
Mutual labels:  cert
openjs-nodejs-application-developer-study-guide
Resources and notes to help prepare for the Node JS Application Developer (JSNAD) certification exam
Stars: ✭ 64 (-31.18%)
Mutual labels:  cert
dnslog
Minimalistic DNS logging tool
Stars: ✭ 40 (-56.99%)
Mutual labels:  cert
NinjaDroid
Ninja Reverse Engineering on Android APK packages
Stars: ✭ 224 (+140.86%)
Mutual labels:  cert
Rxtool
Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | Zip4j压缩(支持分卷压缩与加密) | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | WebView的封装可播放视频 | 仿斗鱼滑动验证码 | Toast封装 | 震动 | GPS | Location定位 | 图片缩放 | Exif 图片添加地理位置信息(经纬度) | 蛛网等级 | 颜色选择器 | ArcGis | VTPK | 编译运行一下说不定会找到惊喜
Stars: ✭ 11,567 (+12337.63%)
Mutual labels:  wechatpay
XLsn0wPay
XLsn0w WeChat And Alipay SDK Pay Manager 微信支付SDK/支付宝SDK/银联支付/Paypal支付 接入指南(一键支付管理工具类)
Stars: ✭ 31 (-66.67%)
Mutual labels:  wechatpay
cordova-plugin-xpay
💰 This is a app payment cordova-plugin, support wechat payment and alipay temporally.
Stars: ✭ 19 (-79.57%)
Mutual labels:  wechatpay
wechat-pay
Simplest WechatPay(最简单的微信支付)
Stars: ✭ 49 (-47.31%)
Mutual labels:  wechatpay
payjs-laravel
基于 PAYJS 微信支付个人接口开发的 Laravel Package,可直接用于生产环境
Stars: ✭ 57 (-38.71%)
Mutual labels:  wechatpay
payjs
基于 PAYJS 微信支付个人接口开发的 Package,可直接用于生产环境
Stars: ✭ 73 (-21.51%)
Mutual labels:  wechatpay
AppPay
💸 AppPay专注于App支付的库,几句代码轻松搞定微信支付、支付宝支付。集成更简单。
Stars: ✭ 33 (-64.52%)
Mutual labels:  wechatpay
anger-wechat
👿Angry wechat api 微信支付、小程序、各种接口的封装。
Stars: ✭ 17 (-81.72%)
Mutual labels:  wechatpay

node-wxpay

微信支付APIv3 for nodejs

功能概述

  • 完成模块 jsapi,native,h5,app统一下单,付款交易查询,退款,退款交易查询,解密通知参数,公钥获取,验证签名,交易账单,资金账单,下载账单
  • 支付模式支持 付款码/公众号/小程序/APP/H5/扫码支付

交流

微信:yangfuhe036,如有任何问题欢迎加微信交流。喜欢或对你有帮助,欢迎右上角 star,非常感谢!

使用前必读

版本要求

nodejs >= 8.3.0

安装

npm i wxpay-v3 --save

# 如已安装旧版, 重新安装最新版
npm i wxpay-v3@latest

实例化

const Payment = require('wxpay-v3');
const paymnet = new Payment({
    appid: '公众号ID',
    mchid: '微信商户号',
    private_key: require('fs').readFileSync('*_key.pem证书文件路径').toString(),//或者直接复制证书文件内容
    serial_no:'证书序列号',
    apiv3_private_key:'api v3密钥',
    notify_url: '支付退款结果通知的回调地址',
})

config说明:

  • appid - 公众号ID(必填)
  • mchid - 微信商户号(必填)
  • private_key - 商户API证书*_key.pem中内容 可在微信支付平台获取(必填, 在微信商户管理界面获取)
  • serial_no - 证书序列号(必填, 证书序列号,可在微信支付平台获取 也可以通过此命令获取(*_cert.pem为你的证书文件) openssl x509 -in *_cert.pem -noout -serial )
  • apiv3_private_key - apiv3密钥 在创建实例时通过apiv3密钥会自动获取平台证书的公钥,以便于验证签名(必填)
  • notify_url - 支付退款结果通知的回调地址(选填)
    • 可以在初始化的时候传入设为默认值, 不传则需在调用相关API时传入
    • 调用相关API时传入新值则使用新值

jsapi统一下单

let result = await payment.jsapi({
    description:'点存云-测试支付',
    out_trade_no:Date.now().toString(),
    amount:{
        total:1
    },
    payer:{
        openid:'ouEJk65CZr8_7eb95RIPDNWZKrvI'
    },

})
console.log(result)

app统一下单

let result = await payment.app({
    description:'点存云-测试支付',
    out_trade_no:Date.now().toString(),
    amount:{
        total:1
    }
})
console.log(result)

h5统一下单

let result = await payment.h5({
    description:'点存云-测试支付',
    out_trade_no:Date.now().toString(),
    amount:{
        total:1
    },
    scene_info:{
        payer_client_ip:'203.205.219.187'
    }
})
console.log(result)

native统一下单

let result = await payment.native({
    description:'点存云-测试支付',
    out_trade_no:Date.now().toString(),
    amount:{
        total:1
    }
})
console.log(result)

通过transaction_id查询订单

let result = await payment.getTransactionsById({
    transaction_id:'4200000928202103013162567337'
})
console.log(result)

通过out_trade_no查询订单

let result = await payment.getTransactionsByOutTradeNo({
    out_trade_no:'1614602083807'
})
console.log(result)

关闭订单

let result = await payment.close({
    out_trade_no:'1614602083807'
})
console.log(result)

退款

let result = await payment.refund({
    transaction_id:'4200000902202103026804947229',
    //out_trade_no:'1614602083807',
    out_refund_no:Date.now().toString(),
    amount:{
        refund:1,
        total:1,
        currency:'CNY'
    }
})
console.log(result)

查询单笔退款订单

let result = await payment.getRefund({
    out_refund_no:'1614757507992',
})
console.log(result)

获取平台证书列表

let result = await payment.getCertificates()
console.log(result)

解密支付退款通知参数

let result = payment.decodeResource({
    "original_type":"refund",
    "algorithm":"AEAD_AES_256_GCM",
    "ciphertext":"d2Zi2VToOGXqB3K6bgQaFKktgA3AHm+cJg0vGZPcD22OUZ+CBymtrFJsFtaKKEwebSDN8Habic7NJVpKJpAxZd8ejm32v4UePg139/gj+X7vJtqB39ZkjZXLH973LT5R5yZQ351R3onlpx9JILN2+FNEbrUNenjgEufuQn45b9jwGSBX/sU6n/+gsCdt8+sSkbMy37sSX1bjMicHzte27fR0QSuO1TDjZjjDqP2ou0j7Jb+x9RRtWlbZ1hOYe7AhSTFzOXvkdCq0M6P6ja1cc2olV9xG8UzKxZN0JLnoqIGWwPzTVOPqmt/N3/MrzCK3TT1mNagBnhqEvSXhL9KUjpAIY8J6tkjfoG+9QwnJA8kW48C3nGsgePvNYvikJooQii7rx78Y2paR7cS8Pn8+sxKg4q91DiovBSdW2/ePDruI6SH/FWFrPmLQCG11fCjz/C9o6bqjaSsHKMaSVSAW9e/et04MP6GcZIDweG5AN9FgOXMI",
    "associated_data":"refund",
    "nonce":"AqfRSFm7h9Sa"
})
console.log(result)

验证签名

setTimeout(async ()=>{
    //timestamp,nonce,serial,signature均在HTTP头中获取,body为请求参数
    let result = await payment.verifySign({
        timestamp:'1614829763',
        nonce:'Eeumuhd3zA5TirWeJUCLCpkENYM8PSUA',
        serial:'3DEA336346E96C002B7B0D514D424C8DEDBF9145',
        signature:'ame3lX1y6FeXrlBN973M1Dhg5n77M1wVsD3VgeyZlb8c3dz/hpQ+9vNOMBBHGdv8kDIfZUxKDdfoeUaVJhfqAEn9ZV4x112ntEzCHpJtIXQ3rr8fScY7cO71EN/QyQHtY1Ovt8U2Yr891iYaLujUrBHtWrhiR6UKecRA+/RgsUBYh4D10rrqW5ywNrLVN+PSuG4QB85bz3jSslMvRrSG7HP/Xwo3e2sWMDuQ2Uadefu+8/FK1P3KDLDO2fq5teSaaqs7oof2WpV6zrVtyQ+P4p5t8NJ0ExlOSAs2xGJ0+xi+U996tq3VYZXf/4nVsfGW9rn0m/mOrYTmiST9PF+q1g==',
        body:'{"id":"3b66121d-c9b9-5d61-9d92-eeec248e993d","create_time":"2021-03-04T11:49:23+08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"PB305U6jR6TN8mBzbzGts5TaKnDXQt/7C+uJpGnvOT1SyCvI18L4f42eTZtrZv+5XUdOkxwEHGWDVl2MwbvpgLjLdjyisaHc+uRQCDoYlusiaeDJzd515Rl36nqmdPD8xFKZahWZBBkAlCgXLuW3qcdxSISTk/pyqPziwUtFKfMeq3LEEm4z8DfBM9cVXJrN8EiY2WaQsm+lGnZAV4+pxCELj67xmccXs3JgJwHSKE4exqW919atQWTwJHzuP3WNd+Xvp0zwm9RtDPTvZ8egehqqBw+DARC5jg8MmDtlMR2sTgH2xq6b4+QqLXPPIooOyvEZKMOteSI4FmSfPNwDfZ26D4ga9yGRIxSQKkWDq3QRNhOzvmSkCax08t2hdq12NxBSE9y7aZkjKIr4/uMEtKDU/3wcSoVKlawfN1hlCKo2nWbdKH1avRvc6FAFxXHtXRw0Y0MRnSk8gPMF/T+QqEMRJniXbrylt21xR0AEKbIVk0xK9jvhXex0AvST4x3eKM0r4DXkmL/pCjo1XmZLZIMc2uJ1jJEyqWcURXirrxADCATIAEWOu1hNL6PE","associated_data":"transaction","nonce":"KcsMoPx5UW1i"}}'
    })
    console.log(result)
},2000)

申请交易账单

let result = await payment.tradebill({
    bill_date:'2021-03-03'
})
console.log(result)

申请资金账单

let result = await payment.fundflowbill({
    bill_date:'2021-03-03'
})
console.log(result)

下载账单

let result = await payment.downloadbill('https://api.mch.weixin.qq.com/v3/billdownload/file?token=ktWgOuBvGNvmCk0NaOTMF41tG3yWsZrdM4zdgl10r1GRRNo4tG5V9mPi04ku-PY8&tartype=gzip')
console.log(result)

交流

微信:yangfuhe036,如有任何问题欢迎加微信交流。喜欢或对你有帮助,欢迎右上角 star,非常感谢!

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].