接入圖圖支付

讓你的產品用圖圖餘額為增值服務收費,不必自建支付。

三步接入

  1. 1

    複製 SDK

    把 lib/pay-sdk/index.ts 複製進你的產品倉。

  2. 2

    建立例項

    用你的 clientId 調 createTutuPay({ clientId })。

  3. 3

    發起收銀

    調 pay.checkout({ sku }),彈窗內完成登入+下單+支付。

import { createTutuPay } from '$lib/pay-sdk';

const pay = createTutuPay({
  baseUrl: import.meta.env.VITE_TUTUPAY_URL,
  clientId: 'tutudd'
});

const r = await pay.checkout({ kind: 'export_credits', sku: 'pack_100' });
if (r.status === 'paid') {
  // grant credits idempotently on your side; use r.orderId to double-check
}

它怎麼工作

託管收銀臺在 popup 內完成登入、下單與支付(同 tutuid 信任根,零重登),支付成功經 postMessage 回傳;產品不接觸餘額與支付憑證。新增 SKU 在後端 orders.rs sku_price() 加一行即可。

開啟整合演示