Skip to content

Commit 611a230

Browse files
committed
chore: wip
1 parent 2c273f6 commit 611a230

File tree

6 files changed

+58
-4
lines changed

6 files changed

+58
-4
lines changed

.stacks/core/config/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export { default as hashing } from '../../../../config/hashing'
1111
export { default as library } from '../../../../config/library'
1212
export { default as page } from '../../../../config/page'
1313
export { default as notification } from '../../../../config/notification'
14+
export { default as payment } from '../../../../config/payment'
1415
export { default as searchEngine } from '../../../../config/search-engine'
1516
export { default as services } from '../../../../config/services'
1617
export { default as storage } from '../../../../config/storage'

.stacks/core/payments/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"typecheck": "tsc --noEmit"
4545
},
4646
"dependencies": {
47-
"@stripe/stripe-js": "^1.46.0"
47+
"@stripe/stripe-js": "^1.46.0",
48+
"stripe": "^11.11.0"
4849
},
4950
"devDependencies": {
5051
"@stacksjs/testing": "workspace:*",
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
export {}
1+
import { payment as config } from '@stacksjs/config'
2+
3+
const stripe = require('stripe')(config.drivers.stripe.key);
4+
5+
const balance = async () => {
6+
return await stripe.balance.retrieve()
7+
}
8+
9+
const balanceTransactions = async (txn: string) => {
10+
return await stripe.balanceTransactions.retrieve(txn)
11+
}
12+
13+
const dispute = async (txn: string) => {
14+
return await stripe.disputes.retrieve(txn);
15+
}
16+
17+
const charge = async (amount: number, options?: object) => {
18+
await stripe.charges.create({
19+
amount: amount,
20+
...options
21+
});
22+
}
23+
24+
export {
25+
balance,
26+
balanceTransactions,
27+
charge,
28+
dispute
29+
}

.stacks/core/types/src/payments.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
export interface PaymentOptions {
22
drivers: {
33
stripe: {
4-
key: env('STRIPE_API_KEY', 'pk_test')
4+
key: string;
55
}
66
}
77
}
8+
9+
export interface ChargeOptions {
10+
currency?: string,
11+
source?: string,
12+
description?: string
13+
}

config/payment.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
import type { PaymentOptions } from '@stacksjs/types'
1+
import { type PaymentOptions } from '@stacksjs/types'
2+
3+
export default <PaymentOptions> {
4+
drivers: {
5+
stripe: {
6+
key: env('STRIPE_API_KEY', 'pk_test')
7+
}
8+
}
9+
}

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)