Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2ee6c0b
implemented webhook handling for customer_cash_balance_transaction.cr…
AdityaK2905 Oct 27, 2025
babe292
removed webhook secret
AdityaK2905 Oct 28, 2025
6130a2a
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 28, 2025
b91d5a1
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 29, 2025
675fa04
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 29, 2025
a02eb8f
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 29, 2025
f3d228a
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 30, 2025
6bbd8dd
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 31, 2025
f043f8b
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 31, 2025
89a53eb
Auto-update feature branch with changes from the main branch
github-actions[bot] Oct 31, 2025
34389ef
fixed sortkey for payments table
AdityaK2905 Nov 1, 2025
0615799
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 1, 2025
9fcaf0b
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 2, 2025
0a43830
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 2, 2025
c85ed70
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 2, 2025
37db5bd
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 3, 2025
0cead0e
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 3, 2025
4474a03
Auto-update feature branch with changes from the main branch
github-actions[bot] Nov 3, 2025
54d91eb
added put error handling and general error handling
AdityaK2905 Nov 3, 2025
aee1aa4
added coderabbit email normalization stuff
AdityaK2905 Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/api/routes/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ScanCommand,
TransactWriteItemsCommand,
UpdateItemCommand,
PutItemCommand,
} from "@aws-sdk/client-dynamodb";
import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
import { withRoles, withTags } from "api/components/index.js";
Expand Down Expand Up @@ -332,6 +333,7 @@ const stripeRoutes: FastifyPluginAsync = async (fastify, _options) => {
sig,
secretApiConfig.stripe_links_endpoint_secret as string,
);
// event = JSON.parse(request.rawBody.toString()); <-- this is for testing without a stripe account via Curl
} catch (err: unknown) {
if (err instanceof BaseError) {
throw err;
Expand Down Expand Up @@ -715,7 +717,57 @@ Please contact Officer Board with any questions.`,
return reply
.code(200)
.send({ handled: false, requestId: request.id });
case "customer_cash_balance_transaction.created": {
const txn = event.data.object as any;

if (txn.funding_method === "bank_transfer") {
const customerId = txn.customer?.toString() ?? "UNKNOWN";
const amount = txn.net_amount;
const currency = txn.currency;
const status = txn.status;
const eventId = event.id;

request.log.info(
`Received ACH push ${status} txn ${txn.id} for ${customerId} (${amount} ${currency})`,
);

await fastify.dynamoClient.send(
new PutItemCommand({
TableName: genericConfig.StripePaymentsDynamoTableName,
Item: marshall({
primaryKey: `CUSTOMER#${customerId}`,
sortKey: `PAY#${txn.id}`,
amount,
currency,
status,
createdAt: Date.now(),
eventId,
}),
}),
);

// if (status === "succeeded") {
// await fastify.dynamoClient.send(
// new UpdateItemCommand({
// TableName: genericConfig.StripePaymentsDynamoTableName,
// Key: marshall({
// primaryKey: `CUSTOMER#${customerId}`,
// sortKey: "SUMMARY",
// }),
// UpdateExpression: "ADD totalPaid :amount SET lastUpdated = :ts",
// ExpressionAttributeValues: marshall({
// ":amount": amount,
// ":ts": Date.now(),
// }),
// })
// );
// }
}

return reply
.status(200)
.send({ handled: true, requestId: request.id });
}
default:
request.log.warn(`Unhandled event type: ${event.type}`);
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type GenericConfigType = {
CacheDynamoTableName: string;
LinkryDynamoTableName: string;
StripeLinksDynamoTableName: string;
StripePaymentsDynamoTableName: string;
EntraSecretName: string;
UpcomingEventThresholdSeconds: number;
AwsRegion: string;
Expand Down Expand Up @@ -83,6 +84,7 @@ export const commChairsGroupId = "105e7d32-7289-435e-a67a-552c7f215507";
const genericConfig: GenericConfigType = {
EventsDynamoTableName: "infra-core-api-events",
StripeLinksDynamoTableName: "infra-core-api-stripe-links",
StripePaymentsDynamoTableName: "infra-core-api-stripe-payments",
CacheDynamoTableName: "infra-core-api-cache",
LinkryDynamoTableName: "infra-core-api-linkry",
EntraSecretName: "infra-core-api-entra",
Expand Down
Loading