Skip to content

Commit c0c08af

Browse files
chore: wip
1 parent 7d828d1 commit c0c08af

36 files changed

+151
-109
lines changed

app/Actions/Payment/CancelSubscriptionAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ export default new Action({
77
description: 'Cancel Subscription for stripe',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10+
const userId = Number(request.getParam('id'))
1011
const providerId = request.get('providerId') as string
1112

12-
const user = await User.find(1)
13+
const user = await User.find(userId)
1314

1415
const subscription = await user?.cancelSubscription(providerId)
1516

app/Actions/Payment/CreateCheckoutAction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import type { RequestInstance } from '@stacksjs/types'
12
import { Action } from '@stacksjs/actions'
23
import User from '../../../storage/framework/orm/src/models/User.ts'
34

45
export default new Action({
56
name: 'CreateCheckoutAction',
67
description: 'Create Checkout link for stripe',
78
method: 'POST',
8-
async handle() {
9-
const user = await User.find(1)
9+
async handle(request: RequestInstance) {
10+
const userId = Number(request.getParam('id'))
11+
12+
const user = await User.find(userId)
1013

1114
const checkout = await user?.checkout([
1215
{

app/Actions/Payment/CreateInvoiceSubscription.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import type { RequestInstance } from '@stacksjs/types'
12
import { Action } from '@stacksjs/actions'
23
import User from '../../../storage/framework/orm/src/models/User.ts'
34

45
export default new Action({
56
name: 'CreateInvoiceSubscription',
67
description: 'Create Invoice Subscription for Stripe',
78
method: 'POST',
8-
async handle() {
9-
const user = await User.find(1)
9+
async handle(request: RequestInstance) {
10+
const userId = Number(request.getParam('id'))
11+
12+
const user = await User.find(userId)
1013

1114
const subscription = await user?.newSubscriptionInvoice('pro', 'stacks_pro_monthly')
1215

app/Actions/Payment/CreatePaymentIntentAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ export default new Action({
77
description: 'Create Payment Intent for stripe',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10+
const userId = Number(request.getParam('id'))
1011
const amount = Number(request.get('amount'))
1112

12-
const user = await User.find(1)
13+
const user = await User.find(userId)
1314

1415
const paymentIntent = await user?.paymentIntent({
1516
amount,

app/Actions/Payment/CreateSetupIntentAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export default new Action({
77
description: 'Create Setup Intent for stripe',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10-
const user = await User.find(1)
10+
const userId = Number(request.getParam('id'))
11+
const user = await User.find(userId)
1112

1213
const setupIntent = await user?.createSetupIntent()
1314

app/Actions/Payment/CreateSubscriptionAction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export default new Action({
77
description: 'Create Subscription for stripe',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10+
const userId = Number(request.getParam('id'))
11+
1012
const type = request.get('type') as string
1113
const plan = request.get('plan') as string
1214
const period = request.get('period') as string
1315
const description = request.get('description') as string
1416

15-
const user = await User.find(1)
17+
const user = await User.find(userId)
1618

1719
const subscription = await user?.newSubscription(plan, type, { description, metadata: { period } })
1820

app/Actions/Payment/DeleteDefaultPaymentAction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export default new Action({
77
description: 'Delete the customers default payment method',
88
method: 'POST',
99
async handle(request: RequestInstance) {
10-
const user = await User.find(1)
10+
const userId = Number(request.getParam('id'))
11+
12+
const user = await User.find(userId)
1113
const paymentMethod = request.get('paymentMethod') as string
1214

1315
await user?.deletePaymentMethod(paymentMethod)

app/Actions/Payment/FetchActiveSubscriptionAction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export default new Action({
66
description: 'Fetch the current active subscription',
77
method: 'GET',
88
async handle() {
9-
const user = await User.find(1)
9+
const userId = Number(request.getParam('id'))
10+
11+
const user = await User.find(userId)
1012

1113
const subscription = await user?.activeSubscription()
1214

app/Actions/Payment/FetchDefaultPaymentMethodAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default new Action({
66
description: 'Fetch the users default payment method',
77
method: 'GET',
88
async handle() {
9-
const user = await User.find(1)
9+
const userId = Number(request.getParam('id'))
10+
const user = await User.find(userId)
1011

1112
const paymentMethod = await user?.defaultPaymentMethod()
1213

app/Actions/Payment/FetchPaymentCustomerAction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import type { RequestInstance } from '@stacksjs/types'
12
import { Action } from '@stacksjs/actions'
23
import User from '../../../storage/framework/orm/src/models/User.ts'
34

45
export default new Action({
56
name: 'FetchPaymentCustomerAction',
67
description: 'Fetch the payment customer',
78
method: 'GET',
8-
async handle() {
9-
const user = await User.find(1)
9+
async handle(request: RequestInstance) {
10+
const id = Number(request.getParam('id'))
11+
12+
const user = await User.find(id)
1013

1114
const customer = await user?.asStripeUser()
1215

0 commit comments

Comments
 (0)