Skip to content

node-weixin/node-weixin-hub

Repository files navigation

NPM version Build Status Dependency Status

Wexin Hub For Every Weixin Usage

Install

$ npm install --save node-weixin-hub

Usage

var nodeWeixinHub = require('node-weixin-hub');

Define config

var app = {
  id: process.env.APP_ID,
  secret: process.env.APP_SECRET,
  token: process.env.APP_TOKEN
};
var merchant = {
  id: process.env.MERCHANT_ID,
  key: process.env.MERCHANT_KEY
};
var certificate = {
  pfx: 'sdfsf',
  pfxKey: 'sss'
};
var config = {
  app: app,
  merchant: merchant,
  certificate: certificate,
  urls: {
    success: 'http://success.com/'
  }
};

Emit Events

//Ack
nodeWeixinHub.emit('weixin-auth-ack', auth, config, req, res);

//JSSDK-Prepare
var url = "http://www.sina.com.cn/";
nodeWeixinHub.emit('weixin-jssdk-prepare', auth, config, url, function (error, preparedData) {
  //preparedData
});

//Oauth access and redirect
nodeWeixinHub.emit('weixin-oauth-access', config, {state: 'STATUE', scope: 0}, res);

//Oauth success 
nodeWeixinHub.emit('weixin-oauth-success', config, code, function (error, data) {
  //data.openid
  //data.access_token
  //data.refresh_token
});

//Pay init
nodeWeixinHub.emit('weixin-pay-init', config, data, function (error, prepayData) {
});

//Pay notify
nodeWeixinHub.emit('weixin-pay-notify', config, req, res, function (error, data) {
  //data.is_subscribe
  //data.trade_type
  //data.bank_type
  //data.total_fee
  //data.fee_type
  //data.transaction_id
  //data.out_trade_no
  //data.time_end
});

License

MIT © node-weixin

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published