GS2-Money2 Script Trigger Reference

Reference of event triggers that call extended scripts

Trigger

deposit

Wallet balance addition

Synchronous Execution Script

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

Request
TypeDescription
namespaceNamespaceNamespace
oldWalletWalletWallet before deposit
newWalletWalletWallet after deposit
transactionsDepositTransaction[]List of occurred transactions
countintAmount of balance to be added
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow wallet balance addition
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local transactions = args.transactions
local count = args.count

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

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

Request
TypeDescription
namespaceNamespaceNamespace
oldWalletWalletWallet before deposit
newWalletWalletWallet after deposit
transactionsDepositTransaction[]List of occurred transactions
countintAmount of balance to be added
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local transactions = args.transactions
local count = args.count

-- 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
TypeDescription
namespaceNamespaceNamespace
oldWalletWalletWallet before withdraw
newWalletWalletWallet after withdraw
transactionsDepositTransaction[]List of occurred transactions
countintAmount of balance to be consumed
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow wallet balance consumption
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local transactions = args.transactions
local count = args.count

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

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

Request
TypeDescription
namespaceNamespaceNamespace
oldWalletWalletWallet before withdraw
newWalletWalletWallet after withdraw
transactionsDepositTransaction[]List of occurred transactions
countintAmount of balance to be consumed
Implementation Example
-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local transactions = args.transactions
local count = args.count

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

result = {
}

subscribe

New subscription

Synchronous Execution Script

The script is executed synchronously before the new subscription process.

Request
TypeDescription
namespaceNamespaceNamespace
contentModelStoreSubscriptionContentModelStore Subscription Content Model
transactionSubscribeTransactionSubscription Status
userIdstringUser ID
ttlAtlongTime to live for GS2-Schedule trigger
Implementation Example
-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local userId = args.userId
local ttlAt = args.ttlAt

-- Business logic:

-- Result
result = {
}

renew

Renewal subscription

Synchronous Execution Script

The script is executed synchronously before the renewal subscription process.

Request
TypeDescription
namespaceNamespaceNamespace
contentModelStoreSubscriptionContentModelStore Subscription Content Model
transactionSubscribeTransactionSubscription Status
userIdstringUser ID
ttlAtlongTime to live for GS2-Schedule trigger
Implementation Example
-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local userId = args.userId
local ttlAt = args.ttlAt

-- Business logic:

-- Result
result = {
}

unsubscribe

Unsubscribe

Synchronous Execution Script

The script is executed synchronously before the unsubscribe process.

Request
TypeDescription
namespaceNamespaceNamespace
contentModelStoreSubscriptionContentModelStore Subscription Content Model
transactionSubscribeTransactionSubscription Status
userIdstringUser ID
Implementation Example
-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local userId = args.userId

-- Business logic:

-- Result
result = {
}

takeOver

Subscription take over

Synchronous Execution Script

The script is executed synchronously before the subscription take over process.

Request
TypeDescription
namespaceNamespaceNamespace
contentModelStoreSubscriptionContentModelStore Subscription Content Model
transactionSubscribeTransactionSubscription Status
fromUserIdstringUser ID
toUserIdstringUser ID
elapsedHoursintElapsed hours since last user change
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow subscription take over
Implementation Example
-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local fromUserId = args.fromUserId
local toUserId = args.toUserId
local elapsedHours = args.elapsedHours

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the subscription take over process.

Request
TypeDescription
namespaceNamespaceNamespace
contentModelStoreSubscriptionContentModelStore Subscription Content Model
transactionSubscribeTransactionSubscription Status
fromUserIdstringUser ID
toUserIdstringUser ID
elapsedHoursintElapsed hours since last user change
Implementation Example
-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local fromUserId = args.fromUserId
local toUserId = args.toUserId
local elapsedHours = args.elapsedHours

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

result = {
}

verifyReceipt

Receipt verification

Synchronous Execution Script

The script is executed synchronously before the receipt verification process.

Request
TypeDescription
namespaceNamespaceNamespace
storeContentModelStoreContentModelStore Content Model
receiptReceiptReceipt
userIdstringUser ID
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow receipt verification
Implementation Example
-- Request
local namespace = args.namespace
local storeContentModel = args.storeContentModel
local receipt = args.receipt
local userId = args.userId

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the receipt verification process.

Request
TypeDescription
namespaceNamespaceNamespace
storeContentModelStoreContentModelStore Content Model
receiptReceiptReceipt
userIdstringUser ID
Implementation Example
-- Request
local namespace = args.namespace
local storeContentModel = args.storeContentModel
local receipt = args.receipt
local userId = args.userId

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

result = {
}