Пример #1
0
 public static function init()
 {
     if (self::$config == null) {
         self::$config = new PagSeguroConfig();
     }
     return self::$config;
 }
Пример #2
0
 public static function main()
 {
     $amount = 30.0;
     //Required
     $cardBrand = "visa";
     //Optional
     $maxInstallmentNoInterest = 2;
     //Optional
     try {
         /**
          * #### Credentials #####
          * Replace the parameters below with your credentials
          * You can also get your credentials from a config file. See an example:
          * $credentials = new PagSeguroAccountCredentials("*****@*****.**",
          *   "E231B2C9BCC8474DA2E260B6C8CF60D3");
          */
         $credentials = PagSeguroConfig::getAccountCredentials();
         // Application authentication
         //$credentials = PagSeguroConfig::getApplicationCredentials();
         //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3");
         $installments = PagSeguroInstallmentService::getInstallments($credentials, $amount, $cardBrand, $maxInstallmentNoInterest);
         self::printInstallment($installments);
     } catch (Exception $e) {
         die($e->getMessage());
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 public static function main()
 {
     $reference = "REF123";
     $initialDate = '2015-09-03T00:00';
     $finalDate = '2015-09-09T11:13';
     $pageNumber = 1;
     $maxPageResults = 20;
     //        $reference = "REF123";
     //
     //        $initialDate = '2014-12-03T00:00';
     //        $finalDate = '2014-12-08T00:00';
     //        $pageNumber = 1;
     //        $maxPageResults = 20;
     try {
         /*
          * #### Credentials #####
          * Substitute the parameters below with your credentials
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         // seller authentication
         $credentials = new PagSeguroAccountCredentials("*****@*****.**", "E231B2C9BCC8474DA2E260B6C8CF60D3");
         $credentials = PagSeguroConfig::getAccountCredentials();
         // application authentication
         //$credentials = PagSeguroConfig::getApplicationCredentials();
         //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3");
         $result = PagSeguroTransactionSearchService::searchByReference($credentials, $reference, $initialDate, $finalDate, $pageNumber, $maxPageResults);
         self::printResult($result, $initialDate, $finalDate);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #4
0
 /**
  * Perform instalation of PagSeguro module
  * 
  * @return boolean
  */
 public function install()
 {
     if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn') || !Configuration::updateValue('PAGSEGURO_EMAIL', '') || !Configuration::updateValue('PAGSEGURO_TOKEN', '') || !Configuration::updateValue('PAGSEGURO_URL_REDIRECT', '') || !Configuration::updateValue('PAGSEGURO_NOTIFICATION_URL', '') || !Configuration::updateValue('PAGSEGURO_CHARSET', PagSeguroConfig::getData('application', 'charset')) || !Configuration::updateValue('PAGSEGURO_LOG_ACTIVE', PagSeguroConfig::getData('log', 'active')) || !Configuration::updateValue('PAGSEGURO_LOG_FILELOCATION', PagSeguroConfig::getData('log', 'fileLocation')) || !Configuration::updateValue('PS_OS_PAGSEGURO', 0) || !$this->_generatePagSeguroOrderStatus()) {
         return false;
     }
     return true;
 }
Пример #5
0
 /**
  *
  */
 public static function main()
 {
     // Instantiate a new authorization request
     $authorizationRequest = new PagSeguroAuthorizationRequest();
     $authorizationRequest->setReference('REF123');
     $authorizationRequest->setRedirectURL('http://www.lojamodelo.com.br');
     $authorizationRequest->setNotificationURL('http://www.lojamodelo.com.br');
     /**
      * @enum "CREATE_CHECKOUTS",
      * @enum "RECEIVE_TRANSACTION_NOTIFICATIONS",
      * @enum "SEARCH_TRANSACTIONS",
      * @enum "MANAGE_PAYMENT_PRE_APPROVALS",
      * @enum "DIRECT_PAYMENT",
      * @enum "REFUND_TRANSACTIONS",
      * @enum "CANCEL_TRANSACTIONS"
      */
     $authorizationRequest->setPermissions(array("CREATE_CHECKOUTS", "RECEIVE_TRANSACTION_NOTIFICATIONS", "SEARCH_TRANSACTIONS", "MANAGE_PAYMENT_PRE_APPROVALS", "DIRECT_PAYMENT", "REFUND_TRANSACTIONS", "CANCEL_TRANSACTIONS"));
     try {
         /**
          * #### Credentials #####
          * Replace the parameters below with your credentials
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getApplicationCredentials();
          */
         $credentials = new PagSeguroApplicationCredentials("appId", "appKey");
         $credentials = PagSeguroConfig::getApplicationCredentials();
         // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
         $return = $authorizationRequest->register($credentials);
         self::printAuthorizationReturn($return);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 private function __construct()
 {
     self::$path = dirname(__FILE__);
     PagSeguroAutoloader::init();
     self::$resources = PagSeguroResources::init();
     self::$config = PagSeguroConfig::init();
     self::$log = LogPagSeguro::init();
 }
 private static function transactionNotification($notificationCode)
 {
     $credentials = PagSeguroConfig::getAccountCredentials();
     try {
         return PagSeguroNotificationService::checkTransaction($credentials, $notificationCode);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 public static function main()
 {
     // Instantiate a new payment request
     $directPaymentRequest = new PagSeguroDirectPaymentRequest();
     // Set the Payment Mode for this payment request
     $directPaymentRequest->setPaymentMode('DEFAULT');
     // Set the Payment Method for this payment request
     $directPaymentRequest->setPaymentMethod('CREDIT_CARD');
     /**
      * @todo Change the receiver Email
      */
     $directPaymentRequest->setReceiverEmail('*****@*****.**');
     // Set the currency
     $directPaymentRequest->setCurrency("BRL");
     // Add an item for this payment request
     // Add an item for this payment request
     $directPaymentRequest->addItem('0001', 'Descricao do item a ser vendido', 2, 10.0);
     // Add an item for this payment request
     $directPaymentRequest->addItem('0002', 'Descricao do item a ser vendido', 2, 5.0);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $directPaymentRequest->setReference("REF123");
     // Set your customer information.
     // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br
     $directPaymentRequest->setSender('João Comprador', '*****@*****.**', '11', '56273440', 'CPF', '156.009.442-76', true);
     $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986");
     // Set shipping information for this payment request
     $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX');
     $directPaymentRequest->setShippingType($sedexCode);
     $directPaymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA');
     //Set billing information for credit card
     $billing = new PagSeguroBilling(array('postalCode' => '01452002', 'street' => 'Av. Brig. Faria Lima', 'number' => '1384', 'complement' => 'apto. 114', 'district' => 'Jardim Paulistano', 'city' => 'São Paulo', 'state' => 'SP', 'country' => 'BRA'));
     $token = "5b97542cd1524b67a9e89b3d90c1f262";
     $installment = new PagSeguroDirectPaymentInstallment(array("quantity" => 2, "value" => "15.00", "noInterestInstallmentQuantity" => 2));
     $cardCheckout = new PagSeguroCreditCardCheckout(array('token' => $token, 'installment' => $installment, 'holder' => new PagSeguroCreditCardHolder(array('name' => 'João Comprador', 'documents' => array('type' => 'CPF', 'value' => '156.009.442-76'), 'birthDate' => date('01/10/1979'), 'areaCode' => 11, 'number' => 56273440)), 'billing' => $billing));
     //Set credit card for payment
     $directPaymentRequest->setCreditCard($cardCheckout);
     try {
         /**
          * #### Credentials #####
          * Replace the parameters below with your credentials
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         // seller authentication
         //$credentials = new PagSeguroAccountCredentials("*****@*****.**",
         //    "E231B2C9BCC8474DA2E260B6C8CF60D3");
         // application authentication
         $credentials = PagSeguroConfig::getApplicationCredentials();
         $credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3");
         // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
         $return = $directPaymentRequest->register($credentials);
         self::printTransactionReturn($return);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #9
0
 /**
  * Load model and language
  */
 private function _load()
 {
     PagSeguroConfig::activeLog($this->_getDirectoryLog());
     $this->language->load('payment/pagseguro');
     $this->load->model('checkout/order');
     $this->load->model('setting/setting');
     $this->load->model('payment/pagseguro');
     $this->language->load('payment/pagseguro');
 }
Пример #10
0
 private static function preApprovalNotification($preApprovalCode)
 {
     $credentials = PagSeguroConfig::getAccountCredentials();
     try {
         $preApproval = PagSeguroNotificationService::checkPreApproval($credentials, $preApprovalCode);
         // Do something with $preApproval
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 private static function authorizationNotification($notificationCode)
 {
     $credentials = PagSeguroConfig::getApplicationCredentials();
     try {
         $authorization = PagSeguroNotificationService::checkAuthorization($credentials, $notificationCode);
         // Do something with $authorization
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 /**
  * 
  * @param \Controller $controller
  * @throws RuntimeException
  * @since 2.1
  */
 public function startup(\Controller $controller)
 {
     $this->config = Configure::read('PagSeguro');
     if (empty($this->config)) {
         throw new RuntimeException('Você precisa definir as configurações básicas do plugin "PagSeguro", leia o manual.');
     }
     if (isset($this->config['isSandbox']) && true === $this->config['isSandbox']) {
         PagSeguroConfig::setEnvironment('sandbox');
     }
     $this->credenciais = new PagSeguroAccountCredentials($this->config['email'], $this->config['token']);
 }
Пример #13
0
 private function __construct()
 {
     self::$active = PagSeguroConfig::logIsActive();
     if (self::$active) {
         $fileLocation = PagSeguroConfig::getLogFileLocation();
         if (file_exists($fileLocation) && is_file($fileLocation)) {
             self::$fileLocation = $fileLocation;
         } else {
             self::createFile();
         }
     }
 }
Пример #14
0
 /**
  * Process the payment request and redirect to PagSeguro Gateway
  */
 public function requestAction()
 {
     $Order = $this->getOrder();
     //Order Data
     $PagSeguroPaymentModel = $this->getPagSeguroPaymentModel();
     $enabledOSC = false;
     $fileOSC = scandir(getcwd() . '/app/code/community/DeivisonArthur');
     if ($fileOSC) {
         $enabledOSC = Mage::helper('onepagecheckout')->isOnepageCheckoutEnabled();
     }
     $feedback = $enabledOSC == false ? 'checkout/onepage' : 'onepagecheckout';
     if ($Order->getState() == Mage_Sales_Model_Order::STATE_NEW and $Order->getPayment()->getMethod() == $PagSeguroPaymentModel->getCode() and $Order->getId()) {
         $orderId = $Order->getEntityId();
         include_once Mage::getBaseDir('lib') . '/PagSeguroLibrary/PagSeguroLibrary.php';
         $environment = PagSeguroConfig::getEnvironment();
         if ($environment == 'production') {
             $environment = "Produção";
         } else {
             $environment = "Sandbox";
         }
         $tp = (string) Mage::getConfig()->getTablePrefix();
         $table = $tp . 'pagseguro_orders';
         $read = Mage::getSingleton('core/resource')->getConnection('core_read');
         $value = $read->query("SELECT `order_id` FROM `" . $table . "` WHERE `order_id` = " . $orderId);
         $row = $value->fetch();
         if ($row == false) {
             $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
             $sql = "INSERT INTO `" . $table . "` (`order_id`, `environment`) \n                        VALUES ('{$orderId}','{$environment}')";
             $connection->query($sql);
         }
         try {
             $PagSeguroPaymentModel->setOrder($Order);
             $this->_redirectUrl($PagSeguroPaymentModel->getRedirectPaymentHtml($Order));
             //after verify if the order was created, instantiates the sendEmail() method
             $this->sendEmail();
         } catch (Exception $ex) {
             Mage::log($ex->getMessage());
             Mage::getSingleton('core/session')->addError(self::MENSAGEM);
             $this->_redirectUrl(Mage::getUrl('checkout/cart'));
             if ($checkout == 'PADRAO') {
                 $this->_redirectUrl(Mage::getUrl() . $feedback);
             }
             $this->_canceledStatus($Order);
         }
     } else {
         Mage::getSingleton('core/session/canceled')->addError(self::MENSAGEM);
         $this->_redirectUrl(Mage::getUrl('checkout/cart'));
         if ($checkout == 'PADRAO') {
             $this->_redirectUrl(Mage::getUrl() . $feedback);
         }
         $this->_canceledStatus($Order);
     }
 }
Пример #15
0
 public static function reLoad()
 {
     self::$active = PagSeguroConfig::logIsActive();
     if (self::$active) {
         $logFile = PagSeguroConfig::getLogFileLocation();
         if (!empty($logFile)) {
             self::createFile($logFile);
         } else {
             self::createFile();
         }
     }
 }
 public static function reLoad()
 {
     self::$active = PagSeguroConfig::logIsActive();
     if (self::$active) {
         $fileLocation = PagSeguroConfig::getLogFileLocation();
         if (file_exists($fileLocation) && is_file($fileLocation)) {
             self::$fileLocation = $fileLocation;
         } else {
             self::createFile();
         }
     }
 }
Пример #17
0
 private function __construct()
 {
     self::$path = dirname(__FILE__);
     if (function_exists('spl_autoload_register')) {
         require_once "loader" . DIRECTORY_SEPARATOR . "PagSeguroAutoLoader.class.php";
         PagSeguroAutoloader::init();
     } else {
         require_once "loader" . DIRECTORY_SEPARATOR . "PagSeguroAutoLoader.php";
     }
     self::$resources = PagSeguroResources::init();
     self::$config = PagSeguroConfig::init();
     self::$log = LogPagSeguro::init();
 }
 public static function main()
 {
     // Instantiate a new payment request
     $directPaymentRequest = new PagSeguroDirectPaymentRequest();
     // Set the Payment Mode for this payment request
     $directPaymentRequest->setPaymentMode('DEFAULT');
     // Set the Payment Method for this payment request
     $directPaymentRequest->setPaymentMethod('CREDIT_CARD');
     /**
      * @todo Change the receiver Email
      */
     $directPaymentRequest->setReceiverEmail('*****@*****.**');
     // Set the currency
     $directPaymentRequest->setCurrency("BRL");
     // Add an item for this payment request
     // Add an item for this payment request
     $directPaymentRequest->addItem('0001', 'Descricao do item a ser vendido', 2, 10.0);
     // Add an item for this payment request
     $directPaymentRequest->addItem('0002', 'Descricao do item a ser vendido', 2, 5.0);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $directPaymentRequest->setReference("REF123");
     // Set your customer information.
     // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br
     $directPaymentRequest->setSender('João Comprador', '*****@*****.**');
     $directPaymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br');
     $token = "5b97542cd1524b67a9e89b3d90c1f262";
     $installment = new PagSeguroInstallment(array("quantity" => 1, "value" => "30.00"));
     $cardCheckout = new PagSeguroCreditCardCheckout(array('token' => $token, 'installment' => $installment));
     //Set credit card for payment
     $directPaymentRequest->setCreditCard($cardCheckout);
     try {
         /**
          * #### Credentials #####
          * Replace the parameters below with your credentials
          * You can also get your credentials like this:
          * $credentials = new PagSeguroAccountCredentials("*****@*****.**",
          *   "E231B2C9BCC8474DA2E260B6C8CF60D3");
          */
         // seller authentication
         $credentials = PagSeguroConfig::getAccountCredentials();
         // application authentication
         //$credentials = PagSeguroConfig::getApplicationCredentials();
         //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3");
         // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
         $return = $directPaymentRequest->register($credentials);
         self::printTransactionReturn($return);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
 /**
  * Process the payment request and redirect to PagSeguro Gateway
  */
 public function requestAction()
 {
     $helper = Mage::helper('pagseguro');
     $paymentMethod = $helper->paymentModel();
     $feedback = 'checkout/onepage';
     $order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId());
     $method = $order->getPayment()->getMethod();
     $code = $paymentMethod->getCode();
     if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW && $method == $code && $order->getId()) {
         $orderId = $order->getEntityId();
         include_once Mage::getBaseDir('lib') . '/PagSeguroLibrary/PagSeguroLibrary.php';
         $environment = PagSeguroConfig::getEnvironment();
         if ($environment == 'production') {
             $environment = $helper->__("Produção");
         } else {
             $environment = $helper->__("Sandbox ");
         }
         $tp = (string) Mage::getConfig()->getTablePrefix();
         $table = $tp . 'pagseguro_orders';
         $read = Mage::getSingleton('core/resource')->getConnection('core_read');
         $value = $read->query("SELECT `order_id` FROM `" . $table . "` WHERE `order_id` = " . $orderId);
         $row = $value->fetch();
         if ($row == false) {
             $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
             $sql = "INSERT INTO `" . $table . "` (`order_id`, `environment`) VALUES ('{$orderId}','{$environment}')";
             $connection->query($sql);
         }
         try {
             $paymentMethod->setOrder($order);
             $this->_redirectUrl($paymentMethod->getRedirectPaymentHtml($order));
             //after verify if the order was created, instantiates the sendEmail() method
             $this->sendEmail();
         } catch (Exception $ex) {
             Mage::log($ex->getMessage());
             Mage::getSingleton('core/session')->addError($helper->__(self::MENSAGEM));
             $this->_redirectUrl(Mage::getUrl('checkout/cart'));
             if ($checkout == 'PADRAO') {
                 $this->_redirectUrl(Mage::getUrl() . $feedback);
             }
             $this->canceledStatus($order);
         }
     } else {
         Mage::getSingleton('core/session/canceled')->addError($helper->__(self::MENSAGEM));
         $this->_redirectUrl(Mage::getUrl('checkout/cart'));
         if ($checkout == 'PADRAO') {
             $this->_redirectUrl(Mage::getUrl() . $feedback);
         }
         $this->canceledStatus($order);
     }
 }
 public function __construct()
 {
     if (self::verifyDependencies()) {
         if (self::$library == null) {
             self::$path = dirname(__FILE__);
             PagSeguroAutoloader::init();
             self::$resources = PagSeguroResources::init();
             self::$config = PagSeguroConfig::init();
             self::$log = LogPagSeguro::init();
             self::$library = $this;
         }
     }
     return self::$library;
 }
 public function __construct(Credentials $credentials, $serviceName)
 {
     $this->credentials = $credentials;
     $this->serviceName = $serviceName;
     $this->setEnvironment(PagSeguroConfig::getEnvironment());
     $this->setWebserviceUrl(PagSeguroResources::getWebserviceUrl($this->getEnvironment()));
     $this->setCharset(PagSeguroConfig::getApplicationCharset());
     $this->resources = PagSeguroResources::getData($this->serviceName);
     if (isset($this->resources['servicePath'])) {
         $this->setServicePath($this->resources['servicePath']);
     }
     if (isset($this->resources['serviceTimeout'])) {
         $this->setServiceTimeout($this->resources['serviceTimeout']);
     }
 }
Пример #22
0
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $payment = new PagSeguroPaymentOrderPrestashop();
     $payment->setVariablesPaymentExecutionView();
     $environment = PagSeguroConfig::getEnvironment();
     $this->context = Context::getContext();
     $this->context->smarty->assign('environment', $environment);
     if (version_compare(_PS_VERSION_, '1.5.0.1', '>=')) {
         $this->context->smarty->assign('width_center_column', '100%');
     }
     $url = "index.php?fc=module&module=pagseguro&controller=error";
     $this->context->smarty->assign('errurl', $url);
     $this->setTemplate('payment_execution.tpl');
 }
Пример #23
0
 public function pagSeguro()
 {
     /*
             /* Carrega a biblioteca do CodeIgniter responsável pela validação dos formulários */
     $this->load->library('form_validation', 'PagSeguroLibrary');
     $this->load->model('presentes_model');
     /* Define as tags onde a mensagem de erro será exibida na página */
     $this->form_validation->set_error_delimiters('<span>', '</span>');
     /* Define as regras para validação */
     $this->form_validation->set_rules('valor', 'decimal', 'required');
     /* Executa a validação e caso houver erro... */
     if ($this->form_validation->run() === FALSE) {
         /* Chama a função index do controlador */
         $this->load->view('pages/presentes.php');
         /* Senão, caso sucesso na validação... */
     } else {
         /* Recebe os dados do formulário (visão) */
         $data['valor'] = $this->input->post('valor');
         $data['descricao'] = 'Presente Luana e Juninho';
         //inserir data atual também....
         /* Chama a função inserir do modelo */
         $this->presentes_model->pagSeguro($data);
         //redirect('#contact');
     }
     /** INICIO PROCESSO PAGSEGURO */
     require_once APPPATH . 'libraries/PagSeguroLibrary/PagSeguroLibrary.php';
     /** INICIO PROCESSO PAGSEGURO */
     $paymentrequest = new PagSeguroPaymentRequest();
     $data = array('id' => '01', 'description' => 'Presente Luana e Juninho', 'quantity' => 1, 'amount' => $this->input->post('valor'));
     $item = new PagSeguroItem($data);
     /* $paymentRequest deve ser um objeto do tipo PagSeguroPaymentRequest */
     $paymentrequest->addItem($item);
     //Definindo moeda
     $paymentrequest->setCurrency('BRL');
     // 1- PAC(Encomenda Normal)
     // 2-SEDEX
     // 3-NOT_SPECIFIED(Não especificar tipo de frete)
     $paymentrequest->setShipping(3);
     //Url de redirecionamento
     //$paymentrequest->setRedirectURL($redirectURL);// Url de retorno
     $credentials = PagSeguroConfig::getAccountCredentials();
     //credenciais do vendedor
     //$compra_id = App_Lib_Compras::insert($produto);
     //$paymentrequest->setReference($compra_id);//Referencia;
     $url = $paymentrequest->register($credentials);
     header("Location: {$url}");
 }
 public function pay($id)
 {
     \PagSeguroLibrary::init();
     \PagSeguroConfig::setEnvironment('production');
     $this->plan = Plans::find($id);
     $this->client = User::find(Auth::user()->id);
     $this->payment = Payments::create(['plan_name' => $this->plan->name, 'plan_value' => $this->plan->value, 'plan_id' => $this->plan->id, 'user_id' => $this->client->id, 'confirmed' => 0]);
     // Instantiate a new payment request
     $paymentRequest = new \PagSeguroPaymentRequest();
     // Set the currency
     $paymentRequest->setCurrency("BRL");
     /* // Add an item for this payment request
        $paymentRequest->addItem('0001', 'Sempre da Negócio - Plano '.$this->plan->name, 1, $this->plan->value);*/
     $paymentRequest->addItem($this->plan->id, 'Sempre da Negócio - Plano ' . $this->plan->name, 1, $this->plan->value);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $paymentRequest->setReference($this->payment->id);
     //Create object PagSeguroShipping
     $shipping = new \PagSeguroShipping();
     //Set Type Shipping
     $type = new \PagSeguroShippingType(3);
     $shipping->setType($type);
     //Set address of client
     $data = array('postalCode' => $this->client->zipcode, 'street' => $this->client->address, 'number' => $this->client->number, 'city' => $this->client->city, 'state' => $this->client->state);
     $address = new \PagSeguroAddress($data);
     $shipping->setAddress($address);
     //Add Shipping to Payment Request
     $paymentRequest->setShipping($shipping);
     // Set your customer information.
     $phone = str_replace(['(', ')', ' ', '-'], ['', '', '', ''], $this->client->phone);
     $paymentRequest->setSender($this->client->name, $this->client->email_responsible, substr($phone, 0, 2), substr($phone, 2));
     try {
         /*
                      * #### Credentials #####
                      * Replace the parameters below with your credentials (e-mail and token)
                      * You can also get your credentials from a config file. See an example:
                      * $credentials = PagSeguroConfig::getAccountCredentials();
                     //  */
         $credentials = new \PagSeguroAccountCredentials($this->email, $this->token);
         // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
         $onlyCheckoutCode = true;
         $code = $paymentRequest->register($credentials, $onlyCheckoutCode);
         return view('site.pages.confirma_pagamento', compact('code'));
     } catch (\PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #25
0
 /**
  * Alert the requiriement invalid, of cURL, version of PHP, SPL or DOM.
  */
 public function alertRequeriments()
 {
     $requirements = PagSeguroConfig::validateRequirements();
     $required = array();
     foreach ($requirements as $key => $value) {
         if ($value != '') {
             $required[] = $value;
         }
     }
     if (!empty($required)) {
         $message = $helper = Mage::helper('pagseguro')->__("Requerimentos para o sistema funcionar:");
         foreach ($required as $value) {
             $message .= "<br />" . $value;
         }
         Mage::getSingleton('core/session')->addError($message);
     }
 }
Пример #26
0
 private function makeRequisition()
 {
     require_once VENDOR_PATH . 'PagSeguro/PagSeguroLibrary.php';
     $payment = new \PagSeguroPaymentRequest();
     $payment->setCurrency('BRL');
     $payment->addItem('0001', $this->productName, $this->productQuantity, $this->productPrice);
     $payment->setReference($this->pid);
     $payment->setShippingType(3);
     $payment->setsender($this->clientName, $this->clientMail, $this->clientAreaCode, $this->clientPhone);
     $payment->setRedirectUrl($this->redirectUrl);
     $credentials = \PagSeguroConfig::getAccountCredentials();
     if (defined('ALLOW_PAYMENT_REQUEST') and ALLOW_PAYMENT_REQUEST === true) {
         $this->paymentUrl = $payment->register($credentials);
     } else {
         $this->paymentUrl = '/loja/checkout/pid/' . $this->pid . '/continue/ok/';
     }
 }
 public static function searchByNotification()
 {
     // Substitute the code below with a valid code notification for your account
     $notificationCode = "29B0BEC9D653D653435EE42F3FAEF4461091";
     try {
         /**
          * @todo
          * #### Credentials #####
          * Replace the parameters below with your credentials (e-mail and token)
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         $credentials = PagSeguroConfig::getAccountCredentials();
         $result = PagSeguroPreApprovalSearchService::findByNotification($credentials, $notificationCode);
         self::printResult($result);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #28
0
 public static function main()
 {
     //$authorizationCode = "C7A067F4AEDC4B538242EBBE3B7FB755";
     $authorizationCode = "FD3AF1B214EC40F0B0A6745D041BF50D";
     try {
         /**
          * #### Credentials #####
          * Replace the parameters below with your credentials
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getApplicationCredentials();
          */
         $credentials = new PagSeguroApplicationCredentials("appId", "appKey");
         $credentials = PagSeguroConfig::getApplicationCredentials();
         $authorization = PagSeguroAuthorizationSearchService::searchByCode($credentials, $authorizationCode);
         self::printAuthorization($authorization);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #29
0
 public static function searchByCode()
 {
     // Substitute the code below with a valid pre-approval code for your account
     $preApprovalCode = "0FEBE545C6C657A77402DF878C539E56";
     try {
         /**
          * @todo
          * #### Credentials #####
          * Replace the parameters below with your credentials (e-mail and token)
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         $credentials = PagSeguroConfig::getAccountCredentials();
         $result = PagSeguroPreApprovalSearchService::searchByCode($credentials, $preApprovalCode);
         self::printResult($result);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Пример #30
0
 public static function searchByInterval()
 {
     // Substitute the code below
     $days = 20;
     try {
         /**
          * @todo
          * #### Credentials #####
          * Replace the parameters below with your credentials (e-mail and token)
          * You can also get your credentials from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         $credentials = PagSeguroConfig::getAccountCredentials();
         $result = PagSeguroPreApprovalSearchService::searchByInterval($credentials, $days);
         self::printResult($result);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }