Skip to content

Commit a107824

Browse files
committed
@trigger.dev/stripe: Added PaymentIntent and Payout trigger events
1 parent 6ad9112 commit a107824

File tree

8 files changed

+1477
-52
lines changed

8 files changed

+1477
-52
lines changed

.changeset/rich-emus-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/stripe": patch
3+
---
4+
5+
Added additional triggers for PaymentIntent and Payout events

apps/webapp/app/routes/api.internal.stripe_webhooks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export async function action({ request }: ActionArgs) {
1919
},
2020
body: JSON.stringify({
2121
title: body.type,
22-
content: body,
22+
content: {
23+
...body,
24+
example: { id: body.type, name: body.type, icon: "stripe", payload: body.data.object },
25+
},
2326
readOnly: true,
2427
}),
2528
});

docs/integrations/apis/stripe.mdx

Lines changed: 80 additions & 41 deletions
Large diffs are not rendered by default.

examples/job-catalog/src/stripe.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,14 @@ client.defineJob({
186186
},
187187
});
188188

189+
client.defineJob({
190+
id: "stripe-on-charge",
191+
name: "Stripe On Charge",
192+
version: "0.1.0",
193+
trigger: stripe.onCharge(),
194+
run: async (payload, io, ctx) => {
195+
await io.logger.info("ctx", { ctx });
196+
},
197+
});
198+
189199
createExpressServer(client);

integrations/stripe/src/events.ts

