Log In

Linking Purchase Complete Event(Server)

Purchase completion events can also be received from multiplay servers.

After purchase, the player's status or server-manged items can be applied to the World that needs to be changed.

Items to be carried out in advance before linking purchases, please check more information in the following link.


Items to be carried out in advance before linking purchases



Multi-play elements must be implemented to use the IWP function to store purchase history.

The IWP completion event will be delivered by the ZEPETO IWP system upon purchase of the product by adding the onPurchased method to the World.multiplay package in the index.ts file.

  • onPurchased(Client, Receipt)
    • The onPurchased function has the following parameters:
      • Client: ID of purchased user
      • Receipt: Purchase information

When implementing IWP onPurchased() in the server code, logic must be implemented for failure or exception handling.

If you fail to receive the item when purchasing the IWP product, please implement the logic to create an error by referring to the example below so that there is no situation where only ZEM deduction occurs.
Cases in which failure or exception handling logic is not implemented and does not function normally will be rejected during World Review.

This is an example of receiving an IWP event from the server and updating the status of the user.

import { Sandbox, SandboxOptions, SandboxPlayer } from 'ZEPETO.Multiplay';
import { IReceiptMessage } from 'ZEPETO.Multiplay.IWP';

export default class extends Sandbox {

    onPurchased(client: SandboxPlayer, receipt: IReceiptMessage) {
        // Find purchased user by session id
        const player = this.state.players.get(client.sessionId);

        // Exception handling example
        if (error condition) {
            // The user's ZEM is not wrongfully deducted.  
            throw new Error('error message');

        // If onPurchased is terminated without any logic problems, the user's ZEM will be deducted normally.        

        // Set user stat by item id
        if (receipt.itemId == "potion.haste") {
            player.stat.speed += 1;
        } else if (receipt.itemId == "potion.gravity") {
            player.stat.jumpPower += 1;
        } else if (receipt.itemId == "sound.bgm") {
            player.stat.isBGMOn = true;
        } else {
   = + 1;