backend-manager 5.9.7 → 5.9.9
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/package.json +5 -3
- package/src/cli/commands/setup-tests/bem-config.js +3 -2
- package/src/cli/commands/setup-tests/helpers.js +5 -0
- package/src/cli/commands/setup-tests/project-id-consistency.js +2 -1
- package/src/test/fixtures/firebase-project/.temp/test-mode.json +1 -1
- package/src/test/fixtures/firebase-project/database-debug.log +8 -8
- package/src/test/fixtures/firebase-project/firestore-debug.log +57 -55
- package/src/test/fixtures/firebase-project/pubsub-debug.log +3 -3
- package/templates/_.env +42 -0
- package/templates/_.gitignore +60 -0
- package/templates/backend-manager-config.json +249 -0
- package/templates/database.rules.json +83 -0
- package/templates/firebase.json +66 -0
- package/templates/firestore.indexes.json +4 -0
- package/templates/firestore.rules +112 -0
- package/templates/public/404.html +26 -0
- package/templates/public/index.html +24 -0
- package/templates/remoteconfig.template.json +1 -0
- package/templates/storage-lifecycle-config-1-day.json +9 -0
- package/templates/storage-lifecycle-config-30-days.json +9 -0
- package/templates/storage.rules +8 -0
- package/test/_init/accounts-validation.js +58 -0
- package/test/_legacy/ai/index.js +231 -0
- package/test/_legacy/ai/test.jpg +0 -0
- package/test/_legacy/ai/test.pdf +0 -0
- package/test/_legacy/index.js +31 -0
- package/test/_legacy/payment-resolver/chargebee/orders/refunded.json +0 -0
- package/test/_legacy/payment-resolver/chargebee/orders/unpaid.json +98 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/active.json +578 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-in-trial.json +38 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-skipped-to-active.json +135 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active-to-cancelled.json +42 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active.json +44 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-cancelled.json +39 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-refund.json +143 -0
- package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-suspended.json +48 -0
- package/test/_legacy/payment-resolver/coinbase/orders/regular.json +204 -0
- package/test/_legacy/payment-resolver/coinbase/subscriptions/cancelled.json +204 -0
- package/test/_legacy/payment-resolver/coinbase/subscriptions/paid-2.json +125 -0
- package/test/_legacy/payment-resolver/index.js +1558 -0
- package/test/_legacy/payment-resolver/paypal/orders/refunded.json +0 -0
- package/test/_legacy/payment-resolver/paypal/orders/regular.json +120 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/active-refund-previous-stmnt.json +323 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/active.json +192 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-in-trial.json +125 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-not-complete.json +76 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue-2.json +114 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue.json +114 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active-to-cancelled.json +111 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active.json +132 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-cancelled.json +107 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-expired.json +91 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-refund.json +147 -0
- package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-suspended.json +120 -0
- package/test/_legacy/payment-resolver/stripe/orders/refunded.json +0 -0
- package/test/_legacy/payment-resolver/stripe/orders/regular.json +91 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/active.json +421 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-in-trial.json +349 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active-failed-authorization.json +430 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active.json +319 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-cancelled.json +319 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-refund.json +414 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-suspended.json +319 -0
- package/test/_legacy/payment-resolver/stripe/subscriptions/unsure.json +339 -0
- package/test/_legacy/test-new +1178 -0
- package/test/_legacy/test.md +89 -0
- package/test/_legacy/usage.js +175 -0
- package/test/_legacy/user.js +31 -0
- package/test/ai/tools-live.js +170 -0
- package/test/boot/emulator-boots.js +37 -0
- package/test/content/blog-generate.js +160 -0
- package/test/email/campaign-send.js +45 -0
- package/test/email/consent-lifecycle.js +257 -0
- package/test/email/feedback-and-plain-send.js +52 -0
- package/test/email/fixtures/clean.json +30 -0
- package/test/email/fixtures/editorial.json +30 -0
- package/test/email/fixtures/field-report.json +53 -0
- package/test/email/marketing-lifecycle.js +132 -0
- package/test/email/newsletter-generate.js +819 -0
- package/test/email/newsletter-templates.js +491 -0
- package/test/email/templates.js +207 -0
- package/test/email/transactional-send.js +34 -0
- package/test/email/transactional.js +560 -0
- package/test/email/validation.js +710 -0
- package/test/events/auth-delete-race.js +201 -0
- package/test/events/payments/journey-payments-cancel-endpoint.js +100 -0
- package/test/events/payments/journey-payments-cancel.js +182 -0
- package/test/events/payments/journey-payments-discount.js +89 -0
- package/test/events/payments/journey-payments-failure.js +146 -0
- package/test/events/payments/journey-payments-legacy-product.js +149 -0
- package/test/events/payments/journey-payments-one-time-failure.js +111 -0
- package/test/events/payments/journey-payments-one-time.js +136 -0
- package/test/events/payments/journey-payments-plan-change.js +144 -0
- package/test/events/payments/journey-payments-refund-webhook.js +180 -0
- package/test/events/payments/journey-payments-suspend.js +181 -0
- package/test/events/payments/journey-payments-trial-cancel.js +130 -0
- package/test/events/payments/journey-payments-trial.js +171 -0
- package/test/events/payments/journey-payments-uid-resolution.js +132 -0
- package/test/events/payments/journey-payments-upgrade.js +135 -0
- package/test/fixtures/chargebee/invoice-one-time.json +27 -0
- package/test/fixtures/chargebee/subscription-active.json +44 -0
- package/test/fixtures/chargebee/subscription-cancelled.json +42 -0
- package/test/fixtures/chargebee/subscription-in-trial.json +41 -0
- package/test/fixtures/chargebee/subscription-legacy-plan.json +41 -0
- package/test/fixtures/chargebee/subscription-non-renewing.json +41 -0
- package/test/fixtures/chargebee/subscription-paused.json +42 -0
- package/test/fixtures/chargebee/webhook-payment-failed.json +51 -0
- package/test/fixtures/chargebee/webhook-subscription-created.json +47 -0
- package/test/fixtures/paypal/order-approved.json +62 -0
- package/test/fixtures/paypal/order-completed.json +110 -0
- package/test/fixtures/paypal/subscription-active.json +76 -0
- package/test/fixtures/paypal/subscription-cancelled.json +50 -0
- package/test/fixtures/paypal/subscription-suspended.json +65 -0
- package/test/fixtures/stripe/checkout-session-completed.json +130 -0
- package/test/fixtures/stripe/invoice-payment-failed.json +148 -0
- package/test/fixtures/stripe/invoice-subscription-payment-failed.json +28 -0
- package/test/fixtures/stripe/subscription-active.json +161 -0
- package/test/fixtures/stripe/subscription-canceled.json +161 -0
- package/test/fixtures/stripe/subscription-trialing.json +161 -0
- package/test/functions/admin/database-read.js +134 -0
- package/test/functions/admin/database-write.js +159 -0
- package/test/functions/admin/edit-post.js +366 -0
- package/test/functions/admin/firestore-query.js +207 -0
- package/test/functions/admin/firestore-read.js +129 -0
- package/test/functions/admin/firestore-write.js +105 -0
- package/test/functions/admin/get-stats.js +115 -0
- package/test/functions/admin/send-email.js +119 -0
- package/test/functions/admin/send-notification.js +208 -0
- package/test/functions/admin/write-repo-content.js +223 -0
- package/test/functions/general/add-marketing-contact.js +335 -0
- package/test/functions/general/fetch-post.js +54 -0
- package/test/functions/general/generate-uuid.js +114 -0
- package/test/functions/test/authenticate.js +64 -0
- package/test/functions/user/create-custom-token.js +73 -0
- package/test/functions/user/delete.js +135 -0
- package/test/functions/user/get-active-sessions.js +111 -0
- package/test/functions/user/get-subscription-info.js +99 -0
- package/test/functions/user/regenerate-api-keys.js +156 -0
- package/test/functions/user/resolve.js +52 -0
- package/test/functions/user/sign-out-all-sessions.js +94 -0
- package/test/functions/user/sign-up.js +252 -0
- package/test/functions/user/submit-feedback.js +104 -0
- package/test/functions/user/validate-settings.js +82 -0
- package/test/helpers/ai-request-payload.js +300 -0
- package/test/helpers/ai-test-provider.js +202 -0
- package/test/helpers/ai-tools-format.js +383 -0
- package/test/helpers/content/blog-auto-publisher.js +484 -0
- package/test/helpers/content/feed-parser.js +528 -0
- package/test/helpers/content/ghostii-blocks.js +134 -0
- package/test/helpers/content/ghostii-feed-integration.js +404 -0
- package/test/helpers/content/ghostii-write-article.js +243 -0
- package/test/helpers/environment.js +230 -0
- package/test/helpers/infer-contact.js +113 -0
- package/test/helpers/merge-line-files.js +271 -0
- package/test/helpers/payment/chargebee/parse-webhook.js +413 -0
- package/test/helpers/payment/chargebee/to-unified-one-time.js +147 -0
- package/test/helpers/payment/chargebee/to-unified-subscription.js +648 -0
- package/test/helpers/payment/paypal/parse-webhook.js +539 -0
- package/test/helpers/payment/paypal/to-unified-one-time.js +382 -0
- package/test/helpers/payment/paypal/to-unified-subscription.js +820 -0
- package/test/helpers/payment/stripe/parse-webhook.js +447 -0
- package/test/helpers/payment/stripe/to-unified-one-time.js +306 -0
- package/test/helpers/payment/stripe/to-unified-subscription.js +708 -0
- package/test/helpers/sanitize.js +222 -0
- package/test/helpers/slugify.js +394 -0
- package/test/helpers/storage.js +194 -0
- package/test/helpers/user.js +755 -0
- package/test/helpers/webhook-forward.js +418 -0
- package/test/mcp/discovery.js +53 -0
- package/test/mcp/oauth.js +161 -0
- package/test/mcp/protocol.js +268 -0
- package/test/mcp/roles.js +188 -0
- package/test/mcp/utils.js +245 -0
- package/test/routes/admin/create-post.js +364 -0
- package/test/routes/admin/database.js +131 -0
- package/test/routes/admin/deduplicate-image-alts.js +190 -0
- package/test/routes/admin/email.js +114 -0
- package/test/routes/admin/firestore-query.js +204 -0
- package/test/routes/admin/firestore.js +127 -0
- package/test/routes/admin/infer-contact.js +218 -0
- package/test/routes/admin/notification.js +198 -0
- package/test/routes/admin/post-resize-image.js +184 -0
- package/test/routes/admin/post.js +368 -0
- package/test/routes/admin/repo-content.js +223 -0
- package/test/routes/admin/stats.js +112 -0
- package/test/routes/content/post.js +54 -0
- package/test/routes/general/uuid.js +115 -0
- package/test/routes/marketing/campaign.js +125 -0
- package/test/routes/marketing/contact.js +370 -0
- package/test/routes/marketing/email-preferences.js +292 -0
- package/test/routes/marketing/push-send.js +32 -0
- package/test/routes/marketing/webhook-forward.js +61 -0
- package/test/routes/marketing/webhook.js +639 -0
- package/test/routes/payments/cancel.js +163 -0
- package/test/routes/payments/discount.js +80 -0
- package/test/routes/payments/dispute-alert.js +320 -0
- package/test/routes/payments/intent.js +336 -0
- package/test/routes/payments/portal.js +92 -0
- package/test/routes/payments/refund.js +179 -0
- package/test/routes/payments/trial-eligibility.js +71 -0
- package/test/routes/payments/webhook.js +107 -0
- package/test/routes/test/authenticate.js +59 -0
- package/test/routes/test/schema.js +554 -0
- package/test/routes/test/usage.js +342 -0
- package/test/routes/user/api-keys.js +156 -0
- package/test/routes/user/delete.js +136 -0
- package/test/routes/user/feedback.js +104 -0
- package/test/routes/user/sessions.js +199 -0
- package/test/routes/user/settings-validate.js +82 -0
- package/test/routes/user/signup.js +542 -0
- package/test/routes/user/subscription.js +99 -0
- package/test/routes/user/token.js +73 -0
- package/test/routes/user/user.js +157 -0
- package/test/rules/notifications.js +410 -0
- package/test/rules/payments-carts.js +371 -0
- package/test/rules/user.js +396 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test: Payment Journey - UID Resolution Fallback
|
|
3
|
+
* Simulates: paid active subscription → webhook with uid OMITTED from metadata
|
|
4
|
+
*
|
|
5
|
+
* Verifies Fix 1: when a webhook event doesn't carry uid in metadata (like PayPal's
|
|
6
|
+
* PAYMENT.SALE events), the pipeline resolves uid from the fetched resource using
|
|
7
|
+
* library.getUid() and persists it on the webhook doc.
|
|
8
|
+
*
|
|
9
|
+
* Flow:
|
|
10
|
+
* 1. Set up paid subscription via test intent (establishes payments-orders doc with resourceId)
|
|
11
|
+
* 2. Send customer.subscription.updated webhook WITHOUT uid in metadata
|
|
12
|
+
* 3. Verify: webhook completes (not fails), uid resolved, subscription updated
|
|
13
|
+
*
|
|
14
|
+
* Product-agnostic: resolves the first paid product from config.payment.products
|
|
15
|
+
*/
|
|
16
|
+
module.exports = {
|
|
17
|
+
description: 'Payment journey: webhook without uid → UID resolved from fetched resource',
|
|
18
|
+
type: 'suite',
|
|
19
|
+
timeout: 30000,
|
|
20
|
+
|
|
21
|
+
tests: [
|
|
22
|
+
{
|
|
23
|
+
name: 'setup-paid-subscription',
|
|
24
|
+
async run({ accounts, firestore, assert, state, config, http, waitFor, skip, payments }) {
|
|
25
|
+
const uid = accounts['journey-payments-uid-resolution'].uid;
|
|
26
|
+
|
|
27
|
+
// Resolve a paid product with a monthly price. If the brand has none configured,
|
|
28
|
+
// skip the entire journey — this is a config-gap, not a code failure.
|
|
29
|
+
const paidProduct = config.payment.products.find(p => p.id !== 'basic' && p.prices?.monthly);
|
|
30
|
+
if (!paidProduct) {
|
|
31
|
+
skip('No paid product with monthly price configured in this brand');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
state.uid = uid;
|
|
35
|
+
state.paidProductId = paidProduct.id;
|
|
36
|
+
state.product = payments.products[paidProduct.id];
|
|
37
|
+
// Create subscription via test intent
|
|
38
|
+
const response = await http.as('journey-payments-uid-resolution').post('backend-manager/payments/intent', {
|
|
39
|
+
processor: 'test',
|
|
40
|
+
productId: paidProduct.id,
|
|
41
|
+
frequency: state.product.frequency,
|
|
42
|
+
});
|
|
43
|
+
assert.isSuccess(response, 'Intent should succeed');
|
|
44
|
+
state.orderId = response.data.orderId;
|
|
45
|
+
|
|
46
|
+
// Wait for subscription to activate
|
|
47
|
+
await waitFor(async () => {
|
|
48
|
+
const userDoc = await firestore.get(`users/${uid}`);
|
|
49
|
+
return userDoc?.subscription?.product?.id === paidProduct.id
|
|
50
|
+
&& userDoc?.subscription?.status === 'active';
|
|
51
|
+
}, 15000, 500);
|
|
52
|
+
|
|
53
|
+
const userDoc = await firestore.get(`users/${uid}`);
|
|
54
|
+
state.subscriptionId = userDoc.subscription.payment.resourceId;
|
|
55
|
+
|
|
56
|
+
assert.ok(state.subscriptionId, 'Subscription resource ID should exist');
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
name: 'send-webhook-without-uid',
|
|
62
|
+
async run({ http, assert, state, config, payments }) {
|
|
63
|
+
// Send a subscription update webhook WITHOUT uid in metadata
|
|
64
|
+
// The test processor's fetchResource() will look up payments-orders by resourceId
|
|
65
|
+
// and reconstruct a Stripe-shaped subscription that includes metadata.uid
|
|
66
|
+
// Then library.getUid() extracts uid from the fetched resource
|
|
67
|
+
const futureDate = new Date();
|
|
68
|
+
futureDate.setMonth(futureDate.getMonth() + 1);
|
|
69
|
+
|
|
70
|
+
state.noUidEventId = `_test-evt-journey-uid-resolve-${Date.now()}`;
|
|
71
|
+
|
|
72
|
+
const response = await http.as('none').post(`backend-manager/payments/webhook?processor=test&key=${config.backendManagerWebhookKey}`, {
|
|
73
|
+
id: state.noUidEventId,
|
|
74
|
+
type: 'customer.subscription.updated',
|
|
75
|
+
data: {
|
|
76
|
+
object: {
|
|
77
|
+
id: state.subscriptionId,
|
|
78
|
+
object: 'subscription',
|
|
79
|
+
status: 'active',
|
|
80
|
+
// NO metadata.uid — this is the key part of the test
|
|
81
|
+
metadata: {},
|
|
82
|
+
cancel_at_period_end: true,
|
|
83
|
+
cancel_at: Math.floor(futureDate.getTime() / 1000),
|
|
84
|
+
canceled_at: null,
|
|
85
|
+
current_period_end: Math.floor(futureDate.getTime() / 1000),
|
|
86
|
+
current_period_start: Math.floor(Date.now() / 1000),
|
|
87
|
+
start_date: Math.floor(Date.now() / 1000) - 86400 * 30,
|
|
88
|
+
trial_start: null,
|
|
89
|
+
trial_end: null,
|
|
90
|
+
plan: { product: payments.stripeProductIds[state.paidProductId], interval: state.product.interval },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
assert.isSuccess(response, 'Webhook should be accepted (even without uid)');
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
name: 'uid-resolved-and-webhook-completed',
|
|
101
|
+
async run({ firestore, assert, state, waitFor }) {
|
|
102
|
+
// Wait for the webhook to be processed
|
|
103
|
+
await waitFor(async () => {
|
|
104
|
+
const doc = await firestore.get(`payments-webhooks/${state.noUidEventId}`);
|
|
105
|
+
return doc?.status === 'completed' || doc?.status === 'failed';
|
|
106
|
+
}, 15000, 500);
|
|
107
|
+
|
|
108
|
+
const webhookDoc = await firestore.get(`payments-webhooks/${state.noUidEventId}`);
|
|
109
|
+
|
|
110
|
+
// Core assertions: UID was resolved from the fetched resource
|
|
111
|
+
assert.equal(webhookDoc.status, 'completed', 'Webhook should complete (not fail due to missing UID)');
|
|
112
|
+
assert.equal(webhookDoc.owner, state.uid, 'Owner should be resolved to the correct UID');
|
|
113
|
+
assert.equal(webhookDoc.orderId, state.orderId, 'Order ID should match');
|
|
114
|
+
|
|
115
|
+
// Transition should be cancellation-requested (we sent cancel_at_period_end: true)
|
|
116
|
+
assert.equal(webhookDoc.transition, 'cancellation-requested', 'Transition should be cancellation-requested');
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
{
|
|
121
|
+
name: 'subscription-updated-correctly',
|
|
122
|
+
async run({ firestore, assert, state }) {
|
|
123
|
+
const userDoc = await firestore.get(`users/${state.uid}`);
|
|
124
|
+
|
|
125
|
+
// The webhook should have updated the user doc even though uid wasn't in the webhook metadata
|
|
126
|
+
assert.equal(userDoc.subscription.status, 'active', 'Status should still be active');
|
|
127
|
+
assert.equal(userDoc.subscription.cancellation.pending, true, 'Cancellation should be pending');
|
|
128
|
+
assert.equal(userDoc.subscription.product.id, state.paidProductId, `Product should be ${state.paidProductId}`);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test: Payment Journey - Upgrade
|
|
3
|
+
* Simulates: basic user → test intent → auto-webhook → paid active subscription
|
|
4
|
+
*
|
|
5
|
+
* Uses the test processor to exercise the full intent→webhook→trigger pipeline
|
|
6
|
+
* Product-agnostic: resolves the first paid product from config.payment.products
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
description: 'Payment journey: basic → paid upgrade via test intent',
|
|
10
|
+
type: 'suite',
|
|
11
|
+
timeout: 30000,
|
|
12
|
+
|
|
13
|
+
tests: [
|
|
14
|
+
{
|
|
15
|
+
name: 'verify-starts-as-basic',
|
|
16
|
+
async run({ accounts, firestore, assert, state, config, skip, payments }) {
|
|
17
|
+
const uid = accounts['journey-payments-upgrade'].uid;
|
|
18
|
+
const userDoc = await firestore.get(`users/${uid}`);
|
|
19
|
+
|
|
20
|
+
assert.ok(userDoc, 'User doc should exist');
|
|
21
|
+
assert.equal(userDoc.subscription?.product?.id, 'basic', 'Should start as basic');
|
|
22
|
+
assert.equal(userDoc.subscription?.status, 'active', 'Should be active');
|
|
23
|
+
|
|
24
|
+
// Resolve first paid product from config. If the brand has none configured,
|
|
25
|
+
// skip the entire journey — this is a config-gap, not a code failure.
|
|
26
|
+
const paidProduct = config.payment.products.find(p => p.id !== 'basic' && p.prices);
|
|
27
|
+
if (!paidProduct) {
|
|
28
|
+
skip('No paid product configured in this brand');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
state.uid = uid;
|
|
32
|
+
state.paidProductId = paidProduct.id;
|
|
33
|
+
state.product = payments.products[paidProduct.id];
|
|
34
|
+
|
|
35
|
+
state.paidProductName = paidProduct.name;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
name: 'create-test-intent',
|
|
41
|
+
async run({ http, assert, state }) {
|
|
42
|
+
const response = await http.as('journey-payments-upgrade').post('backend-manager/payments/intent', {
|
|
43
|
+
processor: 'test',
|
|
44
|
+
productId: state.paidProductId,
|
|
45
|
+
frequency: state.product.frequency,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
assert.isSuccess(response, 'Intent should succeed');
|
|
49
|
+
assert.ok(response.data.id, 'Should return intent ID');
|
|
50
|
+
assert.ok(response.data.orderId, 'Should return orderId');
|
|
51
|
+
assert.match(response.data.orderId, /^\d{4}-\d{4}-\d{4}$/, 'orderId should be XXXX-XXXX-XXXX format');
|
|
52
|
+
assert.ok(response.data.url, 'Should return URL');
|
|
53
|
+
|
|
54
|
+
state.intentId = response.data.id;
|
|
55
|
+
state.orderId = response.data.orderId;
|
|
56
|
+
|
|
57
|
+
// Derive webhook event ID from intent ID (same timestamp)
|
|
58
|
+
state.eventId = response.data.id.replace('_test-cs-', '_test-evt-');
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
name: 'subscription-activated',
|
|
64
|
+
async run({ firestore, assert, state, waitFor }) {
|
|
65
|
+
// Poll user doc until subscription changes from basic to paid
|
|
66
|
+
await waitFor(async () => {
|
|
67
|
+
const userDoc = await firestore.get(`users/${state.uid}`);
|
|
68
|
+
return userDoc?.subscription?.product?.id === state.paidProductId;
|
|
69
|
+
}, 15000, 500);
|
|
70
|
+
|
|
71
|
+
const userDoc = await firestore.get(`users/${state.uid}`);
|
|
72
|
+
|
|
73
|
+
assert.equal(userDoc.subscription.product.id, state.paidProductId, `Product should be ${state.paidProductId}`);
|
|
74
|
+
assert.equal(userDoc.subscription.status, 'active', 'Status should be active');
|
|
75
|
+
assert.equal(userDoc.subscription.payment.processor, 'test', 'Processor should be test');
|
|
76
|
+
assert.equal(userDoc.subscription.payment.orderId, state.orderId, 'Order ID should match intent');
|
|
77
|
+
assert.ok(userDoc.subscription.payment.resourceId, 'Resource ID should be set');
|
|
78
|
+
assert.equal(userDoc.subscription.payment.frequency, state.product.frequency, 'Frequency should be monthly');
|
|
79
|
+
assert.equal(userDoc.subscription.cancellation.pending, false, 'Should not be pending cancellation');
|
|
80
|
+
|
|
81
|
+
state.subscriptionId = userDoc.subscription.payment.resourceId;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
{
|
|
86
|
+
name: 'order-doc-created',
|
|
87
|
+
async run({ firestore, assert, state }) {
|
|
88
|
+
const orderDoc = await firestore.get(`payments-orders/${state.orderId}`);
|
|
89
|
+
|
|
90
|
+
assert.ok(orderDoc, 'Order doc should exist');
|
|
91
|
+
assert.equal(orderDoc.id, state.orderId, 'ID should match orderId');
|
|
92
|
+
assert.equal(orderDoc.type, 'subscription', 'Type should be subscription');
|
|
93
|
+
assert.equal(orderDoc.owner, state.uid, 'Owner should match');
|
|
94
|
+
assert.equal(orderDoc.processor, 'test', 'Processor should be test');
|
|
95
|
+
assert.equal(orderDoc.resourceId, state.subscriptionId, 'Resource ID should match');
|
|
96
|
+
assert.equal(orderDoc.unified.product.id, state.paidProductId, `Product should be ${state.paidProductId}`);
|
|
97
|
+
assert.equal(orderDoc.unified.status, 'active', 'Status should be active');
|
|
98
|
+
assert.ok(orderDoc.requests !== undefined, 'requests field should exist');
|
|
99
|
+
assert.equal(orderDoc.requests.cancellation, null, 'requests.cancellation should be null initially');
|
|
100
|
+
assert.equal(orderDoc.requests.refund, null, 'requests.refund should be null initially');
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
name: 'webhook-transition-new-subscription',
|
|
106
|
+
async run({ firestore, assert, state, waitFor }) {
|
|
107
|
+
await waitFor(async () => {
|
|
108
|
+
const doc = await firestore.get(`payments-webhooks/${state.eventId}`);
|
|
109
|
+
return doc?.status === 'completed';
|
|
110
|
+
}, 15000, 500);
|
|
111
|
+
|
|
112
|
+
const webhookDoc = await firestore.get(`payments-webhooks/${state.eventId}`);
|
|
113
|
+
assert.ok(webhookDoc, 'Webhook doc should exist');
|
|
114
|
+
assert.equal(webhookDoc.transition, 'new-subscription', 'Transition should be new-subscription');
|
|
115
|
+
assert.equal(webhookDoc.orderId, state.orderId, 'Webhook doc orderId should match intent');
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
name: 'intent-doc-completed',
|
|
121
|
+
async run({ firestore, assert, state }) {
|
|
122
|
+
const intentDoc = await firestore.get(`payments-intents/${state.orderId}`);
|
|
123
|
+
|
|
124
|
+
assert.ok(intentDoc, 'Intent doc should exist');
|
|
125
|
+
assert.equal(intentDoc.id, state.orderId, 'ID should match orderId');
|
|
126
|
+
assert.equal(intentDoc.intentId, state.intentId, 'Intent ID should match processor session ID');
|
|
127
|
+
assert.equal(intentDoc.owner, state.uid, 'Owner should match');
|
|
128
|
+
assert.equal(intentDoc.processor, 'test', 'Processor should be test');
|
|
129
|
+
assert.equal(intentDoc.status, 'completed', 'Intent status should be completed after webhook processing');
|
|
130
|
+
assert.equal(intentDoc.productId, state.paidProductId, `Product should be ${state.paidProductId}`);
|
|
131
|
+
assert.ok(intentDoc.metadata?.completed?.timestampUNIX > 0, 'Completed timestamp should be set');
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "inv_cb_onetime_001",
|
|
3
|
+
"customer_id": "cb_cust_006",
|
|
4
|
+
"status": "paid",
|
|
5
|
+
"total": 999,
|
|
6
|
+
"amount_paid": 999,
|
|
7
|
+
"amount_due": 0,
|
|
8
|
+
"recurring": false,
|
|
9
|
+
"date": 1700000000,
|
|
10
|
+
"paid_at": 1700000001,
|
|
11
|
+
"currency_code": "USD",
|
|
12
|
+
"object": "invoice",
|
|
13
|
+
"meta_data": "{\"uid\":\"test-uid-006\",\"orderId\":\"6789-0123-4567\",\"productId\":\"credits-100\"}",
|
|
14
|
+
"line_items": [
|
|
15
|
+
{
|
|
16
|
+
"id": "li_cb_001",
|
|
17
|
+
"date_from": 1700000000,
|
|
18
|
+
"date_to": 1700000000,
|
|
19
|
+
"unit_amount": 999,
|
|
20
|
+
"quantity": 1,
|
|
21
|
+
"amount": 999,
|
|
22
|
+
"description": "100 Credits",
|
|
23
|
+
"entity_type": "charge",
|
|
24
|
+
"object": "line_item"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cb_sub_active_001",
|
|
3
|
+
"customer_id": "cb_cust_001",
|
|
4
|
+
"status": "active",
|
|
5
|
+
"current_term_start": 1700000000,
|
|
6
|
+
"current_term_end": 1702592000,
|
|
7
|
+
"next_billing_at": 1702592000,
|
|
8
|
+
"created_at": 1697321600,
|
|
9
|
+
"started_at": 1697321600,
|
|
10
|
+
"activated_at": 1697321600,
|
|
11
|
+
"updated_at": 1700000000,
|
|
12
|
+
"has_scheduled_changes": false,
|
|
13
|
+
"channel": "web",
|
|
14
|
+
"resource_version": 1700000000000,
|
|
15
|
+
"deleted": false,
|
|
16
|
+
"object": "subscription",
|
|
17
|
+
"currency_code": "USD",
|
|
18
|
+
"subscription_items": [
|
|
19
|
+
{
|
|
20
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
21
|
+
"item_type": "plan",
|
|
22
|
+
"quantity": 1,
|
|
23
|
+
"unit_price": 499,
|
|
24
|
+
"amount": 499,
|
|
25
|
+
"object": "subscription_item"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"meta_data": "{\"uid\":\"test-uid-001\",\"orderId\":\"1234-5678-9012\"}",
|
|
29
|
+
"shipping_address": {
|
|
30
|
+
"first_name": "Test",
|
|
31
|
+
"last_name": "User",
|
|
32
|
+
"line1": "123 Main Street",
|
|
33
|
+
"city": "San Francisco",
|
|
34
|
+
"state": "CA",
|
|
35
|
+
"country": "US",
|
|
36
|
+
"validation_status": "not_validated",
|
|
37
|
+
"object": "shipping_address"
|
|
38
|
+
},
|
|
39
|
+
"due_invoices_count": 0,
|
|
40
|
+
"mrr": 499,
|
|
41
|
+
"exchange_rate": 1,
|
|
42
|
+
"base_currency_code": "USD",
|
|
43
|
+
"has_scheduled_advance_invoices": false
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cb_sub_cancelled_001",
|
|
3
|
+
"customer_id": "cb_cust_002",
|
|
4
|
+
"status": "cancelled",
|
|
5
|
+
"current_term_start": 1697321600,
|
|
6
|
+
"current_term_end": 1700000000,
|
|
7
|
+
"created_at": 1694643200,
|
|
8
|
+
"started_at": 1694643200,
|
|
9
|
+
"activated_at": 1694643200,
|
|
10
|
+
"cancelled_at": 1699500000,
|
|
11
|
+
"updated_at": 1699500000,
|
|
12
|
+
"has_scheduled_changes": false,
|
|
13
|
+
"channel": "web",
|
|
14
|
+
"resource_version": 1699500000000,
|
|
15
|
+
"deleted": false,
|
|
16
|
+
"object": "subscription",
|
|
17
|
+
"currency_code": "USD",
|
|
18
|
+
"subscription_items": [
|
|
19
|
+
{
|
|
20
|
+
"item_price_id": "somiibo-pro-annually",
|
|
21
|
+
"item_type": "plan",
|
|
22
|
+
"quantity": 1,
|
|
23
|
+
"unit_price": 4999,
|
|
24
|
+
"amount": 4999,
|
|
25
|
+
"object": "subscription_item"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"meta_data": "{\"uid\":\"test-uid-002\",\"orderId\":\"2345-6789-0123\"}",
|
|
29
|
+
"shipping_address": {
|
|
30
|
+
"first_name": "Cancelled",
|
|
31
|
+
"last_name": "User",
|
|
32
|
+
"line1": "456 Oak Avenue",
|
|
33
|
+
"city": "New York",
|
|
34
|
+
"state": "NY",
|
|
35
|
+
"country": "US",
|
|
36
|
+
"validation_status": "not_validated",
|
|
37
|
+
"object": "shipping_address"
|
|
38
|
+
},
|
|
39
|
+
"due_invoices_count": 0,
|
|
40
|
+
"mrr": 0,
|
|
41
|
+
"has_scheduled_advance_invoices": false
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cb_sub_trial_001",
|
|
3
|
+
"customer_id": "cb_cust_003",
|
|
4
|
+
"status": "in_trial",
|
|
5
|
+
"trial_start": 1700000000,
|
|
6
|
+
"trial_end": 1701209600,
|
|
7
|
+
"next_billing_at": 1701209600,
|
|
8
|
+
"created_at": 1700000000,
|
|
9
|
+
"started_at": 1700000000,
|
|
10
|
+
"updated_at": 1700000000,
|
|
11
|
+
"has_scheduled_changes": false,
|
|
12
|
+
"channel": "web",
|
|
13
|
+
"resource_version": 1700000000000,
|
|
14
|
+
"deleted": false,
|
|
15
|
+
"object": "subscription",
|
|
16
|
+
"currency_code": "USD",
|
|
17
|
+
"subscription_items": [
|
|
18
|
+
{
|
|
19
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
20
|
+
"item_type": "plan",
|
|
21
|
+
"quantity": 1,
|
|
22
|
+
"unit_price": 499,
|
|
23
|
+
"amount": 499,
|
|
24
|
+
"object": "subscription_item"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"meta_data": "{\"uid\":\"test-uid-003\",\"orderId\":\"3456-7890-1234\"}",
|
|
28
|
+
"shipping_address": {
|
|
29
|
+
"first_name": "Trial",
|
|
30
|
+
"last_name": "User",
|
|
31
|
+
"line1": "789 Elm Drive",
|
|
32
|
+
"city": "Chicago",
|
|
33
|
+
"state": "IL",
|
|
34
|
+
"country": "US",
|
|
35
|
+
"validation_status": "not_validated",
|
|
36
|
+
"object": "shipping_address"
|
|
37
|
+
},
|
|
38
|
+
"due_invoices_count": 0,
|
|
39
|
+
"mrr": 0,
|
|
40
|
+
"has_scheduled_advance_invoices": false
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "AzZMxvTYTQUmw1Iw7",
|
|
3
|
+
"plan_id": "somiibo-premium-monthly-1",
|
|
4
|
+
"plan_quantity": 1,
|
|
5
|
+
"plan_unit_price": 1995,
|
|
6
|
+
"billing_period": 1,
|
|
7
|
+
"billing_period_unit": "month",
|
|
8
|
+
"customer_id": "AzZMxvTYTQUmw1Iw7",
|
|
9
|
+
"plan_amount": 1995,
|
|
10
|
+
"plan_free_quantity": 0,
|
|
11
|
+
"status": "active",
|
|
12
|
+
"current_term_start": 1692009453,
|
|
13
|
+
"current_term_end": 1694687853,
|
|
14
|
+
"next_billing_at": 1694687853,
|
|
15
|
+
"created_at": 1678790253,
|
|
16
|
+
"started_at": 1678790253,
|
|
17
|
+
"activated_at": 1678790253,
|
|
18
|
+
"updated_at": 1692009461,
|
|
19
|
+
"has_scheduled_changes": false,
|
|
20
|
+
"channel": "web",
|
|
21
|
+
"resource_version": 1692009461863,
|
|
22
|
+
"deleted": false,
|
|
23
|
+
"object": "subscription",
|
|
24
|
+
"currency_code": "USD",
|
|
25
|
+
"shipping_address": {
|
|
26
|
+
"first_name": "Legacy",
|
|
27
|
+
"last_name": "User",
|
|
28
|
+
"line1": "Kalograion",
|
|
29
|
+
"city": "Larnaca",
|
|
30
|
+
"state": "Larnaca",
|
|
31
|
+
"country": "CY",
|
|
32
|
+
"validation_status": "not_validated",
|
|
33
|
+
"object": "shipping_address"
|
|
34
|
+
},
|
|
35
|
+
"due_invoices_count": 0,
|
|
36
|
+
"mrr": 1995,
|
|
37
|
+
"exchange_rate": 1,
|
|
38
|
+
"base_currency_code": "USD",
|
|
39
|
+
"cf_clientorderid": "1678790168794-0784",
|
|
40
|
+
"has_scheduled_advance_invoices": false
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cb_sub_nonrenew_001",
|
|
3
|
+
"customer_id": "cb_cust_004",
|
|
4
|
+
"status": "non_renewing",
|
|
5
|
+
"current_term_start": 1700000000,
|
|
6
|
+
"current_term_end": 1702592000,
|
|
7
|
+
"created_at": 1694643200,
|
|
8
|
+
"started_at": 1694643200,
|
|
9
|
+
"activated_at": 1694643200,
|
|
10
|
+
"updated_at": 1701000000,
|
|
11
|
+
"has_scheduled_changes": false,
|
|
12
|
+
"channel": "web",
|
|
13
|
+
"resource_version": 1701000000000,
|
|
14
|
+
"deleted": false,
|
|
15
|
+
"object": "subscription",
|
|
16
|
+
"currency_code": "USD",
|
|
17
|
+
"subscription_items": [
|
|
18
|
+
{
|
|
19
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
20
|
+
"item_type": "plan",
|
|
21
|
+
"quantity": 1,
|
|
22
|
+
"unit_price": 499,
|
|
23
|
+
"amount": 499,
|
|
24
|
+
"object": "subscription_item"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"meta_data": "{\"uid\":\"test-uid-004\",\"orderId\":\"4567-8901-2345\"}",
|
|
28
|
+
"shipping_address": {
|
|
29
|
+
"first_name": "NonRenew",
|
|
30
|
+
"last_name": "User",
|
|
31
|
+
"line1": "321 Pine Road",
|
|
32
|
+
"city": "Austin",
|
|
33
|
+
"state": "TX",
|
|
34
|
+
"country": "US",
|
|
35
|
+
"validation_status": "not_validated",
|
|
36
|
+
"object": "shipping_address"
|
|
37
|
+
},
|
|
38
|
+
"due_invoices_count": 0,
|
|
39
|
+
"mrr": 0,
|
|
40
|
+
"has_scheduled_advance_invoices": false
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cb_sub_paused_001",
|
|
3
|
+
"customer_id": "cb_cust_005",
|
|
4
|
+
"status": "paused",
|
|
5
|
+
"current_term_start": 1700000000,
|
|
6
|
+
"current_term_end": 1702592000,
|
|
7
|
+
"pause_date": 1701000000,
|
|
8
|
+
"created_at": 1694643200,
|
|
9
|
+
"started_at": 1694643200,
|
|
10
|
+
"activated_at": 1694643200,
|
|
11
|
+
"updated_at": 1701000000,
|
|
12
|
+
"has_scheduled_changes": false,
|
|
13
|
+
"channel": "web",
|
|
14
|
+
"resource_version": 1701000000000,
|
|
15
|
+
"deleted": false,
|
|
16
|
+
"object": "subscription",
|
|
17
|
+
"currency_code": "USD",
|
|
18
|
+
"subscription_items": [
|
|
19
|
+
{
|
|
20
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
21
|
+
"item_type": "plan",
|
|
22
|
+
"quantity": 1,
|
|
23
|
+
"unit_price": 499,
|
|
24
|
+
"amount": 499,
|
|
25
|
+
"object": "subscription_item"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"meta_data": "{\"uid\":\"test-uid-005\",\"orderId\":\"5678-9012-3456\"}",
|
|
29
|
+
"shipping_address": {
|
|
30
|
+
"first_name": "Paused",
|
|
31
|
+
"last_name": "User",
|
|
32
|
+
"line1": "654 Maple Lane",
|
|
33
|
+
"city": "Seattle",
|
|
34
|
+
"state": "WA",
|
|
35
|
+
"country": "US",
|
|
36
|
+
"validation_status": "not_validated",
|
|
37
|
+
"object": "shipping_address"
|
|
38
|
+
},
|
|
39
|
+
"due_invoices_count": 0,
|
|
40
|
+
"mrr": 0,
|
|
41
|
+
"has_scheduled_advance_invoices": false
|
|
42
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "ev_cb_payment_failed_001",
|
|
3
|
+
"occurred_at": 1700500000,
|
|
4
|
+
"source": "system",
|
|
5
|
+
"event_type": "payment_failed",
|
|
6
|
+
"api_version": "v2",
|
|
7
|
+
"content": {
|
|
8
|
+
"subscription": {
|
|
9
|
+
"id": "cb_sub_active_001",
|
|
10
|
+
"customer_id": "cb_cust_001",
|
|
11
|
+
"status": "active",
|
|
12
|
+
"current_term_start": 1700000000,
|
|
13
|
+
"current_term_end": 1702592000,
|
|
14
|
+
"subscription_items": [
|
|
15
|
+
{
|
|
16
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
17
|
+
"item_type": "plan",
|
|
18
|
+
"quantity": 1,
|
|
19
|
+
"unit_price": 499,
|
|
20
|
+
"amount": 499
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"meta_data": "{\"uid\":\"test-uid-001\",\"orderId\":\"1234-5678-9012\"}",
|
|
24
|
+
"currency_code": "USD",
|
|
25
|
+
"object": "subscription"
|
|
26
|
+
},
|
|
27
|
+
"customer": {
|
|
28
|
+
"id": "cb_cust_001",
|
|
29
|
+
"first_name": "Test",
|
|
30
|
+
"last_name": "User",
|
|
31
|
+
"email": "test@example.com",
|
|
32
|
+
"object": "customer"
|
|
33
|
+
},
|
|
34
|
+
"invoice": {
|
|
35
|
+
"id": "inv_cb_002",
|
|
36
|
+
"subscription_id": "cb_sub_active_001",
|
|
37
|
+
"status": "not_paid",
|
|
38
|
+
"total": 499,
|
|
39
|
+
"amount_due": 499,
|
|
40
|
+
"currency_code": "USD",
|
|
41
|
+
"object": "invoice"
|
|
42
|
+
},
|
|
43
|
+
"transaction": {
|
|
44
|
+
"id": "txn_cb_002",
|
|
45
|
+
"status": "failure",
|
|
46
|
+
"amount": 499,
|
|
47
|
+
"currency_code": "USD",
|
|
48
|
+
"object": "transaction"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "ev_cb_sub_created_001",
|
|
3
|
+
"occurred_at": 1700000000,
|
|
4
|
+
"source": "hosted_page",
|
|
5
|
+
"event_type": "subscription_created",
|
|
6
|
+
"api_version": "v2",
|
|
7
|
+
"content": {
|
|
8
|
+
"subscription": {
|
|
9
|
+
"id": "cb_sub_active_001",
|
|
10
|
+
"customer_id": "cb_cust_001",
|
|
11
|
+
"status": "active",
|
|
12
|
+
"current_term_start": 1700000000,
|
|
13
|
+
"current_term_end": 1702592000,
|
|
14
|
+
"created_at": 1700000000,
|
|
15
|
+
"started_at": 1700000000,
|
|
16
|
+
"activated_at": 1700000000,
|
|
17
|
+
"subscription_items": [
|
|
18
|
+
{
|
|
19
|
+
"item_price_id": "somiibo-pro-monthly",
|
|
20
|
+
"item_type": "plan",
|
|
21
|
+
"quantity": 1,
|
|
22
|
+
"unit_price": 499,
|
|
23
|
+
"amount": 499
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"meta_data": "{\"uid\":\"test-uid-001\",\"orderId\":\"1234-5678-9012\"}",
|
|
27
|
+
"currency_code": "USD",
|
|
28
|
+
"object": "subscription"
|
|
29
|
+
},
|
|
30
|
+
"customer": {
|
|
31
|
+
"id": "cb_cust_001",
|
|
32
|
+
"first_name": "Test",
|
|
33
|
+
"last_name": "User",
|
|
34
|
+
"email": "test@example.com",
|
|
35
|
+
"object": "customer"
|
|
36
|
+
},
|
|
37
|
+
"invoice": {
|
|
38
|
+
"id": "inv_cb_001",
|
|
39
|
+
"subscription_id": "cb_sub_active_001",
|
|
40
|
+
"status": "paid",
|
|
41
|
+
"total": 499,
|
|
42
|
+
"amount_paid": 499,
|
|
43
|
+
"currency_code": "USD",
|
|
44
|
+
"object": "invoice"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|