backend-manager 5.0.84 → 5.0.86
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/CHANGELOG.md +34 -0
- package/CLAUDE.md +66 -3
- package/README.md +7 -5
- package/package.json +5 -4
- package/src/cli/commands/base-command.js +89 -0
- package/src/cli/commands/emulators.js +3 -0
- package/src/cli/commands/serve.js +5 -1
- package/src/cli/commands/stripe.js +14 -0
- package/src/cli/commands/test.js +11 -6
- package/src/cli/index.js +7 -0
- package/src/manager/cron/daily/reset-usage.js +56 -34
- package/src/manager/events/firestore/payments-webhooks/on-write.js +15 -13
- package/src/manager/functions/core/actions/api/user/get-subscription-info.js +1 -1
- package/src/manager/helpers/analytics.js +2 -2
- package/src/manager/helpers/api-manager.js +1 -1
- package/src/manager/helpers/usage.js +51 -3
- package/src/manager/index.js +5 -19
- package/src/manager/libraries/stripe.js +12 -8
- package/src/manager/libraries/test.js +27 -0
- package/src/manager/routes/app/get.js +11 -8
- package/src/manager/routes/payments/intent/post.js +31 -16
- package/src/manager/routes/payments/intent/processors/stripe.js +130 -0
- package/src/manager/routes/payments/intent/processors/test.js +106 -0
- package/src/manager/routes/payments/webhook/post.js +21 -8
- package/src/manager/routes/payments/webhook/{providers → processors}/stripe.js +16 -1
- package/src/manager/routes/payments/webhook/processors/test.js +15 -0
- package/src/manager/routes/user/subscription/get.js +1 -1
- package/src/manager/schemas/payments/webhook/post.js +1 -1
- package/src/test/test-accounts.js +18 -18
- package/templates/_.env +0 -2
- package/templates/backend-manager-config.json +50 -34
- package/test/events/payments/journey-payments-cancel.js +144 -0
- package/test/events/payments/journey-payments-suspend.js +143 -0
- package/test/events/payments/journey-payments-trial.js +120 -0
- package/test/events/payments/journey-payments-upgrade.js +99 -0
- package/test/fixtures/stripe/subscription-active.json +161 -0
- package/test/fixtures/stripe/subscription-canceled.json +161 -0
- package/test/fixtures/stripe/subscription-trialing.json +161 -0
- package/test/functions/user/get-subscription-info.js +2 -2
- package/test/helpers/stripe-to-unified.js +684 -0
- package/test/routes/payments/intent.js +189 -0
- package/test/{payments → routes/payments}/webhook.js +1 -1
- package/test/routes/test/usage.js +7 -6
- package/test/routes/user/subscription.js +2 -2
- package/src/manager/routes/payments/intent/providers/stripe.js +0 -66
- package/test/payments/intent.js +0 -104
- package/test/payments/journey-payment-cancel.js +0 -166
- package/test/payments/journey-payment-suspend.js +0 -162
- package/test/payments/journey-payment-trial.js +0 -167
- package/test/payments/journey-payment-upgrade.js +0 -136
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "sub_1T2Sv0DEGraYraOkYSU3tfYm",
|
|
3
|
+
"object": "subscription",
|
|
4
|
+
"application": null,
|
|
5
|
+
"application_fee_percent": null,
|
|
6
|
+
"automatic_tax": {
|
|
7
|
+
"disabled_reason": null,
|
|
8
|
+
"enabled": false,
|
|
9
|
+
"liability": null
|
|
10
|
+
},
|
|
11
|
+
"billing_cycle_anchor": 1771577346,
|
|
12
|
+
"billing_cycle_anchor_config": null,
|
|
13
|
+
"billing_mode": {
|
|
14
|
+
"flexible": null,
|
|
15
|
+
"type": "classic"
|
|
16
|
+
},
|
|
17
|
+
"billing_thresholds": null,
|
|
18
|
+
"cancel_at": null,
|
|
19
|
+
"cancel_at_period_end": false,
|
|
20
|
+
"canceled_at": null,
|
|
21
|
+
"cancellation_details": {
|
|
22
|
+
"comment": null,
|
|
23
|
+
"feedback": null,
|
|
24
|
+
"reason": null
|
|
25
|
+
},
|
|
26
|
+
"collection_method": "charge_automatically",
|
|
27
|
+
"created": 1771490946,
|
|
28
|
+
"currency": "usd",
|
|
29
|
+
"customer": "cus_U0Ts6oZ7oPlNan",
|
|
30
|
+
"customer_account": null,
|
|
31
|
+
"days_until_due": null,
|
|
32
|
+
"default_payment_method": null,
|
|
33
|
+
"default_source": null,
|
|
34
|
+
"default_tax_rates": [],
|
|
35
|
+
"description": null,
|
|
36
|
+
"discounts": [],
|
|
37
|
+
"ended_at": null,
|
|
38
|
+
"invoice_settings": {
|
|
39
|
+
"account_tax_ids": null,
|
|
40
|
+
"issuer": {
|
|
41
|
+
"type": "self"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"items": {
|
|
45
|
+
"object": "list",
|
|
46
|
+
"data": [
|
|
47
|
+
{
|
|
48
|
+
"id": "si_U0Tsz1kj4mzWg5",
|
|
49
|
+
"object": "subscription_item",
|
|
50
|
+
"billing_thresholds": null,
|
|
51
|
+
"created": 1771490946,
|
|
52
|
+
"current_period_end": 1771577346,
|
|
53
|
+
"current_period_start": 1771490946,
|
|
54
|
+
"discounts": [],
|
|
55
|
+
"metadata": {},
|
|
56
|
+
"plan": {
|
|
57
|
+
"id": "price_1T2SuzDEGraYraOkQxPibfiV",
|
|
58
|
+
"object": "plan",
|
|
59
|
+
"active": true,
|
|
60
|
+
"amount": 1500,
|
|
61
|
+
"amount_decimal": "1500",
|
|
62
|
+
"billing_scheme": "per_unit",
|
|
63
|
+
"created": 1771490945,
|
|
64
|
+
"currency": "usd",
|
|
65
|
+
"interval": "month",
|
|
66
|
+
"interval_count": 1,
|
|
67
|
+
"livemode": false,
|
|
68
|
+
"metadata": {},
|
|
69
|
+
"meter": null,
|
|
70
|
+
"nickname": null,
|
|
71
|
+
"product": "prod_U0TsJBVgyOkInl",
|
|
72
|
+
"tiers_mode": null,
|
|
73
|
+
"transform_usage": null,
|
|
74
|
+
"trial_period_days": null,
|
|
75
|
+
"usage_type": "licensed"
|
|
76
|
+
},
|
|
77
|
+
"price": {
|
|
78
|
+
"id": "price_1T2SuzDEGraYraOkQxPibfiV",
|
|
79
|
+
"object": "price",
|
|
80
|
+
"active": true,
|
|
81
|
+
"billing_scheme": "per_unit",
|
|
82
|
+
"created": 1771490945,
|
|
83
|
+
"currency": "usd",
|
|
84
|
+
"custom_unit_amount": null,
|
|
85
|
+
"livemode": false,
|
|
86
|
+
"lookup_key": null,
|
|
87
|
+
"metadata": {},
|
|
88
|
+
"nickname": null,
|
|
89
|
+
"product": "prod_U0TsJBVgyOkInl",
|
|
90
|
+
"recurring": {
|
|
91
|
+
"interval": "month",
|
|
92
|
+
"interval_count": 1,
|
|
93
|
+
"meter": null,
|
|
94
|
+
"trial_period_days": null,
|
|
95
|
+
"usage_type": "licensed"
|
|
96
|
+
},
|
|
97
|
+
"tax_behavior": "unspecified",
|
|
98
|
+
"tiers_mode": null,
|
|
99
|
+
"transform_quantity": null,
|
|
100
|
+
"type": "recurring",
|
|
101
|
+
"unit_amount": 1500,
|
|
102
|
+
"unit_amount_decimal": "1500"
|
|
103
|
+
},
|
|
104
|
+
"quantity": 1,
|
|
105
|
+
"subscription": "sub_1T2Sv0DEGraYraOkYSU3tfYm",
|
|
106
|
+
"tax_rates": []
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"has_more": false,
|
|
110
|
+
"total_count": 1,
|
|
111
|
+
"url": "/v1/subscription_items?subscription=sub_1T2Sv0DEGraYraOkYSU3tfYm"
|
|
112
|
+
},
|
|
113
|
+
"latest_invoice": "in_1T2Sv0DEGraYraOkRi6kQMI5",
|
|
114
|
+
"livemode": false,
|
|
115
|
+
"metadata": {},
|
|
116
|
+
"next_pending_invoice_item_invoice": null,
|
|
117
|
+
"on_behalf_of": null,
|
|
118
|
+
"pause_collection": null,
|
|
119
|
+
"payment_settings": {
|
|
120
|
+
"payment_method_options": null,
|
|
121
|
+
"payment_method_types": null,
|
|
122
|
+
"save_default_payment_method": "off"
|
|
123
|
+
},
|
|
124
|
+
"pending_invoice_item_interval": null,
|
|
125
|
+
"pending_setup_intent": "seti_1T2Sv1DEGraYraOkqUY8NXFI",
|
|
126
|
+
"pending_update": null,
|
|
127
|
+
"plan": {
|
|
128
|
+
"id": "price_1T2SuzDEGraYraOkQxPibfiV",
|
|
129
|
+
"object": "plan",
|
|
130
|
+
"active": true,
|
|
131
|
+
"amount": 1500,
|
|
132
|
+
"amount_decimal": "1500",
|
|
133
|
+
"billing_scheme": "per_unit",
|
|
134
|
+
"created": 1771490945,
|
|
135
|
+
"currency": "usd",
|
|
136
|
+
"interval": "month",
|
|
137
|
+
"interval_count": 1,
|
|
138
|
+
"livemode": false,
|
|
139
|
+
"metadata": {},
|
|
140
|
+
"meter": null,
|
|
141
|
+
"nickname": null,
|
|
142
|
+
"product": "prod_U0TsJBVgyOkInl",
|
|
143
|
+
"tiers_mode": null,
|
|
144
|
+
"transform_usage": null,
|
|
145
|
+
"trial_period_days": null,
|
|
146
|
+
"usage_type": "licensed"
|
|
147
|
+
},
|
|
148
|
+
"quantity": 1,
|
|
149
|
+
"schedule": null,
|
|
150
|
+
"start_date": 1771490946,
|
|
151
|
+
"status": "trialing",
|
|
152
|
+
"test_clock": null,
|
|
153
|
+
"transfer_data": null,
|
|
154
|
+
"trial_end": 1771577346,
|
|
155
|
+
"trial_settings": {
|
|
156
|
+
"end_behavior": {
|
|
157
|
+
"missing_payment_method": "create_invoice"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"trial_start": 1771490946
|
|
161
|
+
}
|
|
@@ -44,8 +44,8 @@ module.exports = {
|
|
|
44
44
|
|
|
45
45
|
// Check trial structure
|
|
46
46
|
assert.ok(
|
|
47
|
-
typeof subscription.trial.
|
|
48
|
-
'trial.
|
|
47
|
+
typeof subscription.trial.claimed === 'boolean',
|
|
48
|
+
'trial.claimed should be boolean'
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
// Check payment structure
|