GS2-Money Script Trigger Reference

Reference for event triggers that call extended scripts

Trigger

createWallet

wallet creation

Synchronous Execution Script

The script is executed synchronously before the wallet creation process.

Request
Type Description
namespace Namespace Namespace
wallet Wallet Wallet
Result
Type Required Default Value Limits Description
permit bool
Whether to allow wallet creation
initialAmount int
0 ~ 2147483645 Initial Wallet balance - will be credited as a free grant
Implementation Example
-- Request
local namespace = args.namespace
local wallet = args.wallet

-- Business logic:
local permit = true
local initialAmount = 0

-- Result
result = {
  permit=permit,
  initialAmount=initialAmount
}

Asynchronous Execution Script

The script is executed asynchronously after the wallet creation process.

Request
Type Description
namespace Namespace Namespace
wallet Wallet Wallet
Implementation Example
-- Request
local namespace = args.namespace
local wallet = args.wallet

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

deposit

Wallet balance addition

Synchronous Execution Script

The script is executed synchronously before the wallet balance addition process.

Request
Type Description
namespace Namespace Namespace
oldWallet Wallet Wallet before deposit
newWallet Wallet Wallet after deposit
price float Purchase Price
depositCount int Quantity of premium currency to be granted
Result
Type Required Default Value Limits Description
permit bool
Whether to allow wallet balance addition
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local price = args.price
local depositCount = args.depositCount

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the wallet balance addition process.

Request
Type Description
namespace Namespace Namespace
oldWallet Wallet Wallet before deposit
newWallet Wallet Wallet after deposit
price float Purchase Price
depositCount int Quantity of premium currency to be granted
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local price = args.price
local depositCount = args.depositCount

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

withdraw

Wallet balance consumption

Synchronous Execution Script

The script is executed synchronously before the wallet balance consumption process.

Request
Type Description
namespace Namespace Namespace
oldWallet Wallet Wallet before withdraw
newWallet Wallet Wallet after withdraw
withdrawCount int Quantity of premium currency to be consumed
paidOnly bool Whether to target only paid currency
Result
Type Required Default Value Limits Description
permit bool
Whether to allow wallet balance consumption
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local withdrawCount = args.withdrawCount
local paidOnly = args.paidOnly

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the wallet balance consumption process.

Request
Type Description
namespace Namespace Namespace
oldWallet Wallet Wallet before withdraw
newWallet Wallet Wallet after withdraw
withdrawCount int Quantity of premium currency to be consumed
paidOnly bool Whether to target only paid currency
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local withdrawCount = args.withdrawCount
local paidOnly = args.paidOnly

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}