Class: ProductSubscriptionsService
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:66
Extends
BaseService
Constructors
Constructor
new ProductSubscriptionsService(
client):ProductSubscriptionsService
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:12
Parameters
client
Returns
ProductSubscriptionsService
Inherited from
BaseService.constructor
Properties
client
protectedclient:TanqoryClient
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:10
Inherited from
BaseService.client
Methods
addPaymentMethod()
addPaymentMethod(
storeId,customerId,data):Promise<any>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:210
Add a payment method for a customer
Parameters
storeId
string
customerId
string
data
billingAddress?
{ address1: string; address2?: string; city: string; company?: string; country: string; countryCode: string; firstName?: string; lastName?: string; phone?: string; province?: string; provinceCode?: string; zip: string; }
billingAddress.address1
string
billingAddress.address2?
string
billingAddress.city
string
billingAddress.company?
string
billingAddress.country
string
billingAddress.countryCode
string
billingAddress.firstName?
string
billingAddress.lastName?
string
billingAddress.phone?
string
billingAddress.province?
string
billingAddress.provinceCode?
string
billingAddress.zip
string
brand?
string
expMonth?
number
expYear?
number
isDefault
boolean
last4?
string
name?
string
omiseToken?
string
stripePaymentMethodId?
string
type
"CARD" | "BANK_ACCOUNT" | "PROMPTPAY" | "TRUEMONEY"
Returns
Promise<any>
buildQuery()
protectedbuildQuery(options?):Record<string,any>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:26
Build query parameters
Parameters
options?
Returns
Record<string, any>
Inherited from
BaseService.buildQuery
cancel()
cancel(
storeId,contractId,data):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:125
Cancel a subscription
Parameters
storeId
string
contractId
string
data
cancelImmediately
boolean
feedback?
string
reason?
string
Returns
Promise<SubscriptionContractResponse>
create()
create(
storeId,data):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:96
Create a new subscription contract
Parameters
storeId
string
data
billingAddress
{ address1: string; address2?: string; city: string; company?: string; country: string; countryCode: string; firstName?: string; lastName?: string; phone?: string; province?: string; provinceCode?: string; zip: string; }
billingAddress.address1
string
billingAddress.address2?
string
billingAddress.city
string
billingAddress.company?
string
billingAddress.country
string
billingAddress.countryCode
string
billingAddress.firstName?
string
billingAddress.lastName?
string
billingAddress.phone?
string
billingAddress.province?
string
billingAddress.provinceCode?
string
billingAddress.zip
string
customerId
string
deliveryAddress
{ address1: string; address2?: string; city: string; company?: string; country: string; countryCode: string; firstName?: string; lastName?: string; phone?: string; province?: string; provinceCode?: string; zip: string; }
deliveryAddress.address1
string
deliveryAddress.address2?
string
deliveryAddress.city
string
deliveryAddress.company?
string
deliveryAddress.country
string
deliveryAddress.countryCode
string
deliveryAddress.firstName?
string
deliveryAddress.lastName?
string
deliveryAddress.phone?
string
deliveryAddress.province?
string
deliveryAddress.provinceCode?
string
deliveryAddress.zip
string
note?
string
paymentMethodId?
string
quantity
number
sellingPlanId
string
variantId
string
Returns
Promise<SubscriptionContractResponse>
generateIdempotencyKey()
protectedgenerateIdempotencyKey(prefix):string
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:19
Generate idempotency key
Parameters
prefix
string
Returns
string
Inherited from
BaseService.generateIdempotencyKey
getBillingAttempts()
getBillingAttempts(
storeId,contractId,params?):Promise<PaginatedBillingAttemptsResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:167
Get billing attempts for a subscription
Parameters
storeId
string
contractId
string
params?
endDate?
string
limit
number
page
number
sortBy
"createdAt" | "cycleIndex" | "readyAt"
sortOrder
"asc" | "desc"
startDate?
string
status?
"PENDING" | "PROCESSING" | "FAILED" | "SUCCESS" | "SKIPPED"
subscriptionContractId?
string
Returns
Promise<PaginatedBillingAttemptsResponse>
getCountsTimeseries()
getCountsTimeseries(
storeId,params):Promise<{active:object[];all:object[];cancelled:object[];paused:object[]; }>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:265
Get subscription counts time-series data
Parameters
storeId
string
params
from
string
groupBy?
"day" | "week" | "month"
to
string
Returns
Promise<{ active: object[]; all: object[]; cancelled: object[]; paused: object[]; }>
getCustomerPaymentMethods()
getCustomerPaymentMethods(
storeId,customerId):Promise<any[]>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:197
Get payment methods for a customer
Parameters
storeId
string
customerId
string
Returns
Promise<any[]>
getCustomerSubscriptions()
getCustomerSubscriptions(
storeId,customerId,params?):Promise<PaginatedSubscriptionContractsResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:287
Get subscriptions for a specific customer
Parameters
storeId
string
customerId
string
params?
customerId?
string
limit
number
page
number
search?
string
sortBy
"createdAt" | "nextBillingDate" | "contractNumber"
sortOrder
"asc" | "desc"
status?
"EXPIRED" | "FAILED" | "CANCELLED" | "ACTIVE" | "PAUSED"
Returns
Promise<PaginatedSubscriptionContractsResponse>
getExportMimeType()
protectedgetExportMimeType(format):string
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:45
Get MIME type for export format
Parameters
format
string
Returns
string
Inherited from
BaseService.getExportMimeType
getSummary()
getSummary(
storeId):Promise<SubscriptionSummaryResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:255
Get subscription summary for dashboard
Parameters
storeId
string
Returns
Promise<SubscriptionSummaryResponse>
list()
list(
storeId,params?):Promise<PaginatedSubscriptionContractsResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:72
List all subscription contracts for a store
Parameters
storeId
string
params?
customerId?
string
limit
number
page
number
search?
string
sortBy
"createdAt" | "nextBillingDate" | "contractNumber"
sortOrder
"asc" | "desc"
status?
"EXPIRED" | "FAILED" | "CANCELLED" | "ACTIVE" | "PAUSED"
Returns
Promise<PaginatedSubscriptionContractsResponse>
pause()
pause(
storeId,contractId,data):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:140
Pause a subscription
Parameters
storeId
string
contractId
string
data
pauseUntil?
string
skipNextBillingCycles?
number
Returns
Promise<SubscriptionContractResponse>
removePaymentMethod()
removePaymentMethod(
storeId,customerId,paymentMethodId):Promise<SuccessResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:239
Remove a payment method
Parameters
storeId
string
customerId
string
paymentMethodId
string
Returns
Promise<SuccessResponse>
resume()
resume(
storeId,contractId):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:155
Resume a paused subscription
Parameters
storeId
string
contractId
string
Returns
Promise<SubscriptionContractResponse>
retrieve()
retrieve(
storeId,contractId):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:86
Get a single subscription contract by ID
Parameters
storeId
string
contractId
string
Returns
Promise<SubscriptionContractResponse>
retryBillingAttempt()
retryBillingAttempt(
storeId,attemptId):Promise<SubscriptionBillingAttemptResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:182
Retry a failed billing attempt
Parameters
storeId
string
attemptId
string
Returns
Promise<SubscriptionBillingAttemptResponse>
setDefaultPaymentMethod()
setDefaultPaymentMethod(
storeId,customerId,paymentMethodId):Promise<SuccessResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:225
Set a payment method as default
Parameters
storeId
string
customerId
string
paymentMethodId
string
Returns
Promise<SuccessResponse>
update()
update(
storeId,contractId,data):Promise<SubscriptionContractResponse>
Defined in: tanqory-platform-packages/packages/api/sdk/src/services/product-subscriptions.ts:110
Update a subscription contract
Parameters
storeId
string
contractId
string
data
billingAddress?
{ address1: string; address2?: string; city: string; company?: string; country: string; countryCode: string; firstName?: string; lastName?: string; phone?: string; province?: string; provinceCode?: string; zip: string; }
billingAddress.address1
string
billingAddress.address2?
string
billingAddress.city
string
billingAddress.company?
string
billingAddress.country
string
billingAddress.countryCode
string
billingAddress.firstName?
string
billingAddress.lastName?
string
billingAddress.phone?
string
billingAddress.province?
string
billingAddress.provinceCode?
string
billingAddress.zip
string
deliveryAddress?
{ address1: string; address2?: string; city: string; company?: string; country: string; countryCode: string; firstName?: string; lastName?: string; phone?: string; province?: string; provinceCode?: string; zip: string; }
deliveryAddress.address1
string
deliveryAddress.address2?
string
deliveryAddress.city
string
deliveryAddress.company?
string
deliveryAddress.country
string
deliveryAddress.countryCode
string
deliveryAddress.firstName?
string
deliveryAddress.lastName?
string
deliveryAddress.phone?
string
deliveryAddress.province?
string
deliveryAddress.provinceCode?
string
deliveryAddress.zip
string
nextBillingDate?
string
note?
string
paymentMethodId?
string
status?
"EXPIRED" | "FAILED" | "CANCELLED" | "ACTIVE" | "PAUSED"
Returns
Promise<SubscriptionContractResponse>