Class: PostgresBillingStore
Defined in: javascript/src/billing/postgres/store.ts:150
Abstract billing store — provider-agnostic persistence layer for subscription lifecycle state.
Mirrors Python bursar/billing/store.py.
Extends
Constructors
Constructor
new PostgresBillingStore(
options):PostgresBillingStore
Defined in: javascript/src/billing/postgres/store.ts:166
Parameters
options
Returns
PostgresBillingStore
Overrides
Properties
providerEnvironment
readonlyproviderEnvironment:"live"|"test"|"sandbox"
Defined in: javascript/src/billing/postgres/store.ts:152
Exposed by environment-partitioned stores so composition can reject drift.
Overrides
BillingStore.providerEnvironment
Methods
claimAutoRechargeAttempt()
claimAutoRechargeAttempt(
input):Promise<BillingAutoRechargeAttempt|null>
Defined in: javascript/src/billing/postgres/store.ts:880
Parameters
input
AutoRechargeAttemptClaim
Returns
Promise<BillingAutoRechargeAttempt | null>
Overrides
BillingStore.claimAutoRechargeAttempt
claimBillingEvent()
claimBillingEvent(
provider,eventId,eventType,envelope?):Promise<BillingEventClaim>
Defined in: javascript/src/billing/postgres/store.ts:396
Parameters
provider
string
eventId
string
eventType
string
envelope?
Record<string, unknown>
Returns
Promise<BillingEventClaim>
Overrides
BillingStore.claimBillingEvent
close()
close():
Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:192
Returns
Promise<void>
completeBillingEvent()
completeBillingEvent(
provider,eventId,claimToken):Promise<boolean>
Defined in: javascript/src/billing/postgres/store.ts:436
Parameters
provider
string
eventId
string
claimToken
string
Returns
Promise<boolean>
Overrides
BillingStore.completeBillingEvent
computeTopupCredits()
computeTopupCredits(
amountMinor,topupConfig):Promise<Decimal>
Defined in: javascript/src/billing/postgres/store.ts:611
Parameters
amountMinor
number
topupConfig
BillingTopupResult
Returns
Promise<Decimal>
Overrides
BillingStore.computeTopupCredits
countAutoRechargeAttempts()
countAutoRechargeAttempts(
userId,since):Promise<number>
Defined in: javascript/src/billing/postgres/store.ts:896
Parameters
userId
string
since
string | Date
Returns
Promise<number>
Overrides
BillingStore.countAutoRechargeAttempts
createBillingCreditGrant()
createBillingCreditGrant(
input):Promise<string>
Defined in: javascript/src/billing/postgres/store.ts:643
Parameters
input
BillingCreditGrantCreate
Returns
Promise<string>
Overrides
BillingStore.createBillingCreditGrant
createBillingSubscriptionChange()
createBillingSubscriptionChange(
input):Promise<BillingSubscriptionChange>
Defined in: javascript/src/billing/postgres/store.ts:484
Parameters
input
BillingSubscriptionChangeInput
Returns
Promise<BillingSubscriptionChange>
Overrides
BillingStore.createBillingSubscriptionChange
createOrGetCheckoutIntent()
createOrGetCheckoutIntent(
input):Promise<CheckoutIntent>
Defined in: javascript/src/billing/postgres/store.ts:262
Parameters
input
CheckoutIntentCreate
Returns
Promise<CheckoutIntent>
Overrides
BillingStore.createOrGetCheckoutIntent
failBillingEvent()
failBillingEvent(
provider,eventId,claimToken,error?):Promise<boolean>
Defined in: javascript/src/billing/postgres/store.ts:444
Parameters
provider
string
eventId
string
claimToken
string
error?
string
Returns
Promise<boolean>
Overrides
getActiveCatalogDocument()
getActiveCatalogDocument():
Promise<Record<string,unknown> |null>
Defined in: javascript/src/billing/postgres/store.ts:833
Returns
Promise<Record<string, unknown> | null>
Overrides
BillingStore.getActiveCatalogDocument
getAutoRechargeProfile()
getAutoRechargeProfile(
userId):Promise<BillingAutoRechargeProfile|null>
Defined in: javascript/src/billing/postgres/store.ts:869
Parameters
userId
string
Returns
Promise<BillingAutoRechargeProfile | null>
Overrides
BillingStore.getAutoRechargeProfile
getBillingCreditGrantByPayment()
getBillingCreditGrantByPayment(
paymentId):Promise<string|null>
Defined in: javascript/src/billing/postgres/store.ts:674
Parameters
paymentId
string
Returns
Promise<string | null>
Overrides
BillingStore.getBillingCreditGrantByPayment
getBillingCustomer()
getBillingCustomer(
provider,providerCustomerId):Promise<string|null>
Defined in: javascript/src/billing/postgres/store.ts:471
Parameters
provider
string
providerCustomerId
string
Returns
Promise<string | null>
Overrides
BillingStore.getBillingCustomer
getBillingCustomerByUserId()
getBillingCustomerByUserId(
userId,provider?):Promise<BillingCustomerRecord|null>
Defined in: javascript/src/billing/postgres/store.ts:900
Parameters
userId
string
provider?
string | null
Returns
Promise<BillingCustomerRecord | null>
Overrides
BillingStore.getBillingCustomerByUserId
getBillingPayment()
getBillingPayment(
provider,providerPaymentId):Promise<BillingPaymentRecord|null>
Defined in: javascript/src/billing/postgres/store.ts:773
Parameters
provider
string
providerPaymentId
string
Returns
Promise<BillingPaymentRecord | null>
Overrides
BillingStore.getBillingPayment
getBillingPreferences()
getBillingPreferences(
userId):Promise<BillingPreferences|null>
Defined in: javascript/src/billing/postgres/store.ts:861
Parameters
userId
string
Returns
Promise<BillingPreferences | null>
Overrides
BillingStore.getBillingPreferences
getBillingSubscription()
getBillingSubscription(
provider,providerSubscriptionId):Promise<BillingSubscriptionState|null>
Defined in: javascript/src/billing/postgres/store.ts:475
Parameters
provider
string
providerSubscriptionId
string
Returns
Promise<BillingSubscriptionState | null>
Overrides
BillingStore.getBillingSubscription
getCheckoutIntent()
getCheckoutIntent(
id,subjectId):Promise<CheckoutIntent|null>
Defined in: javascript/src/billing/postgres/store.ts:311
Parameters
id
string
subjectId
string
Returns
Promise<CheckoutIntent | null>
Overrides
BillingStore.getCheckoutIntent
getOpenBillingSubscriptionChange()
getOpenBillingSubscriptionChange(
provider,providerSubscriptionId):Promise<BillingSubscriptionChange|null>
Defined in: javascript/src/billing/postgres/store.ts:503
Parameters
provider
string
providerSubscriptionId
string
Returns
Promise<BillingSubscriptionChange | null>
Overrides
BillingStore.getOpenBillingSubscriptionChange
getUserSubscription()
getUserSubscription(
userId,statuses?):Promise<BillingSubscriptionState|null>
Defined in: javascript/src/billing/postgres/store.ts:537
Parameters
userId
string
statuses?
string[]
Returns
Promise<BillingSubscriptionState | null>
Overrides
BillingStore.getUserSubscription
getUserSubscriptions()
getUserSubscriptions(
userId):Promise<BillingSubscriptionState[]>
Defined in: javascript/src/billing/postgres/store.ts:546
Parameters
userId
string
Returns
Promise<BillingSubscriptionState[]>
Overrides
BillingStore.getUserSubscriptions
grantBillingCredit()
grantBillingCredit(
grantId,idempotencyKey):Promise<BillingCreditPostingResult>
Defined in: javascript/src/billing/postgres/store.ts:663
Parameters
grantId
string
idempotencyKey
string
Returns
Promise<BillingCreditPostingResult>
Overrides
BillingStore.grantBillingCredit
listBillingInvoices()
listBillingInvoices(
userId):Promise<BillingInvoiceRecord[]>
Defined in: javascript/src/billing/postgres/store.ts:743
Parameters
userId
string
Returns
Promise<BillingInvoiceRecord[]>
Overrides
BillingStore.listBillingInvoices
listExpiredGraceSubscriptions()
listExpiredGraceSubscriptions(
now,limit?):Promise<BillingSubscriptionState[]>
Defined in: javascript/src/billing/postgres/store.ts:510
Parameters
now
string
limit?
number = 100
Returns
Promise<BillingSubscriptionState[]>
Overrides
BillingStore.listExpiredGraceSubscriptions
markSubscriptionGraceExpired()
markSubscriptionGraceExpired(
subscriptionId,expectedGraceEndsAt,expiredAt?):Promise<boolean>
Defined in: javascript/src/billing/postgres/store.ts:518
Parameters
subscriptionId
string
expectedGraceEndsAt
string
expiredAt?
string = ...
Returns
Promise<boolean>
Overrides
BillingStore.markSubscriptionGraceExpired
postBillingRefund()
postBillingRefund(
refundId,grantId,amountMinor,idempotencyKey):Promise<BillingCreditPostingResult>
Defined in: javascript/src/billing/postgres/store.ts:685
Parameters
refundId
string
grantId
string
amountMinor
number
idempotencyKey
string
Returns
Promise<BillingCreditPostingResult>
Overrides
BillingStore.postBillingRefund
pseudonymizeFinancialSubject()
pseudonymizeFinancialSubject(
userId):Promise<boolean>
Defined in: javascript/src/billing/postgres/store.ts:848
Parameters
userId
string
Returns
Promise<boolean>
Overrides
BillingStore.pseudonymizeFinancialSubject
recordSubscriptionConflict()
recordSubscriptionConflict(
input):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:551
Parameters
input
BillingSubscriptionConflictCreate
Returns
Promise<void>
Overrides
BillingStore.recordSubscriptionConflict
resolveBillingOffer()
resolveBillingOffer(
provider,productId?,priceId?):Promise<BillingOfferResult|null>
Defined in: javascript/src/billing/postgres/store.ts:379
Parameters
provider
string
productId?
string | null
priceId?
string | null
Returns
Promise<BillingOfferResult | null>
Overrides
BillingStore.resolveBillingOffer
resolveBillingOfferByLookup()
resolveBillingOfferByLookup(
provider,lookupKey):Promise<BillingOfferResult|null>
Defined in: javascript/src/billing/postgres/store.ts:388
Parameters
provider
string
lookupKey
string
Returns
Promise<BillingOfferResult | null>
Overrides
BillingStore.resolveBillingOfferByLookup
resolveCreditTopup()
resolveCreditTopup(
provider,productId?,priceId?):Promise<BillingTopupResult|null>
Defined in: javascript/src/billing/postgres/store.ts:594
Parameters
provider
string
productId?
string | null
priceId?
string | null
Returns
Promise<BillingTopupResult | null>
Overrides
BillingStore.resolveCreditTopup
resolveCreditTopupByLookup()
resolveCreditTopupByLookup(
provider,lookupKey):Promise<BillingTopupResult|null>
Defined in: javascript/src/billing/postgres/store.ts:603
Parameters
provider
string
lookupKey
string
Returns
Promise<BillingTopupResult | null>
Overrides
BillingStore.resolveCreditTopupByLookup
selectSubscriptionEntitlementSource()
selectSubscriptionEntitlementSource(
userId,provider,providerSubscriptionId?):Promise<boolean>
Defined in: javascript/src/billing/postgres/store.ts:555
Select a current provider subscription as the subject's entitlement source.
Parameters
userId
string
provider
string
providerSubscriptionId?
string | null
Returns
Promise<boolean>
Overrides
BillingStore.selectSubscriptionEntitlementSource
updateAutoRechargeAttempt()
updateAutoRechargeAttempt(
input):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:886
Parameters
input
AutoRechargeAttemptUpdate
Returns
Promise<void>
Overrides
BillingStore.updateAutoRechargeAttempt
updateAutoRechargeAttemptByProviderPayment()
updateAutoRechargeAttemptByProviderPayment(
input):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:890
Parameters
input
AutoRechargeProviderPaymentUpdate
Returns
Promise<void>
Overrides
BillingStore.updateAutoRechargeAttemptByProviderPayment
updateBillingSubscriptionChange()
updateBillingSubscriptionChange(
id,update):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:530
Parameters
id
string
update
BillingSubscriptionChangeUpdate
Returns
Promise<void>
Overrides
BillingStore.updateBillingSubscriptionChange
updateCheckoutIntent()
updateCheckoutIntent(
id,update):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:297
Parameters
id
string
update
CheckoutIntentUpdate
Returns
Promise<void>
Overrides
BillingStore.updateCheckoutIntent
upsertAutoRechargeProfile()
upsertAutoRechargeProfile(
profile,options?):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:873
Parameters
profile
options?
resetCooldown?
boolean
Returns
Promise<void>
Overrides
BillingStore.upsertAutoRechargeProfile
upsertBillingCustomer()
upsertBillingCustomer(
provider,providerCustomerId,userId,email?):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:458
Parameters
provider
string
providerCustomerId
string
userId
string
email?
string | null
Returns
Promise<void>
Overrides
BillingStore.upsertBillingCustomer
upsertBillingDispute()
upsertBillingDispute(
options):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:747
Parameters
options
BillingDisputeUpsert
Returns
Promise<void>
Overrides
BillingStore.upsertBillingDispute
upsertBillingInvoice()
upsertBillingInvoice(
options):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:713
Parameters
options
BillingInvoiceUpsert
Returns
Promise<void>
Overrides
BillingStore.upsertBillingInvoice
upsertBillingPayment()
upsertBillingPayment(
options):Promise<string>
Defined in: javascript/src/billing/postgres/store.ts:627
Parameters
options
BillingPaymentUpsert
Returns
Promise<string>
Overrides
BillingStore.upsertBillingPayment
upsertBillingPreferences()
upsertBillingPreferences(
prefs):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:865
Parameters
prefs
Returns
Promise<void>
Overrides
BillingStore.upsertBillingPreferences
upsertBillingRefund()
upsertBillingRefund(
options):Promise<string>
Defined in: javascript/src/billing/postgres/store.ts:698
Parameters
options
BillingRefundUpsert
Returns
Promise<string>
Overrides
BillingStore.upsertBillingRefund
upsertBillingSubscription()
upsertBillingSubscription(
state):Promise<void>
Defined in: javascript/src/billing/postgres/store.ts:467
Parameters
state
Returns
Promise<void>