Skip to content

These samples push PlayFab real-money and paid-purchase events to the Creator Code attribution endpoint from an Azure Cloud Function, so purchases are attributed to creators.

  1. Nexus Support-a-Creator Getting Started Guide
  2. PlayFab Azure Cloud Functions Quick Start Guide
handlers.PushToNexus = function (args)
{
const requiredFields = ['creatorCode', 'transactionCurrency', 'transactionAmount', 'transactionID'];
for (let field of requiredFields)
{
if (!args[field])
{
log.error(`Missing required field: ${field}`);
return;
}
}
const contentBody =
{
creatorId: args.creatorCode,
playerName: args.playerName || "Unknown Player",
currency: args.transactionCurrency,
description: args.transactionName || "No Description",
subtotal: args.transactionAmount,
transactionId: args.transactionID,
transactionDate: new Date().toISOString(),
};
const contentType = "application/json";
const headers =
{
'X-SHARED-SECRET': 'nexus_sk_your_key_here'
};
const url = "https://api.nexus-dev.gg/v1/attributions/transactions";
try
{
const response = http.request(url, "POST", JSON.stringify(contentBody), contentType, headers);
if (response.status >= 200 && response.status < 300)
{
log.debug("Success:", response.body);
}
else
{
log.error("HTTP Error:", response.status, response.body);
}
return response;
}
catch (error)
{
log.error("Request failed:", error);
return null;
}
};

Both samples call the attribution endpoint:

POST/attributions/transactions

PlayFab exposes two events you can send to Nexus:

  1. player_realmoney_purchase: fires when a player makes a real-money purchase and carries the amount, currency, and transaction details. Use it to attribute real-money purchases to creators.
  2. player_paid_for_purchase: fires when a player completes a purchase and also covers in-game-currency purchases, so it can attribute both real-money and virtual-currency transactions.

Choose between player_realmoney_purchase and player_paid_for_purchase based on which purchases you attribute:

  • Use player_realmoney_purchase: If your creator program requires tracking and rewarding creators solely based on real-money transactions, this event is the best choice. It ensures that only actual monetary purchases are captured and processed, aligning with scenarios where real-money revenue is the primary focus.
  • Use player_paid_for_purchase: If your creator program needs to handle a broader range of transactions, including both real-money and in-game currency purchases, this event offers greater flexibility. It allows Nexus to process all types of purchases, making it ideal for scenarios where virtual currency transactions are also relevant for creator rewards or attribution.