SEMIPAY - An Open Source Wechat Payment Solution
Welcome to SEMIPAY, a semi-automatic WeChat payment solution that can be easily deployed privately with a single click on Vercel.
It helps create a personal semi-automatic payment collection system and eliminates the need for record filing and transaction fees associated with online payments
github forkhttps://github.com/wanghsinche/semipay
Demo
Usage
Set up the config
use the following JSON to set up your vercel edge-config https://vercel.com/dashboard/stores/edge-config
{
"qrcode": [
{
"url": "https://..co/storage/v1/object/public/static/five1.jpg",
"remark": "five1",
"price": 5
},
{
"url": "https://..co/storage/v1/object/public/static/five2.jpg",
"remark": "five2",
"price": 5
},
{
"url": "https://..co/storage/v1/object/public/static/five3.jpg",
"remark": "five3",
"price": 5
}
],
"webhook": "https://ok/api/wepaynotify?",
"telegram": "https://api.telegram.org/botxxxx:xxxx/sendMessage?chat_id=xxx&",
"email": "",
"notifier": "",
"hostname": "https://pay",
"confirmWebhook": "https://ok/api/wepaynotify?",
"secret": "123"
}
To get a checkout link from your business server
const hostname = 'https://your.pay.domain';
// prepare your info
const info = {
price: 0,
user: 'donate@user.com',
extra: 'donate',
timestamp: Date.now()
};
// get the secret
const secret = process.env.SECRET;
// in alphabet order
const text = Object.keys(info).sort().map(k=> info[k]).join(',');
// use sha256 to encrypt your info
const token = createHmac('sha256', secret).update(text).digest('base64');
const checkout = await fetch(`${hostname}/api/checkout`, {
method: 'post',
body: JSON.stringify({...info, token})
}).then(res=>{
if(res.status !== 200) throw new Error(res.status);
return res;
}).then(res=>res.json());
// get the checkout url
console.log(checkout);