コード例 #1
0
 public static function main()
 {
     // Instantiate a new payment request
     $paymentRequest = new PagSeguroPaymentRequest();
     // Set the currency
     $paymentRequest->setCurrency("BRL");
     // Add an item for this payment request
     $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.0);
     // Add another item for this payment request
     $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.0);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $paymentRequest->setReference("REF123");
     // Set shipping information for this payment request
     $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX');
     $paymentRequest->setShippingType($sedexCode);
     $paymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA');
     // Set your customer information.
     $paymentRequest->setSender('João Comprador', '*****@*****.**', '11', '56273440', 'CPF', '156.009.442-76');
     // Set the url used by PagSeguro to redirect user after checkout process ends
     $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br");
     // Add checkout metadata information
     $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1);
     $paymentRequest->addMetadata('GAME_NAME', 'DOTA');
     $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1);
     // Another way to set checkout parameters
     $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas');
     $paymentRequest->addParameter('senderBornDate', '07/05/1981');
     $paymentRequest->addIndexedParameter('itemId', '0003', 3);
     $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3);
     $paymentRequest->addIndexedParameter('itemQuantity', '1', 3);
     $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3);
     // Add discount per payment method
     $paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 1.0, 'DISCOUNT_PERCENT');
     $paymentRequest->addPaymentMethodConfig('EFT', 2.9, 'DISCOUNT_PERCENT');
     $paymentRequest->addPaymentMethodConfig('BOLETO', 10.0, 'DISCOUNT_PERCENT');
     $paymentRequest->addPaymentMethodConfig('DEPOSIT', 3.45, 'DISCOUNT_PERCENT');
     $paymentRequest->addPaymentMethodConfig('BALANCE', 0.01, 'DISCOUNT_PERCENT');
     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.
         $url = $paymentRequest->register($credentials);
         self::printPaymentUrl($url);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
コード例 #2
0
 public function button()
 {
     $paymentRequest = new \PagSeguroPaymentRequest();
     $paymentRequest->setCurrency('BRL');
     $paymentRequest->setReference($this->options['dataPedido']['codigo']);
     foreach ($this->options['dataPedido']['ComponentProdutosDoPedido'] as $product) {
         $paymentRequest->addItem($product['component_produtos_id'], sprintf('%s %s', $product['ComponentProdutos']['titulo'], $product['ComponentProdutos']['chapeu']), $product['quantity'], $product['preco']);
     }
     if ($this->options['dataPedido']['desconto'] > 0) {
         $paymentRequest->setExtraAmount($this->options['dataPedido']['desconto'] * -1);
     }
     if ($this->options['dataPedido']['shipping_price'] > 0) {
         $paymentRequest->addItem('frete', sprintf('Frete por %s', $this->options['dataPedido']['ComponentFormasDeEntrega']['titulo']), 1, $this->options['dataPedido']['shipping_price']);
     }
     // customer information.
     $paymentRequest->setSender($this->options['dataUsuario']['titulo'], $this->options['dataUsuario']['email'], mb_substr($this->options['dataUsuario']['telefone'], 1, 2), preg_replace('/[^\\d]/', '', mb_substr($this->options['dataUsuario']['telefone'], 5)), 'CPF', $this->options['dataUsuario']['cpf']);
     $paymentRequest->setRedirectUrl($this->options['redirectUrl']);
     $paymentRequest->addParameter('notificationURL', $this->options['notificationURL']);
     try {
         // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer.
         $url = $paymentRequest->register(new \PagSeguroAccountCredentials($this->credentials['email'], $this->credentials['token']));
         return sprintf('<a class="btn btn-fill btn-lg btn-aircode btn-aircode-primary" href="%s" target="_blank">Pagar com PagSeguro</a>', $url);
     } catch (\PagSeguroServiceException $e) {
         return $e->getMessage();
     }
 }
