Skip to content
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: update Stripe plan in PlansStorage#set #318

Closed
wants to merge 13 commits into from
Closed
3 changes: 3 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ R2_SECRET_ACCESS_KEY = ''
R2_UCAN_BUCKET_NAME = ''
R2_DELEGATION_BUCKET_NAME = ''
SATNAV_BUCKET_NAME = ''
STRIPE_SECRET_KEY = ''

# Following variables are only required to run integration tests

Expand All @@ -44,6 +45,8 @@ MAILSLURP_TIMEOUT = '120000'
# these values are from the Stripe test environment
STRIPE_PRICING_TABLE_ID = 'prctbl_1NzhdvF6A5ufQX5vKNZuRhie'
STRIPE_PUBLISHABLE_KEY = 'pk_test_51LO87hF6A5ufQX5viNsPTbuErzfavdrEFoBuaJJPfoIhzQXdOUdefwL70YewaXA32ZrSRbK4U4fqebC7SVtyeNcz00qmgNgueC'
# this is used in tests and should always be set to the test env secret key
STRIPE_TEST_SECRET_KEY = ''

# Feature flags
REQUIRE_PAYMENT_PLAN = 'true'
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
AWS_REGION: 'us-west-2'
AWS_ACCESS_KEY_ID: 'NOSUCH'
AWS_SECRET_ACCESS_KEY: 'NOSUCH'
STRIPE_TEST_SECRET_KEY: ${{ secrets.STRIPE_TEST_SECRET_KEY }}
4 changes: 2 additions & 2 deletions billing/tables/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const createCustomerStore = (conf, { tableName }) => ({
Key: marshall({ customer }),
UpdateExpression: 'SET product = :product, updatedAt = :updatedAt',
ExpressionAttributeValues: marshall({
product,
updatedAt: new Date().toISOString()
':product': product,
':updatedAt': new Date().toISOString()
travis marked this conversation as resolved.
Show resolved Hide resolved
})
}))
if (res.$metadata.httpStatusCode !== 200) {
Expand Down
155 changes: 102 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions stacks/billing-db-stack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table } from '@serverless-stack/resources'
import { Table, Config } from '@serverless-stack/resources'
import { customerTableProps } from '../billing/tables/customer.js'
import { spaceDiffTableProps } from '../billing/tables/space-diff.js'
import { spaceSnapshotTableProps } from '../billing/tables/space-snapshot.js'
Expand All @@ -23,5 +23,7 @@ export const BillingDbStack = ({ stack }) => {
usageTable: usageTable.tableName
})

return { customerTable, spaceSnapshotTable, spaceDiffTable, usageTable }
const stripeSecretKey = new Config.Secret(stack, 'STRIPE_SECRET_KEY')

return { customerTable, spaceSnapshotTable, spaceDiffTable, usageTable, stripeSecretKey }
}
5 changes: 2 additions & 3 deletions stacks/billing-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function BillingStack ({ stack, app }) {
customerTable,
spaceSnapshotTable,
spaceDiffTable,
usageTable
usageTable,
stripeSecretKey
} = use(BillingDbStack)
const { subscriptionTable, consumerTable } = use(UploadDbStack)

Expand Down Expand Up @@ -113,8 +114,6 @@ export function BillingStack ({ stack, app }) {
}
})

const stripeSecretKey = new Config.Secret(stack, 'STRIPE_SECRET_KEY')

// Lambda that sends usage table records to Stripe for invoicing.
const usageTableHandler = new Function(stack, 'usage-table-handler', {
permissions: [spaceSnapshotTable, spaceDiffTable],
Expand Down
5 changes: 3 additions & 2 deletions stacks/upload-api-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function UploadApiStack({ stack, app }) {
const { carparkBucket } = use(CarparkStack)
const { storeTable, uploadTable, delegationBucket, delegationTable, revocationTable, adminMetricsTable, spaceMetricsTable, consumerTable, subscriptionTable, rateLimitTable, pieceTable, privateKey } = use(UploadDbStack)
const { invocationBucket, taskBucket, workflowBucket, ucanStream } = use(UcanInvocationStack)
const { customerTable, spaceDiffTable, spaceSnapshotTable } = use(BillingDbStack)
const { customerTable, spaceDiffTable, spaceSnapshotTable, stripeSecretKey } = use(BillingDbStack)
const { pieceOfferQueue, filecoinSubmitQueue } = use(FilecoinStack)

// Setup API
Expand Down Expand Up @@ -113,7 +113,8 @@ export function UploadApiStack({ stack, app }) {
},
bind: [
privateKey,
ucanInvocationPostbasicAuth
ucanInvocationPostbasicAuth,
stripeSecretKey
]
}
},
Expand Down
Loading
Loading