Skip to Content
defold-typescript libraries
megalanthusdefold-gamepush

megalanthus/defold-gamepush/gamepush.core.payments

GamePush in-game purchases and subscriptions: products, purchase, consume and their events.

  • GitHub: megalanthus/defold-gamepush — pinned to v1.4.1
    1. Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as core_payments from "gamepush.core.payments"

Functions

is_available(): boolean

Whether the platform supports payments.

Returns

  • boolean

products(): Record<string, unknown>[]

The products on sale.

Returns

  • Record<string, unknown>[]

purchases(): Record<string, unknown>[]

The player's purchases.

Returns

  • Record<string, unknown>[]

purchase(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Buys a product. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The product to buy, for example { id: 749 }.
  • callback?: (result: unknown) => void — Receives the purchase result.

consume(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Consumes a purchase. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The product to consume, for example { id: 749 }.
  • callback?: (result: unknown) => void — Receives the consume result.

has(product: string | number): boolean

Whether the player owns a product.

Parameters

  • product: string | number — The product's id or tag.

Returns

  • boolean

fetch_products(callback?: (result: unknown) => void)

Fetches the product list.

Parameters

  • callback?: (result: unknown) => void — Receives the fetch result.

is_subscriptions_available(): boolean

Whether the platform supports subscriptions.

Returns

  • boolean

subscribe(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Subscribes the player. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The subscription, for example { tag: "Test_subscription" }.
  • callback?: (result: unknown) => void — Receives the subscription result.

unsubscribe(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Cancels a subscription. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The subscription, for example { tag: "Test_subscription" }.
  • callback?: (result: unknown) => void — Receives the cancellation result.

Variables

callbacks: PaymentsCallbacks

The payment event handlers.

Types

PaymentsCallbacks

PaymentsCallbacks.purchase?: (result: unknown) => void

A product was purchased.

PaymentsCallbacks.error_purchase?: (error: unknown) => void

A purchase failed.

PaymentsCallbacks.consume?: (result: unknown) => void

A purchase was consumed.

PaymentsCallbacks.error_consume?: (error: unknown) => void

Consuming a purchase failed.

PaymentsCallbacks.fetch_products?: (result: unknown) => void

The product list was fetched.

PaymentsCallbacks.error_fetch_products?: (error: unknown) => void

Fetching the product list failed.

PaymentsCallbacks.subscribe?: (result: unknown) => void

The player subscribed.

PaymentsCallbacks.error_subscribe?: (error: unknown) => void

Subscribing failed.

PaymentsCallbacks.unsubscribe?: (result: unknown) => void

The player unsubscribed.

PaymentsCallbacks.error_unsubscribe?: (error: unknown) => void

Unsubscribing failed.

On this page