コード例 #3
0
 public static function main()
 {
     // Instantiate a new payment request
     $paymentRequest = new PagSeguroPaymentRequest();
     // Sets the currency
     $paymentRequest->setCurrency("BRL");
     // Add an item for this payment request
     $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.0);
     // Add another item for this payment request
     $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.0);
     // Sets a reference code for this payment request, it is useful to identify this payment in future notifications.
     $paymentRequest->setReference("REF123");
     // Sets shipping information for this payment request
     $CODIGO_SEDEX = PagSeguroShippingType::getCodeByType('SEDEX');
     $paymentRequest->setShippingType($CODIGO_SEDEX);
     $paymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA');
     // Sets your customer information.
     $paymentRequest->setSender('João Comprador', '*****@*****.**', '11', '56273440', 'CPF', '156.009.442-76');
     // Sets the url used by PagSeguro for redirect user after ends checkout process
     $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br");
     // Add checkout metadata information
     $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1);
     $paymentRequest->addMetadata('GAME_NAME', 'DOTA');
     $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1);
     // Another way to set checkout parameters
     $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas');
     $paymentRequest->addIndexedParameter('itemId', '0003', 3);
     $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3);
     $paymentRequest->addIndexedParameter('itemQuantity', '1', 3);
     $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3);
     try {
         /*
          * #### Crendencials #####
          * Substitute the parameters below with your credentials (e-mail and token)
          * You can also get your credentails from a config file. See an example:
          * $credentials = PagSeguroConfig::getAccountCredentials();
          */
         $credentials = new PagSeguroAccountCredentials("*****@*****.**", "your_token_here");
         // Register this payment request in PagSeguro, to obtain the payment URL for redirect your customer.
         $url = $paymentRequest->register($credentials);
         self::printPaymentUrl($url);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
コード例 #4
0
ファイル: ad.php プロジェクト: caina/pando
 function payment()
 {
     require_once APPPATH . 'third_party/PagSeguroLibrary/PagSeguroLibrary.php';
     $this->load->model('../libraries/anuncios/model/ad_price_model', 'price');
     $this->load->model('user_model');
     // valida se o anuncio e o preco realmente existem
     if (!$this->price->get($this->input->post('price_id', TRUE))->exists() || !$this->ad_model->get($this->input->post('ad_id', TRUE))->is_mine()) {
         set_message("Operação inválida", 2);
         redirect(site_url("act/anuncios/ad/home_page"));
     }
     $paymentRequest = new PagSeguroPaymentRequest();
     $paymentRequest->AddItem($this->price->object->id, $this->price->object->title, 1, '0.10');
     $paymentRequest->setShippingType(3);
     $user_object = $this->user_model->get();
     // dump($user_object);
     // precisamos dos dados de cidade, bairro, rua e numero
     $paymentRequest->setShippingAddress(str_replace(array("-", "."), "", $user_object->zip_code), @$user_object->street_name, @$user_object->number, '', @$user_object->district, @$user_object->city_name, @$user_object->state_letter, 'BRA');
     $type = !empty($user_object->cpf) ? "CPF" : "CNPJ";
     $type_value = !empty($user_object->cpf) ? $user_object->cpf : $user_object->cnpj;
     $paymentRequest->setSender($user_object->name, $user_object->username, '11', '', $type, $type_value);
     $paymentRequest->setCurrency("BRL");
     $paymentRequest->setReference($this->ad_model->object->id);
     $paymentRequest->setRedirectUrl(site_url("act/anuncios/ad/home_page"));
     $paymentRequest->addParameter('notificationURL', site_url("pagseguro/notification/anuncios/" . $this->ad_model->object->id));
     try {
         $credentials = PagSeguroConfig::getAccountCredentials();
         // getApplicationCredentials()
         $checkoutUrl = $paymentRequest->register($credentials);
     } catch (PagSeguroServiceException $e) {
         set_message("Erro ao gerar link pagamento: " . $e->getMessage(), 2);
         redirect(site_url("act/anuncios/ad/home_page"));
     }
     $this->data["ad"] = $this->ad_model->object;
     $this->data["price"] = $this->price->object;
     $this->load_view("../libraries/anuncios/views/anuncio_view/payment");
 }
コード例 #5
0
 /**
  * Process Payment
  *
  * Process payments trough the PagSeguro gateway.
  *
  * @return   void
  * @since    1.0
  */
 function process_payment($purchase_data)
 {
     global $edd_options;
     // check there is a gateway name
     if (!isset($purchase_data['post_data']['edd-gateway'])) {
         return;
     }
     // get credentials
     $credentials = $this->get_credentials();
     // check credentials have been set
     if (is_null($credentials['email']) || is_null($credentials['token'])) {
         edd_set_error(0, __('Please enter your PagSeguro Client Email and Token in settings', 'edd-pagseguro-gateway'));
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     }
     // get payment
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_option('currency', 'BRL'), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
     // insert pending payment
     $payment = edd_insert_payment($payment_data);
     if (!$payment) {
         // problems? send back
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     } else {
         // require PagSeguro files
         $this->load_pagseguro_sdk();
         // verify classes exists
         if (!class_exists('PagSeguroPaymentRequest')) {
             edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
         }
         // create payment request
         $paymentRequest = new PagSeguroPaymentRequest();
         // sets the currency
         $paymentRequest->setCurrency('BRL');
         // cart summary
         $cart_summary = edd_get_purchase_summary($purchase_data, false);
         // format total price
         $total_price = number_format($purchase_data['price'], 2, '.', '');
         // payment request details
         $paymentRequest->addItem('01', sanitize_text_field(substr($cart_summary, 0, 95)), '1', strval($total_price));
         // sets the reference code for this request
         $paymentRequest->setReference($payment);
         // sets customer information
         $paymentRequest->setSender(sanitize_text_field($purchase_data['user_info']['first_name'] . ' ' . $purchase_data['user_info']['last_name']), $purchase_data['user_email']);
         // redirect url
         $paymentRequest->setRedirectUrl(add_query_arg('payment-confirmation', 'pagseguro', edd_get_success_page_uri()));
         // IPN URL
         $paymentRequest->addParameter('notificationURL', get_site_url());
         /* TRY CHECKOUT */
         try {
             // generate credentials
             $credentials = new PagSeguroAccountCredentials($credentials['email'], $credentials['token']);
             // register this payment request in PagSeguro, to obtain the payment URL for redirect your customer
             $checkout_uri = $paymentRequest->register($credentials);
             if (gettype($checkout_uri) != 'string') {
                 throw new exception($checkout_uri);
             }
             // empty cart
             edd_empty_cart();
             // send the user to PagSeguro
             wp_redirect($checkout_uri);
             die;
         } catch (Exception $e) {
             //catch exception
             wp_mail(get_bloginfo('admin_email'), __('PagSeguro Checkout Error', 'edd-pagseguro-gateway'), $e->getMessage());
             edd_set_error('pagseguro_exception', $e->getMessage());
             edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
         }
     }
 }
コード例 #6
0
 public static function main()
 {
     // Instantiate a new payment request
     $paymentRequest = new PagSeguroPaymentRequest();
     // Set the currency
     $paymentRequest->setCurrency("BRL");
     $finalPrice = (double) self::$productData->price - self::$productData->discount;
     // Add an item for this payment request
     $paymentRequest->addItem('0001', self::$productData->name, 1, $finalPrice);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $paymentRequest->setReference(self::$referenceID);
     // Set shipping information for this payment request
     // 1 = PAC
     // 2 = SEDEX
     $sedexCode = PagSeguroShippingType::getCodeByType('PAC');
     $paymentRequest->setShippingType($sedexCode);
     $paymentRequest->setShippingAddress(self::$orderData->zipcode, self::$orderData->street, self::$orderData->number, self::$orderData->complement, self::$orderData->local, self::$orderData->city, self::$orderData->state, 'BRA');
     //$paymentRequest->setShippingCost(new BigDecimal("23.30"));
     // Adapta nome ao padrão do PagSeguro ("Nome Sobrenome")
     $name = self::$accountData->name;
     $name = preg_replace('/\\d/', '', $name);
     $name = preg_replace('/[\\n\\t\\r]/', ' ', $name);
     $name = preg_replace('/\\s(?=\\s)/', '', $name);
     $name = trim($name);
     $name = explode(' ', $name);
     if (count($name) == 1) {
         $name[] = ' dos Santos';
     }
     $name = implode(' ', $name);
     // Set your customer information.
     $paymentRequest->setSender($name, self::$accountData->email, '11', '56273440', 'CPF', '156.009.442-76');
     $paymentRequest->addParameter('senderCPF', self::$accountData->cpf);
     $paymentRequest->addParameter('senderAreaCode', 11);
     $paymentRequest->addParameter('senderCPF', 36251520884);
     //self::$accountData->cpf);
     $paymentRequest->addParameter('senderPhone', 921231232);
     $paymentRequest->addParameter('senderBornDate', "11/11/2012");
     // Set the url used by PagSeguro to redirect user after checkout process ends
     $paymentRequest->setRedirectUrl($_SERVER['SERVER_NAME'] . Config::read('page.url.order.completed') . '/' . self::$referenceID);
     // Add checkout metadata information
     // $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1);
     // $paymentRequest->addMetadata('GAME_NAME', 'DOTA');
     // $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1);
     // Another way to set checkout parameters
     $paymentRequest->addParameter('notificationURL', $_SERVER['SERVER_NAME'] . Config::read('page.url.order.notifications'));
     $paymentRequest->addParameter('senderBornDate', '07/05/1981');
     // $paymentRequest->addIndexedParameter('itemId', '0003', 3);
     // $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3);
     // $paymentRequest->addIndexedParameter('itemQuantity', '1', 3);
     // $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3);
     // Add discount per payment method
     //$paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 1.00, 'DISCOUNT_PERCENT');
     //$paymentRequest->addPaymentMethodConfig('EFT', 2.90, 'DISCOUNT_PERCENT');
     //$paymentRequest->addPaymentMethodConfig('BOLETO', 10.00, 'DISCOUNT_PERCENT');
     //$paymentRequest->addPaymentMethodConfig('DEPOSIT', 3.45, 'DISCOUNT_PERCENT');
     //$paymentRequest->addPaymentMethodConfig('BALANCE', 0.01, 'DISCOUNT_PERCENT');
     // Add installment without addition per payment method
     $paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 6, 'MAX_INSTALLMENTS_NO_INTEREST');
     // Add installment limit per payment method
     $paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 8, 'MAX_INSTALLMENTS_LIMIT');
     // Add and remove a group and payment methods
     //$paymentRequest->acceptPaymentMethodGroup('CREDIT_CARD', 'DEBITO_ITAU');
     //$paymentRequest->excludePaymentMethodGroup('BOLETO', 'BOLETO');
     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");
          */
         // 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.
         $url = $paymentRequest->register($credentials);
         return $url;
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
コード例 #7
0
	public function iniciaPagamentoPagSeguro() {
        $paymentRequest = new PagSeguroPaymentRequest();

        $paymentRequest->setCurrency("BRL");
        $this->razao = $this->razao . $this->transacaoID;
        //Itens compra | Não posso colocar o dinheiro por partes por conta do cupom
        $paymentRequest->addItem('0001', $this->razao, 1, $this->valor);
        
        $paymentRequest->setReference($this->transacaoID);

        // Dados do usuario
        $paymentRequest->setSender(
            $this->nomeUsuario,
            $this->emailUsuario
        );
        // Url de retorno após pagamento
        $paymentRequest->setRedirectUrl($this->system->getUrlSite());

        // Url de notificação de modificação de status
        $paymentRequest->addParameter('notificationURL', $this->notificationURL);
        
        try {
            $credentials = $this->obterCredenciaisPagSeguro();                           
            $url = $paymentRequest->register($credentials);
            return $url;
        } catch (PagSeguroServiceException $e) {
        	print_r($e);
        	$erros = array();
        	foreach($e->getErrors() as $erro)
        		$erros[] = $erro->getMessage();
        	echo '<script>alert("' . implode('<br/>', $erros) . '")</script>';
            die;
        }   
	}
