File tree Expand file tree Collapse file tree 6 files changed +58
-4
lines changed Expand file tree Collapse file tree 6 files changed +58
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export { default as hashing } from '../../../../config/hashing'
11
11
export { default as library } from '../../../../config/library'
12
12
export { default as page } from '../../../../config/page'
13
13
export { default as notification } from '../../../../config/notification'
14
+ export { default as payment } from '../../../../config/payment'
14
15
export { default as searchEngine } from '../../../../config/search-engine'
15
16
export { default as services } from '../../../../config/services'
16
17
export { default as storage } from '../../../../config/storage'
Original file line number Diff line number Diff line change 44
44
"typecheck" : " tsc --noEmit"
45
45
},
46
46
"dependencies" : {
47
- "@stripe/stripe-js" : " ^1.46.0"
47
+ "@stripe/stripe-js" : " ^1.46.0" ,
48
+ "stripe" : " ^11.11.0"
48
49
},
49
50
"devDependencies" : {
50
51
"@stacksjs/testing" : " workspace:*" ,
Original file line number Diff line number Diff line change 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
+ }
Original file line number Diff line number Diff line change 1
1
export interface PaymentOptions {
2
2
drivers : {
3
3
stripe : {
4
- key : env ( 'STRIPE_API_KEY' , 'pk_test' )
4
+ key : string ;
5
5
}
6
6
}
7
7
}
8
+
9
+ export interface ChargeOptions {
10
+ currency ?: string ,
11
+ source ?: string ,
12
+ description ?: string
13
+ }
Original file line number Diff line number Diff line change 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
+ }
You can’t perform that action at this time.
0 commit comments