• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

利用有赞云和有赞微小店实现个人收款解决方案

YouzanQrPayPortal

利用有赞云和有赞微小店实现个人收款解决方案 .

GitHub issues GitHub forks GitHub stars dependency status Build Status GitHub license code style: prettier


Intro

利用有赞云和有赞微小店实现个人收款解决方案, 提供如下两个服务:

  • 代理简化生成收款二维码的 API,支持微信支付宝扫描付款
  • 接收有赞云的交易消息推送并处理(需要二次请求交易详情),简化订单状态通知到指定的服务器

核心原理是提供了一个支付中转层,将自有商户订单与有赞云的订单绑定起来,实现支付状态更新

为什么做成单独的服务:

  • 方便对接任何系统
  • 状态推送可以更灵活的自定义
  • 单独服务模式维护减少对原有系统影响

Usage

有赞云端

  • 注册有赞云 开发者

  • 创建有赞微小店 并扫码下载相应 APP 便于后续管理资金,注意这个小店在有赞后台看不到,只有 APP 可见

  • 应用授权-有赞云控制台创建自用型应用并授权刚创建的店铺,在[推送服务]设置中设置推送网址http://www.example.com/api/status , 同时勾选下方的交易消息选项。

本服务

  • 启动服务配置环境参数,复制envrc.sampleenvrc并填写

其中:

YOUZANYUN_CLIENT_ID: 有赞云应用的 client_id

YOUZANYUN_CLIENT_SECRET: 有赞云应用的 client_secret

YOUZAN_KDT_ID: 有赞云应用绑定的微小店 ID

SELF_SECRET: 自有订单系统接收本服务推送数据的加盐 secret

PUSH_API: 自有订单系统接收本服务推送数据的地址

npm run start // 启动服务
npm run list // 查看服务列表及状态
npm run stop // 停止服务
  • 提供公网服务,请使用 Nginx 代理至 Node Server,这样能够让有赞推送消息到达推送网址

自有订单系统端

  • 接入自有商店订单系统,支付时请求服务生成收款二维码

    • 接口地址示例: http://www.example.com/api/payment/qrcode
    • 调用方法 POST application/json
    • 请求数据 name: 商品名, price: 价格(分), order_id: 自有系统的订单号
    • 返回数据
        1. 正常情况 qr_id: 二维码 ID; qr_url: 有赞系统内支付地址(不推荐使用,需要付费者注册有赞); qr_code: Base64 图片数据,可直接作为 img 的 src 使用
        1. 异常情况 null
    curl -X POST -H 'Content-type: application/json' --data '{"name":"test name", "price": 1, "order_id": "your orderid"}' http://www.example.com/api/payment/qrcode
    
  • 接收状态推送自有订单系统提供一个PUSH_API地址接收数据推送,数据格式如下:

    {
        "tradeNo": "E20180201105656001353613-6377801",
        "orderId": "1515174485676262",
        "payment": 10,
        "status": "TRADE_SUCCESS",
        "sign": "c857c0f8d52ae9713a77b5c07dda93dc",
        "time": "1517457474"
    }

    其中 sign 是time,tradeNo,orderId,payment,status,SELF_SECRET使用"|"拼接字符串的 MD5 特征值,请在状态接收端按此逻辑进行校验数据合法性

    此外 status 的 enum 如下:

    enum YZBusinessStatus {
        // 等待买家付款
        WAIT_BUYER_PAY = "WAIT_BUYER_PAY",
        // 待确认,包括(待成团:拼团订单、待接单:外卖订单)
        WAIT_CONFIRM = "WAIT_CONFIRM",
        // 等待卖家发货,即:买家已付款
        WAIT_SELLER_SEND_GOODS = "WAIT_SELLER_SEND_GOODS",
        // 等待买家确认收货,即:卖家已发货
        WAIT_BUYER_CONFIRM_GOODS = "WAIT_BUYER_CONFIRM_GOODS",
        // 买家已签收
        TRADE_BUYER_SIGNED = "TRADE_BUYER_SIGNED",
        // 交易成功
        TRADE_SUCCESS = "TRADE_SUCCESS",
        // 交易关闭
        TRADE_CLOSED = "TRADE_CLOSED"
    }

    一般处理TRADE_SUCCESSTRADE_CLOSED即可,返回 200 状态表示处理成功

TODO

  • 推送失败重推

More Repositories

1

StarCabinet

🎉 开源的跨平台Github Stars管理分析工具
TypeScript
408
star
2

AlipayOrdersSupervisor

✨ 使用Node监视支付宝订单,即时通知服务器以实现免签约支付接口
JavaScript
374
star
3

AlipayOrdersSupervisor-GUI

GUI of AlipayOrdersSupervisor, implemented in Java and Swing
Java
87
star
4

Tint

