目前實現了支付寶當面付的掃碼支付功能、二維碼支付功能,即主動掃和被動掃。測試請使用支付寶沙箱環境,支付寶是沙箱版。
最終效果以下:
前端頁面使用阿里的組件,ant-design-vue
經過node,使用nedb內存數據庫進行本地數據存儲
安裝文件支持自定義。生成的exe,安裝過程以下css
程序代碼簡述
main.js前端
import devtools from '@vue/devtools' import Vue from 'vue' import axios from 'axios' import App from './App' import router from './router' import store from './store' import db from './nedb'//訂單表 import Antd from 'ant-design-vue' import 'ant-design-vue/dist/antd.css' import alipayhelper from './alipayhelper' import moment from 'moment'//導入文件 Vue.prototype.$moment = moment;//賦值使用 Vue.prototype.$db = db Vue.prototype.alipayhelper = alipayhelper; Vue.use(Antd) if (!process.env.IS_WEB) Vue.use(require('vue-electron')) Vue.http = Vue.prototype.$http = axios Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ components: { App }, router, store, template: '<App/>' }).$mount('#app')
alipayhelper.js 裏存儲的支付寶收款方的APPID,pem路徑下應用私鑰。這些信息能夠經過阿里官方申請,便可以在線收款vue
const path = require('path'); const fs = require('fs'); const moment = require('moment'); const crypto = require('crypto'); const electron = require('electron'); const dataPath = (electron.app || electron.remote.app).getPath('userData'); const home = (electron.app || electron.remote.app).getPath('home'); const appData = (electron.app || electron.remote.app).getPath('appData'); let ALI_PAY_SETTINGS = { APP_ID: '2016100100638328', APP_GATEWAY_URL: 'http://localhost',//用於接收支付寶異步通知 AUTH_REDIRECT_URL: 'xxxxxxx',//第三方受權或用戶信息受權後回調地址。受權連接中配置的redirect_uri的值必須與此值保持一致。 //__dirname 獲取當前目錄,沒法在生產模式assr 獲取到路徑 /* APP_PRIVATE_KEY_PATH: path.join(__dirname, 'pem', 'rsa_private_key.pem'),//應用私鑰 APP_PUBLIC_KEY_PATH: path.join(__dirname, 'pem', 'rsa_public_key.pem'),//應用公鑰 ALI_PUBLIC_KEY_PATH: path.join(__dirname, 'pem','ali_rsa_public_key.pem'),//阿里公鑰*/ APP_PRIVATE_KEY_PATH: path.join(__static, '/pem/rsa_private_key.pem'),//應用私鑰 APP_PUBLIC_KEY_PATH: path.join(__static, '/pem/rsa_public_key.pem'),//應用公鑰 ALI_PUBLIC_KEY_PATH: path.join(__static, '/pem/ali_rsa_public_key.pem'),//阿里公鑰 AES_PATH: path.join(__dirname, 'pem', 'remind', 'sandbox', 'aes.txt'),//aes加密(暫未使用) ALI_GATEWAY_URL: 'https://openapi.alipaydev.com/gateway.do?',//用於接收支付寶異步通知 };