> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Money2 Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### deposit

Wallet balance addition

**Related methods:**
depositByUserId - Deposit balance to Wallet by User ID


#### Synchronous Execution Script

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

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before deposit |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after deposit |
| transactions | [DepositTransaction[]](../sdk/#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


**Lua**
```lua

-- 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](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before deposit |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after deposit |
| transactions | [DepositTransaction[]](../sdk/#deposittransaction) | List of occurred transactions |
| count | int | Amount of balance to be added |


##### Implementation Example


**Lua**
```lua

-- 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.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### withdraw

Wallet balance consumption

**Related methods:**
withdraw - Withdraw balance from wallet


#### Synchronous Execution Script

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

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before withdraw |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after withdraw |
| transactions | [DepositTransaction[]](../sdk/#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


**Lua**
```lua

-- 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](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before withdraw |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after withdraw |
| transactions | [DepositTransaction[]](../sdk/#deposittransaction) | List of occurred transactions |
| count | int | Amount of balance to be consumed |


##### Implementation Example


**Lua**
```lua

-- 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.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### subscribe

New subscription

**Related methods:**
allocateSubscriptionStatus - Allocate subscription status from receipt
allocateSubscriptionStatusByUserId - Allocate subscription status by User ID from receipt


#### Synchronous Execution Script

The script is executed synchronously before the new subscription process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| contentModel | [StoreSubscriptionContentModel](../sdk/#storesubscriptioncontentmodel) | Store Subscription Content Model |
| transaction | [SubscribeTransaction](../sdk/#subscribetransaction) | Subscription Status |
| userId | string | User ID |
| ttlAt | long | Time to live for GS2-Schedule trigger |


##### Implementation Example


**Lua**
```lua

-- 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](../sdk/#namespace) | Namespace |
| contentModel | [StoreSubscriptionContentModel](../sdk/#storesubscriptioncontentmodel) | Store Subscription Content Model |
| transaction | [SubscribeTransaction](../sdk/#subscribetransaction) | Subscription Status |
| userId | string | User ID |
| ttlAt | long | Time to live for GS2-Schedule trigger |


##### Implementation Example


**Lua**
```lua

-- 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](../sdk/#namespace) | Namespace |
| contentModel | [StoreSubscriptionContentModel](../sdk/#storesubscriptioncontentmodel) | Store Subscription Content Model |
| transaction | [SubscribeTransaction](../sdk/#subscribetransaction) | Subscription Status |
| userId | string | User ID |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local contentModel = args.contentModel
local transaction = args.transaction
local userId = args.userId

-- Business logic:

-- Result
result = {
}
```


---
  
### takeOver

Subscription takeover

**Related methods:**
takeoverSubscriptionStatus - Takeover the subscription status of a subscription that is already assigned to another user
takeoverSubscriptionStatusByUserId - Takeover the subscription status of a subscription that is already assigned to another user by User ID


#### Synchronous Execution Script

The script is executed synchronously before the subscription takeover process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| contentModel | [StoreSubscriptionContentModel](../sdk/#storesubscriptioncontentmodel) | Store Subscription Content Model |
| transaction | [SubscribeTransaction](../sdk/#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 takeover |

##### Implementation Example


**Lua**
```lua

-- 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 takeover process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| contentModel | [StoreSubscriptionContentModel](../sdk/#storesubscriptioncontentmodel) | Store Subscription Content Model |
| transaction | [SubscribeTransaction](../sdk/#subscribetransaction) | Subscription Status |
| fromUserId | string | User ID |
| toUserId | string | User ID |
| elapsedHours | int | Elapsed hours since last user change |


##### Implementation Example


**Lua**
```lua

-- 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.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### verifyReceipt

Receipt verification

**Related methods:**
verifyReceipt - Record receipt


#### Synchronous Execution Script

The script is executed synchronously before the receipt verification process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| storeContentModel | [StoreContentModel](../sdk/#storecontentmodel) | Store Content Model |
| receipt | [Receipt](../sdk/#receipt) | Receipt |
| userId | string | User ID |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow receipt verification |

##### Implementation Example


**Lua**
```lua

-- 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](../sdk/#namespace) | Namespace |
| storeContentModel | [StoreContentModel](../sdk/#storecontentmodel) | Store Content Model |
| receipt | [Receipt](../sdk/#receipt) | Receipt |
| userId | string | User ID |


##### Implementation Example


**Lua**
```lua

-- 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.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  



