You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __publicField = (obj, key, value) => {
|
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
return value;
|
|
};
|
|
const utils_pay_index = require("./index.js");
|
|
const _Pay = class {
|
|
static inject(name, module2) {
|
|
this.modules.set(name, module2);
|
|
}
|
|
constructor() {
|
|
for (const [name, module2] of _Pay.modules.entries()) {
|
|
module2.init(name, this);
|
|
}
|
|
}
|
|
//调用支付
|
|
async payment(payWay, options) {
|
|
try {
|
|
const module2 = this[utils_pay_index.PayWayEnum[payWay]];
|
|
if (!module2) {
|
|
return Promise.reject(`can not find pay way ${payWay}`);
|
|
}
|
|
return await module2.run(options);
|
|
} catch (error) {
|
|
return Promise.reject(error);
|
|
}
|
|
}
|
|
};
|
|
let Pay = _Pay;
|
|
__publicField(Pay, "modules", /* @__PURE__ */ new Map());
|
|
exports.Pay = Pay;
|
|
|