Gestión de Bonificaciones por Promotores
Aprende cómo permitir que tus promotores gestionen y canjeen sus bonificaciones con facilidad. En Genius Referrals, te proporcionamos ejemplos prácticos en PHP para facilitar la integración de estas funcionalidades en tu sistema.
Requisitos Previos
<?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.
}