@xuda.io/account_module 1.2.85 → 1.2.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +37 -37
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1393,49 +1393,49 @@ exports.get_account_rt_info = async function (uid) {
|
|
|
1393
1393
|
return account_info;
|
|
1394
1394
|
};
|
|
1395
1395
|
|
|
1396
|
-
exports.validate_account_topup = async function (uid, items = []) {
|
|
1397
|
-
|
|
1396
|
+
// exports.validate_account_topup = async function (uid, items = []) {
|
|
1397
|
+
// const stripe_module = require(`${module_path}/stripe_module`);
|
|
1398
1398
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1399
|
+
// const { code, data } = await stripe_module.get_billing_metrics({ uid });
|
|
1400
|
+
// if (code < 0) {
|
|
1401
|
+
// throw new Error(data);
|
|
1402
|
+
// }
|
|
1403
|
+
// let topup = 0;
|
|
1404
|
+
// for (const item of items) {
|
|
1405
|
+
// topup += get_prices(uid, item);
|
|
1406
|
+
// }
|
|
1407
1407
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1408
|
+
// // if ((!data?.customer_obj?.default_source, { billing_problem: true, topup })) {
|
|
1409
|
+
// // throw new Error("no card on file");
|
|
1410
|
+
// // }
|
|
1411
|
+
// debugger;
|
|
1412
|
+
// if (data?.balance?.past_due) {
|
|
1413
|
+
// throw new Error(`past_due ${data?.balance?.past_due}`, {
|
|
1414
|
+
// billing_problem: true,
|
|
1415
|
+
// topup,
|
|
1416
|
+
// });
|
|
1417
|
+
// }
|
|
1418
1418
|
|
|
1419
|
-
|
|
1419
|
+
// const balance = data?.balance?.account || 0; // minus balance represents positive balance
|
|
1420
1420
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1421
|
+
// if (balance > 0) {
|
|
1422
|
+
// throw new Error(`negative balance ${-balance}`, {
|
|
1423
|
+
// billing_problem: true,
|
|
1424
|
+
// topup: topup - balance, // ask for whole balance
|
|
1425
|
+
// });
|
|
1426
|
+
// }
|
|
1427
1427
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1428
|
+
// if (topup + balance > 0) {
|
|
1429
|
+
// throw new Error(`not enough balance ${topup + balance}`, {
|
|
1430
|
+
// billing_problem: true,
|
|
1431
|
+
// topup, //-(topup + balance)
|
|
1432
|
+
// });
|
|
1433
|
+
// }
|
|
1434
1434
|
|
|
1435
|
-
|
|
1436
|
-
};
|
|
1435
|
+
// return true;
|
|
1436
|
+
// };
|
|
1437
1437
|
|
|
1438
|
-
exports.
|
|
1438
|
+
exports.validate_account_topup = async function (uid, items = []) {
|
|
1439
1439
|
const stripe_module = require(`${module_path}/stripe_module`);
|
|
1440
1440
|
|
|
1441
1441
|
const { code, data } = await stripe_module.get_billing_metrics({ uid });
|
|
@@ -1444,7 +1444,7 @@ exports.validate_account_topup2 = async function (uid, items = []) {
|
|
|
1444
1444
|
}
|
|
1445
1445
|
let topup = 0;
|
|
1446
1446
|
for (const item of items) {
|
|
1447
|
-
topup += get_prices(item);
|
|
1447
|
+
topup += get_prices(uid, item);
|
|
1448
1448
|
}
|
|
1449
1449
|
|
|
1450
1450
|
if ((!data?.customer_obj?.default_source, { billing_problem: true, topup })) {
|