@cosmosapp/pay_sdkServeur
Produits et clients
Gérez votre catalogue de produits et vos clients, y compris leurs statistiques de paiement.
Les produits et les clients sont des catalogues facultatifs que vous pouvez rattacher aux paiements pour les organiser et en faire des rapports.
Produits / prix : 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();Accesseurs de Product : id, name, description, amount, asset, assetLabel,
kind, active, reference, createdAt, updatedAt.
Clients : 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);
}Accesseurs de Customer : id, name, alias, note, email,
account, reference, createdAt, updatedAt, plus les statistiques propres à la liste
payments, succeeded, total (null en dehors de list()).