@xuda.io/account_module 1.2.2251 → 1.2.2252
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.mjs +24 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1701,7 +1701,6 @@ export const get_account_rt_info = async function (uid) {
|
|
|
1701
1701
|
};
|
|
1702
1702
|
|
|
1703
1703
|
export const validate_account_topup = async function (uid, items = []) {
|
|
1704
|
-
debugger;
|
|
1705
1704
|
const { code, data } = await stripe_ms.get_billing_metrics({ uid });
|
|
1706
1705
|
if (code < 0) {
|
|
1707
1706
|
throw new Error(data);
|
|
@@ -1720,7 +1719,7 @@ export const validate_account_topup = async function (uid, items = []) {
|
|
|
1720
1719
|
}
|
|
1721
1720
|
|
|
1722
1721
|
if (data?.balance?.past_due) {
|
|
1723
|
-
let err = new Error(`past due ${data.balance.past_due
|
|
1722
|
+
let err = new Error(`past due ${data.balance.past_due}`);
|
|
1724
1723
|
err.code = -91;
|
|
1725
1724
|
err.billing_problem = true;
|
|
1726
1725
|
err.topup = topup + data.balance.past_due;
|
|
@@ -1753,9 +1752,32 @@ export const validate_account_topup = async function (uid, items = []) {
|
|
|
1753
1752
|
throw err;
|
|
1754
1753
|
}
|
|
1755
1754
|
|
|
1755
|
+
await release_account_billing_hold_if_current(uid);
|
|
1756
|
+
|
|
1756
1757
|
return true;
|
|
1757
1758
|
};
|
|
1758
1759
|
|
|
1760
|
+
const release_account_billing_hold_if_current = async function (uid) {
|
|
1761
|
+
const account_ret = await db_module.get_couch_doc('xuda_accounts', uid);
|
|
1762
|
+
if (account_ret.code < 0 || !account_ret.data?.account_billing_hold_status) {
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
const account_obj = account_ret.data;
|
|
1767
|
+
account_obj.account_billing_hold_status = 0;
|
|
1768
|
+
account_obj.account_billing_hold_date = Date.now();
|
|
1769
|
+
await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
1770
|
+
|
|
1771
|
+
ws_dashboard_msa.emit_message_to_dashboard({
|
|
1772
|
+
service: 'account_billing_hold_released',
|
|
1773
|
+
to: [uid],
|
|
1774
|
+
data: {
|
|
1775
|
+
account_billing_hold_status: 0,
|
|
1776
|
+
account_billing_hold_date: account_obj.account_billing_hold_date,
|
|
1777
|
+
},
|
|
1778
|
+
});
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1759
1781
|
const get_prices = function (uid, item) {
|
|
1760
1782
|
let price;
|
|
1761
1783
|
|