Lines changed: 232 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import type { EventSpecification } from "@trigger.dev/sdk";
22
import {
3+
amountCapturablePaymentIntentExample,
4+
cancelledPaymentIntentExample,
35
cancelledSubscriptionExample,
6+
capturedChargeExample,
47
checkoutSessionExample,
8+
createdCustomerExample,
9+
createdPaymentIntentExample,
510
customerSubscriptionExample,
11+
deletedCustomerExample,
12+
failedChargeExample,
13+
failedPaymentIntentExample,
614
pausedSubscriptionExample,
15+
refundedChargeExample,
16+
succeededChargeExample,
17+
succeededPaymentIntentExample,
18+
updatedAccountExample,
719
updatedSubscriptionExample,
820
} from "./examples";
921
import {
@@ -13,6 +25,8 @@ import {
1325
OnCustomerEvent,
1426
OnCustomerSubscription,
1527
OnExternalAccountEvent,
28+
OnPaymentIntentEvent,
29+
OnPayoutEvent,
1630
OnPersonEvent,
1731
OnPriceEvent,
1832
OnProductEvent,
@@ -467,7 +481,7 @@ export const onAccountUpdated: EventSpecification<OnAccountEvent> = {
467481
title: "On Account Updated",
468482
source: "stripe.com",
469483
icon: "stripe",
470-
examples: [],
484+
examples: [updatedAccountExample],
471485
parsePayload: (payload) => payload as OnAccountEvent,
472486
runProperties: (payload) => [
473487
{ label: "Account ID", text: payload.id },
@@ -480,7 +494,7 @@ export const onCustomer: EventSpecification<OnCustomerEvent> = {
480494
title: "On Customer Event",
481495
source: "stripe.com",
482496
icon: "stripe",
483-
examples: [],
497+
examples: [createdCustomerExample],
484498
parsePayload: (payload) => payload as OnCustomerEvent,
485499
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
486500
};
@@ -490,7 +504,7 @@ export const onCustomerCreated: EventSpecification<OnCustomerEvent> = {
490504
title: "On Customer Created",
491505
source: "stripe.com",
492506
icon: "stripe",
493-
examples: [],
507+
examples: [createdCustomerExample],
494508
parsePayload: (payload) => payload as OnCustomerEvent,
495509
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
496510
};
@@ -500,7 +514,7 @@ export const onCustomerDeleted: EventSpecification<OnCustomerEvent> = {
500514
title: "On Customer Deleted",
501515
source: "stripe.com",
502516
icon: "stripe",
503-
examples: [],
517+
examples: [deletedCustomerExample],
504518
parsePayload: (payload) => payload as OnCustomerEvent,
505519
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
506520
};
@@ -510,7 +524,7 @@ export const onCustomerUpdated: EventSpecification<OnCustomerEvent> = {
510524
title: "On Customer Updated",
511525
source: "stripe.com",
512526
icon: "stripe",
513-
examples: [],
527+
examples: [createdCustomerExample],
514528
parsePayload: (payload) => payload as OnCustomerEvent,
515529
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
516530
};
@@ -528,7 +542,12 @@ export const onCharge: EventSpecification<OnChargeEvent> = {
528542
title: "On Charge Event",
529543
source: "stripe.com",
530544
icon: "stripe",
531-
examples: [],
545+
examples: [
546+
capturedChargeExample,
547+
succeededChargeExample,
548+
failedChargeExample,
549+
refundedChargeExample,
550+
],
532551
parsePayload: (payload) => payload as OnChargeEvent,
533552
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
534553
};
@@ -538,7 +557,7 @@ export const onChargeCaptured: EventSpecification<OnChargeEvent> = {
538557
title: "On Charge Captured",
539558
source: "stripe.com",
540559
icon: "stripe",
541-
examples: [],
560+
examples: [capturedChargeExample],
542561
parsePayload: (payload) => payload as OnChargeEvent,
543562
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
544563
};
@@ -558,7 +577,7 @@ export const onChargeFailed: EventSpecification<OnChargeEvent> = {
558577
title: "On Charge Failed",
559578
source: "stripe.com",
560579
icon: "stripe",
561-
examples: [],
580+
examples: [failedChargeExample],
562581
parsePayload: (payload) => payload as OnChargeEvent,
563582
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
564583
};
@@ -578,7 +597,7 @@ export const onChargeRefunded: EventSpecification<OnChargeEvent> = {
578597
title: "On Charge Refunded",
579598
source: "stripe.com",
580599
icon: "stripe",
581-
examples: [],
600+
examples: [refundedChargeExample],
582601
parsePayload: (payload) => payload as OnChargeEvent,
583602
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
584603
};
@@ -588,7 +607,7 @@ export const onChargeSucceeded: EventSpecification<OnChargeEvent> = {
588607
title: "On Charge Succeeded",
589608
source: "stripe.com",
590609
icon: "stripe",
591-
examples: [],
610+
examples: [succeededChargeExample],
592611
parsePayload: (payload) => payload as OnChargeEvent,
593612
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
594613
};
@@ -710,3 +729,206 @@ export const onPersonUpdated: EventSpecification<OnPersonEvent> = {
710729
{ label: "Account", text: payload.account },
711730
],
712731
};
732+
733+
export const onPaymentIntent: EventSpecification<OnPaymentIntentEvent> = {
734+
name: [
735+
"payment_intent.created",
736+
"payment_intent.succeeded",
737+
"payment_intent.canceled",
738+
"payment_intent.processing",
739+
"payment_intent.requires_action",
740+
"payment_intent.amount_capturable_updated",
741+
"payment_intent.payment_failed",
742+
"payment_intent.partially_funded",
743+
],
744+
title: "On Payment Intent Event",
745+
source: "stripe.com",
746+
icon: "stripe",
747+
examples: [
748+
createdPaymentIntentExample,
749+
succeededPaymentIntentExample,
750+
cancelledPaymentIntentExample,
751+
amountCapturablePaymentIntentExample,
752+
failedPaymentIntentExample,
753+
],
754+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
755+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
756+
};
757+
758+
export const onPaymentIntentCreated: EventSpecification<OnPaymentIntentEvent> = {
759+
name: "payment_intent.created",
760+
title: "On Payment Intent Created",
761+
source: "stripe.com",
762+
icon: "stripe",
763+
examples: [createdPaymentIntentExample],
764+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
765+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
766+
};
767+
768+
export const onPaymentIntentSucceeded: EventSpecification<OnPaymentIntentEvent> = {
769+
name: "payment_intent.succeeded",
770+
title: "On Payment Intent Succeeded",
771+
source: "stripe.com",
772+
icon: "stripe",
773+
examples: [succeededPaymentIntentExample],
774+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
775+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
776+
};
777+
778+
export const onPaymentIntentCanceled: EventSpecification<OnPaymentIntentEvent> = {
779+
name: "payment_intent.canceled",
780+
title: "On Payment Intent Canceled",
781+
source: "stripe.com",
782+
icon: "stripe",
783+
examples: [cancelledPaymentIntentExample],
784+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
785+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
786+
};
787+
788+
export const onPaymentIntentProcessing: EventSpecification<OnPaymentIntentEvent> = {
789+
name: "payment_intent.processing",
790+
title: "On Payment Intent Processing",
791+
source: "stripe.com",
792+
icon: "stripe",
793+
examples: [],
794+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
795+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
796+
};
797+
798+
export const onPaymentIntentRequiresAction: EventSpecification<OnPaymentIntentEvent> = {
799+
name: "payment_intent.requires_action",
800+
title: "On Payment Intent Requires Action",
801+
source: "stripe.com",
802+
icon: "stripe",
803+
examples: [],
804+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
805+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
806+
};
807+
808+
export const onPaymentIntentAmountCapturableUpdated: EventSpecification<OnPaymentIntentEvent> = {
809+
name: "payment_intent.amount_capturable_updated",
810+
title: "On Payment Intent Amount Capturable Updated",
811+
source: "stripe.com",
812+
icon: "stripe",
813+
examples: [amountCapturablePaymentIntentExample],
814+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
815+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
816+
};
817+
818+
export const onPaymentIntentPaymentFailed: EventSpecification<OnPaymentIntentEvent> = {
819+
name: "payment_intent.payment_failed",
820+
title: "On Payment Intent Payment Failed",
821+
source: "stripe.com",
822+
icon: "stripe",
823+
examples: [failedPaymentIntentExample],
824+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
825+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
826+
};
827+
828+
export const onPaymentIntentPartiallyFunded: EventSpecification<OnPaymentIntentEvent> = {
829+
name: "payment_intent.partially_funded",
830+
title: "On Payment Intent Partially Funded",
831+
source: "stripe.com",
832+
icon: "stripe",
833+
examples: [],
834+
parsePayload: (payload) => payload as OnPaymentIntentEvent,
835+
runProperties: (payload) => [{ label: "Payment Intent ID", text: payload.id }],
836+
};
837+
838+
export const onPayout: EventSpecification<OnPayoutEvent> = {
839+
name: [
840+
"payout.canceled",
841+
"payout.created",
842+
"payout.failed",
843+
"payout.paid",
844+
"payout.reconciliation_completed",
845+
"payout.updated",
846+
],
847+
title: "On Payout Event",
848+
source: "stripe.com",
849+
icon: "stripe",
850+
examples: [],
851+
parsePayload: (payload) => payload as OnPayoutEvent,
852+
runProperties: (payload) => [
853+
{ label: "Payout ID", text: payload.id },
854+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
855+
],
856+
};
857+
858+
export const onPayoutCancelled: EventSpecification<OnPayoutEvent> = {
859+
name: "payout.canceled",
860+
title: "On Payout Cancelled Event",
861+
source: "stripe.com",
862+
icon: "stripe",
863+
examples: [],
864+
parsePayload: (payload) => payload as OnPayoutEvent,
865+
runProperties: (payload) => [
866+
{ label: "Payout ID", text: payload.id },
867+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
868+
],
869+
};
870+
871+
export const onPayoutCreated: EventSpecification<OnPayoutEvent> = {
872+
name: "payout.created",
873+
title: "On Payout Created Event",
874+
source: "stripe.com",
875+
icon: "stripe",
876+
examples: [],
877+
parsePayload: (payload) => payload as OnPayoutEvent,
878+
runProperties: (payload) => [
879+
{ label: "Payout ID", text: payload.id },
880+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
881+
],
882+
};
883+
884+
export const onPayoutFailed: EventSpecification<OnPayoutEvent> = {
885+
name: "payout.failed",
886+
title: "On Payout Failed Event",
887+
source: "stripe.com",
888+
icon: "stripe",
889+
examples: [],
890+
parsePayload: (payload) => payload as OnPayoutEvent,
891+
runProperties: (payload) => [
892+
{ label: "Payout ID", text: payload.id },
893+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
894+
],
895+
};
896+
897+
export const onPayoutPaid: EventSpecification<OnPayoutEvent> = {
898+
name: "payout.paid",
899+
title: "On Payout Paid Event",
900+
source: "stripe.com",
901+
icon: "stripe",
902+
examples: [],
903+
parsePayload: (payload) => payload as OnPayoutEvent,
904+
runProperties: (payload) => [
905+
{ label: "Payout ID", text: payload.id },
906+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
907+
],
908+
};
909+
910+
export const onPayoutReconciliationCompleted: EventSpecification<OnPayoutEvent> = {
911+
name: "payout.reconciliation_completed",
912+
title: "On Payout Reconciliation Completed Event",
913+
source: "stripe.com",
914+
icon: "stripe",
915+
examples: [],
916+
parsePayload: (payload) => payload as OnPayoutEvent,
917+
runProperties: (payload) => [
918+
{ label: "Payout ID", text: payload.id },
919+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
920+
],
921+
};
922+
923+
export const onPayoutUpdated: EventSpecification<OnPayoutEvent> = {
924+
name: "payout.updated",
925+
title: "On Payout Updated Event",
926+
source: "stripe.com",
927+
icon: "stripe",
928+
examples: [],
929+
parsePayload: (payload) => payload as OnPayoutEvent,
930+
runProperties: (payload) => [
931+
{ label: "Payout ID", text: payload.id },
932+
{ label: "Amount", text: `${payload.amount} ${payload.currency}` },
933+
],
934+
};

0 commit comments

Comments
 (0)