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
The amount paid for the purchase
ISO 8601
ISO 8601
ISO 8601, when the purchase was completed
The ID of the purchased product
The ID of the wallet that made the purchase
Create a Purchase
- TypeScript / JavaScript
let purchase = await solidtx.purchases.create({
productId: 'prod_01234567890abcdef',
walletId: 'wallet_01234567890abcdef',
stripePaymentMethodId: 'default'
})
Parameters
The ID of the product being purchased
The ID of the wallet making the purchase
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
- TypeScript / JavaScript
let purchase = await solidtx.purchases.cancelSubscription('purchase_01234567890abcdef')
Parameters
The ID of the subscription product being canceled
The ID of the wallet canceling the subscription
Returns
Returns the Purchase (subscription) you just canceled.
{
"id": "purchase_01234567890abcdef"
}