Skip to content

Instantly share code, notes, and snippets.

@caionorder
Created April 22, 2016 20:58
Show Gist options
  • Save caionorder/a49dee6a13a42bd75b814cc6baa82fa8 to your computer and use it in GitHub Desktop.
Save caionorder/a49dee6a13a42bd75b814cc6baa82fa8 to your computer and use it in GitHub Desktop.
<?PHP
class UsersController extends AppController{
use Gerencianet\Exception\GerencianetException;
use Gerencianet\Gerencianet;
public function admin_home($id=null) {
$this->layout="Adm.admin";
$this->User->recursive = 3;
if ($this->request->is('post')) {
$id = $this->request->params['pass'][0];
$user = $this->User->find('all',array(
'conditions'=>array(
'User.id'=>$id
)
)
);
$user = $user[0]['User'];
App::import('Vendor', 'Vendor', array('file'=>'Vendor/autoload.php'));
$clientId = 'Client_Id_76ca70999bb5ba6cdc876f9f101b20134039bd17';
$clientSecret = 'Client_Secret_ba3fa57abaf8ac0ef4809fd1695ae5a0076a742c';
$options = [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'sandbox' => true
];
$params = [
'id' => 1000
];
$customer = [
'name' => 'Gorbadoc Oldbuck',
'cpf' => '04267484171' ,
'phone_number' => '5144916523'
];
$bankingBillet = [
'expire_at' => '2018-12-12',
'customer' => $customer
];
$payment = [
'banking_billet' => $bankingBillet
];
$body = [
'payment' => $payment
];
try {
$api = new Gerencianet($options);
$charge = $api->payCharge($params, $body);
print_r($charge);
} catch (GerencianetException $e) {
print_r($e->code);
print_r($e->error);
print_r($e->errorDescription);
} catch (Exception $e) {
print_r($e->getMessage());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment