GS2-Money2 Script Trigger Reference
Trigger
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 |
| transactions | DepositTransaction[] | List of occurred transactions |
| count | int | Amount of balance to be added |
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 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| oldWallet | Wallet | Wallet before deposit |
| newWallet | Wallet | Wallet after deposit |
| transactions | DepositTransaction[] | List of occurred transactions |
| count | int | Amount 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| oldWallet | Wallet | Wallet before withdraw |
| newWallet | Wallet | Wallet after withdraw |
| transactions | DepositTransaction[] | List of occurred transactions |
| count | int | Amount of balance to be consumed |
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 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| oldWallet | Wallet | Wallet before withdraw |
| newWallet | Wallet | Wallet after withdraw |
| transactions | DepositTransaction[] | List of occurred transactions |
| count | int | Amount 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| contentModel | StoreSubscriptionContentModel | Store Subscription Content Model |
| transaction | SubscribeTransaction | Subscription Status |
| userId | string | User ID |
| ttlAt | long | Time 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| contentModel | StoreSubscriptionContentModel | Store Subscription Content Model |
| transaction | SubscribeTransaction | Subscription Status |
| userId | string | User ID |
| ttlAt | long | Time 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| contentModel | StoreSubscriptionContentModel | Store Subscription Content Model |
| transaction | SubscribeTransaction | Subscription Status |
| userId | string | User 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| contentModel | StoreSubscriptionContentModel | Store Subscription Content Model |
| transaction | SubscribeTransaction | Subscription Status |
| fromUserId | string | User ID |
| toUserId | string | User ID |
| elapsedHours | int | Elapsed hours since last user change |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| contentModel | StoreSubscriptionContentModel | Store Subscription Content Model |
| transaction | SubscribeTransaction | Subscription Status |
| fromUserId | string | User ID |
| toUserId | string | User ID |
| elapsedHours | int | Elapsed 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| storeContentModel | StoreContentModel | Store Content Model |
| receipt | Receipt | Receipt |
| userId | string | User ID |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| storeContentModel | StoreContentModel | Store Content Model |
| receipt | Receipt | Receipt |
| userId | string | User 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 = {
}