Managing Bonuses for Advocates
Discover How to Simplify the Process of Allowing Advocates to Manage and Redeem Their Bonuses. This guide includes practical PHP examples from Genius Referrals to help you seamlessly integrate these features into your system.
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e"; // 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);
$advocatesController = $client->getAdvocates();
//// 1. Find advocate by email
$advocateEmail = 'john.doe@example.com'; // The advocate's email
$advocatesController = $client->getAdvocates();
$advocateResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $advocateEmail);
if($advocateResponse->data->total == 1){ // Found the advocate?
$advocate = $advocateResponse->data->results[0];
$paymentMethodModel = new \GeniusReferralsLib\Models\PaymentMethod();
$paymentMethodModel->description = 'Personal PayPal account';
$paymentMethodModel->isActive = true;
$paymentMethodModel->username = 'john@mail.com';
$paymentMethodForm = new \GeniusReferralsLib\Models\PaymentMethodForm($paymentMethodModel);
$paymentMethodResponse = $advocatesController->postPaymentMethod($accountSlug, $advocate->token, $paymentMethodForm);
if(isset($paymentMethodResponse->id)){
// PayPal account successfully created
}
else{
// handle errors
}
}else{
// We couldn't find the advocate, nothing to do here.
}
?>
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e6"; // 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);
$advocatesController = $client->getAdvocates();
//// 1. Find advocate by email
$advocateEmail = 'john.doe@example.com'; // The advocate's email
$advocatesController = $client->getAdvocates();
$advocateResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $advocateEmail);
if($advocateResponse->data->total == 1){ // Found the advocate?
$advocate = $advocateResponse->data->results[0];
$redemptionRequestModel = new \GeniusReferralsLib\Models\RedemptionRequest();
$redemptionRequestModel->description = 'Redeeming as credit';
$redemptionRequestModel->advocateToken = $advocate->token;
$redemptionRequestModel->amount = 50;
$redemptionRequestModel->currencyCode = 'USD';
$redemptionRequestModel->requestActionSlug = 'credit';
$redemptionRequestModel->requestStatusSlug = 'requested';
$redemptionRequestForm = new \GeniusReferralsLib\Models\RedemptionRequestForm($redemptionRequestModel);
$redemptionRequestController = $client->getRedemptionRequests();
$redemptionRequestResponse = $redemptionRequestController->postRedemptionRequest($accountSlug,$redemptionRequestForm);
if(isset($redemptionRequestResponse->id)){
// RedemptionRequest successfully created
}
else{
// handle errors
}
}else{
// We couldn't find the advocate, nothing to do here.
}
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e6"; // 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);
$advocatesController = $client->getAdvocates();
//// 1. Find advocate by email
$advocateEmail = 'john.doe@example.com'; // The advocate's email
$advocatesController = $client->getAdvocates();
$advocateResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $advocateEmail);
if($advocateResponse->data->total == 1){ // Found the advocate?
$advocate = $advocateResponse->data->results[0];
$redemptionRequestID = 19530526;
$redemptionRequestController = $client->getRedemptionRequests();
$redemptionRequestController->patchRedemptionRequest($accountSlug,$redemptionRequestID);
}else{
// We couldn't find the advocate, nothing to do here.
}
<?php
require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e6"; // 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);
$advocatesController = $client->getAdvocates();
//// 1. Find advocate by email
$advocateEmail = 'john.doe@example.com'; // The advocate's email
$advocatesController = $client->getAdvocates();
$advocateResponse = $advocatesController->getAdvocates($accountSlug,1,1, 'email::' . $advocateEmail);
if($advocateResponse->data->total == 1){ // Found the advocate?
$advocate = $advocateResponse->data->results[0];
$advocateUnclaimedBalance = $advocate->unclaimed_balance;
$advocateClaimedBalance = $advocate->unclaimed_balance;
$advocateTotalReferralsGenerated = $advocate->total_referrals;
$advocateTotalBonusesGenerated = $advocate->total_bonuses;
}else{
// We couldn't find the advocate, nothing to do here.
}