Skip to content

การเรียกเก็บเงิน ​

Gommo Developer client

Client Gommo Developer TypeScript — npm alias @ai-gateway/client เรียก Gommo public API (api.gommo.net, v2.api.gommo.net)

→ Gommo public API · Roadmap

Coming to Gommo platform

client.billing ต้องใช้ self-hosted gateway (transport: 'gateway', gatewayBaseUrl) SDK billing บน Gommo platform อยู่ใน roadmap

Gommo billing API — เติม credits ผ่านโอนเงินธนาคาร (ปัจจุบันผ่าน gateway proxy)

สถานะและแพ็กเกจ ​

typescript
const status = await client.billing.status();
const packages = await client.billing.packages();

สร้างการชำระ Gommo (แนะนำ) ​

typescript
const me = await client.auth.me();
const username = me.userInfo?.username!;

const payment = await client.billing.createPayment({
  username,
  packageId: 'basic-member',
  invoiceBuyer: {
    type: 'consumer',
    name: 'Bán cho người tiêu dùng',
    email: '',
  },
  promoCode: 'OPTIONAL',
});

const orderCode = payment.data?.content ?? payment.data?.orderCode;
console.log(payment.data?.qrImage);

Poll จนชำระแล้ว ​

typescript
const sync = await client.billing.syncPayment({ orderCode: String(orderCode) });
if (sync.data?.paid) console.log('Credits applied by Gommo');

ประวัติคำสั่งซื้อ ​

typescript
const orders = await client.billing.listOrders(username, 20);

PayOS legacy ​

typescript
const order = await client.billing.createTopup({ username, packageId: 'basic-member' });

ต้องมี PAYOS_* บน server + merchant token

ดู Billing reference และ Cookbook: Gommo เติมเครดิต