Giter Club home page Giter Club logo

payjs-node-sdk's Introduction

PayJS SDK 的 nodejs 版本

typescript code style: prettier

使用 typescript 编写,用于对接 PayJS 的非官方 sdk.

安装

$ npm install @mefedev/payjs-node-sdk --save

演示( 仅支持微信 )

演示地址请在微信浏览器打开

屏幕截图

使用

支付

import PayJS from '@mefedev/payjs-node-sdk'

const sdk = PayJS({
  key: 'PayJS 通信密钥',
  mchId: 'PayJS 商户号'
})

// 获取支付二维码
const result = await sdk.payment.native({
  total_fee: 100,
  out_trade_no: '内部系统订单'
})

// 付款码支付
const result = await sdk.payment.microPay({
  total_fee: 100,
  out_trade_no: '内部系统订单'
})

// JS API 支付
const result = await sdk.payment.jsPay({
  total_fee: 100,
  out_trade_no: '内部系统订单',
  openid: '微信 openid'
})

// 获取收银台地址
const redirectUri = sdk.payment.getCashierUri({
  total_fee: 100,
  out_trade_no: '内部系统订单'
})

订单接口

import PayJS from '@mefedev/payjs-node-sdk'

const sdk = PayJS({
  key: 'PayJS 通信密钥',
  mchId: 'PayJS 商户号'
})

// 查询订单
const order = await sdk.order.query('payjs_order_id')

// 撤销订单
const result = await sdk.order.reverse('payjs_order_id')

// 关闭订单
const result = await sdk.order.close('payjs_order_id')

// 主动退款
const result = await sdk.order.refund('payjs_order_id')

其他 API

import PayJS from '@mefedev/payjs-node-sdk'

const sdk = PayJS({
  key: 'PayJS 通信密钥',
  mchId: 'PayJS 商户号'
})

// 生成微信授权地址
// 注意: 这会同步方法
const authUri = sdk.wechat.getAuthUri('http://example.com')

// 获取商户数据
const merchant = await sdk.merchant.getInfo()

本地开发

你需要安装 node.js 的版本为 nodejs >= 8.0

克隆此仓库后运行:

# 推荐使用 yarn 或 cnpm 来管理依赖
$ npm install

# 监听文件变化
$ npm run watch

# 生成 API 文档.
$ npm run doc

package.json 文件的 scripts 部分还有一些其他脚本可用.

版本发布

# 更新版本号,内置代码检查
$ npm version <new_version|major|minor|patch>

可使用 npm version --help 查看帮助信息

升级日志

ChangeLog.

payjs-node-sdk's People

Contributors

zhengxs2018 avatar

Stargazers

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