Skip to content

[stripe] Use AttributionID metadata when querying for customers #12921

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 1 commit into from
Sep 13, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Sep 13, 2022

Description

Use attributionId when querying for customers, instead team/user Id

Related Issue(s)

Fixes #

How to test

  1. Go to preview
  2. Create team with name Gitpod-something
  3. Enable billing
  4. See billing enables OK
  5. Check in Test Stripe account customer has attributionId:... set

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ force-pushed the mp/server-stripe-attribution-id branch from 27adefa to 00ad1c5 Compare September 13, 2022 14:01
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mp-server-stripe-attribution-id.1 because the annotations in the pull request description changed
(with .werft/ from main)

@easyCZ easyCZ changed the title [stripe] Use AttributionID metadat when querying for customers [stripe] Use AttributionID metadata when querying for customers Sep 13, 2022
@easyCZ
Copy link
Member Author

easyCZ commented Sep 13, 2022

/werft run with-preview with-billing

👍 started the job as gitpod-build-mp-server-stripe-attribution-id.2
(with .werft/ from main)

@easyCZ
Copy link
Member Author

easyCZ commented Sep 13, 2022

/werft run with-preview with-payment

👍 started the job as gitpod-build-mp-server-stripe-attribution-id.3
(with .werft/ from main)

@easyCZ easyCZ marked this pull request as ready for review September 13, 2022 15:00
@easyCZ easyCZ requested a review from a team September 13, 2022 15:00
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 13, 2022
Copy link
Member

@svenefftinge svenefftinge left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up! Would be great to also generalize the methods in StripeService.
I.e. have findByAttributionID and createCustomerForAttributionID.

@@ -34,11 +36,15 @@ export class StripeService {
}

async findCustomerByUserId(userId: string): Promise<Stripe.Customer | undefined> {
return this.findCustomerByQuery(`metadata['userId']:'${userId}'`);
return this.findCustomerByQuery(
`metadata['${ATTRIBUTION_ID_METADATA_KEY}']:'${AttributionId.render({ kind: "user", userId })}'`,
Copy link
Member

Choose a reason for hiding this comment

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

do you plan to manually update existing customers?

Copy link
Member Author

Choose a reason for hiding this comment

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

They've already been updated. The previous PR changed the subscription queries to set the attribution ID alongside the previous team/user id, this now removes old I'd usage

@roboquat roboquat merged commit 759e588 into main Sep 13, 2022
@roboquat roboquat deleted the mp/server-stripe-attribution-id branch September 13, 2022 15:14
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/S team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants