Skip to content

we-demo/gh-wxpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gh-wxpay

[WIP] 打造一个基于github登录与微信支付,但又不依赖于微信登录(由github登录替代)的创新型支付体系,简称gx。

要求:前端页面、node后端、注册一个github-oauth应用、一个开通微信支付的公众号及商户信息。

发起github登录

location.href = 'https://example.com/gx/api/login'
  + `?from=${encodeURIComponent(location.href)}`

获取用户信息及已付费的项目列表

let { error, user, paid } = await request({
  url: 'https://example.com/gx/api/session'
})

获取微信支付二维码并展示

let { error, code_url } = await request({
  url: 'https://example.com/gx/api/order',
  query: {
    product_id,
    user_id,
    appid
  }
})

小程序发起微信支付

let { openid } = await request({
  url: 'https://example.com/gx/api/wx/token',
  query: {
    code,
    appid
  }
})

let { error, prepay_id } = await request({
  url: 'https://example.com/gx/api/order',
  query: {
    trade_type: 'JSAPI',
    openid,
    product_id,
    user_id,
    appid
  }
})

配置信息

// gx.conf.example.js
let host_url = 'https://example.com/gx'
let host_ip = '120.11.11.111'

module.exports = {
  gh: {
    client_id: 'xxxxxxxxxxxxxxxxxxxx',
    client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    callback_url: `${host_url}/api/oauth/callback`
  },
  wx: {
    mps: [ // 公众号/小程序
      {
        oid: 'xxxxxxxxxxxxxxx', // 原始id
        appid: 'xxxxxxxxxxxxxxxxxx', // 开发者id
        secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // 秘钥
      }
    ],
    mch_id: 'xxxxxxxxxx', // 商户号
    mch_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // 商户key
    notify_url: `${host_url}/api/wxpay/notify`, // 通知地址
    host_ip
  },
  app: {
    keys: ['xxxxxx']
  }
}

参考资料

About

打造一个基于github登录与微信支付,但又不依赖于微信登录(由github登录替代)的创新型支付体系,简称gx。

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published