Skip to content

Commit 20058e1

Browse files
Copilotalexanmtz
andauthored
Refactor stripe module to TypeScript and relocate to client/payment (#1368)
* Initial plan * Update all stripe module imports to use new path Changed from ../../shared/stripe/stripe to ../../client/payment/stripe across all files Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Remove old stripe.js file after migration to TypeScript Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Fix require() statements to use .default for ES module exports Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Fix TypeScript build by using 'any' return type for stripe module Changed the return type from 'Stripe' to 'any' to maintain backward compatibility and avoid exposing pre-existing type errors in consuming code. Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com>
1 parent 01ca22e commit 20058e1

55 files changed

Lines changed: 63 additions & 62 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/controllers/webhooks/webhook-connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (process.env.NODE_ENV !== 'production') {
33
require('dotenv').config()
44
}
55

6-
import Stripe from '../../../shared/stripe/stripe'
6+
import Stripe from '../../../client/payment/stripe'
77
import { payoutCreated } from '../../../modules/webhooks/payouts'
88
import { payoutUpdated } from '../../../modules/webhooks/payouts'
99
import { payoutFailed } from '../../../modules/webhooks/payouts'

src/app/controllers/webhooks/webhook-platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (process.env.NODE_ENV !== 'production') {
33
require('dotenv').config()
44
}
55

6-
const stripe = require('../../../shared/stripe/stripe')()
6+
const stripe = require('../../../client/payment/stripe').default()
77
const chargeSucceeded = require('../../../modules/webhooks/chargeSucceeded')
88
const checkoutSessionCompleted = require('../../../modules/webhooks/checkoutSessionCompleted')
99
const customerSourceCreated = require('../../../modules/webhooks/customerSourceCreated')

src/client/payment/stripe.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Stripe from 'stripe'
2+
3+
export default (): any => {
4+
const passthroughFetch = (...args: Parameters<typeof fetch>) => fetch(...args)
5+
6+
return new Stripe(process.env.STRIPE_KEY || '', {
7+
httpClient:
8+
process.env.NODE_ENV === 'test' ? Stripe.createFetchHttpClient(passthroughFetch) : undefined
9+
})
10+
}

src/modules/orders/orderBuilds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import requestPromise from 'request-promise'
44
import URLSearchParams from 'url-search-params'
55
import * as URL from 'url'
66
import Decimal from 'decimal.js'
7-
import stripeModule from '../../shared/stripe/stripe'
7+
import stripeModule from '../../client/payment/stripe'
88
const stripe = stripeModule()
99
import Sendmail from '../mail/mail'
1010
import { userCustomerCreate } from '../users/userCustomerCreate'

src/modules/orders/orderDetails/orderFetchInvoice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Stripe from '../../../shared/stripe/stripe'
1+
import Stripe from '../../../client/payment/stripe'
22
const stripe = Stripe()
33

44
export default async function orderFetchInvoice(sourceId: any) {

src/modules/orders/orderRefund.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import models from '../../models'
22
import PaymentMail from '../mail/payment'
33
import requestPromise from 'request-promise'
44
import { handleAmount } from '../util/handle-amount/handle-amount'
5-
import stripeModule from '../../shared/stripe/stripe'
5+
import stripeModule from '../../client/payment/stripe'
66
const stripe = stripeModule()
77

88
const currentModels = models as any

src/modules/orders/orderUpdate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import requestPromise from 'request-promise'
44
import URLSearchParams from 'url-search-params'
55
import * as URL from 'url'
66

7-
import stripeModule from '../../shared/stripe/stripe'
7+
import stripeModule from '../../client/payment/stripe'
88
const stripe = stripeModule()
99

1010
const currentModels = models as any

src/modules/paymentRequestPayments/paymentRequestPaymentRefund.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import models from '../../models'
2-
import Stripe from '../../shared/stripe/stripe'
2+
import Stripe from '../../client/payment/stripe'
33

44
const stripe = Stripe()
55
const currentModels = models as any

src/modules/paymentRequests/paymentRequestBuilds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Models from '../../models'
2-
import createStripe from '../../shared/stripe/stripe'
2+
import createStripe from '../../client/payment/stripe'
33
import PaymentRequestMail from '../mail/paymentRequest'
44

55
const db = Models as any

src/modules/paymentRequests/paymentRequestUpdate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stripeModule from '../../shared/stripe/stripe'
1+
import stripeModule from '../../client/payment/stripe'
22
const stripe = stripeModule()
33
import Models from '../../models'
44

0 commit comments

Comments
 (0)