使用Electron-vue開發的客戶端支付收款工具

Electron-vue開發的客戶端支付收款工具


目前實現了支付寶當面付的掃碼支付功能、二維碼支付功能,即主動掃和被動掃。測試請使用支付寶沙箱環境,支付寶是沙箱版。
最終效果如下:
圖片描述
圖片描述
前端頁面使用阿里的組件,ant-design-vue
通過node,使用nedb內存數據庫進行本地數據存儲
圖片描述
安裝文件支持自定義。生成的exe,安裝過程如下

圖片描述

程序代碼簡述
圖片描述
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路徑下應用私鑰。這些信息可以通過阿里官方申請,即可以在線收款

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?',//用於接收支付寶異步通知
};

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章