Skip to main content

Purchases

Purchases represent customer transactions for products. When a customer buys a product, a purchase record is created that links the product to the customer's wallet.

The Purchase Object


id string

amount decimal

The amount paid for the purchase


createdAt string

ISO 8601


updatedAt string

ISO 8601


concludedAt string | null

ISO 8601, when the purchase was completed


productId string

The ID of the purchased product


product Product

walletId string

The ID of the wallet that made the purchase


wallet Wallet

Create a Purchase

let purchase = await solidtx.purchases.create({
productId: 'prod_01234567890abcdef',
walletId: 'wallet_01234567890abcdef',
stripePaymentMethodId: 'default'
})

Parameters


productId stringRequired

The ID of the product being purchased


walletId stringRequired

The ID of the wallet making the purchase


stripePaymentMethodId string

Pass a Stripe payment method ID to use a customer's specific id or default to let Stripe use their default id. Omit this field to prevent a purchase from being created in Stripe, useful for keeping a customer's purchase history up-to-date.

Returns

Returns the Purchase object you just created.

{
"id": "purchase_01234567890abcdef",
"amount": "10.00",
"createdAt": "2025-05-21T15:30:00Z",
"updatedAt": "2025-05-21T15:31:00Z",
"concludedAt": "2025-05-21T15:31:00Z",
"productId": "product_01234567890abcdef",
"product": {
"id": "product_01234567890abcdef",
"name": "Premium Gem Package",
"description": "Get 1000 gems at a special price",
"price": "10.00",
"purchaseFrequency": "ONCE"
},
"walletId": "wallet_01234567890abcdef",
"wallet": {
"id": "wallet_01234567890abcdef",
"name": "Jane Doe"
}
}

Cancel a Subscription

let purchase = await solidtx.purchases.cancelSubscription('purchase_01234567890abcdef')

Parameters


productId stringRequired

The ID of the subscription product being canceled


walletId stringRequired

The ID of the wallet canceling the subscription

Returns

Returns the Purchase (subscription) you just canceled.

{
"id": "purchase_01234567890abcdef"
}