TikTok for Developers

Docs

Payment

checkBalance(cb,opts)

Callback

type Callback = (result: Result) => void;
interface Result {
  is_sufficient?: boolean;
  error?: {
    error_code: number;
    error_msg: string;
    error_extra: Record<string, unkown>;
  };
}

Options

interface Options {
  type: 'BEANS';
  amount: number;
}

Example

Minis.checkBalance(
  function (result) {
    if (result?.is_sufficient) {
      // do something
    } else {
      if (result?.error) {
        // error case do something
      } else {
        // do something for is_sufficient === false
      }
    }
  },
  {
    type: "BEANS",
    amount: 500,
  }
);

recharge(cb,opts)

Callback

   type Callback = (result: Result) => void;

    interface Result {
      is_success?: boolean;
      tier_id?: string;
      trade_order_id?: string;
      error?: {
        error_code: number;
        error_msg: string;
        error_extra: Record<string, unkown>;
      };
    }

Options

interface Options {
   /**
    * the target tier ID user chose
   */
   tier_id: string;
}

Example

Minis.recharg((result)=>{
  if(result.is_success){
    // do something
  } else {
    // do something
  }
},{tier_id: "demo"})

pay(cb,opts)

Callback

type PayBeansCallback = (result: Result) => void;

interface Result {
   is_success: boolean;
   error?: {
     error_code: number;
     error_msg: string;
     error_extra: Record<string, unkown>;
   };
 }

Options

interface Options {
  trade_order_id: string;      
}

Example

Minis.pay((result)=>{
  if(result.is_success){
    // do something
  } else {
    // do something
  }
},{trade_order_id: "demo"})

Jump to Balance page

Callback

type Callback = (result: Result) => void;
interface Result {
  is_success: boolean;
   error?: {
     error_code: number;
     error_msg: string;
     error_extra: Record<string, unknown>;
   };
}

Options

interface Options {
  type: 'BEANS'
}

Example

TTMinis.navigateToBalance((result) => {
  if(result?.is_success) {
    // do something
  } else {
    // do something
  }
}, {
  type: "BEANS"
})


Was this document helpful?
TikTok for Developers