目前實現了支付寶當面付的掃碼支付功能、二維碼支付功能,即主動掃和被動掃。測試請使用支付寶沙箱環境,支付寶是沙箱版。
最終效果如下:
前端頁面使用阿里的組件,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 = dbVue.prototype.alipayhelper = alipayhelper;Vue.use(Antd)if (!process.env.IS_WEB) Vue.use(require('vue-electron'))Vue.http = Vue.prototype.$http = axiosVue.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?',//用于接收支付寶異步通知};
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答