@@ -54,6 +54,34 @@ type SyncObject =
5454 | 'payment_intent'
5555 | 'plan'
5656
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+
5785export async function syncBackfill ( params ?: SyncBackfillParams ) : Promise < SyncBackfill > {
5886 const { created, object } = params ?? { }
5987 let products ,
0 commit comments