@manifoldco/manifold-subscription
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -8,5 +8,5 @@ 'use strict'; | ||
const defineCustomElements = (win, options) => index.patchEsm().then(() => { | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
}); | ||
exports.defineCustomElements = defineCustomElements; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
index.patchBrowser().then(options => { | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
}); |
@@ -8,2 +8,3 @@ import { Component, Element, Prop, h, Watch, State, Listen, Event, } from '@stencil/core'; | ||
import planListQuery from './plan-list.graphql'; | ||
import profileQuery from './profile.graphql'; | ||
import createSubscrptionMutation from './create-subscription.graphql'; | ||
@@ -34,2 +35,5 @@ import { filterErrors, interfaceError, dataError, subscriptionError, validationError, } from '../../utils/error'; | ||
e.preventDefault(); | ||
if (this.preview) { | ||
return; | ||
} | ||
await this.removeErrors('subscription', 'card'); | ||
@@ -50,3 +54,3 @@ if (this.cardStatus === 'empty') { | ||
this.subscribing = true; | ||
const { stripeSetupIntentSecret } = this.data.profile; | ||
const { stripeSetupIntentSecret } = this.profile; | ||
const { setupIntent, error } = await this.stripe.confirmCardSetup(stripeSetupIntentSecret, { | ||
@@ -140,3 +144,6 @@ payment_method: { | ||
} | ||
async initializeStripeElements(data) { | ||
componentDidLoad() { | ||
this.initializeStripeElements(); | ||
} | ||
async initializeStripeElements() { | ||
// Only initialize once | ||
@@ -147,6 +154,39 @@ if (this.stripe) { | ||
this.removeErrors('stripe-init'); | ||
if (!this.connection) { | ||
this.addErrors(interfaceError('stripe-init')); | ||
throw new Error('Missing property `connection` on `manifold-subscription-create`.'); | ||
} | ||
let res; | ||
if (this.preview) { | ||
res = { | ||
data: { | ||
profile: { | ||
stripeAccount: { | ||
id: '', | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
else { | ||
res = await this.connection | ||
.graphqlFetch({ | ||
query: profileQuery, | ||
}) | ||
.catch(e => { | ||
this.addErrors(dataError('stripe-init', 'profile')); | ||
throw new Error(e); | ||
}); | ||
} | ||
if (res.errors || !res.data) { | ||
this.addErrors(dataError('stripe-init', 'profile')); | ||
return; | ||
} | ||
this.profile = res.data.profile; | ||
// Initialize Stripe | ||
this.stripe = await loadStripe(this.stripePublishableKey, { | ||
stripeAccount: data.profile.stripeAccount.id, | ||
}); | ||
this.stripe = await loadStripe(this.stripePublishableKey, this.preview | ||
? {} | ||
: { | ||
stripeAccount: res.data.profile.stripeAccount.id, | ||
}); | ||
if (!this.stripe) { | ||
@@ -156,3 +196,3 @@ this.addErrors(interfaceError('stripe-init')); | ||
`\n\tStripePublishable Key: ${this.stripePublishableKey}` + | ||
`\n\tStripe Account ID: ${data.profile.stripeAccount.id}`); | ||
`\n\tStripe Account ID: ${res.data.profile.stripeAccount.id}`); | ||
} | ||
@@ -346,3 +386,3 @@ // Create and mount Stripe card element | ||
"original": "PlanQuery", | ||
"resolved": "undefined | { __typename?: \"Query\" | undefined; } & { plan: { __typename?: \"Plan\" | undefined; } & Pick<Plan, \"displayName\" | \"cost\"> & { product: { __typename?: \"Product\" | undefined; } & Pick<Product, \"label\">; configurableFeatures: { __typename?: \"PlanConfigurableFeatureConnection\" | undefined; } & { edges: ({ __typename?: \"PlanConfigurableFeatureEdge\" | undefined; } & { node: { __typename?: \"PlanConfigurableFeature\" | undefined; } & Pick<PlanConfigurableFeature, \"id\">; })[]; }; }; profile: { __typename?: \"Profile\" | undefined; } & Pick<Profile, \"stripeSetupIntentSecret\"> & { stripeAccount: { __typename?: \"StripeAccount\" | undefined; } & Pick<StripeAccount, \"id\">; }; }", | ||
"resolved": "undefined | { __typename?: \"Query\" | undefined; } & { plan: { __typename?: \"Plan\" | undefined; } & Pick<Plan, \"displayName\" | \"cost\"> & { product: { __typename?: \"Product\" | undefined; } & Pick<Product, \"label\">; configurableFeatures: { __typename?: \"PlanConfigurableFeatureConnection\" | undefined; } & { edges: ({ __typename?: \"PlanConfigurableFeatureEdge\" | undefined; } & { node: { __typename?: \"PlanConfigurableFeature\" | undefined; } & Pick<PlanConfigurableFeature, \"id\">; })[]; }; }; }", | ||
"references": { | ||
@@ -495,2 +535,19 @@ "PlanQuery": { | ||
}, | ||
"preview": { | ||
"type": "boolean", | ||
"mutable": false, | ||
"complexType": { | ||
"original": "boolean", | ||
"resolved": "boolean | undefined", | ||
"references": {} | ||
}, | ||
"required": false, | ||
"optional": true, | ||
"docs": { | ||
"tags": [], | ||
"text": "Puts the component in preview mode" | ||
}, | ||
"attribute": "preview", | ||
"reflect": false | ||
}, | ||
"heading": { | ||
@@ -601,3 +658,4 @@ "type": "string", | ||
"card": {}, | ||
"cardStatus": {} | ||
"cardStatus": {}, | ||
"profile": {} | ||
}; } | ||
@@ -622,5 +680,2 @@ static get events() { return [{ | ||
static get watchers() { return [{ | ||
"propName": "data", | ||
"methodName": "initializeStripeElements" | ||
}, { | ||
"propName": "planId", | ||
@@ -627,0 +682,0 @@ "methodName": "updatePlan" |
@@ -1,1 +0,1 @@ | ||
import{p as i,b as e}from"./p-a98c757b.js";i().then(i=>e([["p-34fdb56e",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); | ||
import{p as i,b as e}from"./p-a98c757b.js";i().then(i=>e([["p-59c79350",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,i;return{setters:[function(t){e=t.p;i=t.b}],execute:function(){e().then((function(e){return i([["p-efe5d25c.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,i;return{setters:[function(t){e=t.p;i=t.b}],execute:function(){e().then((function(e){return i([["p-3dfb47da.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); |
@@ -48,2 +48,6 @@ /* eslint-disable */ | ||
"planListData"?: PlanListQuery; | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
"preview"?: boolean; | ||
"setupIntentError"?: string; | ||
@@ -153,2 +157,6 @@ "setupIntentStatus"?: SetupIntent.Status; | ||
"planListData"?: PlanListQuery; | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
"preview"?: boolean; | ||
"setupIntentError"?: string; | ||
@@ -155,0 +163,0 @@ "setupIntentStatus"?: SetupIntent.Status; |
import { EventEmitter } from '@stencil/core'; | ||
import { Stripe, StripeCardElement, SetupIntent } from '@stripe/stripe-js'; | ||
import { Connection } from '@manifoldco/manifold-init-types/types/v0'; | ||
import { PlanQuery, PlanListQuery } from '../../types/graphql'; | ||
import { PlanQuery, ProfileQuery, PlanListQuery } from '../../types/graphql'; | ||
import { FeatureMap } from '../../utils/plan'; | ||
@@ -14,2 +14,3 @@ import { UIError } from '../../utils/error'; | ||
cardStatus: 'empty' | 'partial' | 'complete'; | ||
profile: ProfileQuery['profile']; | ||
loading?: boolean; | ||
@@ -27,2 +28,6 @@ isLoadingPlanSelector?: boolean; | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
preview?: boolean; | ||
/** | ||
* Component heading text | ||
@@ -52,5 +57,6 @@ */ | ||
componentWillLoad(): Promise<void>; | ||
componentDidLoad(): void; | ||
addErrors: (...errors: UIError[]) => void; | ||
removeErrors: (...labels: string[]) => void; | ||
initializeStripeElements(data: PlanQuery): Promise<void>; | ||
initializeStripeElements(): Promise<void>; | ||
updatePlan(planId?: string): Promise<void>; | ||
@@ -57,0 +63,0 @@ updateConfiguredFeature(event: CustomEvent<{ |
@@ -9,5 +9,5 @@ import { Connection } from '@manifoldco/manifold-init-types/types/v0'; | ||
node: ({ | ||
__typename?: "NumberConfiguredFeature" | undefined; | ||
} & Pick<import("../../../types/graphql").NumberConfiguredFeature, "label"> & { | ||
numberValue: number; | ||
__typename?: "BooleanConfiguredFeature" | undefined; | ||
} & Pick<import("../../../types/graphql").BooleanConfiguredFeature, "label"> & { | ||
booleanValue: boolean; | ||
}) | ({ | ||
@@ -18,5 +18,5 @@ __typename?: "StringConfiguredFeature" | undefined; | ||
}) | ({ | ||
__typename?: "BooleanConfiguredFeature" | undefined; | ||
} & Pick<import("../../../types/graphql").BooleanConfiguredFeature, "label"> & { | ||
booleanValue: boolean; | ||
__typename?: "NumberConfiguredFeature" | undefined; | ||
} & Pick<import("../../../types/graphql").NumberConfiguredFeature, "label"> & { | ||
numberValue: number; | ||
}); | ||
@@ -23,0 +23,0 @@ })[]; |
@@ -1227,2 +1227,7 @@ export declare type Maybe<T> = T; | ||
})>; | ||
}); | ||
export declare type ProfileQueryVariables = {}; | ||
export declare type ProfileQuery = ({ | ||
__typename?: 'Query'; | ||
} & { | ||
profile: ({ | ||
@@ -1243,5 +1248,5 @@ __typename?: 'Profile'; | ||
node: ({ | ||
__typename?: 'NumberConfiguredFeature'; | ||
} & Pick<NumberConfiguredFeature, 'label'> & { | ||
numberValue: NumberConfiguredFeature['value']; | ||
__typename?: 'BooleanConfiguredFeature'; | ||
} & Pick<BooleanConfiguredFeature, 'label'> & { | ||
booleanValue: BooleanConfiguredFeature['value']; | ||
}) | ({ | ||
@@ -1252,5 +1257,5 @@ __typename?: 'StringConfiguredFeature'; | ||
}) | ({ | ||
__typename?: 'BooleanConfiguredFeature'; | ||
} & Pick<BooleanConfiguredFeature, 'label'> & { | ||
booleanValue: BooleanConfiguredFeature['value']; | ||
__typename?: 'NumberConfiguredFeature'; | ||
} & Pick<NumberConfiguredFeature, 'label'> & { | ||
numberValue: NumberConfiguredFeature['value']; | ||
}); | ||
@@ -1257,0 +1262,0 @@ })>; |
{ | ||
"name": "@manifoldco/manifold-subscription", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Manifold Subscription Web Components", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1393561
21629