Skip to content

feat: cores iap #2783

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

Merged
merged 13 commits into from
Apr 30, 2025
Merged

feat: cores iap #2783

merged 13 commits into from
Apr 30, 2025

Conversation

capJavert
Copy link
Contributor

@capJavert capJavert commented Apr 24, 2025

  • support for IAP and one time purchases
  • refactor apple webhooks file to common to split and reuse common logic
  • will work on adding mores tests for IAP flow in next PR after some sandbox testing e2e if needed
@capJavert capJavert self-assigned this Apr 24, 2025
import type { Block, KnownBlock } from '@slack/web-api';
import { webhooks } from '../slack';

export const isCorePurchaseApple = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New file for Cores related and IAP

import type { Block, KnownBlock } from '@slack/web-api';
import { webhooks } from '../slack';

const getSubscriptionStatus = (
Copy link
Contributor Author

@capJavert capJavert Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly code from webhooks file, subscription related

'/usr/local/share/ca-certificates/AppleRootCA-G3.cer',
];

const getVerifierEnvironment = (): Environment => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly code from webhooks file, for reuse

import { readFile } from 'fs/promises';
import { isTest } from '../utils';

export const verifyAndDecodeAppleSignedData = async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method for decoding both signed data

@@ -250,30 +69,23 @@ const handleNotifcationRequest = async (
return response.status(200).send({ received: true });
}

// Check if the event is a subscription event
// NOTE: When adding support for purchasing cores, we must remove this check as it's not a subscription event
if (isNullOrUndefined(notification?.data?.signedRenewalInfo)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved check down only if subscription transaction type

@capJavert capJavert marked this pull request as ready for review April 25, 2025 12:51
@capJavert capJavert requested a review from a team as a code owner April 25, 2025 12:51
requiredRole: CoresRole.User,
}) === false
) {
throw new Error('User does not have access to cores purchase');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we going to do if the user paid and isn't eligible?

Copy link
Contributor Author

@capJavert capJavert Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are blocked on the client side as well, so its mostly another check, we do it on paddle side as well

we would handle it case by case basis, do you want to handle somehow differently?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there's also much logic even here that can be reused, am i missing anything?
if we define a common type with all the info from apple/paddle and have one function that checks access, create transactions, etc. it should be better, isn't it? again hard to review this specifically as it's going to change once we go production

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, transaction creation is different on apple and paddle, also detection of product type. I imagine that any new provider will also have it different, so I think its actually nicer for now to keep the logics separate.

What could be done is to create a generic provider interface which would standardize what we expect for each provider, but that requires refactoring how apple and paddle webhooks work now (which is quite different) so it would be separate work from this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to add the spec for this in a task, and link back so you can see.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense

@capJavert capJavert requested a review from idoshamun April 28, 2025 10:47
Copy link
Member

@idoshamun idoshamun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. Looks good

@capJavert capJavert merged commit c0469ac into main Apr 30, 2025
8 checks passed
@capJavert capJavert deleted the cores-iap branch April 30, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
X