Skip to content

Commit 72450c9

Browse files
fix(stripe): parse request body before it reaches validation (#1982)
1 parent a43ac15 commit 72450c9

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

docker/dev/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ services:
7373
CARD_PIN_HREF: ${CARD_PIN_HREF}
7474
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
7575
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
76+
USE_STRIPE: ${USE_STRIPE}
7677
restart: always
7778
networks:
7879
- testnet

docker/prod/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ services:
7777
GATEHUB_CARD_PP_PREFIX: ${WALLET_BACKEND_GATEHUB_CARD_PP_PREFIX}
7878
STRIPE_SECRET_KEY: ${WALLET_BACKEND_STRIPE_SECRET_KEY}
7979
STRIPE_WEBHOOK_SECRET: ${WALLET_BACKEND_STRIPE_WEBHOOK_SECRET}
80+
USE_STRIPE: ${USE_STRIPE}
8081
networks:
8182
- testnet
8283
ports:

packages/wallet/backend/src/config/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const envSchema = z.object({
5151
CARD_PIN_HREF: z.string().default('UPDATEME'),
5252
STRIPE_SECRET_KEY: z.string().default('STRIPE_SECRET_KEY'),
5353
STRIPE_WEBHOOK_SECRET: z.string().default('STRIPE_WEBHOOK_SECRET'),
54-
USE_STRIPE: z.boolean().default(false)
54+
USE_STRIPE: z.coerce.boolean().default(false)
5555
})
5656

5757
export type Env = z.infer<typeof envSchema>

packages/wallet/backend/src/stripe-integration/controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export class StripeController implements IStripeController {
4646
throw new BadRequest('Invalid stripe webhook signature')
4747
}
4848

49+
const parsedBody = JSON.parse(req.body.toString())
50+
req.body = parsedBody
51+
4952
const wh = await validate(webhookBodySchema, req)
5053
await this.stripeService.onWebHook(wh.body)
5154
res.status(200).send()

packages/wallet/backend/src/stripe-integration/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class StripeService implements IStripeService {
4848
try {
4949
await this.gateHubClient.createTransaction({
5050
amount,
51-
vault_uuid: this.gateHubClient.getVaultUuid(currency),
51+
vault_uuid: this.gateHubClient.getVaultUuid(currency.toUpperCase()),
5252
receiving_address,
5353
sending_address: this.env.GATEHUB_SETTLEMENT_WALLET_ADDRESS,
5454
type: TransactionTypeEnum.HOSTED,

0 commit comments

Comments
 (0)