@shware/purchase 5.0.0 → 5.1.1
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/dist/app-store/config.d.cts +1 -2
- package/dist/app-store/config.d.cts.map +1 -1
- package/dist/app-store/config.d.mts +1 -2
- package/dist/app-store/config.d.mts.map +1 -1
- package/dist/app-store/handler.d.cts +2 -3
- package/dist/app-store/handler.d.cts.map +1 -1
- package/dist/app-store/handler.d.mts +2 -3
- package/dist/app-store/handler.d.mts.map +1 -1
- package/dist/app-store/index.cjs +2 -0
- package/dist/app-store/index.d.cts +2 -1
- package/dist/app-store/index.d.mts +2 -1
- package/dist/app-store/index.mjs +2 -1
- package/dist/app-store/mapper.cjs +47 -0
- package/dist/app-store/mapper.cjs.map +1 -0
- package/dist/app-store/mapper.d.cts +24 -0
- package/dist/app-store/mapper.d.cts.map +1 -0
- package/dist/app-store/mapper.d.mts +24 -0
- package/dist/app-store/mapper.d.mts.map +1 -0
- package/dist/app-store/mapper.mjs +46 -0
- package/dist/app-store/mapper.mjs.map +1 -0
- package/dist/google-play/config.d.cts +1 -2
- package/dist/google-play/config.d.cts.map +1 -1
- package/dist/google-play/config.d.mts +1 -2
- package/dist/google-play/config.d.mts.map +1 -1
- package/dist/google-play/index.cjs +2 -0
- package/dist/google-play/index.d.cts +2 -2
- package/dist/google-play/index.d.mts +2 -2
- package/dist/google-play/index.mjs +2 -2
- package/dist/google-play/mapper.cjs +48 -0
- package/dist/google-play/mapper.cjs.map +1 -1
- package/dist/google-play/mapper.d.cts +30 -3
- package/dist/google-play/mapper.d.cts.map +1 -1
- package/dist/google-play/mapper.d.mts +30 -3
- package/dist/google-play/mapper.d.mts.map +1 -1
- package/dist/google-play/mapper.mjs +47 -1
- package/dist/google-play/mapper.mjs.map +1 -1
- package/dist/google-play/real-time-developer-notification.d.cts +16 -17
- package/dist/google-play/real-time-developer-notification.d.cts.map +1 -1
- package/dist/google-play/real-time-developer-notification.d.mts +16 -17
- package/dist/google-play/real-time-developer-notification.d.mts.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/stripe/config.d.cts +3 -4
- package/dist/stripe/config.d.cts.map +1 -1
- package/dist/stripe/config.d.mts +3 -4
- package/dist/stripe/config.d.mts.map +1 -1
- package/dist/stripe/handler.d.cts +1 -2
- package/dist/stripe/handler.d.cts.map +1 -1
- package/dist/stripe/handler.d.mts +1 -2
- package/dist/stripe/handler.d.mts.map +1 -1
- package/dist/stripe/index.cjs +1 -0
- package/dist/stripe/index.d.cts +4 -3
- package/dist/stripe/index.d.mts +4 -3
- package/dist/stripe/index.mjs +2 -2
- package/dist/stripe/mapper.cjs +18 -0
- package/dist/stripe/mapper.cjs.map +1 -1
- package/dist/stripe/mapper.d.cts +29 -23
- package/dist/stripe/mapper.d.cts.map +1 -1
- package/dist/stripe/mapper.d.mts +29 -23
- package/dist/stripe/mapper.d.mts.map +1 -1
- package/dist/stripe/mapper.mjs +18 -1
- package/dist/stripe/mapper.mjs.map +1 -1
- package/dist/stripe/metadata.d.cts +1 -2
- package/dist/stripe/metadata.d.cts.map +1 -1
- package/dist/stripe/metadata.d.mts +1 -2
- package/dist/stripe/metadata.d.mts.map +1 -1
- package/dist/stripe/pending-checkout.d.cts +3 -4
- package/dist/stripe/pending-checkout.d.cts.map +1 -1
- package/dist/stripe/pending-checkout.d.mts +3 -4
- package/dist/stripe/pending-checkout.d.mts.map +1 -1
- package/dist/stripe/schema.cjs +4 -15
- package/dist/stripe/schema.cjs.map +1 -1
- package/dist/stripe/schema.d.cts +7 -11
- package/dist/stripe/schema.d.cts.map +1 -1
- package/dist/stripe/schema.d.mts +7 -11
- package/dist/stripe/schema.d.mts.map +1 -1
- package/dist/stripe/schema.mjs +4 -15
- package/dist/stripe/schema.mjs.map +1 -1
- package/dist/subscription/index.cjs +25 -0
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +41 -6
- package/dist/subscription/index.d.cts.map +1 -1
- package/dist/subscription/index.d.mts +41 -6
- package/dist/subscription/index.d.mts.map +1 -1
- package/dist/subscription/index.mjs +23 -1
- package/dist/subscription/index.mjs.map +1 -1
- package/dist/types.d.cts +2 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -3
- package/dist/types.d.mts.map +1 -1
- package/package.json +6 -6
|
@@ -20,7 +20,7 @@ type Options = {
|
|
|
20
20
|
appId: `${number}`;
|
|
21
21
|
bundleId: string;
|
|
22
22
|
};
|
|
23
|
-
declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PL extends string = never, PI extends string = never> {
|
|
23
|
+
export declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PL extends string = never, PI extends string = never> {
|
|
24
24
|
readonly appId: string;
|
|
25
25
|
readonly bundleId: string;
|
|
26
26
|
private readonly products;
|
|
@@ -45,5 +45,4 @@ declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, P
|
|
|
45
45
|
getCreditExpiresAt: (productId: string) => string;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
|
-
export { AppStoreConfig };
|
|
49
48
|
//# sourceMappingURL=config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/app-store/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,2BACA;WAES,MAAM;WACN,eAAe;WACf,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI;WACvC,UAAU,YAAY;EAE/B,kBAAkB;EAElB,YAAY,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK,MAAM,IAAI,eAAe;;;;;;EAajF,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI;EAM5C,UAAO,kBAAsB,MAAC,eAAA,IAAA,IAAA,IAAA,IAAA;;KAW3B;EAAY;EAAoB;;
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/app-store/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,2BACA;WAES,MAAM;WACN,eAAe;WACf,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI;WACvC,UAAU,YAAY;EAE/B,kBAAkB;EAElB,YAAY,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK,MAAM,IAAI,eAAe;;;;;;EAajF,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI;EAM5C,UAAO,kBAAsB,MAAC,eAAA,IAAA,IAAA,IAAA,IAAA;;KAW3B;EAAY;EAAoB;;qBAExB,eACX,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA;WAES;WACA;mBAEQ;mBACA;mBACA;mBACA;MAEb;GAMH,aAAU,cAAkB,aAAa,IAAI,IAAI,IAAI,IAAI;UAWnD;SASA,SAAU,aAAW,mBAAmB,qBAAmB,8BAA0B,SACjF,YAAO,eAAA,MAAA,MAAA;;EAMlB,eAAgB,UAAU,IAAI,UAAU,IAAE,MAClC,GAAC,kBACW,KAAK,YAAY,aAAa,MAAC,aAAA,IAAA,IAAA,IAAA,QAAA,KAAA,KAAA;EAMnD,aAAc,aAAa,MAAM,qBAAmB,WACvC,UAAU,aAAa,GAAC,WACzB,aAKK,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK;EAGrD,gBAAiB,aAAa,MAAM,qBAAmB,WAAa,UAAU,aAAa,MAI1E,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK;;EAIrD,sBAAmB,MAAU,IAAE,eAAiB;EAUhD,UAAO,sBAAwB;EAO/B,mBAAgB,sBAAwB;EAOxC,UAAO;EAQP,kBAAe;mBAOE;EAMjB,qBAAkB"}
|
|
@@ -20,7 +20,7 @@ type Options = {
|
|
|
20
20
|
appId: `${number}`;
|
|
21
21
|
bundleId: string;
|
|
22
22
|
};
|
|
23
|
-
declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PL extends string = never, PI extends string = never> {
|
|
23
|
+
export declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PL extends string = never, PI extends string = never> {
|
|
24
24
|
readonly appId: string;
|
|
25
25
|
readonly bundleId: string;
|
|
26
26
|
private readonly products;
|
|
@@ -45,5 +45,4 @@ declare class AppStoreConfig<NS extends Lowercase<string> = Lowercase<string>, P
|
|
|
45
45
|
getCreditExpiresAt: (productId: string) => string;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
|
-
export { AppStoreConfig };
|
|
49
48
|
//# sourceMappingURL=config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/app-store/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,2BACA;WAES,MAAM;WACN,eAAe;WACf,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI;WACvC,UAAU,YAAY;EAE/B,kBAAkB;EAElB,YAAY,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK,MAAM,IAAI,eAAe;;;;;;EAajF,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI;EAM5C,UAAO,kBAAsB,MAAC,eAAA,IAAA,IAAA,IAAA,IAAA;;KAW3B;EAAY;EAAoB;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/app-store/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,2BACA;WAES,MAAM;WACN,eAAe;WACf,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI;WACvC,UAAU,YAAY;EAE/B,kBAAkB;EAElB,YAAY,QAAQ,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK,MAAM,IAAI,eAAe;;;;;;EAajF,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI;EAM5C,UAAO,kBAAsB,MAAC,eAAA,IAAA,IAAA,IAAA,IAAA;;KAW3B;EAAY;EAAoB;;qBAExB,eACX,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA;WAES;WACA;mBAEQ;mBACA;mBACA;mBACA;MAEb;GAMH,aAAU,cAAkB,aAAa,IAAI,IAAI,IAAI,IAAI;UAWnD;SASA,SAAU,aAAW,mBAAmB,qBAAmB,8BAA0B,SACjF,YAAO,eAAA,MAAA,MAAA;;EAMlB,eAAgB,UAAU,IAAI,UAAU,IAAE,MAClC,GAAC,kBACW,KAAK,YAAY,aAAa,MAAC,aAAA,IAAA,IAAA,IAAA,QAAA,KAAA,KAAA;EAMnD,aAAc,aAAa,MAAM,qBAAmB,WACvC,UAAU,aAAa,GAAC,WACzB,aAKK,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK;EAGrD,gBAAiB,aAAa,MAAM,qBAAmB,WAAa,UAAU,aAAa,MAI1E,eAAe,IAAI,IAAI,IAAI,IAAI,KAAK;;EAIrD,sBAAmB,MAAU,IAAE,eAAiB;EAUhD,UAAO,sBAAwB;EAO/B,mBAAgB,sBAAwB;EAOxC,UAAO;EAQP,kBAAe;mBAOE;EAMjB,qBAAkB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JWSRenewalInfoDecodedPayload, JWSTransactionDecodedPayload, NotificationTypeV2, ResponseBodyV2DecodedPayload } from "@apple/app-store-server-library";
|
|
2
2
|
//#region src/app-store/handler.d.ts
|
|
3
|
-
interface AppStoreNotificationEvent {
|
|
3
|
+
export interface AppStoreNotificationEvent {
|
|
4
4
|
payload: ResponseBodyV2DecodedPayload;
|
|
5
5
|
transaction: JWSTransactionDecodedPayload | null;
|
|
6
6
|
renewalInfo: JWSRenewalInfoDecodedPayload | null;
|
|
@@ -12,7 +12,7 @@ type NotificationHandlerFn = (event: AppStoreNotificationEvent) => Promise<void>
|
|
|
12
12
|
* renewalInfo) first and passes the decoded event in. Subtype branching stays inside each
|
|
13
13
|
* handler: Apple subtypes share the handler's derived context and are usually a few lines each.
|
|
14
14
|
*/
|
|
15
|
-
declare class AppStoreNotificationHandler {
|
|
15
|
+
export declare class AppStoreNotificationHandler {
|
|
16
16
|
private readonly handlers;
|
|
17
17
|
private constructor();
|
|
18
18
|
static create(): AppStoreNotificationHandler;
|
|
@@ -20,5 +20,4 @@ declare class AppStoreNotificationHandler {
|
|
|
20
20
|
process: (event: AppStoreNotificationEvent) => Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
export { AppStoreNotificationEvent, AppStoreNotificationHandler };
|
|
24
23
|
//# sourceMappingURL=handler.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.cts","names":[],"sources":["../../src/app-store/handler.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"handler.d.cts","names":[],"sources":["../../src/app-store/handler.ts"],"mappings":";;iBAOiB;EACf,SAAS;EACT,aAAa;EACb,aAAa;;KAGV,yBAAyB,OAAO,8BAA8B;;;;;;;qBAQtD;mBACM;UAEV;SAIA,UAAM;EAIb,KAAE,MAAU,oBAAkB,SAAW;EASzC,UAAO,OAAiB,8BAA4B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JWSRenewalInfoDecodedPayload, JWSTransactionDecodedPayload, NotificationTypeV2, ResponseBodyV2DecodedPayload } from "@apple/app-store-server-library";
|
|
2
2
|
//#region src/app-store/handler.d.ts
|
|
3
|
-
interface AppStoreNotificationEvent {
|
|
3
|
+
export interface AppStoreNotificationEvent {
|
|
4
4
|
payload: ResponseBodyV2DecodedPayload;
|
|
5
5
|
transaction: JWSTransactionDecodedPayload | null;
|
|
6
6
|
renewalInfo: JWSRenewalInfoDecodedPayload | null;
|
|
@@ -12,7 +12,7 @@ type NotificationHandlerFn = (event: AppStoreNotificationEvent) => Promise<void>
|
|
|
12
12
|
* renewalInfo) first and passes the decoded event in. Subtype branching stays inside each
|
|
13
13
|
* handler: Apple subtypes share the handler's derived context and are usually a few lines each.
|
|
14
14
|
*/
|
|
15
|
-
declare class AppStoreNotificationHandler {
|
|
15
|
+
export declare class AppStoreNotificationHandler {
|
|
16
16
|
private readonly handlers;
|
|
17
17
|
private constructor();
|
|
18
18
|
static create(): AppStoreNotificationHandler;
|
|
@@ -20,5 +20,4 @@ declare class AppStoreNotificationHandler {
|
|
|
20
20
|
process: (event: AppStoreNotificationEvent) => Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
export { AppStoreNotificationEvent, AppStoreNotificationHandler };
|
|
24
23
|
//# sourceMappingURL=handler.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.mts","names":[],"sources":["../../src/app-store/handler.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"handler.d.mts","names":[],"sources":["../../src/app-store/handler.ts"],"mappings":";;iBAOiB;EACf,SAAS;EACT,aAAa;EACb,aAAa;;KAGV,yBAAyB,OAAO,8BAA8B;;;;;;;qBAQtD;mBACM;UAEV;SAIA,UAAM;EAIb,KAAE,MAAU,oBAAkB,SAAW;EASzC,UAAO,OAAiB,8BAA4B"}
|
package/dist/app-store/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_app_store_config = require("./config.cjs");
|
|
3
3
|
const require_app_store_handler = require("./handler.cjs");
|
|
4
|
+
const require_app_store_mapper = require("./mapper.cjs");
|
|
4
5
|
exports.AppStoreConfig = require_app_store_config.AppStoreConfig;
|
|
5
6
|
exports.AppStoreNotificationHandler = require_app_store_handler.AppStoreNotificationHandler;
|
|
7
|
+
exports.mapCancellationDetails = require_app_store_mapper.mapCancellationDetails;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { AppStoreConfig } from "./config.cjs";
|
|
2
2
|
import { AppStoreNotificationEvent, AppStoreNotificationHandler } from "./handler.cjs";
|
|
3
|
-
|
|
3
|
+
import { AppStoreCancellationSource, mapCancellationDetails } from "./mapper.cjs";
|
|
4
|
+
export { type AppStoreCancellationSource, AppStoreConfig, type AppStoreNotificationEvent, AppStoreNotificationHandler, mapCancellationDetails };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { AppStoreConfig } from "./config.mjs";
|
|
2
2
|
import { AppStoreNotificationEvent, AppStoreNotificationHandler } from "./handler.mjs";
|
|
3
|
-
|
|
3
|
+
import { AppStoreCancellationSource, mapCancellationDetails } from "./mapper.mjs";
|
|
4
|
+
export { type AppStoreCancellationSource, AppStoreConfig, type AppStoreNotificationEvent, AppStoreNotificationHandler, mapCancellationDetails };
|
package/dist/app-store/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { AppStoreConfig } from "./config.mjs";
|
|
2
2
|
import { AppStoreNotificationHandler } from "./handler.mjs";
|
|
3
|
-
|
|
3
|
+
import { mapCancellationDetails } from "./mapper.mjs";
|
|
4
|
+
export { AppStoreConfig, AppStoreNotificationHandler, mapCancellationDetails };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/app-store/mapper.ts
|
|
3
|
+
/**
|
|
4
|
+
* Who ended an App Store subscription and why, from the notification that reported it. Null for
|
|
5
|
+
* anything that is not a cancellation, including the customer turning auto-renew back on.
|
|
6
|
+
*
|
|
7
|
+
* ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)
|
|
8
|
+
* ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)
|
|
9
|
+
*/
|
|
10
|
+
function mapCancellationDetails(source) {
|
|
11
|
+
const { notificationType, subtype, expirationIntent } = source;
|
|
12
|
+
const details = (initiator, reason) => ({
|
|
13
|
+
initiator,
|
|
14
|
+
reason,
|
|
15
|
+
feedback: null,
|
|
16
|
+
comment: null
|
|
17
|
+
});
|
|
18
|
+
switch (notificationType) {
|
|
19
|
+
case "DID_CHANGE_RENEWAL_STATUS": return subtype === "AUTO_RENEW_DISABLED" ? details("user", subtype) : null;
|
|
20
|
+
case "EXPIRED": switch (subtype ?? expirationIntentSubtype(expirationIntent)) {
|
|
21
|
+
case "VOLUNTARY": return details("user", "VOLUNTARY");
|
|
22
|
+
case "BILLING_RETRY": return details("system", "BILLING_RETRY");
|
|
23
|
+
case "PRICE_INCREASE": return details("user", "PRICE_INCREASE");
|
|
24
|
+
case "PRODUCT_NOT_FOR_SALE": return details("developer", "PRODUCT_NOT_FOR_SALE");
|
|
25
|
+
default: return details("system", "EXPIRED");
|
|
26
|
+
}
|
|
27
|
+
case "DID_FAIL_TO_RENEW":
|
|
28
|
+
case "GRACE_PERIOD_EXPIRED":
|
|
29
|
+
case "REFUND":
|
|
30
|
+
case "REVOKE": return details("system", notificationType);
|
|
31
|
+
default: return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The EXPIRED subtype Apple would have sent for an `expirationIntent`. */
|
|
35
|
+
function expirationIntentSubtype(intent) {
|
|
36
|
+
switch (intent) {
|
|
37
|
+
case 1: return "VOLUNTARY";
|
|
38
|
+
case 2: return "BILLING_RETRY";
|
|
39
|
+
case 3: return "PRICE_INCREASE";
|
|
40
|
+
case 4: return "PRODUCT_NOT_FOR_SALE";
|
|
41
|
+
default: return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.mapCancellationDetails = mapCancellationDetails;
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=mapper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.cjs","names":[],"sources":["../../src/app-store/mapper.ts"],"sourcesContent":["import type { CancellationDetails } from '../subscription/index';\n\n/**\n * The App Store Server Notification fields that say why a subscription stops renewing: the\n * notification type and subtype, plus `expirationIntent` from the renewal info once it has\n * expired. Strings and numbers as Apple sends them, so this needs no runtime import of the\n * App Store Server Library.\n */\nexport interface AppStoreCancellationSource {\n notificationType: string;\n subtype?: string | null;\n /** `JWSRenewalInfoDecodedPayload.expirationIntent`: 1 customer, 2 billing, 3 price increase, 4 unavailable, 5 other. */\n expirationIntent?: number | null;\n}\n\n/**\n * Who ended an App Store subscription and why, from the notification that reported it. Null for\n * anything that is not a cancellation, including the customer turning auto-renew back on.\n *\n * ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)\n * ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)\n */\nexport function mapCancellationDetails(\n source: AppStoreCancellationSource\n): CancellationDetails | null {\n const { notificationType, subtype, expirationIntent } = source;\n const details = (initiator: CancellationDetails['initiator'], reason: string) => ({\n initiator,\n reason,\n feedback: null,\n comment: null,\n });\n\n switch (notificationType) {\n case 'DID_CHANGE_RENEWAL_STATUS':\n return subtype === 'AUTO_RENEW_DISABLED' ? details('user', subtype) : null;\n case 'EXPIRED':\n switch (subtype ?? expirationIntentSubtype(expirationIntent)) {\n case 'VOLUNTARY':\n return details('user', 'VOLUNTARY');\n case 'BILLING_RETRY':\n return details('system', 'BILLING_RETRY');\n case 'PRICE_INCREASE':\n return details('user', 'PRICE_INCREASE');\n case 'PRODUCT_NOT_FOR_SALE':\n return details('developer', 'PRODUCT_NOT_FOR_SALE');\n default:\n return details('system', 'EXPIRED');\n }\n case 'DID_FAIL_TO_RENEW':\n case 'GRACE_PERIOD_EXPIRED':\n case 'REFUND':\n case 'REVOKE':\n return details('system', notificationType);\n default:\n return null;\n }\n}\n\n/** The EXPIRED subtype Apple would have sent for an `expirationIntent`. */\nfunction expirationIntentSubtype(intent: number | null | undefined) {\n switch (intent) {\n case 1:\n return 'VOLUNTARY';\n case 2:\n return 'BILLING_RETRY';\n case 3:\n return 'PRICE_INCREASE';\n case 4:\n return 'PRODUCT_NOT_FOR_SALE';\n default:\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,uBACd,QAC4B;CAC5B,MAAM,EAAE,kBAAkB,SAAS,qBAAqB;CACxD,MAAM,WAAW,WAA6C,YAAoB;EAChF;EACA;EACA,UAAU;EACV,SAAS;CACX;CAEA,QAAQ,kBAAR;EACE,KAAK,6BACH,OAAO,YAAY,wBAAwB,QAAQ,QAAQ,OAAO,IAAI;EACxE,KAAK,WACH,QAAQ,WAAW,wBAAwB,gBAAgB,GAA3D;GACE,KAAK,aACH,OAAO,QAAQ,QAAQ,WAAW;GACpC,KAAK,iBACH,OAAO,QAAQ,UAAU,eAAe;GAC1C,KAAK,kBACH,OAAO,QAAQ,QAAQ,gBAAgB;GACzC,KAAK,wBACH,OAAO,QAAQ,aAAa,sBAAsB;GACpD,SACE,OAAO,QAAQ,UAAU,SAAS;EACtC;EACF,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO,QAAQ,UAAU,gBAAgB;EAC3C,SACE,OAAO;CACX;AACF;;AAGA,SAAS,wBAAwB,QAAmC;CAClE,QAAQ,QAAR;EACE,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,SACE;CACJ;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CancellationDetails } from "../subscription/index.cjs";
|
|
2
|
+
//#region src/app-store/mapper.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The App Store Server Notification fields that say why a subscription stops renewing: the
|
|
5
|
+
* notification type and subtype, plus `expirationIntent` from the renewal info once it has
|
|
6
|
+
* expired. Strings and numbers as Apple sends them, so this needs no runtime import of the
|
|
7
|
+
* App Store Server Library.
|
|
8
|
+
*/
|
|
9
|
+
export interface AppStoreCancellationSource {
|
|
10
|
+
notificationType: string;
|
|
11
|
+
subtype?: string | null;
|
|
12
|
+
/** `JWSRenewalInfoDecodedPayload.expirationIntent`: 1 customer, 2 billing, 3 price increase, 4 unavailable, 5 other. */
|
|
13
|
+
expirationIntent?: number | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Who ended an App Store subscription and why, from the notification that reported it. Null for
|
|
17
|
+
* anything that is not a cancellation, including the customer turning auto-renew back on.
|
|
18
|
+
*
|
|
19
|
+
* ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)
|
|
20
|
+
* ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)
|
|
21
|
+
*/
|
|
22
|
+
export declare function mapCancellationDetails(source: AppStoreCancellationSource): CancellationDetails | null;
|
|
23
|
+
//#endregion
|
|
24
|
+
//# sourceMappingURL=mapper.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.d.cts","names":[],"sources":["../../src/app-store/mapper.ts"],"mappings":";;;;;;;;iBAQiB;EACf;EACA;;EAEA;;;;;;;;;wBAUc,uBACd,QAAQ,6BACP"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CancellationDetails } from "../subscription/index.mjs";
|
|
2
|
+
//#region src/app-store/mapper.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The App Store Server Notification fields that say why a subscription stops renewing: the
|
|
5
|
+
* notification type and subtype, plus `expirationIntent` from the renewal info once it has
|
|
6
|
+
* expired. Strings and numbers as Apple sends them, so this needs no runtime import of the
|
|
7
|
+
* App Store Server Library.
|
|
8
|
+
*/
|
|
9
|
+
export interface AppStoreCancellationSource {
|
|
10
|
+
notificationType: string;
|
|
11
|
+
subtype?: string | null;
|
|
12
|
+
/** `JWSRenewalInfoDecodedPayload.expirationIntent`: 1 customer, 2 billing, 3 price increase, 4 unavailable, 5 other. */
|
|
13
|
+
expirationIntent?: number | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Who ended an App Store subscription and why, from the notification that reported it. Null for
|
|
17
|
+
* anything that is not a cancellation, including the customer turning auto-renew back on.
|
|
18
|
+
*
|
|
19
|
+
* ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)
|
|
20
|
+
* ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)
|
|
21
|
+
*/
|
|
22
|
+
export declare function mapCancellationDetails(source: AppStoreCancellationSource): CancellationDetails | null;
|
|
23
|
+
//#endregion
|
|
24
|
+
//# sourceMappingURL=mapper.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.d.mts","names":[],"sources":["../../src/app-store/mapper.ts"],"mappings":";;;;;;;;iBAQiB;EACf;EACA;;EAEA;;;;;;;;;wBAUc,uBACd,QAAQ,6BACP"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/app-store/mapper.ts
|
|
2
|
+
/**
|
|
3
|
+
* Who ended an App Store subscription and why, from the notification that reported it. Null for
|
|
4
|
+
* anything that is not a cancellation, including the customer turning auto-renew back on.
|
|
5
|
+
*
|
|
6
|
+
* ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)
|
|
7
|
+
* ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)
|
|
8
|
+
*/
|
|
9
|
+
function mapCancellationDetails(source) {
|
|
10
|
+
const { notificationType, subtype, expirationIntent } = source;
|
|
11
|
+
const details = (initiator, reason) => ({
|
|
12
|
+
initiator,
|
|
13
|
+
reason,
|
|
14
|
+
feedback: null,
|
|
15
|
+
comment: null
|
|
16
|
+
});
|
|
17
|
+
switch (notificationType) {
|
|
18
|
+
case "DID_CHANGE_RENEWAL_STATUS": return subtype === "AUTO_RENEW_DISABLED" ? details("user", subtype) : null;
|
|
19
|
+
case "EXPIRED": switch (subtype ?? expirationIntentSubtype(expirationIntent)) {
|
|
20
|
+
case "VOLUNTARY": return details("user", "VOLUNTARY");
|
|
21
|
+
case "BILLING_RETRY": return details("system", "BILLING_RETRY");
|
|
22
|
+
case "PRICE_INCREASE": return details("user", "PRICE_INCREASE");
|
|
23
|
+
case "PRODUCT_NOT_FOR_SALE": return details("developer", "PRODUCT_NOT_FOR_SALE");
|
|
24
|
+
default: return details("system", "EXPIRED");
|
|
25
|
+
}
|
|
26
|
+
case "DID_FAIL_TO_RENEW":
|
|
27
|
+
case "GRACE_PERIOD_EXPIRED":
|
|
28
|
+
case "REFUND":
|
|
29
|
+
case "REVOKE": return details("system", notificationType);
|
|
30
|
+
default: return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The EXPIRED subtype Apple would have sent for an `expirationIntent`. */
|
|
34
|
+
function expirationIntentSubtype(intent) {
|
|
35
|
+
switch (intent) {
|
|
36
|
+
case 1: return "VOLUNTARY";
|
|
37
|
+
case 2: return "BILLING_RETRY";
|
|
38
|
+
case 3: return "PRICE_INCREASE";
|
|
39
|
+
case 4: return "PRODUCT_NOT_FOR_SALE";
|
|
40
|
+
default: return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { mapCancellationDetails };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=mapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.mjs","names":[],"sources":["../../src/app-store/mapper.ts"],"sourcesContent":["import type { CancellationDetails } from '../subscription/index';\n\n/**\n * The App Store Server Notification fields that say why a subscription stops renewing: the\n * notification type and subtype, plus `expirationIntent` from the renewal info once it has\n * expired. Strings and numbers as Apple sends them, so this needs no runtime import of the\n * App Store Server Library.\n */\nexport interface AppStoreCancellationSource {\n notificationType: string;\n subtype?: string | null;\n /** `JWSRenewalInfoDecodedPayload.expirationIntent`: 1 customer, 2 billing, 3 price increase, 4 unavailable, 5 other. */\n expirationIntent?: number | null;\n}\n\n/**\n * Who ended an App Store subscription and why, from the notification that reported it. Null for\n * anything that is not a cancellation, including the customer turning auto-renew back on.\n *\n * ref: [notificationType](https://developer.apple.com/documentation/appstoreservernotifications/notificationtype)\n * ref: [expirationIntent](https://developer.apple.com/documentation/appstoreserverapi/expirationintent)\n */\nexport function mapCancellationDetails(\n source: AppStoreCancellationSource\n): CancellationDetails | null {\n const { notificationType, subtype, expirationIntent } = source;\n const details = (initiator: CancellationDetails['initiator'], reason: string) => ({\n initiator,\n reason,\n feedback: null,\n comment: null,\n });\n\n switch (notificationType) {\n case 'DID_CHANGE_RENEWAL_STATUS':\n return subtype === 'AUTO_RENEW_DISABLED' ? details('user', subtype) : null;\n case 'EXPIRED':\n switch (subtype ?? expirationIntentSubtype(expirationIntent)) {\n case 'VOLUNTARY':\n return details('user', 'VOLUNTARY');\n case 'BILLING_RETRY':\n return details('system', 'BILLING_RETRY');\n case 'PRICE_INCREASE':\n return details('user', 'PRICE_INCREASE');\n case 'PRODUCT_NOT_FOR_SALE':\n return details('developer', 'PRODUCT_NOT_FOR_SALE');\n default:\n return details('system', 'EXPIRED');\n }\n case 'DID_FAIL_TO_RENEW':\n case 'GRACE_PERIOD_EXPIRED':\n case 'REFUND':\n case 'REVOKE':\n return details('system', notificationType);\n default:\n return null;\n }\n}\n\n/** The EXPIRED subtype Apple would have sent for an `expirationIntent`. */\nfunction expirationIntentSubtype(intent: number | null | undefined) {\n switch (intent) {\n case 1:\n return 'VOLUNTARY';\n case 2:\n return 'BILLING_RETRY';\n case 3:\n return 'PRICE_INCREASE';\n case 4:\n return 'PRODUCT_NOT_FOR_SALE';\n default:\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;AAsBA,SAAgB,uBACd,QAC4B;CAC5B,MAAM,EAAE,kBAAkB,SAAS,qBAAqB;CACxD,MAAM,WAAW,WAA6C,YAAoB;EAChF;EACA;EACA,UAAU;EACV,SAAS;CACX;CAEA,QAAQ,kBAAR;EACE,KAAK,6BACH,OAAO,YAAY,wBAAwB,QAAQ,QAAQ,OAAO,IAAI;EACxE,KAAK,WACH,QAAQ,WAAW,wBAAwB,gBAAgB,GAA3D;GACE,KAAK,aACH,OAAO,QAAQ,QAAQ,WAAW;GACpC,KAAK,iBACH,OAAO,QAAQ,UAAU,eAAe;GAC1C,KAAK,kBACH,OAAO,QAAQ,QAAQ,gBAAgB;GACzC,KAAK,wBACH,OAAO,QAAQ,aAAa,sBAAsB;GACpD,SACE,OAAO,QAAQ,UAAU,SAAS;EACtC;EACF,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO,QAAQ,UAAU,gBAAgB;EAC3C,SACE,OAAO;CACX;AACF;;AAGA,SAAS,wBAAwB,QAAmC;CAClE,QAAQ,QAAR;EACE,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,KAAK,GACH,OAAO;EACT,SACE;CACJ;AACF"}
|
|
@@ -22,7 +22,7 @@ type Options = {
|
|
|
22
22
|
package: string;
|
|
23
23
|
audience: string;
|
|
24
24
|
};
|
|
25
|
-
declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PI extends string = never> {
|
|
25
|
+
export declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PI extends string = never> {
|
|
26
26
|
readonly package: string;
|
|
27
27
|
readonly audience: string;
|
|
28
28
|
private readonly onetimes;
|
|
@@ -44,5 +44,4 @@ declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>,
|
|
|
44
44
|
getCreditExpiresAt: (productId: string, planId?: string) => string;
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export { GooglePlayConfig };
|
|
48
47
|
//# sourceMappingURL=config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/google-play/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,UAAU;WAED;WACA,QAAQ,iBAAiB,IAAI,IAAI,IAAI;WACrC,OAAO,YAAY;IAAa,OAAO;IAAI,gBAAgB;;WAC3D,cAAc;EAEvB,YAAY,QAAQ,iBAAiB,IAAI,IAAI,IAAI,KAAK;;;;;;EAYtD,WAAY,UAAU,mBAAiB,QAC7B,UAAU,YAAY,GAAC,MACzB,IAAE,eACO,IAAE,WACP,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,IAAI;EAMpC,gBAAiB,oBAAoB,MAAM,MAAI,SACpC,KAAK,SAAS,uCAAkC,iBAAA,IAAA,IAAA,IAAA;;KAWxD;EAAY;EAAiB;;
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/google-play/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,UAAU;WAED;WACA,QAAQ,iBAAiB,IAAI,IAAI,IAAI;WACrC,OAAO,YAAY;IAAa,OAAO;IAAI,gBAAgB;;WAC3D,cAAc;EAEvB,YAAY,QAAQ,iBAAiB,IAAI,IAAI,IAAI,KAAK;;;;;;EAYtD,WAAY,UAAU,mBAAiB,QAC7B,UAAU,YAAY,GAAC,MACzB,IAAE,eACO,IAAE,WACP,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,IAAI;EAMpC,gBAAiB,oBAAoB,MAAM,MAAI,SACpC,KAAK,SAAS,uCAAkC,iBAAA,IAAA,IAAA,IAAA;;KAWxD;EAAY;EAAiB;;qBAErB,iBACX,WAAW,oBAAoB,mBAC/B,4BACA,4BACA;WAES;WACA;mBACQ;mBACA;mBACA;GAIhB,aAAU,cAAkB,aAAa,IAAI,IAAI,IAAI;mBAcrC;UAIV;SAQA,SACL,aAAW,mBACX,8BACA,8BAA0B,SAEjB,YAAO,iBAAA,MAAA,MAAA;EAKlB,eAAgB,aAAa,MAAM,qBAAmB,WAAa,UAAU,aAAa,MAAC,aAAA,IAAA,IAAA,IAAA,IAAA;EAI3F,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aAKK,iBAAiB,IAAI,IAAI,IAAI,KAAK;;EAInD,oBAAiB;EAMjB,UAAO,mBAAqB,mBAAmB;EAQ/C,mBAAgB,mBAAqB,mBAAmB;EAQxD,UAAO;EAMP,kBAAe,mBAAqB;mBAOnB;EAOjB,qBAAkB,mBAAqB"}
|
|
@@ -22,7 +22,7 @@ type Options = {
|
|
|
22
22
|
package: string;
|
|
23
23
|
audience: string;
|
|
24
24
|
};
|
|
25
|
-
declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PI extends string = never> {
|
|
25
|
+
export declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>, PE extends string = string, BP extends string = string, PI extends string = never> {
|
|
26
26
|
readonly package: string;
|
|
27
27
|
readonly audience: string;
|
|
28
28
|
private readonly onetimes;
|
|
@@ -44,5 +44,4 @@ declare class GooglePlayConfig<NS extends Lowercase<string> = Lowercase<string>,
|
|
|
44
44
|
getCreditExpiresAt: (productId: string, planId?: string) => string;
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export { GooglePlayConfig };
|
|
48
47
|
//# sourceMappingURL=config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/google-play/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,UAAU;WAED;WACA,QAAQ,iBAAiB,IAAI,IAAI,IAAI;WACrC,OAAO,YAAY;IAAa,OAAO;IAAI,gBAAgB;;WAC3D,cAAc;EAEvB,YAAY,QAAQ,iBAAiB,IAAI,IAAI,IAAI,KAAK;;;;;;EAYtD,WAAY,UAAU,mBAAiB,QAC7B,UAAU,YAAY,GAAC,MACzB,IAAE,eACO,IAAE,WACP,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,IAAI;EAMpC,gBAAiB,oBAAoB,MAAM,MAAI,SACpC,KAAK,SAAS,uCAAkC,iBAAA,IAAA,IAAA,IAAA;;KAWxD;EAAY;EAAiB;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/google-play/config.ts"],"mappings":";;cAIM;cAEA,aACJ,WAAW,oBAAoB,mBAC/B,4BACA,4BACA,2BACA,UAAU;WAED;WACA,QAAQ,iBAAiB,IAAI,IAAI,IAAI;WACrC,OAAO,YAAY;IAAa,OAAO;IAAI,gBAAgB;;WAC3D,cAAc;EAEvB,YAAY,QAAQ,iBAAiB,IAAI,IAAI,IAAI,KAAK;;;;;;EAYtD,WAAY,UAAU,mBAAiB,QAC7B,UAAU,YAAY,GAAC,MACzB,IAAE,eACO,IAAE,WACP,aACT,aAAa,IAAI,IAAI,IAAI,IAAI,IAAI;EAMpC,gBAAiB,oBAAoB,MAAM,MAAI,SACpC,KAAK,SAAS,uCAAkC,iBAAA,IAAA,IAAA,IAAA;;KAWxD;EAAY;EAAiB;;qBAErB,iBACX,WAAW,oBAAoB,mBAC/B,4BACA,4BACA;WAES;WACA;mBACQ;mBACA;mBACA;GAIhB,aAAU,cAAkB,aAAa,IAAI,IAAI,IAAI;mBAcrC;UAIV;SAQA,SACL,aAAW,mBACX,8BACA,8BAA0B,SAEjB,YAAO,iBAAA,MAAA,MAAA;EAKlB,eAAgB,aAAa,MAAM,qBAAmB,WAAa,UAAU,aAAa,MAAC,aAAA,IAAA,IAAA,IAAA,IAAA;EAI3F,UAAW,aAAa,MAAM,qBAAmB,WACpC,UAAU,aAAa,GAAC,WACzB,aAKK,iBAAiB,IAAI,IAAI,IAAI,KAAK;;EAInD,oBAAiB;EAMjB,UAAO,mBAAqB,mBAAmB;EAQ/C,mBAAgB,mBAAqB,mBAAmB;EAQxD,UAAO;EAMP,kBAAe,mBAAqB;mBAOnB;EAOjB,qBAAkB,mBAAqB"}
|
|
@@ -8,4 +8,6 @@ exports.OneTimeProductNotificationType = require_google_play_real_time_developer
|
|
|
8
8
|
exports.SubscriptionNotificationType = require_google_play_real_time_developer_notification.SubscriptionNotificationType;
|
|
9
9
|
exports.VoidedPurchaseProductType = require_google_play_real_time_developer_notification.VoidedPurchaseProductType;
|
|
10
10
|
exports.VoidedPurchaseRefundType = require_google_play_real_time_developer_notification.VoidedPurchaseRefundType;
|
|
11
|
+
exports.mapCanceledAt = require_google_play_mapper.mapCanceledAt;
|
|
12
|
+
exports.mapCancellationDetails = require_google_play_mapper.mapCancellationDetails;
|
|
11
13
|
exports.mapSubscriptionStatus = require_google_play_mapper.mapSubscriptionStatus;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GooglePlayConfig } from "./config.cjs";
|
|
2
2
|
import { DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlaySubscriptionState, OneTimeProductNotification, OneTimeProductNotificationType, PubsubMessage, SubscriptionNotification, SubscriptionNotificationType, TestNotification, VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType } from "./real-time-developer-notification.cjs";
|
|
3
|
-
import { mapSubscriptionStatus } from "./mapper.cjs";
|
|
4
|
-
export { type DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, type GooglePlaySubscriptionState, type OneTimeProductNotification, OneTimeProductNotificationType, type PubsubMessage, type SubscriptionNotification, SubscriptionNotificationType, type TestNotification, type VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapSubscriptionStatus };
|
|
3
|
+
import { CanceledStateContext, mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus } from "./mapper.cjs";
|
|
4
|
+
export { type CanceledStateContext, type DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, type GooglePlaySubscriptionState, type OneTimeProductNotification, OneTimeProductNotificationType, type PubsubMessage, type SubscriptionNotification, SubscriptionNotificationType, type TestNotification, type VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GooglePlayConfig } from "./config.mjs";
|
|
2
2
|
import { DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlaySubscriptionState, OneTimeProductNotification, OneTimeProductNotificationType, PubsubMessage, SubscriptionNotification, SubscriptionNotificationType, TestNotification, VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType } from "./real-time-developer-notification.mjs";
|
|
3
|
-
import { mapSubscriptionStatus } from "./mapper.mjs";
|
|
4
|
-
export { type DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, type GooglePlaySubscriptionState, type OneTimeProductNotification, OneTimeProductNotificationType, type PubsubMessage, type SubscriptionNotification, SubscriptionNotificationType, type TestNotification, type VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapSubscriptionStatus };
|
|
3
|
+
import { CanceledStateContext, mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus } from "./mapper.mjs";
|
|
4
|
+
export { type CanceledStateContext, type DeveloperNotification, GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, type GooglePlaySubscriptionState, type OneTimeProductNotification, OneTimeProductNotificationType, type PubsubMessage, type SubscriptionNotification, SubscriptionNotificationType, type TestNotification, type VoidedPurchaseNotification, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GooglePlayConfig } from "./config.mjs";
|
|
2
2
|
import { GOOGLE_PLAY_SUBSCRIPTION_STATES, OneTimeProductNotificationType, SubscriptionNotificationType, VoidedPurchaseProductType, VoidedPurchaseRefundType } from "./real-time-developer-notification.mjs";
|
|
3
|
-
import { mapSubscriptionStatus } from "./mapper.mjs";
|
|
4
|
-
export { GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, OneTimeProductNotificationType, SubscriptionNotificationType, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapSubscriptionStatus };
|
|
3
|
+
import { mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus } from "./mapper.mjs";
|
|
4
|
+
export { GOOGLE_PLAY_SUBSCRIPTION_STATES, GooglePlayConfig, OneTimeProductNotificationType, SubscriptionNotificationType, VoidedPurchaseProductType, VoidedPurchaseRefundType, mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus };
|
|
@@ -13,7 +13,55 @@ function mapSubscriptionStatus(state) {
|
|
|
13
13
|
default: throw new Error(`Unknown Google Play subscription state: ${state}`);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
/** Play's cancel-survey answers in the shared vocabulary. */
|
|
17
|
+
const SURVEY_FEEDBACK = {
|
|
18
|
+
CANCEL_SURVEY_REASON_NOT_ENOUGH_USAGE: "unused",
|
|
19
|
+
CANCEL_SURVEY_REASON_TECHNICAL_ISSUES: "low_quality",
|
|
20
|
+
CANCEL_SURVEY_REASON_COST_RELATED: "too_expensive",
|
|
21
|
+
CANCEL_SURVEY_REASON_FOUND_BETTER_APP: "switched_service",
|
|
22
|
+
CANCEL_SURVEY_REASON_OTHERS: "other"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Why a Play subscription stopped renewing. The Play Store asks the user for a reason on cancel
|
|
26
|
+
* (and for free text when it is "Other"), which comes back in `cancelSurveyResult`. Null while
|
|
27
|
+
* the subscription renews, and for a replacement: that is the linked purchase taking over, not a
|
|
28
|
+
* cancellation to report.
|
|
29
|
+
*/
|
|
30
|
+
function mapCancellationDetails(context) {
|
|
31
|
+
if (!context) return null;
|
|
32
|
+
if (context.userInitiatedCancellation) {
|
|
33
|
+
const survey = context.userInitiatedCancellation.cancelSurveyResult;
|
|
34
|
+
return {
|
|
35
|
+
initiator: "user",
|
|
36
|
+
reason: survey?.reason ?? null,
|
|
37
|
+
feedback: survey?.reason && SURVEY_FEEDBACK[survey.reason] || null,
|
|
38
|
+
comment: survey?.reasonUserInput ?? null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (context.systemInitiatedCancellation) return {
|
|
42
|
+
initiator: "system",
|
|
43
|
+
reason: "SYSTEM_INITIATED",
|
|
44
|
+
feedback: null,
|
|
45
|
+
comment: null
|
|
46
|
+
};
|
|
47
|
+
if (context.developerInitiatedCancellation) return {
|
|
48
|
+
initiator: "developer",
|
|
49
|
+
reason: "DEVELOPER_INITIATED",
|
|
50
|
+
feedback: null,
|
|
51
|
+
comment: null
|
|
52
|
+
};
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* When the subscription was cancelled. Only a user cancellation carries the time; for the others
|
|
57
|
+
* the caller falls back to when it learnt of it.
|
|
58
|
+
*/
|
|
59
|
+
function mapCanceledAt(context) {
|
|
60
|
+
return context?.userInitiatedCancellation?.cancelTime ?? null;
|
|
61
|
+
}
|
|
16
62
|
//#endregion
|
|
63
|
+
exports.mapCanceledAt = mapCanceledAt;
|
|
64
|
+
exports.mapCancellationDetails = mapCancellationDetails;
|
|
17
65
|
exports.mapSubscriptionStatus = mapSubscriptionStatus;
|
|
18
66
|
|
|
19
67
|
//# sourceMappingURL=mapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.cjs","names":[],"sources":["../../src/google-play/mapper.ts"],"sourcesContent":["import type { SubscriptionStatus } from '../subscription/index';\nimport type { GooglePlaySubscriptionState } from './real-time-developer-notification';\n\nexport function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus {\n switch (state) {\n case 'SUBSCRIPTION_STATE_PENDING':\n return 'PENDING';\n case 'SUBSCRIPTION_STATE_ACTIVE':\n return 'ACTIVE';\n case 'SUBSCRIPTION_STATE_PAUSED':\n return 'PAUSED';\n case 'SUBSCRIPTION_STATE_IN_GRACE_PERIOD':\n return 'IN_GRACE_PERIOD';\n case 'SUBSCRIPTION_STATE_ON_HOLD':\n return 'ON_HOLD';\n case 'SUBSCRIPTION_STATE_CANCELED':\n return 'CANCELED';\n case 'SUBSCRIPTION_STATE_EXPIRED':\n return 'EXPIRED';\n case 'SUBSCRIPTION_STATE_PENDING_PURCHASE_CANCELED':\n return 'PENDING_PURCHASE_CANCELED';\n default:\n throw new Error(`Unknown Google Play subscription state: ${state}`);\n }\n}\n"],"mappings":";;AAGA,SAAgB,sBAAsB,OAAwD;CAC5F,QAAQ,OAAR;EACE,KAAK,8BACH,OAAO;EACT,KAAK,6BACH,OAAO;EACT,KAAK,6BACH,OAAO;EACT,KAAK,sCACH,OAAO;EACT,KAAK,8BACH,OAAO;EACT,KAAK,+BACH,OAAO;EACT,KAAK,8BACH,OAAO;EACT,KAAK,gDACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,2CAA2C,OAAO;CACtE;AACF"}
|
|
1
|
+
{"version":3,"file":"mapper.cjs","names":[],"sources":["../../src/google-play/mapper.ts"],"sourcesContent":["import type { CancellationDetails, SubscriptionStatus } from '../subscription/index';\nimport type { GooglePlaySubscriptionState } from './real-time-developer-notification';\n\nexport function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus {\n switch (state) {\n case 'SUBSCRIPTION_STATE_PENDING':\n return 'PENDING';\n case 'SUBSCRIPTION_STATE_ACTIVE':\n return 'ACTIVE';\n case 'SUBSCRIPTION_STATE_PAUSED':\n return 'PAUSED';\n case 'SUBSCRIPTION_STATE_IN_GRACE_PERIOD':\n return 'IN_GRACE_PERIOD';\n case 'SUBSCRIPTION_STATE_ON_HOLD':\n return 'ON_HOLD';\n case 'SUBSCRIPTION_STATE_CANCELED':\n return 'CANCELED';\n case 'SUBSCRIPTION_STATE_EXPIRED':\n return 'EXPIRED';\n case 'SUBSCRIPTION_STATE_PENDING_PURCHASE_CANCELED':\n return 'PENDING_PURCHASE_CANCELED';\n default:\n throw new Error(`Unknown Google Play subscription state: ${state}`);\n }\n}\n\n/** Play's cancel-survey answers in the shared vocabulary. */\nconst SURVEY_FEEDBACK: Record<string, CancellationDetails['feedback']> = {\n CANCEL_SURVEY_REASON_NOT_ENOUGH_USAGE: 'unused',\n CANCEL_SURVEY_REASON_TECHNICAL_ISSUES: 'low_quality',\n CANCEL_SURVEY_REASON_COST_RELATED: 'too_expensive',\n CANCEL_SURVEY_REASON_FOUND_BETTER_APP: 'switched_service',\n CANCEL_SURVEY_REASON_OTHERS: 'other',\n};\n\n/**\n * `canceledStateContext` of `purchases.subscriptionsv2.get`, declared structurally so this\n * module does not depend on the Play Developer API client.\n */\nexport interface CanceledStateContext {\n userInitiatedCancellation?: {\n cancelTime?: string | null;\n cancelSurveyResult?: { reason?: string | null; reasonUserInput?: string | null } | null;\n } | null;\n systemInitiatedCancellation?: object | null;\n developerInitiatedCancellation?: object | null;\n replacementCancellation?: object | null;\n}\n\n/**\n * Why a Play subscription stopped renewing. The Play Store asks the user for a reason on cancel\n * (and for free text when it is \"Other\"), which comes back in `cancelSurveyResult`. Null while\n * the subscription renews, and for a replacement: that is the linked purchase taking over, not a\n * cancellation to report.\n */\nexport function mapCancellationDetails(\n context: CanceledStateContext | null | undefined\n): CancellationDetails | null {\n if (!context) return null;\n if (context.userInitiatedCancellation) {\n const survey = context.userInitiatedCancellation.cancelSurveyResult;\n return {\n initiator: 'user',\n reason: survey?.reason ?? null,\n feedback: (survey?.reason && SURVEY_FEEDBACK[survey.reason]) || null,\n comment: survey?.reasonUserInput ?? null,\n };\n }\n if (context.systemInitiatedCancellation) {\n return { initiator: 'system', reason: 'SYSTEM_INITIATED', feedback: null, comment: null };\n }\n if (context.developerInitiatedCancellation) {\n return { initiator: 'developer', reason: 'DEVELOPER_INITIATED', feedback: null, comment: null };\n }\n return null;\n}\n\n/**\n * When the subscription was cancelled. Only a user cancellation carries the time; for the others\n * the caller falls back to when it learnt of it.\n */\nexport function mapCanceledAt(context: CanceledStateContext | null | undefined): string | null {\n return context?.userInitiatedCancellation?.cancelTime ?? null;\n}\n"],"mappings":";;AAGA,SAAgB,sBAAsB,OAAwD;CAC5F,QAAQ,OAAR;EACE,KAAK,8BACH,OAAO;EACT,KAAK,6BACH,OAAO;EACT,KAAK,6BACH,OAAO;EACT,KAAK,sCACH,OAAO;EACT,KAAK,8BACH,OAAO;EACT,KAAK,+BACH,OAAO;EACT,KAAK,8BACH,OAAO;EACT,KAAK,gDACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,2CAA2C,OAAO;CACtE;AACF;;AAGA,MAAM,kBAAmE;CACvE,uCAAuC;CACvC,uCAAuC;CACvC,mCAAmC;CACnC,uCAAuC;CACvC,6BAA6B;AAC/B;;;;;;;AAsBA,SAAgB,uBACd,SAC4B;CAC5B,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,QAAQ,2BAA2B;EACrC,MAAM,SAAS,QAAQ,0BAA0B;EACjD,OAAO;GACL,WAAW;GACX,QAAQ,QAAQ,UAAU;GAC1B,UAAW,QAAQ,UAAU,gBAAgB,OAAO,WAAY;GAChE,SAAS,QAAQ,mBAAmB;EACtC;CACF;CACA,IAAI,QAAQ,6BACV,OAAO;EAAE,WAAW;EAAU,QAAQ;EAAoB,UAAU;EAAM,SAAS;CAAK;CAE1F,IAAI,QAAQ,gCACV,OAAO;EAAE,WAAW;EAAa,QAAQ;EAAuB,UAAU;EAAM,SAAS;CAAK;CAEhG,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,SAAiE;CAC7F,OAAO,SAAS,2BAA2B,cAAc;AAC3D"}
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
+
import { CancellationDetails, SubscriptionStatus } from "../subscription/index.cjs";
|
|
1
2
|
import { GooglePlaySubscriptionState } from "./real-time-developer-notification.cjs";
|
|
2
|
-
import { SubscriptionStatus } from "../subscription/index.cjs";
|
|
3
3
|
//#region src/google-play/mapper.d.ts
|
|
4
|
-
declare function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus;
|
|
4
|
+
export declare function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus;
|
|
5
|
+
/**
|
|
6
|
+
* `canceledStateContext` of `purchases.subscriptionsv2.get`, declared structurally so this
|
|
7
|
+
* module does not depend on the Play Developer API client.
|
|
8
|
+
*/
|
|
9
|
+
export interface CanceledStateContext {
|
|
10
|
+
userInitiatedCancellation?: {
|
|
11
|
+
cancelTime?: string | null;
|
|
12
|
+
cancelSurveyResult?: {
|
|
13
|
+
reason?: string | null;
|
|
14
|
+
reasonUserInput?: string | null;
|
|
15
|
+
} | null;
|
|
16
|
+
} | null;
|
|
17
|
+
systemInitiatedCancellation?: object | null;
|
|
18
|
+
developerInitiatedCancellation?: object | null;
|
|
19
|
+
replacementCancellation?: object | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Why a Play subscription stopped renewing. The Play Store asks the user for a reason on cancel
|
|
23
|
+
* (and for free text when it is "Other"), which comes back in `cancelSurveyResult`. Null while
|
|
24
|
+
* the subscription renews, and for a replacement: that is the linked purchase taking over, not a
|
|
25
|
+
* cancellation to report.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mapCancellationDetails(context: CanceledStateContext | null | undefined): CancellationDetails | null;
|
|
28
|
+
/**
|
|
29
|
+
* When the subscription was cancelled. Only a user cancellation carries the time; for the others
|
|
30
|
+
* the caller falls back to when it learnt of it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mapCanceledAt(context: CanceledStateContext | null | undefined): string | null;
|
|
5
33
|
//#endregion
|
|
6
|
-
export { mapSubscriptionStatus };
|
|
7
34
|
//# sourceMappingURL=mapper.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.cts","names":[],"sources":["../../src/google-play/mapper.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mapper.d.cts","names":[],"sources":["../../src/google-play/mapper.ts"],"mappings":";;;wBAGgB,sBAAsB,OAAO,8BAA8B;;;;;iBAoC1D;EACf;IACE;IACA;MAAuB;MAAwB;;;EAEjD;EACA;EACA;;;;;;;;wBASc,uBACd,SAAS,0CACR;;;;;wBAwBa,cAAc,SAAS"}
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
+
import { CancellationDetails, SubscriptionStatus } from "../subscription/index.mjs";
|
|
1
2
|
import { GooglePlaySubscriptionState } from "./real-time-developer-notification.mjs";
|
|
2
|
-
import { SubscriptionStatus } from "../subscription/index.mjs";
|
|
3
3
|
//#region src/google-play/mapper.d.ts
|
|
4
|
-
declare function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus;
|
|
4
|
+
export declare function mapSubscriptionStatus(state: GooglePlaySubscriptionState): SubscriptionStatus;
|
|
5
|
+
/**
|
|
6
|
+
* `canceledStateContext` of `purchases.subscriptionsv2.get`, declared structurally so this
|
|
7
|
+
* module does not depend on the Play Developer API client.
|
|
8
|
+
*/
|
|
9
|
+
export interface CanceledStateContext {
|
|
10
|
+
userInitiatedCancellation?: {
|
|
11
|
+
cancelTime?: string | null;
|
|
12
|
+
cancelSurveyResult?: {
|
|
13
|
+
reason?: string | null;
|
|
14
|
+
reasonUserInput?: string | null;
|
|
15
|
+
} | null;
|
|
16
|
+
} | null;
|
|
17
|
+
systemInitiatedCancellation?: object | null;
|
|
18
|
+
developerInitiatedCancellation?: object | null;
|
|
19
|
+
replacementCancellation?: object | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Why a Play subscription stopped renewing. The Play Store asks the user for a reason on cancel
|
|
23
|
+
* (and for free text when it is "Other"), which comes back in `cancelSurveyResult`. Null while
|
|
24
|
+
* the subscription renews, and for a replacement: that is the linked purchase taking over, not a
|
|
25
|
+
* cancellation to report.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mapCancellationDetails(context: CanceledStateContext | null | undefined): CancellationDetails | null;
|
|
28
|
+
/**
|
|
29
|
+
* When the subscription was cancelled. Only a user cancellation carries the time; for the others
|
|
30
|
+
* the caller falls back to when it learnt of it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mapCanceledAt(context: CanceledStateContext | null | undefined): string | null;
|
|
5
33
|
//#endregion
|
|
6
|
-
export { mapSubscriptionStatus };
|
|
7
34
|
//# sourceMappingURL=mapper.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.mts","names":[],"sources":["../../src/google-play/mapper.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mapper.d.mts","names":[],"sources":["../../src/google-play/mapper.ts"],"mappings":";;;wBAGgB,sBAAsB,OAAO,8BAA8B;;;;;iBAoC1D;EACf;IACE;IACA;MAAuB;MAAwB;;;EAEjD;EACA;EACA;;;;;;;;wBASc,uBACd,SAAS,0CACR;;;;;wBAwBa,cAAc,SAAS"}
|
|
@@ -12,7 +12,53 @@ function mapSubscriptionStatus(state) {
|
|
|
12
12
|
default: throw new Error(`Unknown Google Play subscription state: ${state}`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
/** Play's cancel-survey answers in the shared vocabulary. */
|
|
16
|
+
const SURVEY_FEEDBACK = {
|
|
17
|
+
CANCEL_SURVEY_REASON_NOT_ENOUGH_USAGE: "unused",
|
|
18
|
+
CANCEL_SURVEY_REASON_TECHNICAL_ISSUES: "low_quality",
|
|
19
|
+
CANCEL_SURVEY_REASON_COST_RELATED: "too_expensive",
|
|
20
|
+
CANCEL_SURVEY_REASON_FOUND_BETTER_APP: "switched_service",
|
|
21
|
+
CANCEL_SURVEY_REASON_OTHERS: "other"
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Why a Play subscription stopped renewing. The Play Store asks the user for a reason on cancel
|
|
25
|
+
* (and for free text when it is "Other"), which comes back in `cancelSurveyResult`. Null while
|
|
26
|
+
* the subscription renews, and for a replacement: that is the linked purchase taking over, not a
|
|
27
|
+
* cancellation to report.
|
|
28
|
+
*/
|
|
29
|
+
function mapCancellationDetails(context) {
|
|
30
|
+
if (!context) return null;
|
|
31
|
+
if (context.userInitiatedCancellation) {
|
|
32
|
+
const survey = context.userInitiatedCancellation.cancelSurveyResult;
|
|
33
|
+
return {
|
|
34
|
+
initiator: "user",
|
|
35
|
+
reason: survey?.reason ?? null,
|
|
36
|
+
feedback: survey?.reason && SURVEY_FEEDBACK[survey.reason] || null,
|
|
37
|
+
comment: survey?.reasonUserInput ?? null
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (context.systemInitiatedCancellation) return {
|
|
41
|
+
initiator: "system",
|
|
42
|
+
reason: "SYSTEM_INITIATED",
|
|
43
|
+
feedback: null,
|
|
44
|
+
comment: null
|
|
45
|
+
};
|
|
46
|
+
if (context.developerInitiatedCancellation) return {
|
|
47
|
+
initiator: "developer",
|
|
48
|
+
reason: "DEVELOPER_INITIATED",
|
|
49
|
+
feedback: null,
|
|
50
|
+
comment: null
|
|
51
|
+
};
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* When the subscription was cancelled. Only a user cancellation carries the time; for the others
|
|
56
|
+
* the caller falls back to when it learnt of it.
|
|
57
|
+
*/
|
|
58
|
+
function mapCanceledAt(context) {
|
|
59
|
+
return context?.userInitiatedCancellation?.cancelTime ?? null;
|
|
60
|
+
}
|
|
15
61
|
//#endregion
|
|
16
|
-
export { mapSubscriptionStatus };
|
|
62
|
+
export { mapCanceledAt, mapCancellationDetails, mapSubscriptionStatus };
|
|
17
63
|
|
|
18
64
|
//# sourceMappingURL=mapper.mjs.map
|