🎨 WordPress高级扩展主题
PHP
65
star
5

GithubProfile

Visualizing GitHub profile
TypeScript
44
star
6

Tint-Pro

WordPress高级扩展主题Tinection Two/Tint
JavaScript
44
star
7

React-Limited-Infinite-Scroll

A limited infinite scroll component for React(React有限无限加载组件)
JavaScript
36
star
8

common-mpvue

使用mpvue开发小程序通用能力封装
JavaScript
30
star
9

Elune

🤔 Elune project
Java
29
star
10

thrift2ts

🚀 Parse Thrift (IDL) to TypeScript and generate thrift clients meanwhile.
TypeScript
27
star
11

generator-mpvue-project

Yeoman generator of mpvue project
JavaScript
25
star
12

CoCode

🐳 CoCode编程交流社区 iOS 客户端
Objective-C
22
star
13

Elune-WWW

🌾 Front end for Elune forum project
CSS
17
star
14

Wechat

Easy to use Wechat SKD for Node(under dev)
TypeScript
13
star
15

JSRegexs

🔧 Useful validate method with JavaScript
JavaScript
12
star
16

Vue-TS-Boilerplate

A Vue.js starter boilerplate with typescript
JavaScript
10
star
17

Browser-Thrift

Thrift RPC data transport protocol re-implementation in TypeScript for browser side RPC client
TypeScript
8
star
18

COS-As-ImageService

Image upload/download service with Tecent COS
TypeScript
8
star
19

UM

WordPress开源博客程序用户中心扩展插件
PHP
7
star
20

dubbo-node

🌏 NodeJS communicate with dubbo and services generator CLI
JavaScript
7
star
21

Vue-TSX-Helper

Write class-based Vue component via TypeScript with better intellisense and type check
TypeScript
6
star
22

str2hex

npm package gulp-str2hex to add confusion for your JavaScript code
JavaScript
5
star
23

Plog

由 Python 开发的个人博客程序
Python
4
star
24

Razor

🚧  基于Netty的轻量级MVC框架
Java
4
star
25

GitRandEmoji

Add random emoji or 颜文字 to git commit message
TypeScript
3
star
26

proto-splitter

Split protobuf files into single method protos and tree shaking
JavaScript
3
star
27

Thrift2TS-Flow-Demo

TypeScript
3
star
28

wordpress-hash-go

WordPress password hasher implemented with Golang
Go
3
star
29

Swift-Pictures

Image storage service with openstack swift
TypeScript
3
star
30

vite-plugin-auto-css-modules

same as babel-plugin-auto-css-modules but for vite
TypeScript
3
star
31

Velay

使用 TypeScript 以 OOP 的方式写 Vue 和 Vuex store.
TypeScript
3
star
32

Node-Socket-Pool

Socket connection pool for Node
JavaScript
2
star
33

CustomTSLintRules

Custom TSLint rules
TypeScript
2
star
34

MyWebpack

My webpack integrated CLI for multi-entries and collaborative projects
TypeScript
2
star
35

mpvue-rc-loader

Mpvue raw components loader
JavaScript
2
star
36

Emojis

😁 Emojis collections in MarkDown and TypeScript file format
TypeScript
2
star
37

Dockerized-Node-Balance

使用Docker和docker-compose快速部署Node APP以及实现Nginx负载均衡
Nginx
2
star
38

customized-progress-webpack-plugin

Fork and customize of simple-progress-webpack-plugin
JavaScript
2
star
39

era

TypeScript
2
star
40

Generator-TS-React

A yeoman generator of helping to init your React/TypeScript project
JavaScript
2
star
41

Electron-React-Webpack-Boilerplate

使用Electron、React、Webpack打包和热加载开发的样板工程,用于快速搭建初始开发环境
JavaScript
2
star
42

English-Books

English books for self-helping/self-development
1
star
43

quick-static-server

Quickly server your static files with only one command
JavaScript
1
star
44

WRGameVideos-Server

游戏视频聚合 Web Client
Python
1
star
45

WRGameVideos-API

a server which provide API data for my next iOS app
Python
1
star
46

MyWechatBot

Wechat bot of mine
JavaScript
1
star
47

vite-plugin-api-mocker

A local api mocker plugin for vite
TypeScript
1
star
48

miniprogram-types

Typings for miniprogram
JavaScript
1
star
49

spectre

React implement for Spectre.css(Deprecated)
CSS
1
star
50

draftjs-to-html-fork

🙇 draftjs raw content to html convertor with code highlight support
JavaScript
1
star
51

WordPressKit

开源博客程序WordPress函数库/API/源码查看以及个人基于WordPress站点的管理工具
PHP
1
star
52

DailyUpdates

Small daily report app for team members
C#
1
star
53

tts-cli

Edge TTS CLI
Python
1
star