コード例 #8
0
 public function iniciaPagamentoPagSeguro()
 {
     $paymentRequest = new PagSeguroPaymentRequest();
     $paymentRequest->setCurrency("BRL");
     $this->razao = $this->razao . $this->transacaoID;
     //Itens compra | Não posso colocar o dinheiro por partes por conta do cupom
     $paymentRequest->addItem('0001', $this->razao, 1, $this->valor);
     $paymentRequest->setReference($this->transacaoID);
     $nomeUsuario = preg_replace('/\\d/', '', $this->nomeUsuario);
     $nomeUsuario = preg_replace('/[\\n\\t\\r]/', ' ', $nomeUsuario);
     $nomeUsuario = preg_replace('/\\s(?=\\s)/', '', $nomeUsuario);
     $nomeUsuario = trim($nomeUsuario);
     $nomeUsuario = explode(' ', $nomeUsuario);
     if (count($nomeUsuario) == 1) {
         $nomeUsuario[] = ' sem Sobrenome';
     }
     $nomeUsuario = implode(' ', $nomeUsuario);
     // Dados do usuario
     $paymentRequest->setSender($nomeUsuario, trim($this->emailUsuario));
     // Url de retorno após pagamento
     $paymentRequest->setRedirectUrl($this->system->getUrlSite());
     // Url de notificação de modificação de status
     $paymentRequest->addParameter('notificationURL', $this->notificationURLPagSeguro);
     $paymentRequest->addParameter('sistemaID', $this->system->session->getItem('session_cod_empresa'));
     try {
         $credentials = $this->obterCredenciaisPagSeguro();
         $url = $paymentRequest->register($credentials);
         return $url;
     } catch (PagSeguroServiceException $e) {
         $erros = array();
         foreach ($e->getErrors() as $erro) {
             $erros[] = $erro->getMessage();
         }
         echo '<script>alert("' . implode('<br/>', $erros) . '")</script>';
         die;
     }
 }
