Trigger Reference of GS2-Exchange Script

Reference for event triggers that call extended scripts, as defined in GS2-Exchange

exchange

Event trigger to call GS2-Script before Exchange.

Request

TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables

Result

TypeRequireDefaultLimitationDescription
permitboolAllow exchange
rateModestring“float”~ 128 charsRate mode
ratefloat1.0~ 1000Acquisition quantity rate
logRateLogRateLogarithmic acquisition correction

Implementation Example

namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
  permit=permit,
  rateMode=rateMode,
  rate=rate,
  logRate=logRate
}

exchangeDone

GS2-Script called after Exchange.

Request

TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

incrementalExchange

Event trigger to call GS2-Script before Exchange.

Request

TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables

Result

TypeRequireDefaultLimitationDescription
permitboolAllow exchange

Implementation Example

namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
  permit=permit
}

incrementalExchangeDone

GS2-Script called after Exchange.

Request

TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

calculateCost

Event trigger to call GS2-Script when Costing Scripts for Cost Increase Type Exchange Rate.

Request

TypeDescription
namespaceNamespaceNamespace
incrementalRateModelIncrementalRateModelCost increase type exchange rate model
currentExchangeCountintCurrent number of exchange counts
quantityintExchange Quantity

Result

TypeRequireDefaultLimitationDescription
costModestring“num”~ 128 charsCost calculation method
costlong~ 9223372036854775805Cost
logCostLogCostCost calculation result using logarithm

Implementation Example

namespace = args.namespace
incrementalRateModel = args.incrementalRateModel
currentExchangeCount = args.currentExchangeCount
quantity = args.quantity

result = {
  costMode=costMode,
  cost=cost,
  logCost=logCost
}