Skip to content

Commit d756f96

Browse files
chore: wip
1 parent 485be43 commit d756f96

File tree

7 files changed

+29
-21
lines changed

7 files changed

+29
-21
lines changed

app/Actions/Payment/FetchTransactionHistoryAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default new Action({
1010
const userId = Number(request.getParam('id'))
1111
const user = await User.find(userId)
1212

13-
const transactions = await user?.subscriptionHistory()
13+
const transactions = await user?.transactionHistory()
1414

1515
return transactions
1616
},

resources/views/dashboard/components/billing/one-time-payment.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { useBillable } from '../../../../functions/billing/payments'
44
import PaymentForm from './payment-form.vue'
55
66
interface Props {
7-
product: number
7+
product: number,
8+
paymentIntent: string,
89
}
910
1011
const props = defineProps<Props>()
@@ -39,6 +40,6 @@ onMounted(async () => {
3940
</div>
4041
</li>
4142
</ul>
42-
<PaymentForm :product-id="1" :price="unitPrice" class="w-2/3" />
43+
<PaymentForm :paymentIntent="props.paymentIntent" :product-id="1" :price="unitPrice" class="w-2/3" />
4344
</div>
4445
</template>

resources/views/dashboard/components/billing/payment-form.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { useBillable } from '../../../../functions/billing/payments'
33
44
interface Props {
55
productId: number
6-
price: string
6+
price: string,
7+
paymentIntent: string,
78
}
89
910
const props = defineProps<Props>()
@@ -13,12 +14,9 @@ const { loadPaymentForm, handlePayment } = useBillable()
1314
const paymentStore = usePaymentStore()
1415
1516
const element = ref(null as any)
16-
let clientSecret: string
1717
1818
onMounted(async () => {
19-
clientSecret = await paymentStore.fetchPaymentIntent(1, props.productId)
20-
21-
element.value = await loadPaymentForm(clientSecret)
19+
element.value = await loadPaymentForm(props.paymentIntent)
2220
})
2321
2422
async function pay() {

resources/views/dashboard/settings/billing.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<script setup lang="ts">
22
import { useBillable } from '../../../functions/billing/payments'
33
4-
// import ActivePlan from '../components/billing/active-plan.vue'
4+
import ActivePlan from '../components/billing/active-plan.vue'
55
6-
// import PaymentMethod from '../components/billing/payment-method.vue'
7-
// import Plans from '../components/billing/plans.vue'
6+
import PaymentMethod from '../components/billing/payment-method.vue'
7+
import Plans from '../components/billing/plans.vue'
88
9-
// import LoadingDetails from '../components/skeleton/loading-card.vue'
10-
// import TransactionHistory from '../components/transaction/index.vue'
11-
12-
import OneTimePayment from '../components/billing/one-time-payment.vue'
9+
import LoadingDetails from '../components/skeleton/loading-card.vue'
10+
import TransactionHistory from '../components/transaction/index.vue'
1311
1412
const { isEmpty, showCurrentPlan } = useBillable()
1513
@@ -28,7 +26,7 @@ onMounted(async () => {
2826

2927
<template>
3028
<div class="mx-auto px-4 py-8 container lg:px-8">
31-
<!-- <div id="subscribed">
29+
<div id="subscribed">
3230
<TransactionHistory />
3331
<div class="flex space-x-8">
3432
<div class="mt-16 w-2/3 bg-white px-8 py-6 shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
@@ -40,8 +38,6 @@ onMounted(async () => {
4038
</div>
4139
<PaymentMethod />
4240
</div>
43-
</div> -->
44-
45-
<OneTimePayment :product="1" />
41+
</div>
4642
</div>
4743
</template>

storage/framework/core/orm/src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,6 @@ export async function generateModelString(
12781278
return updatedPaymentMethod
12791279
}
12801280
1281-
12821281
async deletePaymentMethod(paymentMethodId: number): Promise<Stripe.Response<Stripe.PaymentMethod>> {
12831282
const deletedPaymentMethod = await managePaymentMethod.deletePaymentMethod(this, paymentMethodId)
12841283
return deletedPaymentMethod
@@ -1316,6 +1315,10 @@ export async function generateModelString(
13161315
return manageInvoice.list(this)
13171316
}
13181317
1318+
async transactionHistory(): Promise<TransactionModel[]> {
1319+
return manageTransaction.list(this)
1320+
}
1321+
13191322
async stripeSubscriptions(): Promise<Stripe.Response<Stripe.ApiList<Stripe.Invoice>>> {
13201323
return manageInvoice.list(this)
13211324
}

storage/framework/core/payments/src/billable/transaction.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ export const manageTransaction: ManageTransaction = (() => {
2525
return transaction
2626
}
2727

28-
return { store }
28+
async function list(user: UserModel): Promise<TransactionModel[]> {
29+
const transaction = await Transaction.where('user_id', user.id).get()
30+
31+
return transaction
32+
}
33+
34+
return { store, list }
2935
})()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,10 @@ export class UserModel {
948948
return manageInvoice.list(this)
949949
}
950950

951+
async transactionHistory(): Promise<TransactionModel[]> {
952+
return manageTransaction.list(this)
953+
}
954+
951955
async stripeSubscriptions(): Promise<Stripe.Response<Stripe.ApiList<Stripe.Invoice>>> {
952956
return manageInvoice.list(this)
953957
}

0 commit comments

Comments
 (0)