コード例 #9
0
 public static function main()
 {
     // Instantiate a new payment request
     $paymentRequest = new PagSeguroPaymentRequest();
     // Set the currency
     $paymentRequest->setCurrency("BRL");
     // Add an item for this payment request
     $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.0);
     // Add another item for this payment request
     $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.0);
     // Set a reference code for this payment request. It is useful to identify this payment
     // in future notifications.
     $paymentRequest->setReference("REF123");
     // Set shipping information for this payment request
     $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX');
     $paymentRequest->setShippingType($sedexCode);
     $paymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA');
     // Set your customer information.
     $paymentRequest->setSender('João Comprador', '*****@*****.**', '11', '56273440', 'CPF', '156.009.442-76');
     // Set the url used by PagSeguro to redirect user after checkout process ends
     $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br");
     // Add checkout metadata information
     $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1);
     $paymentRequest->addMetadata('GAME_NAME', 'DOTA');
     $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1);
     // Another way to set checkout parameters
     $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas');
     $paymentRequest->addParameter('senderBornDate', '07/05/1981');
     $paymentRequest->addIndexedParameter('itemId', '0003', 3);
     $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3);
     $paymentRequest->addIndexedParameter('itemQuantity', '1', 3);
     $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3);
     /***
      * Pre Approval information
      */
     $preApprovalRequest = new PagSeguroPreApprovalRequest();
     $preApprovalRequest->setPreApprovalCharge('manual');
     $preApprovalRequest->setPreApprovalName("Seguro contra roubo do Notebook Prata");
     $preApprovalRequest->setPreApprovalDetails("Todo dia 30 será cobrado o valor de R100,00 referente ao seguro contra\n            roubo do Notebook Prata.");
     $preApprovalRequest->setPreApprovalAmountPerPayment('100.00');
     $preApprovalRequest->setPreApprovalMaxAmountPerPeriod('200.00');
     $preApprovalRequest->setPreApprovalPeriod('Monthly');
     $preApprovalRequest->setPreApprovalMaxTotalAmount('2400.00');
     $preApprovalRequest->setPreApprovalInitialDate('2015-09-09T00:00:00');
     $preApprovalRequest->setPreApprovalFinalDate('2017-09-09T00:00:00');
     $preApprovalRequest->setReviewURL("http://www.lojateste.com.br/redirect");
     $paymentRequest->setPreApproval($preApprovalRequest);
     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.
         $url = $paymentRequest->register($credentials);
         self::printPaymentUrl($url);
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }