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.

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

Requisitos Previos

  1. Registro en la plataforma: Regístrate en Genius Referrals y obtén tus credenciales de API.
  2. SDK de Genius Referrals: Asegúrate de haber instalado la SDK de Genius Referrals para PHP.
Paso 1: Permitir a los Promotores Crear Métodos de Pago
Permite a tus promotores añadir métodos de pago, como una cuenta de PayPal, para poder canjear sus bonificaciones.
<?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.
}
?>
Paso 2: Permitir a los Promotores Crear Solicitudes de Pagos para canjear sus Bonificaciones
Permite a tus promotores canjear sus bonificaciones ganadas por crédito, efectivo, tarjetas de regalo, coupones, 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.
}
Paso 3: Procesar las Solicitudes de Canje
Procesa las solicitudes de pagos para que los promotores reciban sus bonificaciones en la forma solicitada.
<?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.
}
Paso 4: Mostrar Información de las Bonificaciones
Obtiene y muestra la información de las bonificaciones disponibles para los promotores.
<?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.
}
¿Fue útil esta página?
LANGUAGE