@tbagtapp/sdk
v0.2.0
Published
TypeScript SDK for the Bag Merchant of Record API
Maintainers
Readme
@tbagtapp/sdk
TypeScript SDK for the Bag Merchant of Record API.
Install
npm install @tbagtapp/sdkQuick Start
import { Bag } from '@tbagtapp/sdk'
const bag = new Bag({ apiKey: 'bag_test_sk_...' })
// Create a payment link
const link = await bag.paymentLinks.create({
name: 'Pro Plan',
amount: 29.99,
network: 'base',
})
console.log(link.id) // "pl_abc123..."
// List transactions
const transactions = await bag.transactions.list()
// Get a tax quote
const quote = await bag.checkout.getTaxQuote({
paymentLinkId: link.id,
customerAddress: {
address_line_1: '123 Main St',
address_city: 'New York',
address_country: 'US',
},
})Configuration
const bag = new Bag({
apiKey: 'bag_live_sk_...', // required
baseUrl: 'https://your-app.com', // optional, defaults to https://justusebag.xyz
})Error Handling
import { Bag, BagError } from '@tbagtapp/sdk'
try {
await bag.paymentLinks.create({ ... })
} catch (err) {
if (err instanceof BagError) {
console.error(err.statusCode, err.message, err.code)
}
}Resources
bag.paymentLinks— create, list, get, update, delete payment linksbag.transactions— list and create transactionsbag.checkout— create sessions, submit tx hashes, get tax quotes
License
MIT
