/*
* En su método acción has algo similar a esto
*/
//el token del promotor que quiere adicionar la nueva cuenta de Paypal
$strGRAdvocateToken = '44ae47f4eda382a8f5830b78fedb7cf1de88981b0';
// Crear un nuevo objeto GRPHPAPIClient
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//Preparando la infomracion a enviar
$arrParams = array(
'advocate_payment_method' => array(
'username' => 'john@mail.com',
'description' => 'Cuenta personal de Paypal',
'is_active' => true
)
);
//Intentando crear una nueva cuenta de Paypal para el promotor
$strResponse = $objGeniusReferralsAPIClient->postAdvocatePaymentMethod('my-store', $strGRAdovocateToken, $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
// Cuenta de Paypal exitosamente creada
}
else{
// gestión de errores
}
/*
* En su método acción has algo similar a esto
*/
//el token del promotor que quiere canjear la bonificación
$strGRAdvocateToken = '44ae47f4eda382a8f5830b78fedb7cf1de88981b0';
// Crear un objeto GRPHPAPIClient
$objGeniusReferralsAPIClient = new GRPHPAPIClient('YOUR_USERNAME', 'YOUR_API_TOKEN');
//preparando los datos a ser enviados en el pedido
$arrParams = array(
'redemption_request' => array(
'advocate_token' => $strGRAdovocateToken,
'request_status_slug' => 'requested',
'request_action_slug' => 'credit',
'currency_code' => 'USD',
'amount' => 50,
'description' => 'Redeeming as credit'
)
);
//Intentando crear una nueva solicitud de canje para el promotor
$strResponse = $objGeniusReferralsAPIClient->postRedemptionRequest('my-store', $arrParams);
$intResponseCode = $objGeniusReferralsAPIClient->getResponseCode();
if($intResponseCode == 201){
// Pedido de canje creado exitosamente
}
else{
// gestión de errores
}