Emitir Bonificaciones a los Promotores via SDK
Aprende cómo otorgar bonificaciones a tus promotores después de que uno de sus referidos complete una acción en tu aplicación. Una vez que hayas identificado la acción de activación, puedes proceder a otorgar la bonificación. Esta guía te mostrará cómo hacerlo utilizando la SDK de PHP.
Requisitos Previos
Ejemplo de Configuración del Cliente en PHP.
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e674ba93b6"; // Your API Token, you can get your token here https://app.geniusreferrals.com/en/settings/api-access
$accountSlug = 'sandbox';
$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);
<?php
// 1. Find referral by email
$referralEmail = 'jane.doe@example.com'; // The referral's email
$advocatesController = $client->getAdvocates();
$referralResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $referralEmail);
<?php
// 2. Process the referral to issue a bonus to the referring advocate.
if($referralResponse->data->total == 1){ // Found the referral?
$referral = $referralResponse->data->results[0];
$bonusesModel = new \GeniusReferralsLib\Models\Bonuses();
$bonusesModel->advocateToken = $referral->token; // This is the token of the referral
$bonusesModel->paymentAmount = 1000; // This is the amount the referral has paid.
$bonusesModel->reference = 'Order 373625236273'; // This is an external reference e.g. order id, transaction id, etc.
$bonusesForm = new \GeniusReferralsLib\Models\BonusesForm($bonusesModel);
$bonusesController = $client->getBonuses();
$bonus = $bonusesController->postBonus($accountSlug, $bonusesForm);
}else{
// We couldn't find the referral, nothing to do here.
}
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e674ba"; // Your API Token, you can get your token here https://app.geniusreferrals.com/en/settings/api-access
$accountSlug = 'sandbox';
$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);
// 1. Find referral by email
$referralEmail = 'jane.doe@example.com'; // The referral's email
$advocatesController = $client->getAdvocates();
$referralResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $referralEmail);
// 2. Process the referral to issue a bonus to the referring advocate.
if($referralResponse->data->total == 1){ // Found the referral?
$referral = $referralResponse->data->results[0];
$bonusesModel = new \GeniusReferralsLib\Models\Bonuses();
$bonusesModel->advocateToken = $referral->token; // This is the token of the referral
$bonusesModel->paymentAmount = 1000; // This is the amount the referral has paid.
$bonusesModel->reference = 'Order 373625236273'; // This is an external reference e.g. order id, transaction id, etc.
$bonusesForm = new \GeniusReferralsLib\Models\BonusesForm($bonusesModel);
$bonusesController = $client->getBonuses();
$bonus = $bonusesController->postBonus($accountSlug, $bonusesForm);
}else{
// We couldn't find the referral, nothing to do here.
}