-
-
Notifications
You must be signed in to change notification settings - Fork 153
feat(membership): confirm Apple IAP subscriptions #2813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e463540
75c5564
10e1b30
8449575
3053f8a
ccbf245
fa46138
191fae9
90f8256
78e147b
d3e4d03
1cc682f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,13 @@ export const MEMBERSHIP_WEBHOOK_EVENTS = [ | |
|
|
||
| export interface MembershipConfigValue { | ||
| apiKey?: string | ||
| appleAppAppleId?: string | ||
| appleBundleId?: string | ||
| appleIssuerId?: string | ||
| appleKeyId?: string | ||
| appleMonthlyProductId?: string | ||
| applePrivateKey?: string | ||
| appleYearlyProductId?: string | ||
| enabled?: boolean | ||
| environment?: string | ||
| monthlyProductId?: string | ||
|
|
@@ -19,10 +26,40 @@ export interface MembershipConfigValue { | |
|
|
||
| export interface MembershipCredentialStatus { | ||
| apiKeyConfigured: boolean | ||
| applePrivateKeyConfigured?: boolean | ||
| supportedProviders: string[] | ||
| webhookSigningKeyConfigured: boolean | ||
| } | ||
|
|
||
| type SetupChecks = Record<string, boolean> | ||
|
|
||
| export function getMembershipSetupProgress( | ||
| membershipChecks: SetupChecks, | ||
| appleChecks: SetupChecks, | ||
| ) { | ||
| const membershipValues = Object.values(membershipChecks) | ||
| const appleValues = Object.values(appleChecks) | ||
| const membershipCompletedCount = membershipValues.filter(Boolean).length | ||
| const appleCompletedCount = appleValues.filter(Boolean).length | ||
| const membershipComplete = | ||
| membershipCompletedCount === membershipValues.length | ||
| const appleComplete = appleCompletedCount === appleValues.length | ||
|
|
||
| if (!membershipComplete && appleComplete) { | ||
| return { | ||
| completedCount: appleCompletedCount, | ||
| setupComplete: true, | ||
| totalCount: appleValues.length, | ||
|
Comment on lines
+48
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Apple-only success branch allows an installation without Dodo credentials to enable membership, but Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| return { | ||
| completedCount: membershipCompletedCount, | ||
| setupComplete: membershipComplete, | ||
| totalCount: membershipValues.length, | ||
| } | ||
| } | ||
|
|
||
| export function buildMembershipWebhookUrl(apiUrl: string, provider = 'dodo') { | ||
| return `${apiUrl.replace(/\/+$/, '')}/membership/webhook/${encodeURIComponent(provider)}` | ||
| } | ||
|
|
@@ -47,3 +84,22 @@ export function getMembershipSetupChecks( | |
| webhookSigningKey: hasWebhookSigningKey, | ||
| } | ||
| } | ||
|
|
||
| export function getAppleIapSetupChecks( | ||
| config: MembershipConfigValue, | ||
| status?: MembershipCredentialStatus, | ||
| ) { | ||
| const appAppleId = Number(config.appleAppAppleId?.trim()) | ||
| const hasPrivateKey = | ||
| Boolean(config.applePrivateKey?.trim()) || | ||
| Boolean(status?.applePrivateKeyConfigured) | ||
| return { | ||
| appAppleId: Number.isSafeInteger(appAppleId) && appAppleId > 0, | ||
| bundleId: Boolean(config.appleBundleId?.trim()), | ||
| issuerId: Boolean(config.appleIssuerId?.trim()), | ||
| keyId: Boolean(config.appleKeyId?.trim()), | ||
| monthlyProductId: Boolean(config.appleMonthlyProductId?.trim()), | ||
|
Comment on lines
+96
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the other Apple fields are populated but Useful? React with 👍 / 👎. |
||
| privateKey: hasPrivateKey, | ||
| yearlyProductId: Boolean(config.appleYearlyProductId?.trim()), | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a fresh Apple-only installation,
appleChecksis calculated but never included insetupComplete; that value still reflects only the Dodo provider, API key, product, and webhook checks. Consequently the Enable toggle remains disabled unless Dodo is also configured, whileresolveAppleIapAvailabilityrequires the sharedenabledflag, making the newly added Apple IAP flow impossible to enable through this editor without unrelated Dodo credentials.Useful? React with 👍 / 👎.