Electron-vue开发的客户端支付收款工具的实现

2019-11-12,,,

目前实现了支付宝当面付的扫码支付功能、二维码支付功能,即主动扫和被动扫。测试请使用支付宝沙箱环境,支付宝是沙箱版。

最终效果如下:

前端页面使用阿里的组件,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?',//用于接收支付宝异步通知
};

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持北冥有鱼。

您可能感兴趣的文章:

  • electron-vue利用webpack打包实现多页面的入口文件问题
  • 使用electron将vue-cli项目打包成exe的方法
  • 解决Vue+Electron下Vuex的Dispatch没有效果问题
  • electron + vue项目实现打印小票功能及实现代码
  • Electron-vue脚手架改造vue项目的方法
  • Electron + vue 打包桌面操作流程详解

《Electron-vue开发的客户端支付收款工具的实现.doc》

下载本文的Word格式文档,以方便收藏与打印。