-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: I can choose a storage pricing tier (issue 1869) #1878
feat: I can choose a storage pricing tier (issue 1869) #1878
Conversation
#1876) * Add typechecking via tsc to packages/api and start WIP billing/stripe save logic * fix type check * rm new stripe stuff for now. just focus on tsc * fix bug in pagination from bad merge * remove unneeded .paths in packages/api/tsconfig.json * build: packages/api build script runs typecheck * Revert "rm new stripe stuff for now. just focus on tsc" This reverts commit 7957f38. * wip * packages/api typecheck checks test dir * feat: split out plans page, start planning onboard mods * fix typecheck on new billing tests * fix test * fix tests * PUT /user/payment API calls saveUserPayments * add packages/api/test/stripe.spec.js * wip stripe * add user_customer table and use in StripeCustomersService * finish StripeCustomersService#getOrCreateUser * cf workers tests use a createTestBillingContext * narrow type on createStripeBillingContext * StripeCustomersService has a stripe instance with paymentMethods.attach * StripeBillingService calls stripe.paymentMethods.attach * tests pass * working stripe userPaymentGet * fix getUserCustomer when no customer is set * Fix StripeBillingService tests * add test 'can userPaymentPut and then userPaymentGet' * userPaymentGet includes stripe.com card info if paymentMethod is a stripe card * wip * feat: split out plans page, start planning onboard mods * website playwright has globalTeardown that runs 'npm stop' * ci: website workflow sets STRIPE_SECRET_KEY * wip * get rid of playwright globalTeardown as it seems to prevent writing of html reporter * add db migration 023-add-user-customer-table.sql * add STRIPE_SECRET_KEY (commented) to .env.tpl * rm env.mockStripePaymentMethodId * relocate some things * rename db stripe.spec.js -> billing.spec.js * increase timeout of test w3name backward compatibility proxy * db mocha hooks log more to debug failed ci * feat: get and update cards with loading * feat: rework payment page to consolidated version * feat: plan switching by role * feat: re-arrange payment page, add loading states and move form into modal * fix: while loading cards dont show buttons * fix: move buttons into component * website/pages/account/payment uses env var NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY instead of old one ('..._TEST_PK') * website test-e2e has env var NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY * account payment page throws if not STRIPE_PUBLISHABLE_KEY * fix how payment page constructs Stripe * fix accountPayment.e2e test with new design * change how website gets stripe config and logging for debug * wip * website test-e2e doesnt set STRIPE_SECRET_KEY at all * only log STRIPE_SECRET_KEY length * clean up diff Co-authored-by: Adam Munns <adam@whetinteractive.com>
…entMethod is saved
…fferently on save
packages/website/components/accountPlansModal/accountPlansModal.js
Outdated
Show resolved
Hide resolved
…ub.com:web3-storage/web3.storage into 1869-i-can-choose-a-storage-subscription-price
…ub.com:web3-storage/web3.storage into 1869-i-can-choose-a-storage-subscription-price
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.
This looks great 💯 with the caveat that I didn't pull it down and try to run it, just read through the diff.
@gobengo you did a great job testing the stripe API boundary IMO - I especially like the assertions on the number of API calls & verification that they were called with the right args.
Looks really nicely put together overall, great job guys.
const method = { id: paymentMethodId } | ||
const subscriptionInput = requestBody?.subscription | ||
if (typeof subscriptionInput !== 'object') { | ||
throw Object.assign(new Error(`subscription must be an object, but got ${typeof subscriptionInput}`), { status: 400 }) |
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.
Hadn't seen this pattern for adding "ad-hoc" fields to an Error
before. Pretty clever 👍
@@ -117,6 +117,10 @@ export class Logging { | |||
} | |||
|
|||
async postBatch () { | |||
if (process.env.NODE_ENV === 'development') { |
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.
good call 🙂
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.
It was slowing down my tests! :P
it('can saveSubscription between prices using real stripe.com API', async function () { | ||
// ensure stripeSecretKey and use it to construct stripe | ||
const stripeSecretKey = process.env.STRIPE_SECRET_KEY | ||
if (!stripeSecretKey) { |
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.
that's cool - for some reason it never occurred to me that you could skip a test dynamically like that; I've always just added it to the it
call if I knew it wasn't going to pass for some reason.
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.
(FWIW me too, I think I copypastad the it.skip()
otherwise I might not have thought about it)
<span> | ||
Your current plan is: <strong>{currentPlan.title}</strong> | ||
</span> | ||
<small>Billing Cycle: Aug 18 - Sept 18</small> |
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.
This probably shouldn't be hard-coded 😛
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.
Oy. Good catch. Thank you!
Co-authored-by: Yusef Napora <yusef@napora.org>
🤖 I have created a release *beep* *boop* --- ## [7.6.0](api-v7.5.1...api-v7.6.0) (2022-09-20) ### Features * I can choose a storage pricing tier (issue 1869) ([#1878](#1878)) ([58de180](58de180)) * put write to cluster behind a flag ([#1785](#1785)) ([eae75d2](eae75d2)) * send timing info to logtail. Time r2 & s3. ([#1908](#1908)) ([8dff635](8dff635)) * use sha256 checksum for r2.put ([#1910](#1910)) ([d277ba0](d277ba0)) ### Other Changes * add a script that generates many uploads ([#1790](#1790)) ([e38b7a0](e38b7a0)) * encode sha256 hash as hex for r2 put ([#1911](#1911)) ([3d66fa9](3d66fa9)) * silence logging debug statements in test/dev ([#1870](#1870)) ([a576131](a576131)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…1913) Motivation: * fix bug discovered while testing on staging #1878 * bug prevented adding a payment method for the first time in both 'add payment form' in lower left of payment page as well as the form in the accountPlanModal * I think this was introduced in [this commit](8adff7b) after last PR review [approval](#1878 (review)) Co-authored-by: Adam Munns <adam@whetinteractive.com>
🤖 I have created a release *beep* *boop* --- ## [2.20.0](website-v2.19.1...website-v2.20.0) (2022-09-21) ### Features * I can choose a storage pricing tier (issue 1869) ([#1878](#1878)) ([58de180](58de180)) ### Bug Fixes * bugs saving credit card at /account/payment for the first time ([#1913](#1913)) ([724e3ab](724e3ab)) * make browser update versions absolute ([#1887](#1887)) ([bca96fa](bca96fa)) ### Other Changes * **docs:** add curl CAR upload example to store howto ([#1735](#1735)) ([54e31d9](54e31d9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
works on prod |
Motivation:
Parts
userPaymentPut
added test here
added here
Opt-in to getting a realistic paymentSettings.subscription:
GET /user/payment?mockSubscription=true
saveStorageSubscription
and use fromuserPaymentPut
saveStorageSubscription
with services backed by stripe.com APIsgetStorageSubscription(customer)
getStorageSubscription(customer) called from api userPaymentGet