Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including wechat-cash with all npm packages installed. Try it out:

var wechatCash = require("wechat-cash")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wechat-cash v0.0.5

Wechat cash Node.js SDK

wechat-cash

Beta release, please do not use in production. For more details, please contact the author.

'use strict';
var fs = require('fs');
var Cash = require('wechat-cash');

var config = {
  partnerKey: '888f8e88888b88a8ebafc8e88e88e88f',
  appId: 'wxc88a88d88d8b8c88',
  mchId: '8888888888',
  pfx: fs.readFileSync(__dirname + '/apiclient_cert.p12')
};

var cash = new Cash(config);
cash.sendRedpack({
  'mch_billno': config.mchId + '201509220123456789',
  'wxappid': config.appId,
  'send_name': 'lodejs.org',
  're_openid': 'o-hVKuNknQQBZFDlbE8eibQzIX8o',
  'total_amount': 10000, //RMB100
  'total_num': 1,
  'wishing': '恭喜发财',
  'client_ip': '127.0.0.1',
  'act_name': '奖金发放',
  'remark': '打赏QQ:5794560'
}, function(err, result) {
  console.log(err, result);
});

cash.sendGroupRedpack({
  'mch_billno': config.mchId + '201509230123456789',
  'wxappid': config.appId,
  'send_name': 'lodejs.org',
  're_openid': 'o-hVKuNknQQBZFDlbE8eibQzIX8o',
  'total_amount': 10000, //RMB100
  'total_num': 3,
  'wishing': '恭喜发财',
  'act_name': '裂变红包',
  'remark': '打赏QQ:5794560'
}, function(err, result) {
  console.log(err, result);
});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free