TypeError .makeVirtualPurchase is not a function[

Hi

its pretty late already here but I am stuck at

await eco.makeVirtualPurchase(projectId, playerId, {
  id: 'TESTPURCHASE'
});

=

TypeError: eco.makeVirtualPurchase is not a function

The function exists in the eco config file and is published.
Other function calls of the api, like currencies, in the same scope work fine

 await eco.decrementPlayerCurrencyBalance(projectId, playerId, 'WOOD', {
      currencyId: 'WOOD',
      amount: priceList[upgradeValue].Wood,
    });

What do I miss here?
8160389--1060961--upload_2022-5-27_4-51-52.jpg

Ok I am a javascript noob

Even tough they point to the same require address they are different based on the constructor
const { CurrenciesApi } = require(" @ -services/economy-2.0");
const { PurchasesApi } = require(" @ -services/economy-2.0");

with an instance of purchaseAPI it works

Hi David,

I'm pleased to see that you figured it out.

You are correct, makeVirtalPurchaseand decrementPlayerCurrencyBalanceare from different parts of the API and both need to be included. You can combine them in to a single statement e.g. const { InventoryApi, CurrenciesApi } = require("@unity-services/economy-2.0");

1 Like