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.

Canjeando las bonificaciones que ha ganado con su programa de marketing de referidos

Prerequisites:

  1. Platform Registration: Sign up for Genius Referrals and obtain your API credentials.
  2. Genius Referrals SDK: Ensure you have installed the Genius Referrals SDK for PHP.
Step 1: Allow Advocates to Add Payment Methods
Enable your advocates to add payment methods, such as a PayPal account, to redeem their bonuses.
<?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.
}
?>
Step 2: Allow Advocates to Create Payment Requests to Redeem Their Bonuses
Allow your advocates to redeem their earned bonuses for credit, cash, gift cards, coupons, etc.
<?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.
}
Step 3: Process Redemption Requests
Handle redemption requests to ensure that advocates receive their bonuses in the preferred method, such as cash, credit, or gift cards.
<?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.
}
Step 4: Display Bonus Details
Retrieve and display the available bonus information for advocates.
<?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.
}
Was this page helpful?
LANGUAGE