@@ -54,6 +54,34 @@ type SyncObject =
54
54
| 'payment_intent'
55
55
| 'plan'
56
56
57
+ export async function syncSingleEntity ( stripeId : string ) {
58
+ if ( stripeId . startsWith ( 'cus_' ) ) {
59
+ return stripe . customers . retrieve ( stripeId ) . then ( ( it ) => {
60
+ if ( ! it || it . deleted ) return
61
+
62
+ return upsertCustomers ( [ it ] )
63
+ } )
64
+ } else if ( stripeId . startsWith ( 'in_' ) ) {
65
+ return stripe . invoices . retrieve ( stripeId ) . then ( ( it ) => upsertInvoices ( [ it ] ) )
66
+ } else if ( stripeId . startsWith ( 'price_' ) ) {
67
+ return stripe . prices . retrieve ( stripeId ) . then ( ( it ) => upsertPrices ( [ it ] ) )
68
+ } else if ( stripeId . startsWith ( 'prod_' ) ) {
69
+ return stripe . products . retrieve ( stripeId ) . then ( ( it ) => upsertProducts ( [ it ] ) )
70
+ } else if ( stripeId . startsWith ( 'sub_' ) ) {
71
+ return stripe . subscriptions . retrieve ( stripeId ) . then ( ( it ) => upsertSubscriptions ( [ it ] ) )
72
+ } else if ( stripeId . startsWith ( 'seti_' ) ) {
73
+ return stripe . setupIntents . retrieve ( stripeId ) . then ( ( it ) => upsertSetupIntents ( [ it ] ) )
74
+ } else if ( stripeId . startsWith ( 'pm_' ) ) {
75
+ return stripe . paymentMethods . retrieve ( stripeId ) . then ( ( it ) => upsertPaymentMethods ( [ it ] ) )
76
+ } else if ( stripeId . startsWith ( 'dp_' ) || stripeId . startsWith ( 'du_' ) ) {
77
+ return stripe . disputes . retrieve ( stripeId ) . then ( ( it ) => upsertDisputes ( [ it ] ) )
78
+ } else if ( stripeId . startsWith ( 'ch_' ) ) {
79
+ return stripe . charges . retrieve ( stripeId ) . then ( ( it ) => upsertCharges ( [ it ] ) )
80
+ } else if ( stripeId . startsWith ( 'pi_' ) ) {
81
+ return stripe . paymentIntents . retrieve ( stripeId ) . then ( ( it ) => upsertPaymentIntents ( [ it ] ) )
82
+ }
83
+ }
84
+
57
85
export async function syncBackfill ( params ?: SyncBackfillParams ) : Promise < SyncBackfill > {
58
86
const { created, object } = params ?? { }
59
87
let products ,
0 commit comments