Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PagSeguro extends CI_Controller {
- #protected $allowed_http_methods = array('get', 'delete', 'post', 'put');
- public function __construct() {
- parent::__construct();
- header('Access-Control-Allow-Origin: *');
- }
- public function notify() {
- PagSeguroLibrary::init();
- $pagseguroConfig = PagSeguroConfig::init();
- $pagseguroConfig->setEnvironment('sandbox');
- $pagseguroConfig->setData('credentials', 'token', array("sandbox" => 'x'));
- $pagseguroConfig->setData('credentials', 'appId', array("sandbox" => "x"));
- $pagseguroConfig->setData('credentials', 'appKey', array("sandbox" => "x"));
- $credentials = PagSeguroConfig::getAccountCredentials(); // getApplicationCredentials()
- $code = $this->input->post("notificationCode");
- $response = PagSeguroNotificationService::checkTransaction(
- $credentials,
- $code
- );
- // 'INITIATED' => 0,
- // 'WAITING_PAYMENT' => 1,
- // 'IN_ANALYSIS' => 2,
- // 'PAID' => 3,
- // 'AVAILABLE' => 4,
- // 'IN_DISPUTE' => 5,
- // 'REFUNDED' => 6,
- // 'CANCELLED' => 7,
- // 'SELLER_CHARGEBACK' => 8,
- // 'CONTESTATION' => 9
- log_message('error', "Recebida notificaçao do pagseguro");
- // pagamentos apenas
- if ($response->getType()->getValue() == 1 && is_numeric($response->getReference())) {
- // echo "<pre>";
- // var_dump($response);
- // echo "</pre>";
- $this->load->model("pagseguro_model");
- $this->pagseguro_model->adicionarTransacaoUpdate($response);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment