@cosmosapp/pay_sdkServidor

Produtos & clientes

Gerencie seu catálogo de produtos e seus clientes, incluindo as estatísticas de pagamento deles.

Produtos e clientes são catálogos opcionais que você pode anexar aos pagamentos para organizá-los e gerar relatórios sobre eles.

Produtos / preços: 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();

Acessadores de Product: id, name, description, amount, asset, assetLabel, kind, active, reference, createdAt, updatedAt.

Clientes: 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);
}

Acessadores de Customer: id, name, alias, note, email, account, reference, createdAt, updatedAt, mais as estatísticas exclusivas da listagem payments, succeeded, total (null fora de list()).

Referências

  • Customer: Um registro de cliente, opcionalmente enriquecido com estatísticas de pagamento on-chain.
  • Product: Um produto / preço pelo qual o consumidor pode cobrar.

Nesta página