function is_filiado() { $usuario = is_logged_in(); $ApiRede = ApiRede::getInstance(); $filiado = $ApiRede->getProfile($usuario->id); // trocar para e-mail if (is_array($filiado) && $filiado['httpCode'] == 404) { return false; } elseif ($filiado && ($filiado->status == 3 || $filiado->status > 10)) { return true; } return false; }
function doUserUpdate() { global $usuario; $apiErrors = null; $profile = ApiRede::getInstance()->getProfile($usuario->id); if ($profile->user_id == $usuario->id) { $profile = (array) $profile; unset($profile['dados_contribuicao']); $profile['fullname'] = $_POST['display_name']; foreach ($_POST as $k => $v) { if (preg_match('/^\\*+$/', $v)) { continue; } if ($k == 'user_id') { // Preventing an injection here. continue; } if ($k == 'contribuicao') { $v = str_replace(',', '.', preg_replace('/[^0-9,]+/', '', $v)); } $profile[$k] = $v; } if ($_POST['contribupdate'] == 1) { if ($profile['tipo'] == 'boleto') { unset($profile['bandeira']); unset($profile['cartao_nome']); unset($profile['cartao_numero']); unset($profile['cartao_codigo_verificacao']); unset($profile['cartao_validade_mes']); unset($profile['cartao_validade_ano']); } } $response = ApiRede::getInstance()->updateProfile($profile); error_log(print_r($response, true)); if (!empty($response->errors)) { $apiErrors = '<div class="pure-alert pure-alert-error">Os seguintes campos contém dados inválidos ou estão vazios: ' . implode(', ', array_keys((array) $response->errors)) . '</div>'; } else { if (is_array($response) && !empty($response['httpCode'])) { $apiErrors = '<div class="pure-alert pure-alert-error">Os dados não foram salvos. Por favor, verifique os dados informados e tente novamente.</div>'; } } } if (null !== $apiErrors) { return $apiErrors; } return '<div class="pure-alert pure-alert-success">Perfil atualizado com sucesso. Caso tenha atualizado os dados de contribuição, eles não aparecem posteriormente por questões de segurança.</div>'; }
<?php //$wp_session = WP_Session::get_instance(); global $usuario; if (isset($_COOKIE['access_token'])) { $ApiRede = ApiRede::getInstance(); $filiado = $ApiRede->getProfile($usuario->id); // trocar para e-mail // try { // $provider = new RsProvider([ // 'clientId' => OAUTH_CLIENT_ID, // 'clientSecret' => OAUTH_CLIENT_SECRET, // 'redirectUri' => OAUTH_REDIRECT_URI, // 'urlAuthorize' => OAUTH_URL_AUTHORIZE, // 'urlAccessToken' => OAUTH_URL_ACCESS_TOKEN, // 'urlResourceOwnerDetails' => OAUTH_URL_RESOURCE // ], ['httpClient' => new \GuzzleHttp\Client(array('verify'=>false))]); // $accessToken = $_COOKIE['access_token']; // $request = $provider->getAuthenticatedRequest( // 'GET', // WP_PASSPORT_PATH . '/user', // $accessToken // ); // $client = new \GuzzleHttp\Client(['base_uri' => WP_PASSPORT_PATH]); // $response = $client->send($request); // $usuario = $response->getBody()->getContents(); // // if (!isset($_COOKIE['usuario'])) { // setcookie('usuario', $usuario); // } // $usuario = json_decode($usuario);
function rs_payment_payment() { $api = ApiRede::getInstance(); $payments = $api->getPayments(); ?> <div class="wrap"> <h2>Contribuições processadas</h2> <br class="clear"> <table class="wp-list-table widefat fixed posts" cellspacing="0"> <thead> <tr> <th scope="col" id="title" class="manage-column column-title">Filiado</th> <th scope="col" id="phone" class="manage-column column-phone">Telefones</th> <th scope="col" id="contrib" class="manage-column column-contrib">Doação</th> <th scope="col" id="return" class="manage-column column-return">Retorno</th> <th scope="col" id="transaction" class="manage-column column-transaction">Transação</th> <th scope="col" id="date" class="manage-column column-date">Data</th> </tr> </thead> <tfoot> <tr> <th scope="col" class="manage-column column-title">Filiado</th> <th scope="col" class="manage-column column-phone">Telefones</th> <th scope="col" class="manage-column column-contrib">Doação</th> <th scope="col" class="manage-column column-return">Retorno</th> <th scope="col" class="manage-column column-transaction">Transação</th> <th scope="col" class="manage-column column-date">Data</th> </tr> </tfoot> <tbody id="the-list"> <?php $i = 0; foreach ($payments as $payment) { ?> <tr id="payment-<?php echo $payment->id; ?> " class="payment-<?php echo $payment->id; ?> <?php if ($i % 2 == 0) { echo 'alternate'; } ?> " valign="top"> <td class="title column-title"> <?php if (!empty($payment->profile)) { ?> <strong><a class="row-title" href="#"><?php echo $payment->profile->fullname; ?> </a></strong><br> <?php echo $payment->profile->cpf; ?> | <?php echo $payment->profile->nome_mae; ?> | <?php echo $payment->profile->birthday; ?> <?php } else { ?> -<?php } ?> </td> <td class="contact column-phone"> <?php if (!empty($payment->profile)) { ?> <?php $phones = array('Residencial' => $payment->profile->telefone_residencial, 'Celular' => $payment->profile->telefone_celular, 'Comercial' => $payment->profile->telefone_comercial); ?> <?php $i = 0; foreach ($phones as $name => $phone) { if (empty($phone)) { continue; } ?> <?php if ($i > 0) { echo '<br>'; } ?> <?php echo $name . ': <strong>' . $phone . '</strong>'; ?> <?php $i++; } ?> <?php } else { ?> -<?php } ?> </td> <td class="categories column-contrib"><?php echo 'R$ ' . number_format($payment->amount / 100, 2, ',', '.'); ?> | **** **** **** <?php echo $payment->number; ?> </td> <td class="tags column-return"><?php echo $payment->return_code . ' - ' . $payment->return_message; ?> </td> <td class="comments column-transaction"><?php echo $payment->transaction_id; ?> </td> <td class="date column-date"><?php echo $payment->created_at; ?> </td> </tr> <?php $i++; } ?> </tbody> </table> <br class="clear"> </div> <?php }