@cosmosapp/pay_sdkServer
Produkte & Kunden
Verwalten Sie Ihren Produktkatalog und Ihre Kunden, einschließlich ihrer Zahlungsstatistiken.
Produkte und Kunden sind optionale Kataloge, die Sie an Zahlungen anhängen können, um sie zu organisieren und darüber zu berichten.
Produkte / Preise: client.products
import { ProductKind } from '@cosmosapp/pay_sdk';
const product = await client.products.create({
name: 'Pro plan (monthly)',
description: 'Priority support included.', // optional
amount: '49.00', // optional; omit for customer-set amount
assetCode: 'USDC', // optional; omit for native XLM
kind: ProductKind.Recurring, // 'recurring' | 'one_time' | 'link'
reference: 'sku_pro_monthly', // optional
});
await client.products.list();
await client.products.fetch(product.id);
await product.edit({ amount: '59.00' });
await product.deactivate(); // active = false
await product.activate(); // active = true
await product.delete();Product-Zugriffsmethoden: id, name, description, amount, asset, assetLabel,
kind, active, reference, createdAt, updatedAt.
Kunden: client.customers
const customer = await client.customers.create({
name: 'Acme Inc.',
email: 'billing@acme.com', // optional
alias: 'acme', // optional
account: 'G...', // optional Stellar account to associate
reference: 'crm_4821', // optional
});
await customer.edit({ note: 'VIP, net-30' });
await client.customers.fetch(customer.id);
await customer.delete();
// list() includes payment stats per customer:
const customers = await client.customers.list();
for (const c of customers) {
console.log(c.name, c.payments, c.succeeded, c.total);
}Customer-Zugriffsmethoden: id, name, alias, note, email,
account, reference, createdAt, updatedAt, plus die nur in der Liste enthaltenen Statistiken
payments, succeeded, total (null außerhalb von list()).