@tellescope/sdk 1.256.2 → 1.256.4
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/lib/cjs/tests/api_tests/metriport_push_form_response.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/metriport_push_form_response.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/metriport_push_form_response.test.js +298 -0
- package/lib/cjs/tests/api_tests/metriport_push_form_response.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/phone_calls_move_enduser.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/phone_calls_move_enduser.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/phone_calls_move_enduser.test.js +274 -0
- package/lib/cjs/tests/api_tests/phone_calls_move_enduser.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.d.ts +18 -0
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.js +964 -0
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/welle_partner_token.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/welle_partner_token.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/welle_partner_token.test.js +313 -0
- package/lib/cjs/tests/api_tests/welle_partner_token.test.js.map +1 -0
- package/lib/cjs/tests/stripe_webhook_helpers.d.ts +204 -0
- package/lib/cjs/tests/stripe_webhook_helpers.d.ts.map +1 -0
- package/lib/cjs/tests/stripe_webhook_helpers.js +286 -0
- package/lib/cjs/tests/stripe_webhook_helpers.js.map +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +192 -180
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/cjs/tests/unit_tests/translation.test.d.ts +3 -0
- package/lib/cjs/tests/unit_tests/translation.test.d.ts.map +1 -0
- package/lib/cjs/tests/unit_tests/translation.test.js.map +1 -0
- package/lib/esm/enduser.d.ts +1 -0
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/sdk.d.ts +3 -2
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/session.d.ts +1 -0
- package/lib/esm/session.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/metriport_push_form_response.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/metriport_push_form_response.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/metriport_push_form_response.test.js +294 -0
- package/lib/esm/tests/api_tests/metriport_push_form_response.test.js.map +1 -0
- package/lib/esm/tests/api_tests/phone_calls_move_enduser.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/phone_calls_move_enduser.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/phone_calls_move_enduser.test.js +270 -0
- package/lib/esm/tests/api_tests/phone_calls_move_enduser.test.js.map +1 -0
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.d.ts +18 -0
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.js +960 -0
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.js.map +1 -0
- package/lib/esm/tests/api_tests/welle_partner_token.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/welle_partner_token.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/welle_partner_token.test.js +309 -0
- package/lib/esm/tests/api_tests/welle_partner_token.test.js.map +1 -0
- package/lib/esm/tests/stripe_webhook_helpers.d.ts +204 -0
- package/lib/esm/tests/stripe_webhook_helpers.d.ts.map +1 -0
- package/lib/esm/tests/stripe_webhook_helpers.js +267 -0
- package/lib/esm/tests/stripe_webhook_helpers.js.map +1 -0
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +192 -180
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/esm/tests/unit_tests/translation.test.d.ts +3 -0
- package/lib/esm/tests/unit_tests/translation.test.d.ts.map +1 -0
- package/lib/esm/tests/unit_tests/translation.test.js +52 -0
- package/lib/esm/tests/unit_tests/translation.test.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/tests/api_tests/metriport_push_form_response.test.ts +226 -0
- package/src/tests/api_tests/stripe_webhook_triggers.test.ts +676 -0
- package/src/tests/api_tests/welle_partner_token.test.ts +249 -0
- package/src/tests/stripe_webhook_helpers.ts +240 -0
- package/src/tests/tests.ts +6 -0
- package/test_generated.pdf +0 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.subscription_resumed_event = exports.subscription_paused_event = exports.subscription_updated_event = exports.PAUSE_COLLECTION = exports.item_with_plan_product = exports.item_with_expanded_price_product = exports.item_with_price_product = exports.subscription_deleted_event = exports.invoice_payment_failed_event = exports.line_with_plan_product = exports.line_with_expanded_price_product = exports.line_with_price_product = exports.cleanup_stripe_test_integrations = exports.setup_stripe_test_integration = exports.post_stripe_webhook = exports.sign_stripe_payload = exports.TEST_STRIPE_ENVIRONMENT = void 0;
|
|
43
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
44
|
+
var host = process.env.API_URL || 'http://localhost:8080';
|
|
45
|
+
// Marks the throwaway integrations created by tests so a run can clear residue left by an earlier
|
|
46
|
+
// run that exited early. The test harness calls process.exit(1) on the first failed assertion, which
|
|
47
|
+
// skips finally blocks, so cleanup cannot be relied on.
|
|
48
|
+
exports.TEST_STRIPE_ENVIRONMENT = 'tellescope-test-stripe-webhooks';
|
|
49
|
+
// title must be exactly STRIPE_TITLE for the webhook handler to find the integration
|
|
50
|
+
var STRIPE_TITLE = 'Stripe';
|
|
51
|
+
var uniqueCounter = 0;
|
|
52
|
+
var unique_suffix = function () { return "".concat(Date.now(), "_").concat(uniqueCounter++); };
|
|
53
|
+
/**
|
|
54
|
+
* Stripe signs `${timestamp}.${rawBody}` with HMAC-SHA256 and sends it hex-encoded in a
|
|
55
|
+
* `t=<unixSeconds>,v1=<hex>` header. Reproducing it here lets tests exercise the real webhook
|
|
56
|
+
* route — signature verification included — without Stripe or network access.
|
|
57
|
+
*
|
|
58
|
+
* The default timestamp is always in tolerance (Stripe allows 300s and only rejects old ones);
|
|
59
|
+
* pass an old timestamp explicitly to test rejection.
|
|
60
|
+
*/
|
|
61
|
+
var sign_stripe_payload = function (rawBody, secret, timestamp) {
|
|
62
|
+
if (timestamp === void 0) { timestamp = Math.floor(Date.now() / 1000); }
|
|
63
|
+
return ("t=".concat(timestamp, ",v1=").concat(crypto_1.default.createHmac('sha256', secret).update("".concat(timestamp, ".").concat(rawBody), 'utf8').digest('hex')));
|
|
64
|
+
};
|
|
65
|
+
exports.sign_stripe_payload = sign_stripe_payload;
|
|
66
|
+
/**
|
|
67
|
+
* POSTs an event to the custom Stripe webhook route.
|
|
68
|
+
*
|
|
69
|
+
* Serializes the body here and signs those exact bytes, because the route uses
|
|
70
|
+
* express.raw and the signature covers the raw body verbatim — handing a pre-serialized
|
|
71
|
+
* string to fetch is what keeps the two in sync.
|
|
72
|
+
*
|
|
73
|
+
* Pass `signature` to override the computed one (for rejection tests).
|
|
74
|
+
*/
|
|
75
|
+
var post_stripe_webhook = function (_a) {
|
|
76
|
+
var stripePublicKey = _a.stripePublicKey, event = _a.event, secret = _a.secret, signature = _a.signature;
|
|
77
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var rawBody, res;
|
|
79
|
+
var _b;
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
switch (_c.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
rawBody = JSON.stringify(event);
|
|
84
|
+
return [4 /*yield*/, fetch("".concat(host, "/v1/webhooks/stripe/custom/").concat(stripePublicKey), {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
headers: {
|
|
87
|
+
// express.raw({ type: 'application/json' }) leaves req.body unset without this
|
|
88
|
+
'Content-Type': 'application/json',
|
|
89
|
+
'stripe-signature': signature !== null && signature !== void 0 ? signature : (0, exports.sign_stripe_payload)(rawBody, secret),
|
|
90
|
+
},
|
|
91
|
+
body: rawBody,
|
|
92
|
+
})];
|
|
93
|
+
case 1:
|
|
94
|
+
res = _c.sent();
|
|
95
|
+
_b = { status: res.status };
|
|
96
|
+
return [4 /*yield*/, res.text()];
|
|
97
|
+
case 2: return [2 /*return*/, (_b.data = _c.sent(), _b)];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
exports.post_stripe_webhook = post_stripe_webhook;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a throwaway custom Stripe integration and returns the values needed to sign webhooks for
|
|
105
|
+
* it, plus a cleanup function to call in a finally block.
|
|
106
|
+
*
|
|
107
|
+
* The access token is never used: neither invoice.payment_failed nor customer.subscription.deleted
|
|
108
|
+
* calls the Stripe API, and constructing a Stripe client doesn't validate the key or hit the network.
|
|
109
|
+
*/
|
|
110
|
+
var setup_stripe_test_integration = function (sdk) { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var stripePublicKey, webhooksSecret, integration;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
stripePublicKey = "pk_test_tellescope_".concat(unique_suffix());
|
|
116
|
+
webhooksSecret = "whsec_test_".concat(crypto_1.default.randomBytes(16).toString('hex'));
|
|
117
|
+
return [4 /*yield*/, (0, exports.cleanup_stripe_test_integrations)(sdk)];
|
|
118
|
+
case 1:
|
|
119
|
+
_a.sent();
|
|
120
|
+
return [4 /*yield*/, sdk.api.integrations.createOne({
|
|
121
|
+
title: STRIPE_TITLE,
|
|
122
|
+
environment: exports.TEST_STRIPE_ENVIRONMENT,
|
|
123
|
+
authentication: {
|
|
124
|
+
type: 'apiKey',
|
|
125
|
+
info: {
|
|
126
|
+
// all of these are required by integrationAuthenticationsValidator, and only
|
|
127
|
+
// external_id (the public key in the webhook URL) is actually read by the handler
|
|
128
|
+
access_token: 'sk_test_unused_by_this_path',
|
|
129
|
+
refresh_token: 'unused',
|
|
130
|
+
scope: '',
|
|
131
|
+
expiry_date: Date.now(),
|
|
132
|
+
token_type: 'Bearer',
|
|
133
|
+
external_id: stripePublicKey,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
// never readable afterwards (redactions: ['all']), so the caller must keep the returned value
|
|
137
|
+
webhooksSecret: webhooksSecret,
|
|
138
|
+
})];
|
|
139
|
+
case 2:
|
|
140
|
+
integration = _a.sent();
|
|
141
|
+
return [2 /*return*/, {
|
|
142
|
+
stripePublicKey: stripePublicKey,
|
|
143
|
+
webhooksSecret: webhooksSecret,
|
|
144
|
+
integrationId: integration.id,
|
|
145
|
+
cleanup: function () { return sdk.api.integrations.deleteOne(integration.id); },
|
|
146
|
+
}];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); };
|
|
150
|
+
exports.setup_stripe_test_integration = setup_stripe_test_integration;
|
|
151
|
+
/** Deletes any test Stripe integrations left behind by a run that exited before its cleanup. */
|
|
152
|
+
var cleanup_stripe_test_integrations = function (sdk) { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
|
+
var existing;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0: return [4 /*yield*/, sdk.api.integrations.getSome({ filter: { title: STRIPE_TITLE } })
|
|
157
|
+
.catch(function () { return []; })];
|
|
158
|
+
case 1:
|
|
159
|
+
existing = _a.sent();
|
|
160
|
+
return [4 /*yield*/, Promise.all(existing
|
|
161
|
+
.filter(function (i) { return i.environment === exports.TEST_STRIPE_ENVIRONMENT; })
|
|
162
|
+
.map(function (i) { return sdk.api.integrations.deleteOne(i.id).catch(console.error); }))];
|
|
163
|
+
case 2:
|
|
164
|
+
_a.sent();
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}); };
|
|
169
|
+
exports.cleanup_stripe_test_integrations = cleanup_stripe_test_integrations;
|
|
170
|
+
/* ------------------------------- event fixtures ------------------------------- */
|
|
171
|
+
// An invoice line item references its product through price.product on every modern line item, and
|
|
172
|
+
// through plan.product only on subscription/proration lines. Either may be a bare id or an expanded
|
|
173
|
+
// object, so each shape gets a builder.
|
|
174
|
+
var line_with_price_product = function (stripeProductId) { return ({
|
|
175
|
+
price: { product: stripeProductId },
|
|
176
|
+
}); };
|
|
177
|
+
exports.line_with_price_product = line_with_price_product;
|
|
178
|
+
var line_with_expanded_price_product = function (stripeProductId) { return ({
|
|
179
|
+
price: { product: { id: stripeProductId, object: 'product' } },
|
|
180
|
+
}); };
|
|
181
|
+
exports.line_with_expanded_price_product = line_with_expanded_price_product;
|
|
182
|
+
var line_with_plan_product = function (stripeProductId) { return ({
|
|
183
|
+
price: null,
|
|
184
|
+
plan: { product: stripeProductId },
|
|
185
|
+
}); };
|
|
186
|
+
exports.line_with_plan_product = line_with_plan_product;
|
|
187
|
+
/**
|
|
188
|
+
* Minimal invoice.payment_failed envelope. constructEvent only requires valid JSON — it does not
|
|
189
|
+
* validate id/object/api_version — so this carries just the fields the handler reads.
|
|
190
|
+
*/
|
|
191
|
+
var invoice_payment_failed_event = function (_a) {
|
|
192
|
+
var stripeCustomerId = _a.stripeCustomerId, _b = _a.lines, lines = _b === void 0 ? [] : _b, _c = _a.has_more, has_more = _c === void 0 ? false : _c;
|
|
193
|
+
return ({
|
|
194
|
+
type: 'invoice.payment_failed',
|
|
195
|
+
data: {
|
|
196
|
+
object: {
|
|
197
|
+
id: "in_test_".concat(unique_suffix()),
|
|
198
|
+
customer: stripeCustomerId,
|
|
199
|
+
lines: { object: 'list', data: lines, has_more: has_more },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
exports.invoice_payment_failed_event = invoice_payment_failed_event;
|
|
205
|
+
/** Minimal customer.subscription.deleted envelope; the handler reads items.data[].plan.product. */
|
|
206
|
+
var subscription_deleted_event = function (_a) {
|
|
207
|
+
var stripeCustomerId = _a.stripeCustomerId, _b = _a.stripeProductIds, stripeProductIds = _b === void 0 ? [] : _b;
|
|
208
|
+
return ({
|
|
209
|
+
type: 'customer.subscription.deleted',
|
|
210
|
+
data: {
|
|
211
|
+
object: {
|
|
212
|
+
id: "sub_test_".concat(unique_suffix()),
|
|
213
|
+
customer: stripeCustomerId,
|
|
214
|
+
items: {
|
|
215
|
+
object: 'list',
|
|
216
|
+
data: stripeProductIds.map(function (product) { return ({ plan: { product: product } }); }),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
exports.subscription_deleted_event = subscription_deleted_event;
|
|
223
|
+
/**
|
|
224
|
+
* A subscription item references its product through price.product on every modern item, and through
|
|
225
|
+
* plan.product on legacy ones. Either may be a bare id or an expanded object.
|
|
226
|
+
*/
|
|
227
|
+
var item_with_price_product = function (stripeProductId) { return ({
|
|
228
|
+
price: { product: stripeProductId },
|
|
229
|
+
}); };
|
|
230
|
+
exports.item_with_price_product = item_with_price_product;
|
|
231
|
+
var item_with_expanded_price_product = function (stripeProductId) { return ({
|
|
232
|
+
price: { product: { id: stripeProductId, object: 'product' } },
|
|
233
|
+
}); };
|
|
234
|
+
exports.item_with_expanded_price_product = item_with_expanded_price_product;
|
|
235
|
+
var item_with_plan_product = function (stripeProductId) { return ({
|
|
236
|
+
price: null,
|
|
237
|
+
plan: { product: stripeProductId },
|
|
238
|
+
}); };
|
|
239
|
+
exports.item_with_plan_product = item_with_plan_product;
|
|
240
|
+
/** A pause_collection value, as Stripe carries it on a paused-collection subscription. */
|
|
241
|
+
exports.PAUSE_COLLECTION = { behavior: 'void', resumes_at: null };
|
|
242
|
+
/**
|
|
243
|
+
* customer.subscription.updated envelope. `previousAttributes` is the whole previous_attributes bag,
|
|
244
|
+
* so a case can express "pause_collection key absent" (pass {}) distinctly from
|
|
245
|
+
* "pause_collection was null" (pass { pause_collection: null }) — that distinction is the entire
|
|
246
|
+
* gate the handler uses to avoid running on every renewal.
|
|
247
|
+
*/
|
|
248
|
+
var subscription_updated_event = function (_a) {
|
|
249
|
+
var stripeCustomerId = _a.stripeCustomerId, _b = _a.items, items = _b === void 0 ? [] : _b, _c = _a.previousAttributes, previousAttributes = _c === void 0 ? {} : _c, _d = _a.pauseCollection, pauseCollection = _d === void 0 ? null : _d, _e = _a.status, status = _e === void 0 ? 'active' : _e;
|
|
250
|
+
return ({
|
|
251
|
+
type: 'customer.subscription.updated',
|
|
252
|
+
data: {
|
|
253
|
+
object: {
|
|
254
|
+
id: "sub_test_".concat(unique_suffix()),
|
|
255
|
+
customer: stripeCustomerId,
|
|
256
|
+
status: status,
|
|
257
|
+
pause_collection: pauseCollection,
|
|
258
|
+
items: { object: 'list', data: items, has_more: false },
|
|
259
|
+
},
|
|
260
|
+
previous_attributes: previousAttributes,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
exports.subscription_updated_event = subscription_updated_event;
|
|
265
|
+
/**
|
|
266
|
+
* The dedicated customer.subscription.paused / .resumed events, which Stripe emits only for
|
|
267
|
+
* status='paused' transitions. The handler fires unconditionally on these, so no previous_attributes.
|
|
268
|
+
*/
|
|
269
|
+
var subscription_pause_event = function (type) { return function (_a) {
|
|
270
|
+
var stripeCustomerId = _a.stripeCustomerId, _b = _a.items, items = _b === void 0 ? [] : _b, status = _a.status;
|
|
271
|
+
return ({
|
|
272
|
+
type: type,
|
|
273
|
+
data: {
|
|
274
|
+
object: {
|
|
275
|
+
id: "sub_test_".concat(unique_suffix()),
|
|
276
|
+
customer: stripeCustomerId,
|
|
277
|
+
status: status !== null && status !== void 0 ? status : (type === 'customer.subscription.paused' ? 'paused' : 'active'),
|
|
278
|
+
pause_collection: null,
|
|
279
|
+
items: { object: 'list', data: items, has_more: false },
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
}; };
|
|
284
|
+
exports.subscription_paused_event = subscription_pause_event('customer.subscription.paused');
|
|
285
|
+
exports.subscription_resumed_event = subscription_pause_event('customer.subscription.resumed');
|
|
286
|
+
//# sourceMappingURL=stripe_webhook_helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe_webhook_helpers.js","sourceRoot":"","sources":["../../../src/tests/stripe_webhook_helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA2B;AAI3B,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,uBAAuB,CAAA;AAE3D,kGAAkG;AAClG,qGAAqG;AACrG,wDAAwD;AAC3C,QAAA,uBAAuB,GAAG,iCAAiC,CAAA;AAExE,qFAAqF;AACrF,IAAM,YAAY,GAAG,QAAQ,CAAA;AAE7B,IAAI,aAAa,GAAG,CAAC,CAAA;AACrB,IAAM,aAAa,GAAG,cAAM,OAAA,UAAG,IAAI,CAAC,GAAG,EAAE,cAAI,aAAa,EAAE,C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AAgB;gBAC1B,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,IAAI,KAAK,8BAA8B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;gBACjF,gBAAgB,EAAE,IAAI;gBACtB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;aACxD;SACF;KACF,CAAC;AAXI,CAWJ,EAfiD,CAejD,CAAA;AAEW,QAAA,yBAAyB,GAAG,wBAAwB,CAAC,8BAA8B,CAAC,CAAA;AACpF,QAAA,0BAA0B,GAAG,wBAAwB,CAAC,+BAA+B,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"AAi2EA,eAAO,MAAM,kCAAkC,qBAgJ9C,CAAA;AAED,eAAO,MAAM,mCAAmC,qBA2K/C,CAAA;AAGD,eAAO,MAAM,oBAAoB,qBAoHhC,CAAA;AAED,eAAO,MAAM,+BAA+B,qBAsF3C,CAAA;AAID,eAAO,MAAM,0BAA0B,qBAqCtC,CAAA;AAu1FD,eAAO,MAAM,cAAc,qBAqC1B,CAAA;AAotBD,eAAO,MAAM,0BAA0B,qBAmFtC,CAAA;AAqED,eAAO,MAAM,eAAe,qBAmD3B,CAAA;AAED,eAAO,MAAM,oBAAoB,6BAsBhC,CAAA;AAED,eAAO,MAAM,oCAAoC,qBA4pBhD,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAkE/C,CAAA;AAqlDD,eAAO,MAAM,yBAAyB,qBA0DrC,CAAA;AAED,eAAO,MAAM,kBAAkB,qBAmK9B,CAAA;AAED,eAAO,MAAM,sBAAsB,qBA0BlC,CAAA;AAGD,eAAO,MAAM,mBAAmB,qBAmC/B,CAAA;AAED,eAAO,MAAM,gCAAgC,mCA8C5C,CAAA;AAED,eAAO,MAAM,cAAc,qBA+b1B,CAAA;AAGD,eAAO,MAAM,oBAAoB,uBAuBhC,CAAA;AA4wBD,eAAO,MAAM,4BAA4B,qBAoExC,CAAA;AAED,eAAO,MAAM,+BAA+B,qBA4U3C,CAAA;AAED,eAAO,MAAM,gDAAgD,qBAwC5D,CAAA;AAED,eAAO,MAAM,qBAAqB,qBAwIjC,CAAA"}
|