Namespace: iap
Interfaces
- ConsumePurchaseRequest
- IAPHandlers
- Product
- ProductsListResponse
- Purchase
- PurchaseData
- PurchaseItemData
- PurchasesResponse
- ServerRequest
- VKErrorResponse
- VKGetItemRequest
- VKGetItemResponse
- VKOrderItemStatusChangeRequest
- VKOrderItemStatusChangeResponse
- VKRequestBase
Type Aliases
ConsumePurchaseResponse
Ƭ ConsumePurchaseResponse: ApiResponse
VKHandlerConfig
Ƭ VKHandlerConfig: Partial
<Omit
<lambda.ApiGatewayHandlerConfig
<VKRequest
>, "handler"
| "errorHandler"
>>
VKRequest
Ƭ VKRequest: VKGetItemRequest
| VKOrderItemStatusChangeRequest
VKResponse
Ƭ VKResponse: VKErrorResponse
| VKGetItemResponse
| VKOrderItemStatusChangeResponse
Variables
VK_SCHEMA
• Const
VK_SCHEMA: Object
Type declaration
Name | Type |
---|---|
properties |
{ app_id : { type : string = ’number’ } ; date : { type : string = ’number’ } ; item : { type : string = ‘string’ } ; item_id : { type : string = ‘string’ } ; item_photo_url : { type : string = ‘string’ } ; item_price : { type : string = ‘string’ } ; item_title : { type : string = ‘string’ } ; lang : { type : string = ‘string’ } ; notification_type : { type : string = ‘string’ } ; order_id : { type : string = ’number’ } ; receiver_id : { type : string = ’number’ } ; sig : { type : string = ‘string’ } ; status : { type : string = ‘string’ } ; user_id : { type : string = ’number’ } } |
properties.app_id |
{ type : string = ’number’ } |
properties.app_id.type |
string |
properties.date |
{ type : string = ’number’ } |
properties.date.type |
string |
properties.item |
{ type : string = ‘string’ } |
properties.item.type |
string |
properties.item_id |
{ type : string = ‘string’ } |
properties.item_id.type |
string |
properties.item_photo_url |
{ type : string = ‘string’ } |
properties.item_photo_url.type |
string |
properties.item_price |
{ type : string = ‘string’ } |
properties.item_price.type |
string |
properties.item_title |
{ type : string = ‘string’ } |
properties.item_title.type |
string |
properties.lang |
{ type : string = ‘string’ } |
properties.lang.type |
string |
properties.notification_type |
{ type : string = ‘string’ } |
properties.notification_type.type |
string |
properties.order_id |
{ type : string = ’number’ } |
properties.order_id.type |
string |
properties.receiver_id |
{ type : string = ’number’ } |
properties.receiver_id.type |
string |
properties.sig |
{ type : string = ‘string’ } |
properties.sig.type |
string |
properties.status |
{ type : string = ‘string’ } |
properties.status.type |
string |
properties.user_id |
{ type : string = ’number’ } |
properties.user_id.type |
string |
required |
string [] |
type |
string |
Functions
VKHookErrorResponse
▸ VKHookErrorResponse(error
): Promise
<APIGatewayProxyResult
>
Parameters
Name | Type |
---|---|
error |
any |
Returns
Promise
<APIGatewayProxyResult
>
VKPlatformGetItemInfo
▸ VKPlatformGetItemInfo(purchasableData
, request
): Promise
<VKGetItemResponse
| VKErrorResponse
>
Parameters
Name | Type |
---|---|
purchasableData |
PurchaseItemData [] |
request |
VKGetItemRequest |
Returns
Promise
<VKGetItemResponse
| VKErrorResponse
>
VKPlatformHookHandler
▸ VKPlatformHookHandler(purchasableData
, inventoryTableId
, request
): Promise
<APIGatewayProxyResult
>
Parameters
Name | Type |
---|---|
purchasableData |
PurchaseItemData [] |
inventoryTableId |
string |
request |
Partial <VKRequest > |
Returns
Promise
<APIGatewayProxyResult
>
VKPlatformUpdateOrder
▸ VKPlatformUpdateOrder(inventoryTableId
, request
): Promise
<VKOrderItemStatusChangeResponse
| VKErrorResponse
>
Parameters
Name | Type |
---|---|
inventoryTableId |
string |
request |
VKOrderItemStatusChangeRequest |
Returns
Promise
<VKOrderItemStatusChangeResponse
| VKErrorResponse
>
VKSchemaErrorHandler
▸ VKSchemaErrorHandler(ajv
, errors
): VKErrorResponse
Parameters
Name | Type |
---|---|
ajv |
Ajv |
errors |
ErrorObject [] |
Returns
consumeHandler
▸ consumeHandler(inventoryTableId
, playerId
, request
): Promise
<ConsumePurchaseResponse
>
Parameters
Name | Type |
---|---|
inventoryTableId |
string |
playerId |
GlobalPlayerId |
request |
ConsumePurchaseRequest |
Returns
Promise
<ConsumePurchaseResponse
>
consumeOrder
▸ consumeOrder(inventoryTableId
, player_id
, purchaseToken
): Promise
<boolean
>
Consume an order
Parameters
Name | Type | Description |
---|---|---|
inventoryTableId |
string |
- |
player_id |
string |
player id |
purchaseToken |
string |
unique identifier from order data |
Returns
Promise
<boolean
>
createIAPHandlers
▸ createIAPHandlers(inventoryTableId
, purchasableData
): IAPHandlers
A helper function to initialize and manage a simple in-app-purchase backend.
Parameters
Name | Type |
---|---|
inventoryTableId |
string |
purchasableData |
PurchaseItemData [] |
Returns
createVKHandler
▸ createVKHandler(inventoryTableId
, purchasableData
, config
): lambda.ApiGatewayHandler
Parameters
Name | Type |
---|---|
inventoryTableId |
string |
purchasableData |
PurchaseItemData [] |
config |
Partial <Omit <ApiGatewayHandlerConfig <VKRequest >, "handler" | "errorHandler" >> |
Returns
lambda.ApiGatewayHandler
getInventoryHandler
▸ getInventoryHandler(inventoryTableId
, playerId
, request
): Promise
<PurchasesResponse
>
Parameters
Name | Type |
---|---|
inventoryTableId |
string |
playerId |
GlobalPlayerId |
request |
ServerRequest |
Returns
Promise
<PurchasesResponse
>
getOrderData
▸ getOrderData(inventoryTableId
, player_id
, order_id
): Promise
<Partial
<PurchaseData
> | undefined
>
Read purchased item data from the database. Returns undefined
if the order id does not match
an entry. The return type is defined as Partial<PurchaseData>
to account for possible new
properties in the interface that have not been updated for all players.
Parameters
Name | Type | Description |
---|---|---|
inventoryTableId |
string |
- |
player_id |
string |
player id |
order_id |
number |
Target order ID |
Returns
Promise
<Partial
<PurchaseData
> | undefined
>
getOrders
▸ getOrders(inventoryTableId
, player_id
): Promise
<Partial
<PurchaseData
>[] | undefined
>
Read purchased item data from the database. Returns all of the existing orders of a player
Parameters
Name | Type | Description |
---|---|---|
inventoryTableId |
string |
- |
player_id |
string |
Target player ID |
Returns
Promise
<Partial
<PurchaseData
>[] | undefined
>
getProductsHandler
▸ getProductsHandler(purchasableData
, playerId
, request
): Promise
<ProductsListResponse
>
Parameters
Name | Type |
---|---|
purchasableData |
PurchaseItemData [] |
playerId |
GlobalPlayerId |
request |
ServerRequest |
Returns
Promise
<ProductsListResponse
>
isReadyHandler
▸ isReadyHandler(purchasableData
, inventoryTableId
, playerId
, request
): Promise
<ApiResponse
>
Parameters
Name | Type |
---|---|
purchasableData |
PurchaseItemData [] |
inventoryTableId |
string |
playerId |
GlobalPlayerId |
request |
ServerRequest |
Returns
Promise
<ApiResponse
>
setOrderData
▸ setOrderData(inventoryTableId
, player_id
, order_id
, item_id
): Promise
<void
>
Update/Set purchased item data in the database.
Parameters
Name | Type | Description |
---|---|---|
inventoryTableId |
string |
- |
player_id |
string |
Purchaser ID |
order_id |
number |
Order ID |
item_id |
string |
ID of item purchased |
Returns
Promise
<void
>