@haatlabs-core/nest-billing 0.11.2 → 0.11.3
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/README.md +13 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/options.d.ts +5 -0
- package/dist/cjs/options.js +3 -0
- package/dist/cjs/payments.controller.d.ts +4 -3
- package/dist/cjs/payments.controller.js +1 -0
- package/dist/cjs/shopify-billing.controller.d.ts +2 -0
- package/dist/cjs/shopify-billing.controller.js +2 -0
- package/dist/cjs/shopify-billing.service.js +14 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +5 -0
- package/dist/options.js +5 -0
- package/dist/options.js.map +1 -1
- package/dist/payments.controller.d.ts +4 -3
- package/dist/payments.controller.js +7 -5
- package/dist/payments.controller.js.map +1 -1
- package/dist/shopify-billing.controller.d.ts +2 -0
- package/dist/shopify-billing.controller.js +5 -1
- package/dist/shopify-billing.controller.js.map +1 -1
- package/dist/shopify-billing.service.js +25 -3
- package/dist/shopify-billing.service.js.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -9,6 +9,19 @@ and what a plan may leave out.
|
|
|
9
9
|
`stores` (optional): the app's stores, for Shopify billing (charging a store through Shopify).
|
|
10
10
|
A web app leaves it out, and the module then has no Shopify billing routes or service.
|
|
11
11
|
|
|
12
|
+
Who may change the plan: buying, changing and cancelling it (`POST billing/checkout`,
|
|
13
|
+
`billing/cancel`, and Shopify billing's `checkout`, `confirm` and `cancel`) is the whole
|
|
14
|
+
organization's. The staff of one store in an organization made on the dashboard (a
|
|
15
|
+
store-only principal, `me.storeOnly`) are refused with 403 `FORBIDDEN` and
|
|
16
|
+
`PLAN_CHANGES_MESSAGE` ("Plan changes are made by the account's owner"); they still read
|
|
17
|
+
`GET usage` and `GET plans`. An app's plan page hides its buttons from them.
|
|
18
|
+
|
|
19
|
+
Test charges: a Shopify charge is a test charge when `SHOPIFY_BILLING_TEST` is true or the
|
|
20
|
+
shop is a partner development store, which Shopify is asked with the store's own token at
|
|
21
|
+
checkout (`shop { plan { partnerDevelopment } }`); a real store gets a real charge. A
|
|
22
|
+
development store's approved test charge puts it on the plan. When Shopify does not answer
|
|
23
|
+
that question, nothing is charged or changed: the request fails with a transient 503.
|
|
24
|
+
|
|
12
25
|
`shopifyThrottle` (optional): the app's `RedisShopifyThrottle`, so Shopify billing paces each
|
|
13
26
|
shop with the app's own jobs; without it, the process throttle. `billingThrottleMaxWaitMs`
|
|
14
27
|
(default 10 s) is the longest a billing call waits there for its turn, not the throttle's
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type { SubscriptionChange, SystemBillingOptions } from './system-billing.
|
|
|
14
14
|
export { runAssignPlan, runSeedPlans, runSetPrice } from './commands.js';
|
|
15
15
|
export type { CommandIo } from './commands.js';
|
|
16
16
|
export { apiFeatureGate, meFeatures, planLimitError, storeLimit } from './gates.js';
|
|
17
|
-
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
17
|
+
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, PLAN_CHANGES_MESSAGE, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
18
18
|
export type { BillingConfig, BillingModuleOptions, BillingStores, UsageEnricher, } from './options.js';
|
|
19
19
|
export { PaymentWebhooksController } from './payment-webhooks.controller.js';
|
|
20
20
|
export { PaymentsController } from './payments.controller.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
FeatureRepository: () => import_feature_repository.FeatureRepository,
|
|
26
26
|
OFFERED_GATEWAYS: () => import_options.OFFERED_GATEWAYS,
|
|
27
27
|
PAYMENT_GATEWAYS: () => import_options.PAYMENT_GATEWAYS,
|
|
28
|
+
PLAN_CHANGES_MESSAGE: () => import_options.PLAN_CHANGES_MESSAGE,
|
|
28
29
|
PaymentWebhooksController: () => import_payment_webhooks_controller.PaymentWebhooksController,
|
|
29
30
|
PaymentsController: () => import_payments_controller.PaymentsController,
|
|
30
31
|
STORES_CAP: () => import_system_billing_repository2.STORES_CAP,
|
|
@@ -71,6 +72,7 @@ var import_usage_controller = require("./usage.controller.js");
|
|
|
71
72
|
FeatureRepository,
|
|
72
73
|
OFFERED_GATEWAYS,
|
|
73
74
|
PAYMENT_GATEWAYS,
|
|
75
|
+
PLAN_CHANGES_MESSAGE,
|
|
74
76
|
PaymentWebhooksController,
|
|
75
77
|
PaymentsController,
|
|
76
78
|
STORES_CAP,
|
package/dist/cjs/options.d.ts
CHANGED
|
@@ -69,3 +69,8 @@ export declare const OFFERED_GATEWAYS: symbol;
|
|
|
69
69
|
export declare const BILLING_STORES: symbol;
|
|
70
70
|
export declare const USAGE_ENRICHER: symbol;
|
|
71
71
|
export declare const SHOPIFY_THROTTLE: symbol;
|
|
72
|
+
/**
|
|
73
|
+
* What the staff of one store in an organization made on the dashboard are told when they
|
|
74
|
+
* try to buy, change or cancel the plan: the plan is the whole organization's.
|
|
75
|
+
*/
|
|
76
|
+
export declare const PLAN_CHANGES_MESSAGE = "Plan changes are made by the account's owner";
|
package/dist/cjs/options.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(options_exports, {
|
|
|
22
22
|
BILLING_STORES: () => BILLING_STORES,
|
|
23
23
|
OFFERED_GATEWAYS: () => OFFERED_GATEWAYS,
|
|
24
24
|
PAYMENT_GATEWAYS: () => PAYMENT_GATEWAYS,
|
|
25
|
+
PLAN_CHANGES_MESSAGE: () => PLAN_CHANGES_MESSAGE,
|
|
25
26
|
SHOPIFY_THROTTLE: () => SHOPIFY_THROTTLE,
|
|
26
27
|
SYSTEM_BILLING_REPOSITORY: () => SYSTEM_BILLING_REPOSITORY,
|
|
27
28
|
USAGE_ENRICHER: () => USAGE_ENRICHER
|
|
@@ -36,6 +37,7 @@ const OFFERED_GATEWAYS = token("OFFERED_GATEWAYS");
|
|
|
36
37
|
const BILLING_STORES = token("BILLING_STORES");
|
|
37
38
|
const USAGE_ENRICHER = token("USAGE_ENRICHER");
|
|
38
39
|
const SHOPIFY_THROTTLE = token("SHOPIFY_THROTTLE");
|
|
40
|
+
const PLAN_CHANGES_MESSAGE = "Plan changes are made by the account's owner";
|
|
39
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
42
|
0 && (module.exports = {
|
|
41
43
|
BILLING_OPTIONS,
|
|
@@ -43,6 +45,7 @@ const SHOPIFY_THROTTLE = token("SHOPIFY_THROTTLE");
|
|
|
43
45
|
BILLING_STORES,
|
|
44
46
|
OFFERED_GATEWAYS,
|
|
45
47
|
PAYMENT_GATEWAYS,
|
|
48
|
+
PLAN_CHANGES_MESSAGE,
|
|
46
49
|
SHOPIFY_THROTTLE,
|
|
47
50
|
SYSTEM_BILLING_REPOSITORY,
|
|
48
51
|
USAGE_ENRICHER
|
|
@@ -7,9 +7,10 @@ import type { SystemBillingRepository } from './system-billing.repository.js';
|
|
|
7
7
|
type AnyBilling = BillingRepository<string, string, string>;
|
|
8
8
|
type AnySystemBilling = SystemBillingRepository<string, string, string>;
|
|
9
9
|
/**
|
|
10
|
-
* Buying and cancelling a plan,
|
|
11
|
-
* admin, Shopify requires its own billing. Payment happens on
|
|
12
|
-
* the plan changes only when the gateway's webhook says the
|
|
10
|
+
* Buying and cancelling a plan, by the organization's owner and from the standalone
|
|
11
|
+
* dashboard only: inside Shopify admin, Shopify requires its own billing. Payment happens on
|
|
12
|
+
* the gateway's hosted page; the plan changes only when the gateway's webhook says the
|
|
13
|
+
* subscription is paid.
|
|
13
14
|
*/
|
|
14
15
|
export declare class PaymentsController {
|
|
15
16
|
private readonly config;
|
|
@@ -107,6 +107,7 @@ __decorate([
|
|
|
107
107
|
__param(0, (0, import_nest_auth.CurrentPrincipal)())
|
|
108
108
|
], PaymentsController.prototype, "cancel", null);
|
|
109
109
|
PaymentsController = __decorate([
|
|
110
|
+
(0, import_nest_auth.WholeOrganization)(import_options.PLAN_CHANGES_MESSAGE),
|
|
110
111
|
(0, import_nest_auth.StandaloneOnly)(),
|
|
111
112
|
(0, import_nest_auth.MinRole)("OWNER"),
|
|
112
113
|
(0, import_common.Controller)("api/v1/billing"),
|
|
@@ -4,6 +4,8 @@ import { ShopifyBillingService } from './shopify-billing.service.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Buying, changing and cancelling a plan through Shopify's billing. For the embedded app
|
|
6
6
|
* only (the service refuses anyone else): the charge is on the merchant's Shopify invoice.
|
|
7
|
+
* The plan is the whole organization's: the staff of one store in an organization made on
|
|
8
|
+
* the dashboard (store-only) change nothing here.
|
|
7
9
|
*/
|
|
8
10
|
export declare class ShopifyBillingController {
|
|
9
11
|
private readonly shopify;
|
|
@@ -24,6 +24,7 @@ var import_common = require("@nestjs/common");
|
|
|
24
24
|
var import_contracts = require("@haatlabs-core/billing/contracts");
|
|
25
25
|
var import_nest_auth = require("@haatlabs-core/nest-auth");
|
|
26
26
|
var import_nest_common = require("@haatlabs-core/nest-common");
|
|
27
|
+
var import_options = require("./options.js");
|
|
27
28
|
var import_shopify_billing_service = require("./shopify-billing.service.js");
|
|
28
29
|
var __decorate = function(decorators, target, key, desc) {
|
|
29
30
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -72,6 +73,7 @@ __decorate([
|
|
|
72
73
|
__param(0, (0, import_nest_auth.CurrentPrincipal)())
|
|
73
74
|
], ShopifyBillingController.prototype, "cancel", null);
|
|
74
75
|
ShopifyBillingController = __decorate([
|
|
76
|
+
(0, import_nest_auth.WholeOrganization)(import_options.PLAN_CHANGES_MESSAGE),
|
|
75
77
|
(0, import_nest_auth.MinRole)("ADMIN"),
|
|
76
78
|
(0, import_common.Controller)("api/v1/billing/shopify"),
|
|
77
79
|
__param(0, (0, import_common.Inject)(import_shopify_billing_service.ShopifyBillingService))
|
|
@@ -42,6 +42,16 @@ var __param = function(paramIndex, decorator) {
|
|
|
42
42
|
const SHOPIFY_CURRENCY = "USD";
|
|
43
43
|
const notForSale = () => new import_errors.AppError(import_errors.CoreErrorCode.VALIDATION_FAILED, "This plan cannot be bought through Shopify");
|
|
44
44
|
const otherGateway = () => new import_errors.AppError(import_errors.CoreErrorCode.CONFLICT, "This organization already pays for its plan another way. Change it from the dashboard.");
|
|
45
|
+
async function developmentStore(client) {
|
|
46
|
+
try {
|
|
47
|
+
return await (0, import_shopify.isDevelopmentStore)(client);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error instanceof import_shopify.ShopifyTokenRejectedError || error instanceof import_shopify.ShopifyReconnectRequiredError) {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
throw (0, import_billing.createBillingError)(import_billing.BillingErrorCode.PAYMENT_PROVIDER_ERROR, "Shopify did not say whether this is a development store, so nothing was charged or changed. Try again in a moment.", { transient: true, cause: error });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
45
55
|
let ShopifyBillingService = class ShopifyBillingService2 {
|
|
46
56
|
config;
|
|
47
57
|
options;
|
|
@@ -116,13 +126,14 @@ let ShopifyBillingService = class ShopifyBillingService2 {
|
|
|
116
126
|
const managed = await this.billing.managedBy((0, import_nest_auth.tenantOf)(principal));
|
|
117
127
|
if (managed && managed.provider !== import_billing.SHOPIFY_PROVIDER)
|
|
118
128
|
throw otherGateway();
|
|
129
|
+
const test = app.billingTest || await developmentStore(client);
|
|
119
130
|
const { confirmationUrl } = await (0, import_shopify.createAppSubscription)(client, {
|
|
120
131
|
name: (0, import_billing.shopifySubscriptionName)(this.options.displayName, price.planName),
|
|
121
132
|
amount: (0, import_billing.decimalAmount)(price.amountMinor, price.currency),
|
|
122
133
|
currencyCode: price.currency,
|
|
123
134
|
// Opens the embedded app's plan page, which then asks to confirm.
|
|
124
135
|
returnUrl: `https://${shopDomain}/admin/apps/${app.apiKey}${this.options.returnPath}?billing=return`,
|
|
125
|
-
test
|
|
136
|
+
test
|
|
126
137
|
});
|
|
127
138
|
return { url: confirmationUrl };
|
|
128
139
|
}
|
|
@@ -151,7 +162,8 @@ let ShopifyBillingService = class ShopifyBillingService2 {
|
|
|
151
162
|
appName: this.options.displayName,
|
|
152
163
|
organizationId,
|
|
153
164
|
storeRef: storeId,
|
|
154
|
-
|
|
165
|
+
// A development store's test charges are what it pays with.
|
|
166
|
+
acceptTest: app.billingTest || (() => developmentStore(client))
|
|
155
167
|
});
|
|
156
168
|
if (outcome.state === "unmatched") {
|
|
157
169
|
this.logger.warn({ storeId, name: outcome.name }, "An active Shopify subscription matches no plan sold here");
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type { SubscriptionChange, SystemBillingOptions } from './system-billing.
|
|
|
14
14
|
export { runAssignPlan, runSeedPlans, runSetPrice } from './commands.js';
|
|
15
15
|
export type { CommandIo } from './commands.js';
|
|
16
16
|
export { apiFeatureGate, meFeatures, planLimitError, storeLimit } from './gates.js';
|
|
17
|
-
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
17
|
+
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, PLAN_CHANGES_MESSAGE, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
18
18
|
export type { BillingConfig, BillingModuleOptions, BillingStores, UsageEnricher, } from './options.js';
|
|
19
19
|
export { PaymentWebhooksController } from './payment-webhooks.controller.js';
|
|
20
20
|
export { PaymentsController } from './payments.controller.js';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { defaultPeriod } from './default-period.js';
|
|
|
6
6
|
export { SystemBillingRepository } from './system-billing.repository.js';
|
|
7
7
|
export { runAssignPlan, runSeedPlans, runSetPrice } from './commands.js';
|
|
8
8
|
export { apiFeatureGate, meFeatures, planLimitError, storeLimit } from './gates.js';
|
|
9
|
-
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
9
|
+
export { BILLING_REPOSITORY, BILLING_STORES, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, PLAN_CHANGES_MESSAGE, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
10
10
|
export { PaymentWebhooksController } from './payment-webhooks.controller.js';
|
|
11
11
|
export { PaymentsController } from './payments.controller.js';
|
|
12
12
|
export { ShopifyBillingController } from './shopify-billing.controller.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,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uBAAuB,CAAC"}
|
package/dist/options.d.ts
CHANGED
|
@@ -69,3 +69,8 @@ export declare const OFFERED_GATEWAYS: symbol;
|
|
|
69
69
|
export declare const BILLING_STORES: symbol;
|
|
70
70
|
export declare const USAGE_ENRICHER: symbol;
|
|
71
71
|
export declare const SHOPIFY_THROTTLE: symbol;
|
|
72
|
+
/**
|
|
73
|
+
* What the staff of one store in an organization made on the dashboard are told when they
|
|
74
|
+
* try to buy, change or cancel the plan: the plan is the whole organization's.
|
|
75
|
+
*/
|
|
76
|
+
export declare const PLAN_CHANGES_MESSAGE = "Plan changes are made by the account's owner";
|
package/dist/options.js
CHANGED
|
@@ -7,4 +7,9 @@ export const OFFERED_GATEWAYS = token('OFFERED_GATEWAYS');
|
|
|
7
7
|
export const BILLING_STORES = token('BILLING_STORES');
|
|
8
8
|
export const USAGE_ENRICHER = token('USAGE_ENRICHER');
|
|
9
9
|
export const SHOPIFY_THROTTLE = token('SHOPIFY_THROTTLE');
|
|
10
|
+
/**
|
|
11
|
+
* What the staff of one store in an organization made on the dashboard are told when they
|
|
12
|
+
* try to buy, change or cancel the plan: the plan is the whole organization's.
|
|
13
|
+
*/
|
|
14
|
+
export const PLAN_CHANGES_MESSAGE = "Plan changes are made by the account's owner";
|
|
10
15
|
//# sourceMappingURL=options.js.map
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAmEA,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;AACrF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAmEA,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;AACrF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,8CAA8C,CAAC"}
|
|
@@ -7,9 +7,10 @@ import type { SystemBillingRepository } from './system-billing.repository.js';
|
|
|
7
7
|
type AnyBilling = BillingRepository<string, string, string>;
|
|
8
8
|
type AnySystemBilling = SystemBillingRepository<string, string, string>;
|
|
9
9
|
/**
|
|
10
|
-
* Buying and cancelling a plan,
|
|
11
|
-
* admin, Shopify requires its own billing. Payment happens on
|
|
12
|
-
* the plan changes only when the gateway's webhook says the
|
|
10
|
+
* Buying and cancelling a plan, by the organization's owner and from the standalone
|
|
11
|
+
* dashboard only: inside Shopify admin, Shopify requires its own billing. Payment happens on
|
|
12
|
+
* the gateway's hosted page; the plan changes only when the gateway's webhook says the
|
|
13
|
+
* subscription is paid.
|
|
13
14
|
*/
|
|
14
15
|
export declare class PaymentsController {
|
|
15
16
|
private readonly config;
|
|
@@ -10,14 +10,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Body, Controller, HttpCode, Inject, Post } from '@nestjs/common';
|
|
11
11
|
import { CheckoutRequestSchema, isGateway } from '@haatlabs-core/billing/contracts';
|
|
12
12
|
import { AppError, CoreErrorCode } from '@haatlabs-core/errors';
|
|
13
|
-
import { CurrentPrincipal, IDENTITY_STORE, MinRole, StandaloneOnly, tenantOf, } from '@haatlabs-core/nest-auth';
|
|
13
|
+
import { CurrentPrincipal, IDENTITY_STORE, MinRole, StandaloneOnly, WholeOrganization, tenantOf, } from '@haatlabs-core/nest-auth';
|
|
14
14
|
import { CONFIG, ZodPipe } from '@haatlabs-core/nest-common';
|
|
15
|
-
import { BILLING_OPTIONS, BILLING_REPOSITORY, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
15
|
+
import { BILLING_OPTIONS, BILLING_REPOSITORY, OFFERED_GATEWAYS, PAYMENT_GATEWAYS, PLAN_CHANGES_MESSAGE, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
16
16
|
const notForSale = () => new AppError(CoreErrorCode.VALIDATION_FAILED, 'This plan cannot be bought through that provider');
|
|
17
17
|
/**
|
|
18
|
-
* Buying and cancelling a plan,
|
|
19
|
-
* admin, Shopify requires its own billing. Payment happens on
|
|
20
|
-
* the plan changes only when the gateway's webhook says the
|
|
18
|
+
* Buying and cancelling a plan, by the organization's owner and from the standalone
|
|
19
|
+
* dashboard only: inside Shopify admin, Shopify requires its own billing. Payment happens on
|
|
20
|
+
* the gateway's hosted page; the plan changes only when the gateway's webhook says the
|
|
21
|
+
* subscription is paid.
|
|
21
22
|
*/
|
|
22
23
|
let PaymentsController = class PaymentsController {
|
|
23
24
|
config;
|
|
@@ -95,6 +96,7 @@ __decorate([
|
|
|
95
96
|
__param(0, CurrentPrincipal())
|
|
96
97
|
], PaymentsController.prototype, "cancel", null);
|
|
97
98
|
PaymentsController = __decorate([
|
|
99
|
+
WholeOrganization(PLAN_CHANGES_MESSAGE),
|
|
98
100
|
StandaloneOnly(),
|
|
99
101
|
MinRole('OWNER'),
|
|
100
102
|
Controller('api/v1/billing'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.controller.js","sourceRoot":"","sources":["../src/payments.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,cAAc,EACd,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAOtB,MAAM,UAAU,GAAG,GAAa,EAAE,CAChC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,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,gDAAgD,CAAC,CAAC;QAC/F,CAAC;QACD,MAAM,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACzD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF,CAAA;AA9DO;IAFL,IAAI,CAAC,UAAU,CAAC;IAChB,QAAQ,CAAC,GAAG,CAAC;IAEX,WAAA,gBAAgB,EAAE,CAAA;IAClB,WAAA,IAAI,CAAC,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAA;kDAuC1C;AAKK;IAFL,IAAI,CAAC,QAAQ,CAAC;IACd,QAAQ,CAAC,GAAG,CAAC;IACA,WAAA,gBAAgB,EAAE,CAAA;gDAe/B;AA1EU,kBAAkB;IAJ9B,iBAAiB,CAAC,oBAAoB,CAAC;IACvC,cAAc,EAAE;IAChB,OAAO,CAAC,OAAO,CAAC;IAChB,UAAU,CAAC,gBAAgB,CAAC;IAGxB,WAAA,MAAM,CAAC,MAAM,CAAC,CAAA;IACd,WAAA,MAAM,CAAC,eAAe,CAAC,CAAA;IACvB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;GARd,kBAAkB,CA2E9B"}
|
|
@@ -4,6 +4,8 @@ import { ShopifyBillingService } from './shopify-billing.service.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Buying, changing and cancelling a plan through Shopify's billing. For the embedded app
|
|
6
6
|
* only (the service refuses anyone else): the charge is on the merchant's Shopify invoice.
|
|
7
|
+
* The plan is the whole organization's: the staff of one store in an organization made on
|
|
8
|
+
* the dashboard (store-only) change nothing here.
|
|
7
9
|
*/
|
|
8
10
|
export declare class ShopifyBillingController {
|
|
9
11
|
private readonly shopify;
|
|
@@ -9,12 +9,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Body, Controller, HttpCode, Inject, Post } from '@nestjs/common';
|
|
11
11
|
import { ShopifyCheckoutRequestSchema } from '@haatlabs-core/billing/contracts';
|
|
12
|
-
import { CurrentPrincipal, MinRole } from '@haatlabs-core/nest-auth';
|
|
12
|
+
import { CurrentPrincipal, MinRole, WholeOrganization } from '@haatlabs-core/nest-auth';
|
|
13
13
|
import { ZodPipe } from '@haatlabs-core/nest-common';
|
|
14
|
+
import { PLAN_CHANGES_MESSAGE } from './options.js';
|
|
14
15
|
import { ShopifyBillingService } from './shopify-billing.service.js';
|
|
15
16
|
/**
|
|
16
17
|
* Buying, changing and cancelling a plan through Shopify's billing. For the embedded app
|
|
17
18
|
* only (the service refuses anyone else): the charge is on the merchant's Shopify invoice.
|
|
19
|
+
* The plan is the whole organization's: the staff of one store in an organization made on
|
|
20
|
+
* the dashboard (store-only) change nothing here.
|
|
18
21
|
*/
|
|
19
22
|
let ShopifyBillingController = class ShopifyBillingController {
|
|
20
23
|
shopify;
|
|
@@ -52,6 +55,7 @@ __decorate([
|
|
|
52
55
|
__param(0, CurrentPrincipal())
|
|
53
56
|
], ShopifyBillingController.prototype, "cancel", null);
|
|
54
57
|
ShopifyBillingController = __decorate([
|
|
58
|
+
WholeOrganization(PLAN_CHANGES_MESSAGE),
|
|
55
59
|
MinRole('ADMIN'),
|
|
56
60
|
Controller('api/v1/billing/shopify'),
|
|
57
61
|
__param(0, Inject(ShopifyBillingService))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-billing.controller.js","sourceRoot":"","sources":["../src/shopify-billing.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ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C,CAAC,IAAI;SAC7F,CAAC;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CAAqB,SAAoB;QACnD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF,CAAA;AAtBC;IAFC,IAAI,CAAC,UAAU,CAAC;IAChB,QAAQ,CAAC,GAAG,CAAC;IAEX,WAAA,gBAAgB,EAAE,CAAA;IAClB,WAAA,IAAI,CAAC,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAA;wDAGjD;AAIK;IAFL,IAAI,CAAC,SAAS,CAAC;IACf,QAAQ,CAAC,GAAG,CAAC;IACC,WAAA,gBAAgB,EAAE,CAAA;uDAKhC;AAIK;IAFL,IAAI,CAAC,QAAQ,CAAC;IACd,QAAQ,CAAC,GAAG,CAAC;IACA,WAAA,gBAAgB,EAAE,CAAA;sDAG/B;AA1BU,wBAAwB;IAHpC,iBAAiB,CAAC,oBAAoB,CAAC;IACvC,OAAO,CAAC,OAAO,CAAC;IAChB,UAAU,CAAC,wBAAwB,CAAC;IAEtB,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;GAD/B,wBAAwB,CA2BpC"}
|
|
@@ -12,13 +12,31 @@ import { BillingErrorCode, SHOPIFY_PROVIDER, createBillingError, decimalAmount,
|
|
|
12
12
|
import { AppError, CoreErrorCode } from '@haatlabs-core/errors';
|
|
13
13
|
import { tenantOf } from '@haatlabs-core/nest-auth';
|
|
14
14
|
import { CONFIG, FETCH, LOGGER, STORE_TOKENS } from '@haatlabs-core/nest-common';
|
|
15
|
-
import { ShopifyAdminClient, ShopifyReconnectRequiredError, cancelAppSubscription, createAppSubscription, listActiveAppSubscriptions, processShopifyThrottle, } from '@haatlabs-core/shopify';
|
|
15
|
+
import { ShopifyAdminClient, ShopifyReconnectRequiredError, ShopifyTokenRejectedError, cancelAppSubscription, createAppSubscription, isDevelopmentStore, listActiveAppSubscriptions, processShopifyThrottle, } from '@haatlabs-core/shopify';
|
|
16
16
|
import { BILLING_OPTIONS, BILLING_REPOSITORY, BILLING_STORES, SHOPIFY_THROTTLE, SYSTEM_BILLING_REPOSITORY, } from './options.js';
|
|
17
17
|
import { limitThrottleWait } from './throttle-limit.js';
|
|
18
18
|
/** The currency Shopify bills apps in. */
|
|
19
19
|
const SHOPIFY_CURRENCY = 'USD';
|
|
20
20
|
const notForSale = () => new AppError(CoreErrorCode.VALIDATION_FAILED, 'This plan cannot be bought through Shopify');
|
|
21
21
|
const otherGateway = () => new AppError(CoreErrorCode.CONFLICT, 'This organization already pays for its plan another way. Change it from the dashboard.');
|
|
22
|
+
/**
|
|
23
|
+
* Whether the shop is a development store, which can only be charged test charges. Asked of
|
|
24
|
+
* Shopify with the store's own token every time it matters (nothing is kept in the process);
|
|
25
|
+
* when Shopify does not answer, nothing is guessed: the request fails, to be tried again.
|
|
26
|
+
*/
|
|
27
|
+
async function developmentStore(client) {
|
|
28
|
+
try {
|
|
29
|
+
return await isDevelopmentStore(client);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
// A store whose token Shopify refuses has its own answer: no retry mends it.
|
|
33
|
+
if (error instanceof ShopifyTokenRejectedError ||
|
|
34
|
+
error instanceof ShopifyReconnectRequiredError) {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
throw createBillingError(BillingErrorCode.PAYMENT_PROVIDER_ERROR, 'Shopify did not say whether this is a development store, so nothing was charged or changed. Try again in a moment.', { transient: true, cause: error });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
22
40
|
/**
|
|
23
41
|
* Plans bought through Shopify's own billing, from inside Shopify admin. Everything is
|
|
24
42
|
* done for the caller's own store, with that store's token: no request names a store.
|
|
@@ -100,13 +118,16 @@ let ShopifyBillingService = class ShopifyBillingService {
|
|
|
100
118
|
const managed = await this.billing.managedBy(tenantOf(principal));
|
|
101
119
|
if (managed && managed.provider !== SHOPIFY_PROVIDER)
|
|
102
120
|
throw otherGateway();
|
|
121
|
+
// A test charge where SHOPIFY_BILLING_TEST says so, or in a development store (an App
|
|
122
|
+
// Store reviewer's, say), which cannot be charged for real; a real store, a real one.
|
|
123
|
+
const test = app.billingTest || (await developmentStore(client));
|
|
103
124
|
const { confirmationUrl } = await createAppSubscription(client, {
|
|
104
125
|
name: shopifySubscriptionName(this.options.displayName, price.planName),
|
|
105
126
|
amount: decimalAmount(price.amountMinor, price.currency),
|
|
106
127
|
currencyCode: price.currency,
|
|
107
128
|
// Opens the embedded app's plan page, which then asks to confirm.
|
|
108
129
|
returnUrl: `https://${shopDomain}/admin/apps/${app.apiKey}${this.options.returnPath}?billing=return`,
|
|
109
|
-
test
|
|
130
|
+
test,
|
|
110
131
|
});
|
|
111
132
|
return { url: confirmationUrl };
|
|
112
133
|
}
|
|
@@ -135,7 +156,8 @@ let ShopifyBillingService = class ShopifyBillingService {
|
|
|
135
156
|
appName: this.options.displayName,
|
|
136
157
|
organizationId,
|
|
137
158
|
storeRef: storeId,
|
|
138
|
-
|
|
159
|
+
// A development store's test charges are what it pays with.
|
|
160
|
+
acceptTest: app.billingTest || (() => developmentStore(client)),
|
|
139
161
|
});
|
|
140
162
|
if (outcome.state === 'unmatched') {
|
|
141
163
|
this.logger.warn({ storeId, name: outcome.name }, 'An active Shopify subscription matches no plan sold here');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-billing.service.js","sourceRoot":"","sources":["../src/shopify-billing.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,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,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,YAAY,GAChB,OAAO,CAAC,KAAK,KAAK,QAAQ;YAC1B,OAAO,CAAC,KAAK,KAAK,WAAW;YAC7B,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChE,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,kBAAkB,CACtB,gBAAgB,CAAC,sBAAsB,EACvC,mEAAmE,EACnE,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA/LY,qBAAqB;IADjC,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,MAAM,CAAC,CAAA;IACd,WAAA,MAAM,CAAC,eAAe,CAAC,CAAA;IACvB,WAAA,MAAM,CAAC,MAAM,CAAC,CAAA;IACd,WAAA,MAAM,CAAC,KAAK,CAAC,CAAA;IACb,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;IACtB,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAEjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,QAAQ,EAAE,CAAA;IAAE,WAAA,MAAM,CAAC,YAAY,CAAC,CAAA;IAChC,WAAA,QAAQ,EAAE,CAAA;IAAE,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;GAX5B,qBAAqB,CA+LjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/nest-billing",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "NestJS billing: plans, periods, metered usage, plan assignment and payment events applied once.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"haatlabs",
|
|
@@ -76,20 +76,20 @@
|
|
|
76
76
|
"@testcontainers/redis": "^12.2.0",
|
|
77
77
|
"testcontainers": "^12.2.0",
|
|
78
78
|
"@types/pg": "^8.23.1",
|
|
79
|
-
"@haatlabs-core/tsconfig": "0.11.
|
|
80
|
-
"@haatlabs-core/
|
|
81
|
-
"@haatlabs-core/
|
|
79
|
+
"@haatlabs-core/tsconfig": "0.11.3",
|
|
80
|
+
"@haatlabs-core/rate-limit": "0.11.3",
|
|
81
|
+
"@haatlabs-core/vitest-config": "0.11.3"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@haatlabs-core/admin-contracts": "0.11.
|
|
85
|
-
"@haatlabs-core/
|
|
86
|
-
"@haatlabs-core/
|
|
87
|
-
"@haatlabs-core/
|
|
88
|
-
"@haatlabs-core/errors": "0.11.
|
|
89
|
-
"@haatlabs-core/
|
|
90
|
-
"@haatlabs-core/nest-
|
|
91
|
-
"@haatlabs-core/
|
|
92
|
-
"@haatlabs-core/
|
|
84
|
+
"@haatlabs-core/admin-contracts": "0.11.3",
|
|
85
|
+
"@haatlabs-core/billing": "0.11.3",
|
|
86
|
+
"@haatlabs-core/config-core": "0.11.3",
|
|
87
|
+
"@haatlabs-core/db-core": "0.11.3",
|
|
88
|
+
"@haatlabs-core/errors": "0.11.3",
|
|
89
|
+
"@haatlabs-core/logger": "0.11.3",
|
|
90
|
+
"@haatlabs-core/nest-auth": "0.11.3",
|
|
91
|
+
"@haatlabs-core/shopify": "0.11.3",
|
|
92
|
+
"@haatlabs-core/nest-common": "0.11.3"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@nestjs/common": "^12.1.2",
|