Skip to content

Commit 2feb95a

Browse files
chore: wip
1 parent ee45143 commit 2feb95a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

app/Actions/Payment/CreateCheckoutAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default new Action({
99
async handle(request: RequestInstance) {
1010
const user = await User.find(1)
1111

12-
const checkout = await user?.checkout({ price_1QBEfsBv6MhUdo23avVV0kqx: 1 })
12+
const checkout = await user?.checkout({ price_1QBEfsBv6MhUdo23avVV0kqx: 1 }, { automatic_tax: { enabled: true } })
1313

1414
return checkout
1515
},

app/Actions/Payment/UpdateCustomerAction.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ export default new Action({
77
description: 'Update customer detauls',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10-
const amount = Number(request.get('amount'))
11-
1210
const user = await User.find(1)
1311

14-
const paymentIntent = await user?.paymentIntent({
15-
amount,
16-
currency: 'usd',
17-
description: 'Subscription to Stacks Pro',
18-
payment_method_types: ['card'],
19-
})
12+
const customer = await user?.syncStripeCustomerDetails({ address: {
13+
line1: '123 Elm St',
14+
city: 'Austin',
15+
state: 'TX',
16+
postal_code: '78701',
17+
country: 'US',
18+
}})
2019

21-
return paymentIntent
20+
return customer
2221
},
2322
})

routes/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ route.post('/ai/summary', 'Actions/AI/SummaryAction')
2727

2828
route.post('/stripe/create-payment-intent', 'Actions/Payment/CreatePaymentIntentAction')
2929
route.post('/stripe/create-subscription', 'Actions/Payment/CreateSubscriptionAction')
30+
route.post('/stripe/update-customer', 'Actions/Payment/UpdateCustomerAction')
31+
route.post('/stripe/checkout', 'Actions/Payment/CreateCheckoutAction')
3032

3133
// route.group('/some-path', async () => {...})
3234
// route.action('/example') // equivalent to `route.get('/example', 'ExampleAction')`

storage/framework/orm/src/models/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ export class UserModel {
738738

739739
async checkout(
740740
priceIds: Record<string, number | undefined>,
741-
options: Partial<Stripe.Checkout.SessionCreateParams> = {},
741+
options: Partial<Stripe.Checkout.SessionCreateParams> = {},
742742
): Promise<Stripe.Response<Stripe.Checkout.Session>> {
743743
const defaultOptions: Partial<Stripe.Checkout.SessionCreateParams> = {
744744
mode: 'payment',

0 commit comments

Comments
 (0)