Public Purchasable Guide

The page outlines a detailed guide on setting up your own purchasable items.

Purchasable items can be added by creating and configuring M2_PurchaseablePrimaryAssets. The main purpose of this asset type is to encapsulate: what the purchasable does when purchased and data regarding how the purchasable should be represented/displayed. You can configure what the purchasable item does at different steps of the transaction the purchase executors. These are UObjects with overridable events that allow you to specify custom logic.

Purchasable data asset properties:

  • Display Name - The name of your purchasable. By default, this is the name that will appear in places such as the vending machine.

  • Purchase Requested Executor - This is fired when a player attempts to purchase this item.

  • Purchase Predicted Success Executor - This executor is fired when we believe a transaction will go through successfully.

  • Purchase Confirmed Executor - The transaction has been approved and actioned by M2 Connect.

  • Purchase Rejected Executor - The transaction has been rejected and ignored by M2 Connect.

  • Can Purchase Executor - Configurable logic allowing you to encapsulate when the purchasable item is allowed to be purchased. Note: this is not used in Origin internal. It is mostly meant to be used in UI to hide or show purchasable items when appropriate.

  • Custom Details - Allows you to add any additional data you might need for your purchasable items through custom instanced UObjects. This could be used to associate an icon with your purchasable items for us in UI.

Purchase Executors

We need to create executors for our purchasables so that they do something meaningful when purchased. Each purchase executor has itโ€™s own specific asset type associated with it (โ€œPurchase Confirmed Executorโ€ - M2_PurchaseConfirmedExecutor etc). We will take a look at the example BP_PurchaseConfirmedExecutor_AddInventoryItem blueprint to see how executors are constructed.

It is important to consider that executors can be called on client and/or server.

Each executor has an Execute function. This is where we will add our custom logic. This function has the following arguments:

  • PurchaseId - This will most likely not be useful to you.

  • Purchaser - the morpheus actor associated with the purchase.

  • Purchasable - A UObject the contains all data about what is being purchased.

  • Callback - A callback to be executed that informs Origin if the executor succeeded, failed or was unhandled. This should be called once in every code path. If the exector logic is not meant to be processed at all i.e. we should not process the logic because we are on client, we should use unhandled. An example of this is shown below.

In the example purchasable primary data asset, you can see that this purchasable item is configured to use the BP_PurchaseConfirmedExecutor_AddInventoryItem. This setup will trigger an object to be added to a players inventory when the purchasable item is purchased. The item added is configurable. Executors should be made configurable through properties whenever possible to improve their re-usability.

Last updated