├── admin ├── view │ ├── image │ │ └── payment │ │ │ └── ps-logo.png │ └── javascript │ │ └── jquery │ │ └── pagseguromodule.js └── language │ ├── english │ └── payment │ │ └── pagseguro.php │ └── portuguese │ └── payment │ └── pagseguro.php ├── .travis.yml ├── catalog ├── view │ └── theme │ │ └── default │ │ └── template │ │ └── payment │ │ ├── pagseguro.tpl │ │ └── pagseguro_lightbox.tpl ├── controller │ └── payment │ │ ├── PagSeguroLibrary │ │ ├── config │ │ │ └── PagSeguroConfig.php │ │ ├── PagSeguroLibrary.php │ │ ├── parser │ │ │ ├── PagSeguroCancelParser.class.php │ │ │ ├── PagSeguroRefundParser.class.php │ │ │ ├── PagSeguroPaymentParserData.class.php │ │ │ ├── PagSeguroSessionParser.class.php │ │ │ ├── PagSeguroServiceParser.class.php │ │ │ ├── PagSeguroInstallmentParser.class.php │ │ │ └── PagSeguroParserData.class.php │ │ ├── domain │ │ │ ├── PagSeguroCredentials.class.php │ │ │ ├── PagSeguroAcceptedPayments.class.php │ │ │ ├── PagSeguroPreApprovalSearchResult.class.php │ │ │ ├── PagSeguroTransactionSearchResult.class.php │ │ │ ├── PagSeguroSession.class.php │ │ │ ├── PagSeguroOnlineDebitCheckout.class.php │ │ │ ├── PagSeguroInstallments.class.php │ │ │ ├── PagSeguroMetaData.class.php │ │ │ ├── PagSeguroParameter.class.php │ │ │ ├── PagSeguroAuthorizationAccount.class.php │ │ │ ├── PagSeguroBilling.class.php │ │ │ ├── PagSeguroPaymentMethodConfig.class.php │ │ │ ├── PagSeguroAcceptedPaymentMethods.class.php │ │ │ ├── PagSeguroAcceptPaymentMethod.class.php │ │ │ ├── PagSeguroExcludePaymentMethod.class.php │ │ │ ├── PagSeguroError.class.php │ │ │ ├── PagSeguroAuthorizationPermissions.class.php │ │ │ ├── PagSeguroDirectPaymentMethods.class.php │ │ │ ├── PagSeguroNotificationType.class.php │ │ │ ├── PagSeguroHttpStatus.class.php │ │ │ ├── PagSeguroPaymentMode.class.php │ │ │ ├── PagSeguroTransactionType.class.php │ │ │ ├── PagSeguroTransactionCreditorFees.class.php │ │ │ ├── PagSeguroPaymentMethod.class.php │ │ │ ├── PagSeguroPaymentMethodType.class.php │ │ │ ├── PagSeguroPaymentMethodGroups.class.php │ │ │ ├── PagSeguroPaymentMethodConfigKeys.class.php │ │ │ ├── PagSeguroSenderDocument.class.php │ │ │ ├── PagSeguroDocuments.class.php │ │ │ ├── PagSeguroDocument.class.php │ │ │ ├── PagSeguroPaymentRequest.class.php │ │ │ ├── PagSeguroTransactionCancellationSource.class.php │ │ │ ├── PagSeguroMetaDataItemKeys.class.php │ │ │ ├── PagSeguroParameterItem.class.php │ │ │ ├── PagSeguroTransactionStatus.class.php │ │ │ ├── PagSeguroAccountCredentials.class.php │ │ │ ├── PagSeguroPaymentMethodConfigItem.class.php │ │ │ ├── PagSeguroCurrencies.class.php │ │ │ ├── PagSeguroPhone.class.php │ │ │ ├── PagSeguroPreApprovalStatus.class.php │ │ │ ├── PagSeguroShipping.class.php │ │ │ ├── PagSeguroAuthorizationPermission.class.php │ │ │ ├── PagSeguroShippingType.class.php │ │ │ ├── PagSeguroAcceptedPaymentMethodName.class.php │ │ │ ├── PagSeguroSearchResult.class.php │ │ │ ├── PagSeguroCreditCard.class.php │ │ │ ├── PagSeguroDirectPaymentInstallment.class.php │ │ │ ├── PagSeguroMetaDataItem.class.php │ │ │ ├── PagSeguroApplicationCredentials.class.php │ │ │ ├── PagSeguroAuthorizationSearchResult.class.php │ │ │ ├── PagSeguroCreditCardCheckout.class.php │ │ │ ├── PagSeguroPreApprovalCharge.class.php │ │ │ └── PagSeguroItem.class.php │ │ ├── loader │ │ │ └── PagSeguroAutoLoader.class.php │ │ ├── PagSeguroLibrary.class.php │ │ ├── exception │ │ │ └── PagSeguroServiceException.class.php │ │ ├── service │ │ │ ├── PagSeguroSessionService.class.php │ │ │ ├── PagSeguroCancelService.class.php │ │ │ └── PagSeguroRefundService.class.php │ │ └── utils │ │ │ ├── PagSeguroXmlParser.class.php │ │ │ └── PagSeguroHttpConnection.class.php │ │ ├── pagseguro_redirect.php │ │ └── pagseguro_error.php └── language │ ├── english │ └── payment │ │ └── pagseguro.php │ └── portuguese │ └── payment │ └── pagseguro.php ├── .github └── ISSUE_TEMPLATE │ └── relatorio-de-bug.md └── .gitignore /admin/view/image/payment/ps-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pagseguro/pagseguro-modulo-opencart/HEAD/admin/view/image/payment/ps-logo.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - "5.4" 4 | - "5.3" 5 | - "5.2" 6 | before_script: 7 | - pear install --alldeps pear/PHP_CodeSniffer 8 | - phpenv rehash 9 | script: 10 | - phpcs --extensions=php -p --standard=PSR2 ./ 11 | -------------------------------------------------------------------------------- /catalog/view/theme/default/template/payment/pagseguro.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 | 7 |
8 |
9 | 10 |
-------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/relatorio-de-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Relatorio de bug 3 | about: Forneça informações do bug encontrado 4 | 5 | --- 6 | 7 | _Este relatório deve ser usado **APENAS** para reportar bugs_ 8 | 9 | ## Comportamento esperado 10 | 11 | 12 | ## Comportamento atual 13 | 14 | 15 | ## Ambiente (produção, sandbox) 16 | 17 | ## Passos para reproduzir o bug 18 | 19 | 20 | 1. 21 | 2. 22 | 3. 23 | 4. 24 | 25 | ## Descrição Detalhada 26 | 27 | 28 | ## Possível solução 29 | 30 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/config/PagSeguroConfig.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/PagSeguroLibrary.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /catalog/language/portuguese/payment/pagseguro.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/parser/PagSeguroCancelParser.class.php: -------------------------------------------------------------------------------- 1 | getResult('result'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/parser/PagSeguroRefundParser.class.php: -------------------------------------------------------------------------------- 1 | getResult('result'); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /admin/view/javascript/jquery/pagseguromodule.js: -------------------------------------------------------------------------------- 1 | /* 2 | ************************************************************************ 3 | Copyright [2017] [PagSeguro Internet Ltda.] 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | ************************************************************************ 17 | */ 18 | 19 | $(function(){ 20 | $('#pagseguro_option_padrao_hint').hide(); 21 | $('#pagseguro_option_lightbox_hint').hide(); 22 | 23 | $("#pagseguro_checkouts").on("change", function(){ 24 | if(this.value === 'padrao'){ 25 | $('#pagseguro_option_padrao_hint').show(); 26 | $('#pagseguro_option_lightbox_hint').hide(); 27 | }else{ 28 | $('#pagseguro_option_lightbox_hint').show(); 29 | $('#pagseguro_option_padrao_hint').hide(); 30 | } 31 | }); 32 | }); -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroCredentials.class.php: -------------------------------------------------------------------------------- 1 | code; 27 | } 28 | public function setCode($code){ 29 | $this->code = $code; 30 | } 31 | 32 | public function getRegistrationDate(){ 33 | return $this->registrationDate; 34 | } 35 | public function setRegistrationDate($registrationDate){ 36 | $this->registrationDate = $registrationDate; 37 | } 38 | 39 | } 40 | 41 | ?> -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAcceptedPayments.class.php: -------------------------------------------------------------------------------- 1 | getResult('session'); 39 | 40 | $session = new PagSeguroSession(); 41 | 42 | if (isset($data['id'])) { 43 | $session->setId($data['id']); 44 | } 45 | 46 | return $session; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPreApprovalSearchResult.class.php: -------------------------------------------------------------------------------- 1 | preApprovals; 41 | } 42 | 43 | /** 44 | * @param array $preApprovals 45 | */ 46 | public function setPreApprovals(array $preApprovals) 47 | { 48 | $this->preApprovals = $preApprovals; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroTransactionSearchResult.class.php: -------------------------------------------------------------------------------- 1 | transactions; 42 | } 43 | 44 | /*** 45 | * Sets the transaction summaries in this page 46 | * 47 | * @param array $transactions 48 | */ 49 | public function setTransactions(array $transactions) 50 | { 51 | $this->transactions = $transactions; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroSession.class.php: -------------------------------------------------------------------------------- 1 | id; 42 | } 43 | 44 | /*** 45 | * Sets the session id 46 | * 47 | * @param string id 48 | */ 49 | public function setId($id) 50 | { 51 | $this->id = $id; 52 | } 53 | 54 | /*** 55 | * @return String a string that represents the current object 56 | */ 57 | public function toString() 58 | { 59 | $session = array(); 60 | $session['id'] = $this->id; 61 | 62 | $session = "Session: " . var_export($session, true); 63 | 64 | return $session; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroOnlineDebitCheckout.class.php: -------------------------------------------------------------------------------- 1 | setBankName($data['bankName']); 45 | } 46 | } 47 | 48 | } 49 | 50 | /*** 51 | * Sets the bank name 52 | * @param String $name 53 | */ 54 | public function setBankName($name) 55 | { 56 | $this->bankName = $name; 57 | } 58 | 59 | /*** 60 | * @return string bank name 61 | */ 62 | public function getBankName() 63 | { 64 | return $this->bankName; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /catalog/view/theme/default/template/payment/pagseguro_lightbox.tpl: -------------------------------------------------------------------------------- 1 | 2 |
3 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 20 | 21 | 22 | 36 | 37 |

Finalizando sua compra com PagSeguro

38 | 39 |
Sua compra está em processo de finalização, aguarde um instante. 40 |
41 | 44 | 45 | 46 | 47 |
48 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroInstallments.class.php: -------------------------------------------------------------------------------- 1 | setInstallments($installments); 43 | } 44 | } 45 | 46 | /*** 47 | * @return array of $installments 48 | */ 49 | public function getInstallments() 50 | { 51 | return $this->installments; 52 | } 53 | 54 | /*** 55 | * @param array $installments 56 | */ 57 | public function setInstallments($installments) 58 | { 59 | if (isset($installments)) { 60 | $this->installments = $installments; 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroMetaData.class.php: -------------------------------------------------------------------------------- 1 | 0) { 41 | $this->setItems($items); 42 | } 43 | } 44 | 45 | /*** 46 | * @param PagSeguroMetaDataItem $metaDataItem 47 | */ 48 | public function addItem(PagSeguroMetaDataItem $metaDataItem) 49 | { 50 | $this->items[] = $metaDataItem; 51 | } 52 | 53 | /*** 54 | * @param array $items 55 | */ 56 | public function setItems(array $items) 57 | { 58 | $this->items = $items; 59 | } 60 | 61 | /*** 62 | * @return array 63 | */ 64 | public function getItems() 65 | { 66 | if ($this->items == null) { 67 | $this->items = array(); 68 | } 69 | return $this->items; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/parser/PagSeguroServiceParser.class.php: -------------------------------------------------------------------------------- 1 | getResult('errors'); 38 | $errors = array(); 39 | if (isset($data['error']) && is_array($data['error'])) { 40 | if (isset($data['error']['code']) && isset($data['error']['message'])) { 41 | array_push($errors, new PagSeguroError($data['error']['code'], $data['error']['message'])); 42 | } else { 43 | foreach ($data['error'] as $key => $value) { 44 | if (isset($value['code']) && isset($value['message'])) { 45 | array_push($errors, new PagSeguroError($value['code'], $value['message'])); 46 | } 47 | } 48 | } 49 | } 50 | return $errors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroParameter.class.php: -------------------------------------------------------------------------------- 1 | 0) { 35 | $this->setItems($items); 36 | } 37 | } 38 | 39 | public function addItem(PagSeguroParameterItem $parameterItem) 40 | { 41 | 42 | if (!PagSeguroHelper::isEmpty($parameterItem->getKey())) { 43 | if (!PagSeguroHelper::isEmpty($parameterItem->getValue())) { 44 | $this->items[] = $parameterItem; 45 | } else { 46 | die('requered parameterValue.'); 47 | } 48 | } else { 49 | die('requered parameterKey.'); 50 | } 51 | } 52 | 53 | public function setItems(array $items) 54 | { 55 | $this->items = $items; 56 | } 57 | 58 | public function getItems() 59 | { 60 | if ($this->items == null) { 61 | $this->items = array(); 62 | } 63 | return $this->items; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAuthorizationAccount.class.php: -------------------------------------------------------------------------------- 1 | setPublicKey($account); 44 | } else { 45 | throw new Exception("Wasn't possible construct the account"); 46 | } 47 | } 48 | 49 | /*** 50 | * @return string of public key 51 | */ 52 | public function getPublicKey() 53 | { 54 | return $this->publicKey; 55 | } 56 | 57 | /*** 58 | * Sets the authorization account public key 59 | * @param string $value 60 | */ 61 | public function setPublicKey($value) 62 | { 63 | if (isset($value)) { 64 | $this->publicKey = $value; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroBilling.class.php: -------------------------------------------------------------------------------- 1 | setAddress(new PagSeguroAddress($data)); 44 | } elseif ($data instanceof PagSeguroAddress) { 45 | $this->setAddress($data); 46 | } 47 | } 48 | 49 | /*** 50 | * Sets the billing address 51 | * @see PagSeguroAddress 52 | * @param PagSeguroAddress $address 53 | */ 54 | public function setAddress(PagSeguroAddress $address) 55 | { 56 | $this->address = $address; 57 | } 58 | 59 | /*** 60 | * @return PagSeguroAddress the billing address 61 | * @see PagSeguroAddress 62 | */ 63 | public function getAddress() 64 | { 65 | return $this->address; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethodConfig.class.php: -------------------------------------------------------------------------------- 1 | 0) { 41 | $this->setConfig($config); 42 | } 43 | } 44 | 45 | /*** 46 | * @param PagSeguroPaymentMethodConfigItem $itemConfig 47 | */ 48 | public function addConfig(PagSeguroPaymentMethodConfigItem $itemConfig) 49 | { 50 | $this->config[] = $itemConfig; 51 | } 52 | 53 | /*** 54 | * @param array $config 55 | */ 56 | public function setConfig(array $config) 57 | { 58 | $this->config = $config; 59 | } 60 | 61 | /*** 62 | * @return array 63 | */ 64 | public function getConfig() 65 | { 66 | if ($this->config == null) { 67 | $this->config = array(); 68 | } 69 | return $this->config; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAcceptedPaymentMethods.class.php: -------------------------------------------------------------------------------- 1 | 0) { 41 | $this->setConfig($config); 42 | } 43 | } 44 | 45 | /** 46 | * @param PagSeguroAcceptedPayments $acceptedPayments 47 | */ 48 | public function addConfig(PagSeguroAcceptedPayments $acceptedPayments) 49 | { 50 | $this->acceptedPaymentsList[] = $acceptedPayments; 51 | } 52 | 53 | /** 54 | * @param array $config 55 | */ 56 | public function setConfig(array $config) 57 | { 58 | $this->acceptedPaymentsList = $config; 59 | } 60 | 61 | /** 62 | * @return array 63 | */ 64 | public function getConfig() 65 | { 66 | if ($this->acceptedPaymentsList == null) { 67 | $this->acceptedPaymentsList = array(); 68 | } 69 | return $this->acceptedPaymentsList; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAcceptPaymentMethod.class.php: -------------------------------------------------------------------------------- 1 | setName($name); 44 | } 45 | if (isset($group) && !PagSeguroHelper::isEmpty($group)) { 46 | $this->setGroup($group); 47 | } 48 | } 49 | 50 | /** 51 | * @return mixed 52 | */ 53 | public function getName() 54 | { 55 | return $this->name; 56 | } 57 | 58 | /** 59 | * @param $name 60 | */ 61 | public function setName($name) 62 | { 63 | $this->name = $name; 64 | } 65 | 66 | /** 67 | * @return mixed 68 | */ 69 | public function getGroup() 70 | { 71 | return $this->group; 72 | } 73 | 74 | /** 75 | * @param $group 76 | */ 77 | public function setGroup($group) 78 | { 79 | $this->group = $group; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroExcludePaymentMethod.class.php: -------------------------------------------------------------------------------- 1 | setName($name); 46 | } 47 | if (isset($group) && !PagSeguroHelper::isEmpty($group)) { 48 | $this->setGroup($group); 49 | } 50 | } 51 | 52 | /** 53 | * @return mixed 54 | */ 55 | public function getName() 56 | { 57 | return $this->name; 58 | } 59 | 60 | /** 61 | * @param $name 62 | */ 63 | public function setName($name) 64 | { 65 | $this->name = $name; 66 | } 67 | 68 | /** 69 | * @return mixed 70 | */ 71 | public function getGroup() 72 | { 73 | return $this->group; 74 | } 75 | 76 | /** 77 | * @param $group 78 | */ 79 | public function setGroup($group) 80 | { 81 | $this->group = $group; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroError.class.php: -------------------------------------------------------------------------------- 1 | setCode($code); 50 | $this->setMessage($message); 51 | } 52 | 53 | /*** 54 | * @return integer|string the code 55 | */ 56 | public function getCode() 57 | { 58 | return $this->code; 59 | } 60 | 61 | /*** 62 | * Sets the code 63 | * @param String $code 64 | */ 65 | public function setCode($code) 66 | { 67 | $this->code = $code; 68 | } 69 | 70 | /*** 71 | * @return String the error description 72 | */ 73 | public function getMessage() 74 | { 75 | return $this->message; 76 | } 77 | 78 | /*** 79 | * Sets the error description 80 | * @param String $message 81 | */ 82 | public function setMessage($message) 83 | { 84 | $this->message = $message; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAuthorizationPermissions.class.php: -------------------------------------------------------------------------------- 1 | setPermissions($permissions); 57 | } 58 | } 59 | 60 | /*** 61 | * @return array of permissions 62 | */ 63 | public function getPermissions() 64 | { 65 | return $this->permissions; 66 | } 67 | 68 | /*** 69 | * @param array $permissions 70 | */ 71 | public function setPermissions($permissions) 72 | { 73 | if (isset($permissions)) { 74 | $this->permissions = $permissions; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/loader/PagSeguroAutoLoader.class.php: -------------------------------------------------------------------------------- 1 | $dir) { 66 | $file = PagSeguroLibrary::getPath() . DIRECTORY_SEPARATOR . 67 | $dir . DIRECTORY_SEPARATOR . $class . '.class.php'; 68 | if (file_exists($file) && is_file($file)) { 69 | require_once $file; 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroDirectPaymentMethods.class.php: -------------------------------------------------------------------------------- 1 | "creditCard", 36 | "BOLETO" => "boleto", 37 | "EFT" => "eft" 38 | ); 39 | 40 | /* 41 | * @var $paymentMethod 42 | */ 43 | private $paymentMethod; 44 | 45 | /*** 46 | * Initializes a new instance of the PaymentMethods class 47 | * @param $paymentMethod 48 | */ 49 | public function __construct($paymentMethod = null) 50 | { 51 | if (isset($paymentMethod)) { 52 | if (array_key_exists($paymentMethod, $this->methodsList)) { 53 | $this->setPaymentMethod($this->methodsList[$paymentMethod]); 54 | } else { 55 | throw new Exception("Direct payment method not found"); 56 | } 57 | } 58 | } 59 | 60 | /*** 61 | * @return the method 62 | */ 63 | public function getPaymentMethod() 64 | { 65 | return $this->paymentMethod; 66 | } 67 | 68 | /*** 69 | * Sets the payment method 70 | * @param $paymentMethod 71 | */ 72 | public function setPaymentMethod($paymentMethod) 73 | { 74 | if (isset($paymentMethod)) { 75 | $this->paymentMethod = $paymentMethod; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroNotificationType.class.php: -------------------------------------------------------------------------------- 1 | 'transaction', 34 | 'APPLICATION_AUTHORIZATION' => 'applicationAuthorization', 35 | 'PRE_APPROVAL' => 'preApproval' 36 | ); 37 | 38 | private $value; 39 | 40 | public function __construct($value = null) 41 | { 42 | if ($value) { 43 | $this->setValue($value); 44 | } 45 | } 46 | 47 | public function setValue($value) 48 | { 49 | $this->value = $value; 50 | } 51 | 52 | public function setByType($type) 53 | { 54 | if (isset(self::$typeList[$type])) { 55 | $this->value = self::$typeList[$type]; 56 | } else { 57 | throw new Exception("undefined index $type"); 58 | } 59 | } 60 | 61 | public function getValue() 62 | { 63 | return $this->value; 64 | } 65 | 66 | /*** 67 | * @param value 68 | * @return the PagSeguroNotificationType corresponding to the informed value 69 | */ 70 | public function getTypeFromValue($value = null) 71 | { 72 | $value = ($value == null ? $this->value : $value); 73 | return array_search($this->value, self::$typeList); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroHttpStatus.class.php: -------------------------------------------------------------------------------- 1 | 'OK', 35 | 400 => 'BAD_REQUEST', 36 | 401 => 'UNAUTHORIZED', 37 | 403 => 'FORBIDDEN', 38 | 404 => 'NOT_FOUND', 39 | 500 => 'INTERNAL_SERVER_ERROR', 40 | 502 => 'BAD_GATEWAY' 41 | ); 42 | /*** 43 | * @var int 44 | */ 45 | private $status; 46 | /*** 47 | * @var bool 48 | */ 49 | private $type; 50 | 51 | /*** 52 | * @param $status 53 | */ 54 | public function __construct($status) 55 | { 56 | if ($status) { 57 | $this->status = (int) $status; 58 | $this->type = $this->getTypeByStatus($this->status); 59 | } 60 | } 61 | 62 | /*** 63 | * @return bool 64 | */ 65 | public function getType() 66 | { 67 | return $this->type; 68 | } 69 | 70 | /*** 71 | * @return int 72 | */ 73 | public function getStatus() 74 | { 75 | return $this->status; 76 | } 77 | 78 | /*** 79 | * @param $status 80 | * @return bool 81 | */ 82 | private function getTypeByStatus($status) 83 | { 84 | if (isset($this->typeList[(int) $status])) { 85 | return $this->typeList[(int) $status]; 86 | } else { 87 | return false; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMode.class.php: -------------------------------------------------------------------------------- 1 | 'default', 32 | 'GATEWAY' => 'gateway' 33 | ); 34 | 35 | /*** 36 | * Payment mode value 37 | * Example: DEFAULT 38 | * @var string 39 | */ 40 | private $value; 41 | 42 | /*** 43 | * Initializes a new instance of the PagSeguroPaymentMode class 44 | * @param array|object $value 45 | */ 46 | public function __construct($value) 47 | { 48 | 49 | if (array_key_exists($value, $this->modeList)) { 50 | $this->setValue($this->modeList[$value]); 51 | } else { 52 | throw new Exception("Payment mode not found"); 53 | } 54 | } 55 | 56 | /*** 57 | * Set the payment mode value 58 | * @param string value 59 | */ 60 | private function setValue($value) 61 | { 62 | $this->value = $value; 63 | } 64 | 65 | /*** 66 | * @return string $value of payment mode value 67 | */ 68 | public function getValue() 69 | { 70 | return $this->value; 71 | } 72 | 73 | /*** 74 | * Find a PagSeguroPaymentMode in a list 75 | * @param value 76 | * @return PagSeguroPaymentMode the corresponding to the informed value 77 | */ 78 | public static function fromValue($value) 79 | { 80 | try { 81 | return array_search(strtoupper($value), $this->modeList); 82 | } catch (Exception $e) { 83 | return null; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroTransactionType.class.php: -------------------------------------------------------------------------------- 1 | 1, 34 | 'TRANSFER' => 2, 35 | 'FUND_ADDITION' => 3, 36 | 'WITHDRAW' => 4, 37 | 'CHARGE' => 5, 38 | 'DONATION' => 6, 39 | 'BONUS' => 7, 40 | 'BONUS_REPASS' => 8, 41 | 'OPERATIONAL' => 9, 42 | 'POLITICAL_DONATION' => 10 43 | ); 44 | 45 | private $value; 46 | 47 | public function __construct($value = null) 48 | { 49 | if ($value) { 50 | $this->value = $value; 51 | } 52 | } 53 | 54 | public function setValue($value) 55 | { 56 | $this->value = $value; 57 | } 58 | 59 | public function setByType($type) 60 | { 61 | if (isset(self::$typeList[$type])) { 62 | $this->value = self::$typeList[$type]; 63 | } else { 64 | throw new Exception("undefined index $type"); 65 | } 66 | } 67 | 68 | public function getValue() 69 | { 70 | return $this->value; 71 | } 72 | 73 | /*** 74 | * @param integer|string $value 75 | * @return string|integer the transaction type corresponding to the informed type value value 76 | */ 77 | public function getTypeFromValue($value = null) 78 | { 79 | $value = ($value == null ? $this->value : $value); 80 | return array_search($value, self::$typeList); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/parser/PagSeguroInstallmentParser.class.php: -------------------------------------------------------------------------------- 1 | 41 | $data = $parser->getResult('installments'); 42 | 43 | 44 | // 45 | if (isset($data)) { 46 | if (isset($data["installment"][0])) { 47 | foreach ($data["installment"] as $installment) { 48 | $installments[] = new PagSeguroInstallment( 49 | $installment['cardBrand'], 50 | $installment['quantity'], 51 | $installment['amount'], 52 | $installment['totalAmount'], 53 | $installment['interestFree'] 54 | ); 55 | } 56 | } else { 57 | $installments[] = new PagSeguroInstallment( 58 | $data["installment"]['cardBrand'], 59 | $data["installment"]['quantity'], 60 | $data["installment"]['amount'], 61 | $data["installment"]['totalAmount'], 62 | $data["installment"]['interestFree'] 63 | ); 64 | } 65 | $installments = new PagSeguroInstallments($installments); 66 | return $installments; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroTransactionCreditorFees.class.php: -------------------------------------------------------------------------------- 1 | setIntermediationRateAmount($value['intermediationRateAmount']); 43 | $this->setIntermediationFeeAmount($value['intermediationFeeAmount']); 44 | } 45 | } 46 | 47 | /*** 48 | * Sets the transaction intermediation Rate Amount 49 | * @param float $intermediationRateAmount 50 | */ 51 | public function setIntermediationRateAmount($intermediationRateAmount) 52 | { 53 | $this->intermediationRateAmount = $intermediationRateAmount; 54 | } 55 | 56 | /*** 57 | * @return float the transaction intermediation Rate Amount 58 | */ 59 | public function getIntermediationRateAmount() 60 | { 61 | return $this->intermediationRateAmount; 62 | } 63 | 64 | /*** 65 | * Sets the transaction intermediation Fee Amount 66 | * @param float $intermediationFeeAmount 67 | */ 68 | public function setIntermediationFeeAmount($intermediationFeeAmount) 69 | { 70 | $this->intermediationFeeAmount = $intermediationFeeAmount; 71 | } 72 | 73 | /*** 74 | * @return float the transaction intermediation Fee Amount 75 | */ 76 | public function getIntermediationFeeAmount() 77 | { 78 | return $this->intermediationFeeAmount; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/parser/PagSeguroParserData.class.php: -------------------------------------------------------------------------------- 1 | code; 49 | } 50 | 51 | /*** 52 | * @param $code 53 | */ 54 | public function setCode($code) 55 | { 56 | $this->code = $code; 57 | } 58 | 59 | /*** 60 | * @return mixed 61 | */ 62 | public function getRegistrationDate() 63 | { 64 | return $this->registrationDate; 65 | } 66 | 67 | /*** 68 | * @param $registrationDate 69 | */ 70 | public function setRegistrationDate($registrationDate) 71 | { 72 | $this->registrationDate = $registrationDate; 73 | } 74 | 75 | /*** 76 | * @return mixed 77 | */ 78 | public function getStatus() 79 | { 80 | return $this->status; 81 | } 82 | 83 | /*** 84 | * @param $status 85 | */ 86 | public function setStatus($status) 87 | { 88 | $this->status = $status; 89 | } 90 | 91 | /** 92 | * @return string 93 | */ 94 | public function toString() 95 | { 96 | 97 | $data = array(); 98 | $data['code'] = $this->code; 99 | $data['registrationDate'] = $this->registrationDate; 100 | $data['status'] = $this->status; 101 | 102 | return "ParserData: " . var_export($data, true); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethod.class.php: -------------------------------------------------------------------------------- 1 | setType($type); 51 | } 52 | if ($code) { 53 | $this->setCode($code); 54 | } 55 | } 56 | 57 | /*** 58 | * @return the payment method type 59 | */ 60 | public function getType() 61 | { 62 | return $this->type; 63 | } 64 | 65 | /*** 66 | * Sets the payment method type 67 | * @param PagSeguroPaymentMethodType $type 68 | */ 69 | public function setType($type) 70 | { 71 | if ($type instanceof PagSeguroPaymentMethodType) { 72 | $this->type = $type; 73 | } else { 74 | $this->type = new PagSeguroPaymentMethodType($type); 75 | } 76 | } 77 | 78 | /*** 79 | * @return the code 80 | */ 81 | public function getCode() 82 | { 83 | return $this->code; 84 | } 85 | 86 | /*** 87 | * Sets the payment method code 88 | * @param PagSeguroPaymentMethodCode $code 89 | */ 90 | public function setCode($code) 91 | { 92 | if ($code instanceof PagSeguroPaymentMethodCode) { 93 | $this->code = $code; 94 | } else { 95 | $this->code = new PagSeguroPaymentMethodCode($code); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethodType.class.php: -------------------------------------------------------------------------------- 1 | 1, 33 | /*** Boleto - is a form of invoicing in Brazil */ 34 | 'BOLETO' => 2, 35 | /*** Online transfer */ 36 | 'ONLINE_TRANSFER' => 3, 37 | /*** PagSeguro account balance */ 38 | 'BALANCE' => 4, 39 | /*** OiPaggo */ 40 | 'OI_PAGGO' => 5, 41 | /*** Direct deposit */ 42 | 'DIRECT_DEPOSIT' => 7 43 | ); 44 | 45 | /*** 46 | * Payment method type value 47 | * Example: 1 48 | * @var integer 49 | */ 50 | private $value; 51 | 52 | public function __construct($value = null) 53 | { 54 | if ($value) { 55 | $this->setValue($value); 56 | } 57 | } 58 | 59 | public function setValue($value) 60 | { 61 | $this->value = $value; 62 | } 63 | 64 | public function setByType($type) 65 | { 66 | if (isset(self::$typeList[$type])) { 67 | $this->value = self::$typeList[$type]; 68 | } else { 69 | throw new Exception("undefined index $type"); 70 | } 71 | } 72 | 73 | /*** 74 | * @return integer payment method type value 75 | * Example: 1 76 | */ 77 | public function getValue() 78 | { 79 | return $this->value; 80 | } 81 | 82 | /*** 83 | * @param value 84 | * @return PagSeguroPaymentMethodType the corresponding to the informed value 85 | */ 86 | public function getTypeFromValue($value = null) 87 | { 88 | $value = ($value == null ? $this->value : $value); 89 | return array_search($value, self::$typeList); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethodGroups.class.php: -------------------------------------------------------------------------------- 1 | 'Payment with Credit Card', 32 | 'BOLETO' => 'Payment with Boleto', 33 | 'EFT' => 'Payment with Online Debit', 34 | 'BALANCE' => 'Payment with PagSeguro Balance', 35 | 'DEPOSIT' => 'Payment with Deposit' 36 | ); 37 | 38 | /*** 39 | * Get available payment method groups list for payment method config use in PagSeguro transactions 40 | * @return array 41 | */ 42 | public static function getAvailableGroupList() 43 | { 44 | return self::$availableGroupList; 45 | } 46 | 47 | /*** 48 | * Check if payment method groups is available for PagSeguro 49 | * @param string $key 50 | * @return boolean 51 | */ 52 | public static function isKeyAvailable($key) 53 | { 54 | $key = strtoupper($key); 55 | return (isset(self::$availableGroupList[$key])); 56 | } 57 | 58 | /*** 59 | * Gets group description by key 60 | * @param string $key 61 | * @return string 62 | */ 63 | public static function getDescriptionByKey($key) 64 | { 65 | $key = strtoupper($key); 66 | if (isset(self::$availableGroupList[$key])) { 67 | return self::$availableGroupList[$key]; 68 | } else { 69 | return false; 70 | } 71 | } 72 | 73 | /*** 74 | * Gets group type by description 75 | * @param string $description 76 | * @return string 77 | */ 78 | public static function getGroupByDescription($description) 79 | { 80 | return array_search(strtolower($description), array_map('strtolower', self::$availableGroupList)); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethodConfigKeys.class.php: -------------------------------------------------------------------------------- 1 | 'Percentual de Desconto', 32 | 'MAX_INSTALLMENTS_NO_INTEREST' => 'Parcelamento sem Acréscimo', 33 | 'MAX_INSTALLMENTS_LIMIT' => 'Limite de Parcelamento' 34 | ); 35 | 36 | /*** 37 | * Get available config key list for payment method config use in PagSeguro transactions 38 | * @return array 39 | */ 40 | public static function getAvailableKeysList() 41 | { 42 | return self::$availableKeyList; 43 | } 44 | 45 | /*** 46 | * Check if config key is available for PagSeguro 47 | * @param string $configKey 48 | * @return boolean 49 | */ 50 | public static function isKeyAvailable($configKey) 51 | { 52 | $configKey = strtoupper($configKey); 53 | return (isset(self::$availableKeyList[$configKey])); 54 | } 55 | 56 | /*** 57 | * Gets config description by key 58 | * @param string $configKey 59 | * @return string 60 | */ 61 | public static function getDescriptionByKey($configKey) 62 | { 63 | $configKey = strtoupper($configKey); 64 | if (isset(self::$availableKeyList[$configKey])) { 65 | return self::$availableKeyList[$configKey]; 66 | } else { 67 | return false; 68 | } 69 | } 70 | 71 | /*** 72 | * Gets config key type by description 73 | * @param string $configDescription 74 | * @return string 75 | */ 76 | public static function getKeyByDescription($configDescription) 77 | { 78 | return array_search(strtolower($configDescription), array_map('strtolower', self::$availableKeyList)); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroSenderDocument.class.php: -------------------------------------------------------------------------------- 1 | setType($type); 50 | $this->setValue($value); 51 | } 52 | } 53 | 54 | /*** 55 | * Get document type 56 | * @return string 57 | */ 58 | public function getType() 59 | { 60 | return $this->type; 61 | } 62 | 63 | /*** 64 | * Set document type 65 | * @param string $type 66 | */ 67 | public function setType($type) 68 | { 69 | $this->type = strtoupper($type); 70 | } 71 | 72 | /*** 73 | * Get document value 74 | * @return string 75 | */ 76 | public function getValue() 77 | { 78 | return $this->value; 79 | } 80 | 81 | /*** 82 | * Set document value 83 | * @param string $value 84 | */ 85 | public function setValue($value) 86 | { 87 | $this->value = PagSeguroHelper::getOnlyNumbers($value); 88 | } 89 | 90 | /*** 91 | * Gets toString class 92 | * @return string 93 | */ 94 | public function toString() 95 | { 96 | $document = array(); 97 | $document['type'] = $this->type; 98 | $document['value'] = $this->value; 99 | 100 | return "PagSeguroSenderDocument: " . var_export($document, true); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroDocuments.class.php: -------------------------------------------------------------------------------- 1 | 'Cadastro de Pessoa Física', 36 | 'CNPJ' => 'Cadastro de Pessoa Jurídica' 37 | ); 38 | 39 | /*** 40 | * Get available document list for Sender use in PagSeguro transactions 41 | * @return array 42 | */ 43 | public static function getAvailableDocumentList() 44 | { 45 | return self::$availableDocumentList; 46 | } 47 | 48 | /*** 49 | * Check if document type is available for PagSeguro 50 | * @param string $documentType 51 | * @return boolean 52 | */ 53 | public static function isDocumentTypeAvailable($documentType) 54 | { 55 | $documentType = strtoupper($documentType); 56 | return (isset(self::$availableDocumentList[$documentType])); 57 | } 58 | 59 | /*** 60 | * Gets document description by type 61 | * @param string 62 | * @return string 63 | */ 64 | public static function getDocumentByType($documentType) 65 | { 66 | $documentType = strtoupper($documentType); 67 | if (isset(self::$availableDocumentList[$documentType])) { 68 | return self::$availableDocumentList[$documentType]; 69 | } else { 70 | return false; 71 | } 72 | } 73 | 74 | /*** 75 | * Gets document type by description 76 | * @param string $documentDescription 77 | * @return string 78 | */ 79 | public static function getDocumentByDescription($documentDescription) 80 | { 81 | return array_search(strtolower($documentDescription), array_map('strtolower', self::$availableDocumentList)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroDocument.class.php: -------------------------------------------------------------------------------- 1 | 'CPF', 32 | 2 => 'CNPJ' 33 | ); 34 | 35 | /*** 36 | * The type of document 37 | * @var string 38 | */ 39 | private $type; 40 | 41 | /*** 42 | * The value of document 43 | * @var string 44 | */ 45 | private $value; 46 | 47 | public function __construct(array $data = null) 48 | { 49 | if ($data) { 50 | if (isset($data['type']) && isset($data['value'])) { 51 | $this->setType($data['type']); 52 | $this->setValue(PagSeguroHelper::getOnlyNumbers($data['value'])); 53 | } 54 | } 55 | } 56 | 57 | /*** 58 | * Get document type 59 | * @return String 60 | */ 61 | public function getType() 62 | { 63 | return $this->type; 64 | } 65 | 66 | /*** 67 | * Set document type 68 | * @param String $type 69 | */ 70 | public function setType($type) 71 | { 72 | $this->type = strtoupper($type); 73 | } 74 | 75 | /*** 76 | * Get document value 77 | * @return String 78 | */ 79 | public function getValue() 80 | { 81 | return $this->value; 82 | } 83 | 84 | /*** 85 | * Set document value 86 | * @param String $value 87 | */ 88 | public function setValue($value) 89 | { 90 | $this->value = $value; 91 | } 92 | 93 | /*** 94 | * Check if document type is available for PagSeguro 95 | * @param string $documentType 96 | * @return array|boolean 97 | */ 98 | public static function isDocumentTypeAvailable($documentType) 99 | { 100 | return (array_search(strtoupper($documentType), self::$availableDocumentList)); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentRequest.class.php: -------------------------------------------------------------------------------- 1 | preApproval = $preApproval; 50 | } 51 | /** 52 | * @return mixed 53 | */ 54 | public function getPreApproval() 55 | { 56 | return $this->preApproval; 57 | } 58 | 59 | /*** 60 | * Calls the PagSeguro web service and register this request for payment 61 | * 62 | * @param PagSeguroCredentials $credentials, lighbox 63 | * @return String The URL to where the user needs to be redirected to in order to complete the payment process or 64 | * the CODE when use lightbox 65 | */ 66 | public function register(PagSeguroCredentials $credentials, $onlyCheckoutCode = false) 67 | { 68 | return PagSeguroPaymentService::checkoutRequest($credentials, $this, $onlyCheckoutCode); 69 | } 70 | 71 | /*** 72 | * Verify if the adress of NotificationURL or RedirectURL is for tests and return empty 73 | * @param type $url 74 | * @return type 75 | */ 76 | public function verifyURLTest($url) 77 | { 78 | $adress = array( 79 | '127.0.0.1', 80 | '::1' 81 | ); 82 | 83 | $urlReturn = null; 84 | foreach ($adress as $item) { 85 | $find = strpos($url, $item); 86 | 87 | if ($find) { 88 | $urlReturn = ''; 89 | break; 90 | } else { 91 | $urlReturn = $url; 92 | } 93 | } 94 | 95 | return $urlReturn; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Sonar 34 | ################# 35 | .sonar/ 36 | sonar-project.properties 37 | 38 | ################# 39 | ## Visual Studio 40 | ################# 41 | 42 | ## Ignore Visual Studio temporary files, build results, and 43 | ## files generated by popular Visual Studio add-ons. 44 | 45 | # User-specific files 46 | *.suo 47 | *.user 48 | *.sln.docstates 49 | 50 | # Build results 51 | [Dd]ebug/ 52 | [Rr]elease/ 53 | *_i.c 54 | *_p.c 55 | *.ilk 56 | *.meta 57 | *.obj 58 | *.pch 59 | *.pdb 60 | *.pgc 61 | *.pgd 62 | *.rsp 63 | *.sbr 64 | *.tlb 65 | *.tli 66 | *.tlh 67 | *.tmp 68 | *.vspscc 69 | .builds 70 | *.dotCover 71 | 72 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 73 | #packages/ 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper* 88 | 89 | # Installshield output folder 90 | [Ee]xpress 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish 104 | 105 | # Others 106 | *~ 107 | [Bb]in 108 | [Oo]bj 109 | sql 110 | TestResults 111 | *.Cache 112 | ClientBin 113 | stylecop.* 114 | ~$* 115 | *.dbmdl 116 | Generated_Code #added for RIA/Silverlight projects 117 | 118 | # Backup & report files from converting an old project file to a newer 119 | # Visual Studio version. Backup files are not needed, because we have git ;-) 120 | _UpgradeReport_Files/ 121 | Backup*/ 122 | UpgradeLog*.XML 123 | 124 | 125 | 126 | ############ 127 | ## Windows 128 | ############ 129 | 130 | # Windows image file caches 131 | Thumbs.db 132 | 133 | # Folder config file 134 | Desktop.ini 135 | 136 | 137 | ############# 138 | ## Python 139 | ############# 140 | 141 | *.py[co] 142 | 143 | # Packages 144 | *.egg 145 | *.egg-info 146 | dist 147 | build 148 | eggs 149 | parts 150 | bin 151 | var 152 | sdist 153 | develop-eggs 154 | .installed.cfg 155 | 156 | # Installer logs 157 | pip-log.txt 158 | 159 | # Unit test / coverage reports 160 | .coverage 161 | .tox 162 | 163 | #Translations 164 | *.mo 165 | 166 | #Mr Developer 167 | .mr.developer.cfg 168 | 169 | # Mac crap 170 | .DS_Store 171 | 172 | ################# 173 | ## SVN 174 | ################# 175 | .svn/ 176 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroTransactionCancellationSource.class.php: -------------------------------------------------------------------------------- 1 | "INTERNAL", 37 | 'FINANCEIRA' => "EXTERNAL" 38 | ); 39 | 40 | /*** 41 | * the value of the transaction cancellation source 42 | * Example: EXTERNAL 43 | */ 44 | private $value; 45 | 46 | /*** 47 | * @param null $value 48 | */ 49 | public function __construct($value = null) 50 | { 51 | if ($value) { 52 | $this->value = $value; 53 | } 54 | } 55 | 56 | /*** 57 | * @param $value 58 | */ 59 | public function setValue($value) 60 | { 61 | $this->value = $value; 62 | } 63 | 64 | /*** 65 | * @param $type 66 | * @throws Exception 67 | */ 68 | public function setByType($type) 69 | { 70 | if (isset(self::$sourceList[$type])) { 71 | $this->value = self::$sourceList[$type]; 72 | } else { 73 | throw new Exception("undefined index $type"); 74 | } 75 | } 76 | 77 | /*** 78 | * @return string the status value. 79 | */ 80 | public function getValue() 81 | { 82 | return $this->value; 83 | } 84 | 85 | /*** 86 | * @param value 87 | * @return String the transaction cancellation source corresponding to the informed source value 88 | */ 89 | public function getTypeFromValue($value = null) 90 | { 91 | $value = ($value == null ? $this->value : $value); 92 | return array_search($this->value, self::$sourceList); 93 | } 94 | 95 | /*** 96 | * Get status list 97 | * @return array 98 | */ 99 | public static function getSourceList() 100 | { 101 | return self::$sourceList; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroMetaDataItemKeys.class.php: -------------------------------------------------------------------------------- 1 | 'Passenger CPF', 32 | 'PASSENGER_PASSPORT' => 'Passager passport', 33 | 'ORIGIN_CITY' => 'Origin city', 34 | 'DESTINATION_CITY' => 'Destination city', 35 | 'ORIGIN_AIRPORT_CODE' => 'Airport source code', 36 | 'DESTINATION_AIRPORT_CODE' => 'Destination airport code', 37 | 'GAME_NAME' => 'Game name', 38 | 'PLAYER_ID' => 'Player identification', 39 | 'TIME_IN_GAME_DAYS' => 'In days game time', 40 | 'MOBILE_NUMBER' => 'Recharge cell', 41 | 'PASSENGER_NAME' => 'Passenger name' 42 | ); 43 | 44 | /*** 45 | * Get available item key list for metadata use in PagSeguro transactions 46 | * @return array 47 | */ 48 | public static function getAvailableItemKeysList() 49 | { 50 | return self::$availableItemKeysList; 51 | } 52 | 53 | /*** 54 | * Check if item key is available for PagSeguro 55 | * @param string $itemKey 56 | * @return boolean 57 | */ 58 | public static function isItemKeyAvailable($itemKey) 59 | { 60 | $itemKey = strtoupper($itemKey); 61 | return (isset(self::$availableItemKeysList[$itemKey])); 62 | } 63 | 64 | /*** 65 | * Gets item description by key 66 | * @param string $itemKey 67 | * @return string 68 | */ 69 | public static function getItemDescriptionByKey($itemKey) 70 | { 71 | $itemKey = strtoupper($itemKey); 72 | if (isset(self::$availableItemKeysList[$itemKey])) { 73 | return self::$availableItemKeysList[$itemKey]; 74 | } else { 75 | return false; 76 | } 77 | } 78 | 79 | /*** 80 | * Gets item key type by description 81 | * @param string $itemDescription 82 | * @return string 83 | */ 84 | public static function getItemKeyByDescription($itemDescription) 85 | { 86 | return array_search(strtolower($itemDescription), array_map('strtolower', self::$availableItemKeysList)); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroParameterItem.class.php: -------------------------------------------------------------------------------- 1 | setKey($key); 54 | } 55 | if (isset($value) && !PagSeguroHelper::isEmpty($value)) { 56 | $this->setValue($value); 57 | } 58 | if (isset($group) && !PagSeguroHelper::isEmpty($group)) { 59 | $this->setGroup($group); 60 | } 61 | } 62 | 63 | /*** 64 | * Gets the parameter item key 65 | * @return string 66 | */ 67 | public function getKey() 68 | { 69 | return $this->key; 70 | } 71 | 72 | /*** 73 | * Sets the parameter item key 74 | * 75 | * @param string $key 76 | */ 77 | public function setKey($key) 78 | { 79 | $this->key = $key; 80 | } 81 | 82 | /*** 83 | * Gets parameter item value 84 | * @return string 85 | */ 86 | public function getValue() 87 | { 88 | return $this->value; 89 | } 90 | 91 | /*** 92 | * Sets parameter item value 93 | * 94 | * @param string $value 95 | */ 96 | public function setValue($value) 97 | { 98 | $this->value = $value; 99 | } 100 | 101 | /*** 102 | * Gets parameter item group 103 | * 104 | * @return int 105 | */ 106 | public function getGroup() 107 | { 108 | return $this->group; 109 | } 110 | 111 | /*** 112 | * Sets parameter item group 113 | * 114 | * @param int $group 115 | */ 116 | public function setGroup($group) 117 | { 118 | $this->group = (int) $group; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroTransactionStatus.class.php: -------------------------------------------------------------------------------- 1 | 0, 37 | 'WAITING_PAYMENT' => 1, 38 | 'IN_ANALYSIS' => 2, 39 | 'PAID' => 3, 40 | 'AVAILABLE' => 4, 41 | 'IN_DISPUTE' => 5, 42 | 'REFUNDED' => 6, 43 | 'CANCELLED' => 7, 44 | 'SELLER_CHARGEBACK' => 8, 45 | 'CONTESTATION' => 9 46 | ); 47 | 48 | /*** 49 | * the value of the transaction status 50 | * Example: 3 51 | */ 52 | private $value; 53 | 54 | /*** 55 | * @param null $value 56 | */ 57 | public function __construct($value = null) 58 | { 59 | if ($value) { 60 | $this->value = $value; 61 | } 62 | } 63 | 64 | /*** 65 | * @param $value 66 | */ 67 | public function setValue($value) 68 | { 69 | $this->value = $value; 70 | } 71 | 72 | /*** 73 | * @param $type 74 | * @throws Exception 75 | */ 76 | public function setByType($type) 77 | { 78 | if (isset(self::$statusList[$type])) { 79 | $this->value = self::$statusList[$type]; 80 | } else { 81 | throw new Exception("undefined index $type"); 82 | } 83 | } 84 | 85 | /*** 86 | * @return integer the status value. 87 | */ 88 | public function getValue() 89 | { 90 | return $this->value; 91 | } 92 | 93 | /*** 94 | * @param value 95 | * @return String the transaction status corresponding to the informed status value 96 | */ 97 | public function getTypeFromValue($value = null) 98 | { 99 | $value = ($value == null ? $this->value : $value); 100 | return array_search($this->value, self::$statusList); 101 | } 102 | 103 | /*** 104 | * Get status list 105 | * @return array 106 | */ 107 | public static function getStatusList() 108 | { 109 | return self::$statusList; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /catalog/controller/payment/pagseguro_redirect.php: -------------------------------------------------------------------------------- 1 | config->get('pagseguro_checkout') == 'lightbox') { 41 | $this->data['breadcrumbs'] = array(); 42 | 43 | $this->data['breadcrumbs'][] = array( 44 | 'text' => $this->language->get('text_home'), 45 | 'href' => $this->url->link('common/home'), 46 | 'separator' => false 47 | ); 48 | 49 | $this->data['breadcrumbs'][] = array( 50 | 'text' => 'Checkout', 51 | 'href' => $this->url->link('information/static'), 52 | 'separator' => $this->language->get('text_separator') 53 | ); 54 | 55 | $this->template = 'default/template/payment/pagseguro_lightbox.tpl'; 56 | $this->children = array( //Required. The children files for the page. 57 | 'common/column_left', 58 | 'common/column_right', 59 | 'common/content_top', 60 | 'common/content_bottom', 61 | 'common/footer', 62 | 'common/header' 63 | ); 64 | 65 | $this->data['code'] = ''; 66 | $this->data['environment'] = ''; 67 | } 68 | $this->_redirect(); 69 | } 70 | $this->response->setOutput($this->render()); 71 | 72 | } 73 | 74 | /** 75 | * Redirect Store for PagSeguro and Clean Cart 76 | */ 77 | private function _redirect() 78 | { 79 | 80 | $this->_urlPagSeguro = $this->request->post['url_ps']; 81 | 82 | if (!empty($this->_urlPagSeguro )) { 83 | if($this->config->get('pagseguro_checkout') == 'lightbox'){ 84 | $this->data['code'] = $this->_urlPagSeguro; 85 | $this->data['environment'] = $this->config->get('pagseguro_environment'); 86 | 87 | $this->cart->clear(); 88 | }else{ 89 | header('Location: ' . $this->_urlPagSeguro); 90 | $this->cart->clear(); 91 | } 92 | 93 | } 94 | } 95 | } 96 | ?> -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAccountCredentials.class.php: -------------------------------------------------------------------------------- 1 | setEmail($email); 52 | $this->setToken($token); 53 | } else { 54 | throw new Exception("Credentials not set."); 55 | } 56 | } 57 | 58 | /*** 59 | * @return string the e-mail from this account credential object 60 | */ 61 | public function getEmail() 62 | { 63 | return $this->email; 64 | } 65 | 66 | /*** 67 | * Sets the e-mail from this account credential object 68 | */ 69 | public function setEmail($email) 70 | { 71 | $this->email = $email; 72 | } 73 | 74 | /*** 75 | * @return string the token from this account credential object 76 | */ 77 | public function getToken() 78 | { 79 | return $this->token; 80 | } 81 | 82 | /*** 83 | * Sets the token in this account credential object 84 | */ 85 | public function setToken($token) 86 | { 87 | $this->token = $token; 88 | } 89 | 90 | /*** 91 | * @return array a map of name value pairs that compose this set of credentials 92 | */ 93 | public function getAttributesMap() 94 | { 95 | return array( 96 | 'email' => $this->email, 97 | 'token' => $this->token 98 | ); 99 | } 100 | 101 | /*** 102 | * @return string a string that represents the current object 103 | */ 104 | public function toString() 105 | { 106 | $credentials = array(); 107 | $credentials['E-mail'] = $this->email; 108 | $credentials['Token'] = $this->token; 109 | return implode(' - ', $credentials); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPaymentMethodConfigItem.class.php: -------------------------------------------------------------------------------- 1 | setKey($key); 55 | } 56 | if (isset($value) && !PagSeguroHelper::isEmpty($value)) { 57 | $this->setValue($value); 58 | } 59 | if (isset($group) && !PagSeguroHelper::isEmpty($group)) { 60 | $this->setGroup($group); 61 | } 62 | } 63 | 64 | /*** 65 | * Gets the payment method config item key 66 | * @return string 67 | */ 68 | public function getKey() 69 | { 70 | return $this->key; 71 | } 72 | 73 | /*** 74 | * Sets the payment method config item key 75 | * 76 | * @param string $key 77 | */ 78 | public function setKey($key) 79 | { 80 | $this->key = $key; 81 | } 82 | 83 | /*** 84 | * Gets payment method config item value 85 | * @return string 86 | */ 87 | public function getValue() 88 | { 89 | return $this->value; 90 | } 91 | 92 | /*** 93 | * Sets payment method config item value 94 | * 95 | * @param string $value 96 | */ 97 | public function setValue($value) 98 | { 99 | $this->value = PagSeguroHelper::decimalFormat($value); 100 | } 101 | 102 | /*** 103 | * Gets payment method config item group 104 | * 105 | * @return int 106 | */ 107 | public function getGroup() 108 | { 109 | return $this->group; 110 | } 111 | 112 | /*** 113 | * Sets payment method config item group 114 | * 115 | * @param int $group 116 | */ 117 | public function setGroup($group) 118 | { 119 | $this->group = $group; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroCurrencies.class.php: -------------------------------------------------------------------------------- 1 | 34 | * key = currency name 35 | * value = currency iso code 3 36 | * 37 | * @var array 38 | */ 39 | private static $currencies = array( 40 | 'REAL' => 'BRL' 41 | ); 42 | 43 | /*** 44 | * Check if currency is available by informed iso code for PagSeguro transactions 45 | * @param string $currency_iso_code 46 | * @return boolean 47 | */ 48 | public static function checkCurrencyAvailabilityByIsoCode($currency_iso_code) 49 | { 50 | $available = false; 51 | if (array_search(strtoupper($currency_iso_code), self::$currencies)) { 52 | $available = true; 53 | } 54 | return $available; 55 | } 56 | 57 | /*** 58 | * Check if currency is available by informed currency name for PagSeguro transactions 59 | * @param string $name 60 | * @return boolean 61 | */ 62 | public static function checkCurrencyAvailabilityByName($name) 63 | { 64 | $available = false; 65 | if (array_key_exists(strtoupper($name), self::$currencies)) { 66 | $available = true; 67 | } 68 | return $available; 69 | } 70 | 71 | /*** 72 | * Return currencies list 73 | * @return array 74 | */ 75 | public static function getCurrenciesList() 76 | { 77 | return self::$currencies; 78 | } 79 | 80 | /*** 81 | * Return iso code by currency name 82 | * Default return BRL (Brazilian Real) iso code 83 | * @param string $name - the currency name 84 | * @return string 85 | */ 86 | public static function getIsoCodeByName($name) 87 | { 88 | $name = strtoupper($name); 89 | return (isset(self::$currencies[$name])) ? self::$currencies[$name] : self::$currencies['REAL']; 90 | } 91 | 92 | /** 93 | * Return currency name by iso code 94 | * @param string $iso_code 95 | * @return string 96 | */ 97 | public static function getCurrencyNameByIsoCode($iso_code) 98 | { 99 | return array_search(strtoupper($iso_code), self::getCurrenciesList()); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPhone.class.php: -------------------------------------------------------------------------------- 1 | areaCode = ($areaCode == null ? null : $areaCode); 50 | $this->number = ($number == null ? null : $number); 51 | return $this; 52 | } 53 | 54 | /*** 55 | * @return int the area code 56 | */ 57 | public function getAreaCode() 58 | { 59 | return $this->areaCode; 60 | } 61 | 62 | /*** 63 | * @return int the number 64 | */ 65 | public function getNumber() 66 | { 67 | return $this->number; 68 | } 69 | 70 | /*** 71 | * Sets the area code 72 | * @param String $areaCode 73 | * @return PagSeguroPhone 74 | */ 75 | public function setAreaCode($areaCode) 76 | { 77 | $this->areaCode = $areaCode; 78 | return $this; 79 | } 80 | 81 | /*** 82 | * Sets the number 83 | * @param String $number 84 | * @return PagSeguroPhone 85 | */ 86 | public function setNumber($number) 87 | { 88 | $this->number = $number; 89 | return $this; 90 | } 91 | 92 | /*** 93 | * Sets the number from a formatted string 94 | * 95 | * @param $number String formatted string like (099) [9]9999-9999 96 | * @return $this 97 | */ 98 | public function setFullPhone($number) 99 | { 100 | /** We clean the string that is coming. Can be formatted or not */ 101 | 102 | $number = preg_replace("/[^0-9]/", '', $number); 103 | $number = $number[0] == 0 ? substr($number, 1) : $number; 104 | 105 | $number = str_split($number, 1); 106 | $areaCode = array_shift($number) . array_shift($number); 107 | $phone = implode('', $number); 108 | 109 | $this->setAreaCode($areaCode); 110 | $this->setNumber($phone); 111 | 112 | return $this->areaCode . $this->number; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPreApprovalStatus.class.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2007-2014 PagSeguro Internet Ltda. 21 | * @license http://www.apache.org/licenses/LICENSE-2.0 22 | */ 23 | 24 | /*** 25 | * Defines a list of known transaction statuses. 26 | * This class is not an enum to enable the introduction of new transaction status. 27 | * without breaking this version of the library. 28 | */ 29 | class PagSeguroPreApprovalStatus 30 | { 31 | 32 | /*** 33 | * @var array 34 | */ 35 | private static $statusList = array( 36 | 'INITIATED' => 0, 37 | 'PENDING' => 1, 38 | 'ACTIVE' => 2, 39 | 'CANCELLED' => 3, 40 | 'CANCELLED_BY_RECEIVER' => 4, 41 | 'CANCELLED_BY_SENDER' => 5, 42 | 'EXPIRED' => 6 43 | ); 44 | 45 | /*** 46 | * the value of the transaction status 47 | * Example: 3 48 | */ 49 | private $value; 50 | 51 | /*** 52 | * @param null $value 53 | */ 54 | public function __construct($value = null) 55 | { 56 | if ($value) { 57 | if (!isset(self::$statusList[$value])) { 58 | self::$statusList = array_merge(self::$statusList, array($value => count(self::$statusList))); 59 | } 60 | $this->value = self::$statusList[$value]; 61 | } 62 | } 63 | 64 | /*** 65 | * @param $value 66 | */ 67 | public function setValue($value) 68 | { 69 | $this->value = $value; 70 | } 71 | 72 | /*** 73 | * @param $type 74 | * @throws Exception 75 | */ 76 | public function setByType($type) 77 | { 78 | if (isset(self::$statusList[$type])) { 79 | $this->value = self::$statusList[$type]; 80 | } else { 81 | throw new Exception("undefined index $type"); 82 | } 83 | } 84 | 85 | /*** 86 | * @return integer the status value. 87 | */ 88 | public function getValue() 89 | { 90 | return $this->value; 91 | } 92 | 93 | /*** 94 | * @param value 95 | * @return String the transaction status corresponding to the informed status value 96 | */ 97 | public function getTypeFromValue($value = null) 98 | { 99 | $value = ($value == null ? $this->value : $value); 100 | return array_search($this->value, self::$statusList); 101 | } 102 | 103 | /*** 104 | * Get status list 105 | * @return array 106 | */ 107 | public static function getStatusList() 108 | { 109 | return self::$statusList; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroShipping.class.php: -------------------------------------------------------------------------------- 1 | address = $data['address']; 56 | } 57 | if (isset($data['type']) && $data['type'] instanceof PagSeguroShippingType) { 58 | $this->type = $data['type']; 59 | } 60 | if (isset($data['cost'])) { 61 | $this->cost = $data['cost']; 62 | } 63 | } 64 | } 65 | 66 | /*** 67 | * Sets the shipping address 68 | * @see PagSeguroAddress 69 | * @param PagSeguroAddress $address 70 | */ 71 | public function setAddress(PagSeguroAddress $address) 72 | { 73 | $this->address = $address; 74 | } 75 | 76 | /*** 77 | * @return PagSeguroAddress the shipping Address 78 | * @see PagSeguroAddress 79 | */ 80 | public function getAddress() 81 | { 82 | return $this->address; 83 | } 84 | 85 | /*** 86 | * Sets the shipping type 87 | * @param PagSeguroShippingType $type 88 | * @see PagSeguroShippingType 89 | */ 90 | public function setType(PagSeguroShippingType $type) 91 | { 92 | $this->type = $type; 93 | } 94 | 95 | /*** 96 | * @return PagSeguroShippingType the shipping type 97 | * @see PagSeguroShippingType 98 | */ 99 | public function getType() 100 | { 101 | return $this->type; 102 | } 103 | 104 | /*** 105 | * @param $cost float 106 | */ 107 | public function setCost($cost) 108 | { 109 | $this->cost = $cost; 110 | } 111 | 112 | /*** 113 | * @return float the shipping cost 114 | */ 115 | public function getCost() 116 | { 117 | return $this->cost; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /admin/language/english/payment/pagseguro.php: -------------------------------------------------------------------------------- 1 | PagSeguro'; 24 | 25 | $_['enable_module'] = 'ENABLE MODULE:'; 26 | $_['display_order'] = 'DISPLAY ORDER:'; 27 | $_['ps_email'] = 'E-MAIL:'; 28 | $_['ps_token'] = 'TOKEN:'; 29 | $_['ps_environment'] = "ENVIRONMENT"; 30 | $_['ps_checkout'] = 'CHECKOUT'; 31 | $_['url_forwarding'] = 'REDIRECT URL:'; 32 | $_['url_notification'] = 'NOTIFICATION URL:'; 33 | $_['charset'] = 'CHARSET:'; 34 | $_['log'] = 'LOG:'; 35 | $_['directory'] = 'DIRECTORY'; 36 | 37 | $_['iso'] = 'ISO-8859-1'; 38 | $_['utf'] = 'UTF-8'; 39 | 40 | $_['text_success'] = 'Success: You have modified settings!'; 41 | 42 | $_['text_module'] = 'Enable the module?'; 43 | $_['text_order'] = 'Enter the order in which PagSeguro should appear in your store checkout.'; 44 | $_['text_email'] = 'Do not have a PagSeguro account? Click here and register for free.'; 45 | $_['text_token'] = 'Do not have or do not know your token? Click here to generate a new one.'; 46 | $_['text_environment'] = 'Sets the usage environment'; 47 | $_['text_checkoutPadrao'] = 'In the standard checkout the buyer, after choosing the products and / or services, is redirected to make the payment in PagSeguro.'; 48 | $_['text_checkoutLightbox'] = 'At the lightbox checkout the buyer, after choosing the products and / or services, will make the payment in a window that overlaps your store.'; 49 | $_['text_url_forwarding'] = 'Your customer will be redirected back to your store or to the URL entered in this field. Click here to activate.'; 50 | $_['text_url_notification'] = 'Whenever a transaction change its status, PagSeguro sends a notification to your store or to the URL entered in this field.'; 51 | $_['text_charset'] = 'Set the charset according to the coding of your system.'; 52 | $_['text_log'] = 'Create log file?'; 53 | $_['text_directory'] = 'Path to the log file.'; 54 | 55 | // ERROR 56 | $_['error_permission'] = 'Warning: You do not have permission to modify settings!'; 57 | $_['error_email_required'] = 'E-mail required!'; 58 | $_['error_email_invalid'] = 'Invalid E-mail!'; 59 | $_['error_token_required'] = 'Token required!'; 60 | $_['error_token_invalid'] = 'Invalid Token!'; 61 | ?> 62 | -------------------------------------------------------------------------------- /admin/language/portuguese/payment/pagseguro.php: -------------------------------------------------------------------------------- 1 | PagSeguro'; 24 | 25 | $_['enable_module'] = 'ATIVAR MÓDULO:'; 26 | $_['display_order'] = 'ORDEM DE EXIBIÇÃO:'; 27 | $_['ps_email'] = 'E-MAIL:'; 28 | $_['ps_token'] = 'TOKEN:'; 29 | $_['ps_environment'] = 'AMBIENTE:'; 30 | $_['ps_checkout'] = 'CHECKOUT'; 31 | $_['url_forwarding'] = 'URL DE REDIRECIONAMENTO:'; 32 | $_['url_notification'] = 'URL DE NOTIFICAÇÃO:'; 33 | $_['charset'] = 'CHARSET:'; 34 | $_['log'] = 'LOG:'; 35 | $_['directory'] = 'DIRETÓRIO'; 36 | 37 | $_['iso'] = 'ISO-8859-1'; 38 | $_['utf'] = 'UTF-8'; 39 | $_['text_success'] = 'Sucesso: Você modificou as configurações!'; 40 | 41 | $_['text_module'] = 'Deseja habilitar o módulo?'; 42 | $_['text_order'] = 'Digite a ordem em que o PagSeguro deve aparecer no checkout de sua loja.'; 43 | $_['text_email'] = 'Não tem conta no PagSeguro? Clique aqui e se cadastre grátis.'; 44 | $_['text_token'] = 'Não tem ou não sabe seu token? Clique aqui para gerar um novo.'; 45 | $_['text_environment'] = 'Define o ambiente de uso'; 46 | $_['text_checkoutPadrao'] = 'No checkout padrão o comprador, após escolher os produtos e/ou serviços, é redirecionado para fazer o pagamento no PagSeguro.'; 47 | $_['text_checkoutLightbox'] = 'No checkout lightbox o comprador, após escolher os produtos e/ou serviços, fará o pagamento em uma janela que se sobrepõe a sua loja.'; 48 | $_['text_url_forwarding'] = 'Seu cliente será redirecionado para sua loja ou para a URL que você informar neste campo. Clique aqui para ativar.'; 49 | $_['text_url_notification'] = 'Sempre que uma transação mudar de status, PagSeguro envia uma notificação para sua loja ou para a URL que você informar neste campo.'; 50 | $_['text_charset'] = 'Definir o charset de acordo com a codificação do seu sistema.'; 51 | $_['text_log'] = 'Criar arquivo de log?'; 52 | $_['text_directory'] = 'Caminho para o arquivo de log.'; 53 | 54 | // ERROR 55 | $_['error_permission'] = 'Aviso: Você não tem permissão para modificar as configurações!'; 56 | $_['error_email_required'] = 'E-mail necessário!'; 57 | $_['error_email_invalid'] = 'E-mail inválido!'; 58 | $_['error_token_required'] = 'Token necessário!'; 59 | $_['error_token_invalid'] = 'Token inválido!'; 60 | ?> 61 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAuthorizationPermission.class.php: -------------------------------------------------------------------------------- 1 | setCode($code); 54 | $this->setStatus($status); 55 | $this->setLastUpdate($lastUpdate); 56 | } else { 57 | throw new Exception("Wasn't possible construct the permission"); 58 | } 59 | } 60 | 61 | /*** 62 | * @return string of authorization permission code 63 | */ 64 | public function getCode() 65 | { 66 | return $this->code; 67 | } 68 | 69 | /*** 70 | * Sets the authorization permission code 71 | * @param mixed $code 72 | */ 73 | public function setCode($code) 74 | { 75 | if (isset($code)) { 76 | $this->code = $code; 77 | } 78 | } 79 | 80 | /*** 81 | * @return string of authorization permission status 82 | */ 83 | public function getStatus() 84 | { 85 | return $this->status; 86 | } 87 | 88 | /*** 89 | * Sets the authorization permission status 90 | * @param string $status 91 | */ 92 | public function setStatus($status) 93 | { 94 | if (isset($status)) { 95 | $this->status = $status; 96 | } 97 | } 98 | 99 | /*** 100 | * @return string of authorization last update 101 | */ 102 | public function getLastUpdate() 103 | { 104 | return $this->lastUpdate; 105 | } 106 | 107 | /*** 108 | * Sets the authorization permission last update 109 | * @param date $lastUpdate 110 | */ 111 | public function setLastUpdate($lastUpdate) 112 | { 113 | if (isset($lastUpdate)) { 114 | $this->lastUpdate = $lastUpdate; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroShippingType.class.php: -------------------------------------------------------------------------------- 1 | 1, 37 | 'SEDEX' => 2, 38 | 'NOT_SPECIFIED' => 3 39 | ); 40 | 41 | /*** 42 | * the shipping type value 43 | * Example: 1 44 | */ 45 | private $value; 46 | 47 | /*** 48 | * @param null $value 49 | */ 50 | public function __construct($value = null) 51 | { 52 | if ($value) { 53 | $this->value = $value; 54 | } 55 | } 56 | 57 | /*** 58 | * @param $value 59 | */ 60 | public function setValue($value) 61 | { 62 | $this->value = $value; 63 | } 64 | 65 | /*** 66 | * @param $type 67 | * @throws Exception 68 | */ 69 | public function setByType($type) 70 | { 71 | if (isset(self::$typeList[$type])) { 72 | $this->value = self::$typeList[$type]; 73 | } else { 74 | throw new Exception("undefined index $type"); 75 | } 76 | } 77 | 78 | /*** 79 | * @return int the value of the shipping type 80 | */ 81 | public function getValue() 82 | { 83 | return $this->value; 84 | } 85 | 86 | /*** 87 | * @param value 88 | * @return PagSeguroShippingType the PagSeguroShippingType corresponding to the informed value 89 | */ 90 | public function getTypeFromValue($value = null) 91 | { 92 | $value = ($value === null ? $this->value : $value); 93 | return array_search($value, self::$typeList); 94 | } 95 | 96 | /*** 97 | * @param string 98 | * @return integer the code corresponding to the informed shipping type 99 | */ 100 | public static function getCodeByType($type) 101 | { 102 | if (isset(self::$typeList[$type])) { 103 | return self::$typeList[$type]; 104 | } else { 105 | return false; 106 | } 107 | } 108 | 109 | /*** 110 | * @param string $type 111 | * @return PagSeguroShippingType a PagSeguroShippingType object corresponding to the informed type 112 | */ 113 | public static function createByType($type) 114 | { 115 | $ShippingType = new PagSeguroShippingType(); 116 | $ShippingType->setByType($type); 117 | return $ShippingType; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /catalog/controller/payment/pagseguro_error.php: -------------------------------------------------------------------------------- 1 | getOrder 29 | * @var array 30 | */ 31 | private $_order_info; 32 | 33 | /** 34 | * The first method to be called by the error PagSeguro treatment. 35 | */ 36 | public function index() 37 | { 38 | 39 | $this->_load(); 40 | $this->_order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); 41 | $this->_updateOrderStatus(); 42 | $this->_redirect(); 43 | } 44 | 45 | private function _load() 46 | { 47 | 48 | PagSeguroConfig::activeLog($this->_getDirectoryLog()); 49 | $this->language->load('payment/pagseguro'); 50 | $this->load->model('checkout/order'); 51 | $this->load->model('setting/setting'); 52 | $this->load->model('payment/pagseguro'); 53 | $this->language->load('payment/pagseguro'); 54 | } 55 | 56 | /** 57 | * Update Order Status for Canceled if is payment aborted 58 | */ 59 | private function _updateOrderStatus() 60 | { 61 | 62 | $id_language = (int) $this->_order_info['language_id']; 63 | $code_language = $this->model_payment_pagseguro->getCodeLanguageById($id_language); 64 | $array_language = $this->model_payment_pagseguro->getOrderStatus(); 65 | $array_language = $array_language['7']; 66 | $canceled_payment = $array_language[$code_language]; 67 | 68 | $id_order_status = $this->model_payment_pagseguro->getOrderStatusByName($canceled_payment, $id_language); 69 | $this->model_payment_pagseguro->updateOrder($this->_order_info['order_id'], $id_order_status); 70 | } 71 | 72 | /** 73 | * Return directory log 74 | */ 75 | private function _getDirectoryLog() 76 | { 77 | 78 | $_dir = str_replace('catalog/', '', DIR_APPLICATION); 79 | return ($this->_isNotNull($this->config->get('pagseguro_directory')) == TRUE) ? $_dir . $this->config->get('pagseguro_directory') : null; 80 | } 81 | 82 | /** 83 | * Validate if value is not null 84 | * @param type $value 85 | * @return boolean 86 | */ 87 | private function _isNotNull($value) 88 | { 89 | 90 | if ($value != null && $value != "") 91 | return TRUE; 92 | 93 | return false; 94 | } 95 | 96 | /** 97 | * Redirect for home 98 | */ 99 | private function _redirect() 100 | { 101 | 102 | header('Location: ' . HTTP_SERVER . "index.php?route=common/home"); 103 | } 104 | } 105 | ?> -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/PagSeguroLibrary.class.php: -------------------------------------------------------------------------------- 1 | 'Bradesco debit', 32 | 'DEBITO_ITAU' => 'Itaú debit', 33 | 'DEBITO_UNIBANCO' => 'Unibanco debit', 34 | 'DEBITO_BANCO_BRASIL' => 'Banco do Brasil debit', 35 | 'DEBITO_BANRISUL' => 'Banrisul debit', 36 | 'DEBITO_HSBC' => 'HSBC bank debit', 37 | 'BOLETO' => 'Boleto', 38 | 'VISA' => 'Visa brand', 39 | 'MASTERCARD' => 'MasterCard brand', 40 | 'AMEX' => 'Amex brand', 41 | 'DINERS' => 'Diners brand', 42 | 'HIPERCARD' => 'Hipercard brand', 43 | 'AURA' => 'Aura brand', 44 | 'ELO' => 'ELO brand', 45 | 'PLENOCARD' => 'PlenoCard brand', 46 | 'PERSONALCARD' => 'PersonalCard brand', 47 | 'JCB' => 'JCB brand', 48 | 'DISCOVER' => 'Discover brand', 49 | 'BRASILCARD' => 'BrasilCard brand', 50 | 'FORTBRASIL' => 'FortBrasil brand', 51 | 'CARDBAN' => 'CardBAN brand', 52 | 'VALECARD' => 'ValeCard brand', 53 | 'CABAL' => 'Cabal brand', 54 | 'MAIS' => 'MAIS brand', 55 | 'AVISTA' => 'AVISTA brand', 56 | 'GRANDCARD' => 'GrandCard brand', 57 | 'SOROCRED' => 'Sorocred brand' 58 | ); 59 | 60 | 61 | /*** 62 | * Get available list for accepted payment methods 63 | * @return array 64 | */ 65 | public static function getAvailableKeysList() 66 | { 67 | return self::$availableNameList; 68 | } 69 | 70 | /*** 71 | * Check if a name is available for accepted payment methods. 72 | * @param string $name 73 | * @return boolean 74 | */ 75 | public static function isNameAvailable($name) 76 | { 77 | $key = strtoupper($name); 78 | return (isset(self::$availableNameList[$key])); 79 | } 80 | 81 | /*** 82 | * Gets description by name 83 | * @param string $name 84 | * @return string 85 | */ 86 | public static function getDescriptionByName($name) 87 | { 88 | $key = strtoupper($name); 89 | if (isset(self::$availableNameList[$key])) { 90 | return self::$availableNameList[$key]; 91 | } else { 92 | return false; 93 | } 94 | } 95 | 96 | /*** 97 | * Gets name key by description 98 | * @param string $description 99 | * @return string 100 | */ 101 | public static function getKeyByDescription($description) 102 | { 103 | return array_search(strtolower($description), array_map('strtolower', self::$availableNameList)); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroSearchResult.class.php: -------------------------------------------------------------------------------- 1 | currentPage; 56 | } 57 | 58 | /*** 59 | * Sets the current page number 60 | * @param integer $currentPage 61 | */ 62 | public function setCurrentPage($currentPage) 63 | { 64 | $this->currentPage = $currentPage; 65 | } 66 | 67 | /*** 68 | * @return the date/time when this search was executed 69 | */ 70 | public function getDate() 71 | { 72 | return $this->date; 73 | } 74 | 75 | /*** 76 | * Set the date/time when this search was executed 77 | * @param date 78 | */ 79 | public function setDate($date) 80 | { 81 | $this->date = $date; 82 | } 83 | 84 | /*** 85 | * @return the number of summaries in the current page 86 | */ 87 | public function getResultsInThisPage() 88 | { 89 | return $this->resultsInThisPage; 90 | } 91 | 92 | /*** 93 | * Sets the number of summaries in the current page 94 | * 95 | * @param resultsInThisPage 96 | */ 97 | public function setResultsInThisPage($resultsInThisPage) 98 | { 99 | $this->resultsInThisPage = $resultsInThisPage; 100 | } 101 | 102 | /*** 103 | * @return the total number of pages 104 | */ 105 | public function getTotalPages() 106 | { 107 | return $this->totalPages; 108 | } 109 | 110 | /*** 111 | * Sets the total number of pages 112 | * 113 | * @param totalPages 114 | */ 115 | public function setTotalPages($totalPages) 116 | { 117 | $this->totalPages = $totalPages; 118 | } 119 | 120 | /*** 121 | * @return String a string that represents the current object 122 | */ 123 | public function toString() 124 | { 125 | $result = array(); 126 | 127 | $result['Date'] = $this->date; 128 | $result['CurrentPage'] = $this->currentPage; 129 | $result['TotalPages'] = $this->totalPages; 130 | $result['Results in this page'] = $this->resultsInThisPage; 131 | 132 | return "PagSeguroSearchResult: " . var_export($result, true); 133 | 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroCreditCard.class.php: -------------------------------------------------------------------------------- 1 | setNumber($data['number']); 60 | } 61 | if (isset($data['cvv'])) { 62 | $this->setCvv($data['cvv']); 63 | } 64 | if (isset($data['expirationMonth'])) { 65 | $this->setExpirationMonth($data['expirationMonth']); 66 | } 67 | if (isset($data['expirationYear'])) { 68 | $this->setExpirationYear($data['expirationYear']); 69 | } 70 | } 71 | } 72 | 73 | /*** 74 | * Sets the card number 75 | * @param int $number 76 | */ 77 | public function setNumber($number) 78 | { 79 | $this->number = $number; 80 | } 81 | 82 | /*** 83 | * @return int the card number 84 | */ 85 | public function getNumber() 86 | { 87 | return $this->number; 88 | } 89 | 90 | /*** 91 | * Sets the card cvv 92 | * @param int $cvv 93 | */ 94 | public function setCvv($cvv) 95 | { 96 | $this->cvv = $cvv; 97 | } 98 | 99 | /*** 100 | * @return int the card cvv 101 | */ 102 | public function getCvv() 103 | { 104 | return $this->cvv; 105 | } 106 | 107 | /*** 108 | * Sets the card expirationMonth 109 | * @param int $expirationMonth 110 | */ 111 | public function setExpirationMonth($expirationMonth) 112 | { 113 | $this->expirationMonth = $expirationMonth; 114 | } 115 | 116 | /*** 117 | * @return int expirationMonth from credit card 118 | */ 119 | public function getExpirationMonth() 120 | { 121 | return $this->expirationMonth; 122 | } 123 | 124 | /*** 125 | * Sets the card expirationYear 126 | * @param int $expirationYear 127 | */ 128 | public function setExpirationYear($expirationYear) 129 | { 130 | $this->expirationYear = $expirationYear; 131 | } 132 | 133 | /*** 134 | * @return int expirationYear from credit card 135 | */ 136 | public function getExpirationYear() 137 | { 138 | return $this->expirationYear; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/exception/PagSeguroServiceException.class.php: -------------------------------------------------------------------------------- 1 | httpStatus = $httpStatus; 53 | if ($errors) { 54 | $this->errors = $errors; 55 | } 56 | //$this->httpMessage = $this->getFormattedMessage(); 57 | parent::__construct($this->getOneLineMessage()); 58 | } 59 | 60 | /*** 61 | * @return array 62 | */ 63 | public function getErrors() 64 | { 65 | return $this->errors; 66 | } 67 | 68 | /*** 69 | * @param array $errors 70 | */ 71 | public function setErrors(array $errors) 72 | { 73 | $this->errors = $errors; 74 | } 75 | 76 | /*** 77 | * @return PagSeguroHttpStatus 78 | */ 79 | public function getHttpStatus() 80 | { 81 | return $this->httpStatus; 82 | } 83 | 84 | /*** 85 | * @param PagSeguroHttpStatus $httpStatus 86 | */ 87 | public function setHttpStatus(PagSeguroHttpStatus $httpStatus) 88 | { 89 | $this->httpStatus = $httpStatus; 90 | } 91 | 92 | /*** 93 | * @return string 94 | */ 95 | private function getHttpMessage() 96 | { 97 | 98 | switch ($type = $this->httpStatus->getType()) { 99 | case 'BAD_REQUEST': 100 | case 'UNAUTHORIZED': 101 | case 'FORBIDDEN': 102 | case 'NOT_FOUND': 103 | case 'INTERNAL_SERVER_ERROR': 104 | case 'BAD_GATEWAY': 105 | $message = $type; 106 | break; 107 | default: 108 | $message = "UNDEFINED"; 109 | break; 110 | } 111 | return $message; 112 | } 113 | 114 | /*** 115 | * @return string 116 | */ 117 | public function getFormattedMessage() 118 | { 119 | $message = ""; 120 | $message .= "[HTTP " . $this->httpStatus->getStatus() . "] - " . $this->getHttpMessage() . "\n"; 121 | foreach ($this->errors as $key => $value) { 122 | if ($value instanceof PagSeguroError) { 123 | $message .= "$key [" . $value->getCode() . "] - " . $value->getMessage(); 124 | } 125 | } 126 | return $message; 127 | } 128 | 129 | /*** 130 | * @return mixed 131 | */ 132 | public function getOneLineMessage() 133 | { 134 | return str_replace("\n", " ", $this->getFormattedMessage()); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/service/PagSeguroSessionService.class.php: -------------------------------------------------------------------------------- 1 | getWebserviceUrl() . $connectionData->getSessionUrl(); 38 | } 39 | 40 | /*** 41 | * Get session for direct payment from webservice 42 | * @param $credentials PagSeguroAccountCredentials 43 | * @return bool|string 44 | * @throws Exception|PagSeguroServiceException 45 | * @throws Exception 46 | */ 47 | public static function getSession($credentials) 48 | { 49 | $connectionData = new PagSeguroConnectionData($credentials, 'sessionService'); 50 | 51 | $url = self::buildSessionURL($connectionData) . "?" . $connectionData->getCredentialsUrlQuery(); 52 | 53 | try { 54 | $connection = new PagSeguroHttpConnection(); 55 | $connection->post( 56 | $url, 57 | array(), 58 | $connectionData->getServiceTimeout(), 59 | $connectionData->getCharset() 60 | ); 61 | 62 | $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); 63 | 64 | switch ($httpStatus->getType()) { 65 | case 'OK': 66 | 67 | $session = PagSeguroSessionParser::readResult($connection->getResponse()); 68 | 69 | return $session->getId(); 70 | 71 | LogPagSeguro::info( 72 | "PagSeguroSessionService.getSession()(" . $session->toString() . ") - end {1}" 73 | ); 74 | break; 75 | case 'BAD_REQUEST': 76 | $errors = PagSeguroSessionParser::readErrors($connection->getStatus()); 77 | $e = new PagSeguroServiceException($httpStatus, $errors); 78 | LogPagSeguro::error( 79 | "PagSeguroSessionService.getSession() - error " . 80 | $e->getOneLineMessage() 81 | ); 82 | throw $e; 83 | break; 84 | default: 85 | 86 | $e = new PagSeguroServiceException($httpStatus); 87 | LogPagSeguro::error( 88 | "PagSeguroSessionService.getSession() - error " . 89 | $e->getOneLineMessage() 90 | ); 91 | throw $e; 92 | break; 93 | } 94 | } catch (PagSeguroServiceException $e) { 95 | throw $e; 96 | } catch (Exception $e) { 97 | LogPagSeguro::error("Exception: " . $e->getMessage()); 98 | throw $e; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroDirectPaymentInstallment.class.php: -------------------------------------------------------------------------------- 1 | setQuantity($data['quantity']); 51 | } 52 | if (isset($data['value'])) { 53 | $this->setValue($data['value']); 54 | } 55 | if (isset($data['noInterestInstallmentQuantity'])) { 56 | $this->setNoInterestInstallmentQuantity($data['noInterestInstallmentQuantity']); 57 | } 58 | } 59 | } 60 | 61 | /*** 62 | * Set installment quantity 63 | * @param $quantity int 64 | */ 65 | public function setQuantity($quantity) 66 | { 67 | $this->quantity = $quantity; 68 | } 69 | 70 | /*** 71 | * @return int installment quantity 72 | */ 73 | public function getQuantity() 74 | { 75 | return $this->quantity; 76 | } 77 | 78 | /*** 79 | * Set installment value 80 | * @param $value float 81 | */ 82 | public function setValue($value) 83 | { 84 | $this->value = $value; 85 | } 86 | 87 | /*** 88 | * @return float installment value 89 | */ 90 | public function getValue() 91 | { 92 | return $this->value; 93 | } 94 | 95 | /** 96 | * @return mixed 97 | */ 98 | public function getNoInterestInstallmentQuantity() 99 | { 100 | return $this->noInterestInstallmentQuantity; 101 | } 102 | 103 | /** 104 | * @param mixed $noInterestInstallmentQuantity 105 | */ 106 | public function setNoInterestInstallmentQuantity($noInterestInstallmentQuantity) 107 | { 108 | $this->noInterestInstallmentQuantity = $noInterestInstallmentQuantity; 109 | } 110 | 111 | /*** 112 | * Sets the installment value and quantity 113 | * @param $quantity int 114 | * @param $value float 115 | */ 116 | public function setInstallment($quantity, $value = null, $noInterestInstallmentQuantity = null) 117 | { 118 | $param = $quantity; 119 | if (isset($param) && is_array($param) || is_object($param)) { 120 | $this->setQuantity($param['quantity']); 121 | $this->setValue($param['value']); 122 | $this->setNoInterestInstallmentQuantity($param["noInterestInstallmentQuantity"]); 123 | } else { 124 | $this->setQuantity($quantity); 125 | $this->setValue($value); 126 | $this->setNoInterestInstallmentQuantity($noInterestInstallmentQuantity); 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroMetaDataItem.class.php: -------------------------------------------------------------------------------- 1 | setKey($key); 55 | } 56 | if (isset($value) && !PagSeguroHelper::isEmpty($value)) { 57 | $this->setValue($value); 58 | } 59 | if (isset($group) && !PagSeguroHelper::isEmpty($group)) { 60 | $this->setGroup($group); 61 | } 62 | } 63 | 64 | /*** 65 | * Gets the metadata item key 66 | * @return string 67 | */ 68 | public function getKey() 69 | { 70 | return $this->key; 71 | } 72 | 73 | /*** 74 | * Sets the metadata item key 75 | * 76 | * @param string $key 77 | */ 78 | public function setKey($key) 79 | { 80 | $this->key = $key; 81 | } 82 | 83 | /*** 84 | * Gets metadata item value 85 | * @return string 86 | */ 87 | public function getValue() 88 | { 89 | return $this->value; 90 | } 91 | 92 | /*** 93 | * Sets metadata item value 94 | * 95 | * @param string $value 96 | */ 97 | public function setValue($value) 98 | { 99 | $this->value = $this->normalizeParameter($value); 100 | } 101 | 102 | /*** 103 | * Gets metadata item group 104 | * 105 | * @return int 106 | */ 107 | public function getGroup() 108 | { 109 | return $this->group; 110 | } 111 | 112 | /*** 113 | * Sets metadata item group 114 | * 115 | * @param int $group 116 | */ 117 | public function setGroup($group) 118 | { 119 | $this->group = (int) $group; 120 | } 121 | 122 | /*** 123 | * Normalize metadata item value 124 | * @param string $parameterValue 125 | * @return string 126 | */ 127 | private function normalizeParameter($parameterValue) 128 | { 129 | 130 | $parameterValue = PagSeguroHelper::formatString($parameterValue, 100, ''); 131 | 132 | switch ($this->getKey()) { 133 | case PagSeguroMetaDataItemKeys::getItemKeyByDescription('CPF do passageiro'): 134 | $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); 135 | break; 136 | case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Tempo no jogo em dias'): 137 | $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); 138 | break; 139 | case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Celular de recarga'): 140 | break; 141 | default: 142 | break; 143 | } 144 | return $parameterValue; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/service/PagSeguroCancelService.class.php: -------------------------------------------------------------------------------- 1 | getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() 43 | . "&transactionCode=" . $transactionCode; 44 | } 45 | 46 | /** 47 | * @param PagSeguroCredentials $credentials 48 | * @param $transactionCode 49 | * @throws Exception 50 | * @throws PagSeguroServiceException 51 | */ 52 | public static function requestCancel( 53 | PagSeguroCredentials $credentials, 54 | $transactionCode 55 | ) { 56 | 57 | LogPagSeguro::info("PagSeguroCancelService.Register(".$transactionCode.") - begin"); 58 | $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); 59 | 60 | try { 61 | $connection = new PagSeguroHttpConnection(); 62 | $connection->post( 63 | self::buildCancelURL($connectionData, $transactionCode), 64 | array(), 65 | $connectionData->getServiceTimeout(), 66 | $connectionData->getCharset() 67 | ); 68 | 69 | return self::getResult($connection); 70 | 71 | } catch (PagSeguroServiceException $err) { 72 | throw $err; 73 | } catch (Exception $err) { 74 | LogPagSeguro::error("Exception: " . $err->getMessage()); 75 | throw $err; 76 | } 77 | } 78 | 79 | /** 80 | * @param $connection 81 | * @return null|PagSeguroParserData 82 | * @throws PagSeguroServiceException 83 | */ 84 | private function getResult($connection) 85 | { 86 | $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); 87 | 88 | switch ($httpStatus->getType()) { 89 | case 'OK': 90 | 91 | $cancel = PagSeguroCancelParser::readSuccessXml($connection->getResponse()); 92 | LogPagSeguro::info( 93 | "PagSeguroCancelService.createRequest(".$cancel.") - end " 94 | ); 95 | break; 96 | case 'BAD_REQUEST': 97 | $errors = PagSeguroCancelParser::readErrors($connection->getResponse()); 98 | $err = new PagSeguroServiceException($httpStatus, $errors); 99 | LogPagSeguro::error( 100 | "PagSeguroCancelService.createRequest() - error " . 101 | $err->getOneLineMessage() 102 | ); 103 | throw $err; 104 | break; 105 | default: 106 | $err = new PagSeguroServiceException($httpStatus); 107 | LogPagSeguro::error( 108 | "PagSeguroCancelService.createRequest() - error " . 109 | $err->getOneLineMessage() 110 | ); 111 | throw $err; 112 | break; 113 | } 114 | return isset($cancel) ? $cancel : false; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/service/PagSeguroRefundService.class.php: -------------------------------------------------------------------------------- 1 | getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() 36 | . "&transactionCode=" . $transactionCode; 37 | } else { 38 | return $connectionData->getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() 39 | . "&transactionCode=" . $transactionCode . "&refundValue=" . $refundValue; 40 | } 41 | } 42 | 43 | public static function createRefundRequest( 44 | PagSeguroCredentials $credentials, 45 | $transactionCode, 46 | $refundValue = null 47 | ) { 48 | 49 | LogPagSeguro::info("PagSeguroRefundService.Register(".$transactionCode.") - begin"); 50 | $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); 51 | 52 | if (is_null($refundValue)) { 53 | $url = self::buildRefundURL($connectionData, $transactionCode); 54 | } else { 55 | $url = self::buildRefundURL($connectionData, $transactionCode, $refundValue); 56 | } 57 | 58 | try { 59 | $connection = new PagSeguroHttpConnection(); 60 | $connection->post( 61 | $url, 62 | array(), 63 | $connectionData->getServiceTimeout(), 64 | $connectionData->getCharset() 65 | ); 66 | 67 | $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); 68 | 69 | switch ($httpStatus->getType()) { 70 | case 'OK': 71 | 72 | $result = PagSeguroRefundParser::readSuccessXml($connection->getResponse()); 73 | LogPagSeguro::info( 74 | "PagSeguroRefundService.createRefundRequest(".$result.") - end " 75 | ); 76 | break; 77 | case 'BAD_REQUEST': 78 | $errors = PagSeguroRefundParser::readErrors($connection->getResponse()); 79 | $err = new PagSeguroServiceException($httpStatus, $errors); 80 | LogPagSeguro::error( 81 | "PagSeguroRefundService.createRefundRequest() - error " . 82 | $err->getOneLineMessage() 83 | ); 84 | throw $err; 85 | break; 86 | default: 87 | $err = new PagSeguroServiceException($httpStatus); 88 | LogPagSeguro::error( 89 | "PagSeguroRefundService.createRefundRequest() - error " . 90 | $err->getOneLineMessage() 91 | ); 92 | throw $err; 93 | break; 94 | } 95 | return isset($result) ? $result : false; 96 | 97 | } catch (PagSeguroServiceException $err) { 98 | throw $err; 99 | } catch (Exception $err) { 100 | LogPagSeguro::error("Exception: " . $err->getMessage()); 101 | throw $err; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/utils/PagSeguroXmlParser.class.php: -------------------------------------------------------------------------------- 1 | dom = new DOMDocument(); 40 | $this->dom->loadXml($xml); 41 | } 42 | } 43 | 44 | public function getResult($node = null) 45 | { 46 | $result = $this->toArray($this->dom); 47 | if ($node) { 48 | if (isset($result[$node])) { 49 | return $result[$node]; 50 | } else { 51 | throw new Exception("PagSeguroLibrary XML parsing error: undefined index [$node]"); 52 | } 53 | } else { 54 | return $result; 55 | } 56 | } 57 | 58 | private function toArray($node) 59 | { 60 | $occurrence = array(); 61 | $result = null; 62 | /*** @var $node DOMNode */ 63 | if ($node->hasChildNodes()) { 64 | foreach ($node->childNodes as $child) { 65 | if (!isset($occurrence[$child->nodeName])) { 66 | $occurrence[$child->nodeName] = null; 67 | } 68 | $occurrence[$child->nodeName]++; 69 | } 70 | } 71 | if (isset($child)) { 72 | if ($child->nodeName == '#text') { 73 | $result = html_entity_decode( 74 | htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), 75 | ENT_COMPAT, 76 | 'ISO-8859-15' 77 | ); 78 | } else { 79 | if ($node->hasChildNodes()) { 80 | $children = $node->childNodes; 81 | for ($i = 0; $i < $children->length; $i++) { 82 | $child = $children->item($i); 83 | if ($child->nodeName != '#text') { 84 | if ($occurrence[$child->nodeName] > 1) { 85 | $result[$child->nodeName][] = $this->toArray($child); 86 | } else { 87 | $result[$child->nodeName] = $this->toArray($child); 88 | } 89 | } else { 90 | if ($child->nodeName == '0') { 91 | $text = $this->toArray($child); 92 | if (trim($text) != '') { 93 | $result[$child->nodeName] = $this->toArray($child); 94 | } 95 | } 96 | } 97 | } 98 | } 99 | if ($node->hasAttributes()) { 100 | $attributes = $node->attributes; 101 | if (!is_null($attributes)) { 102 | foreach ($attributes as $key => $attr) { 103 | $result["@" . $attr->name] = $attr->value; 104 | } 105 | } 106 | } 107 | } 108 | return $result; 109 | } else { 110 | return null; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroApplicationCredentials.class.php: -------------------------------------------------------------------------------- 1 | setAppId($appId); 59 | $this->setAppKey($appKey); 60 | } else { 61 | throw new Exception("Authorization credentials not set."); 62 | } 63 | 64 | if ($authorizationCode !== null) { 65 | $this->setAuthorizationCode($authorizationCode); 66 | } 67 | 68 | } 69 | 70 | /*** 71 | * @return string the appID from this authorization credentials 72 | */ 73 | public function getAppId() 74 | { 75 | return $this->appId; 76 | } 77 | 78 | /*** 79 | * Sets the app ID from this authorization credentials 80 | * @param string $appId 81 | */ 82 | public function setAppId($appId) 83 | { 84 | $this->appId = $appId; 85 | } 86 | 87 | /*** 88 | * @return string the appKey from this authorization credentials 89 | */ 90 | public function getAppKey() 91 | { 92 | return $this->appKey; 93 | } 94 | 95 | /*** 96 | * Sets the app ID from this authorization credentials 97 | * @param string $appKey 98 | */ 99 | public function setAppKey($appKey) 100 | { 101 | $this->appKey = $appKey; 102 | } 103 | 104 | /*** 105 | * @return string the appKey from this authorization credentials 106 | */ 107 | public function getAuthorizationCode() 108 | { 109 | return $this->authorizationCode; 110 | } 111 | 112 | /*** 113 | * Sets the app ID from this authorization credentials 114 | * @param string $authorizationCode 115 | */ 116 | public function setAuthorizationCode($authorizationCode) 117 | { 118 | $this->authorizationCode = $authorizationCode; 119 | } 120 | 121 | /*** 122 | * @return array a map of name value pairs that compose this set of credentials 123 | */ 124 | public function getAttributesMap() 125 | { 126 | return array( 127 | 'appId' => $this->appId, 128 | 'appKey' => $this->appKey, 129 | 'authorizationCode' => $this->authorizationCode 130 | ); 131 | } 132 | 133 | /*** 134 | * @return string a string that represents the current object 135 | */ 136 | public function toString() 137 | { 138 | $credentials = array(); 139 | $credentials['AppID'] = $this->appId; 140 | $credentials['AppKey'] = $this->appKey; 141 | $credentials['AuthorizationCode'] = $this->appKey; 142 | return implode(' - ', $credentials); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroAuthorizationSearchResult.class.php: -------------------------------------------------------------------------------- 1 | currentPage; 61 | } 62 | 63 | /*** 64 | * Sets the current page number 65 | * @param integer $currentPage 66 | */ 67 | public function setCurrentPage($currentPage) 68 | { 69 | $this->currentPage = $currentPage; 70 | } 71 | 72 | /*** 73 | * @return the date/time when this search was executed 74 | */ 75 | public function getDate() 76 | { 77 | return $this->date; 78 | } 79 | 80 | /*** 81 | * Set the date/time when this search was executed 82 | * @param date 83 | */ 84 | public function setDate($date) 85 | { 86 | $this->date = $date; 87 | } 88 | 89 | /*** 90 | * @return the number of authorizations summaries in the current page 91 | */ 92 | public function getResultsInThisPage() 93 | { 94 | return $this->resultsInThisPage; 95 | } 96 | 97 | /*** 98 | * Sets the number of authorizations summaries in the current page 99 | * 100 | * @param resultsInThisPage 101 | */ 102 | public function setResultsInThisPage($resultsInThisPage) 103 | { 104 | $this->resultsInThisPage = $resultsInThisPage; 105 | } 106 | 107 | /*** 108 | * @return the total number of pages 109 | */ 110 | public function getTotalPages() 111 | { 112 | return $this->totalPages; 113 | } 114 | 115 | /*** 116 | * Sets the total number of pages 117 | * 118 | * @param totalPages 119 | */ 120 | public function setTotalPages($totalPages) 121 | { 122 | $this->totalPages = $totalPages; 123 | } 124 | 125 | /*** 126 | * @return PagSeguroAuthorizations the authorizations summaries in this page 127 | * @see PagSeguroAuthorizations 128 | */ 129 | public function getAuthorizations() 130 | { 131 | return $this->authorizations; 132 | } 133 | 134 | /*** 135 | * Sets the authorizations summaries in this page 136 | * @param PagSeguroAuthorization $authorizations 137 | */ 138 | public function setAuthorizations($authorizations) 139 | { 140 | $this->authorizations = $authorizations; 141 | } 142 | 143 | /*** 144 | * @return String a string that represents the current object 145 | */ 146 | public function toString() 147 | { 148 | $authorizations = array(); 149 | 150 | $authorizations['Date'] = $this->date; 151 | $authorizations['CurrentPage'] = $this->currentPage; 152 | $authorizations['TotalPages'] = $this->totalPages; 153 | $authorizations['Transactions in this page'] = $this->resultsInThisPage; 154 | 155 | return "PagSeguroAuthorizationsSearchResult: " . implode(' - ', $authorizations); 156 | 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/utils/PagSeguroHttpConnection.class.php: -------------------------------------------------------------------------------- 1 | status; 43 | } 44 | 45 | public function setStatus($status) 46 | { 47 | $this->status = $status; 48 | } 49 | 50 | public function getResponse() 51 | { 52 | return $this->response; 53 | } 54 | 55 | public function setResponse($response) 56 | { 57 | $this->response = $response; 58 | } 59 | 60 | public function post($url, array $data = array(), $timeout = 20, $charset = 'ISO-8859-1') 61 | { 62 | return $this->curlConnection('POST', $url, $timeout, $charset, $data); 63 | } 64 | 65 | public function get($url, $timeout = 20, $charset = 'ISO-8859-1') 66 | { 67 | return $this->curlConnection('GET', $url, $timeout, $charset, null); 68 | } 69 | 70 | private function curlConnection($method, $url, $timeout, $charset, array $data = null) 71 | { 72 | 73 | if (strtoupper($method) === 'POST') { 74 | $postFields = ($data ? http_build_query($data, '', '&') : ""); 75 | $contentLength = "Content-length: " . strlen($postFields); 76 | $methodOptions = array( 77 | CURLOPT_POST => true, 78 | CURLOPT_POSTFIELDS => $postFields, 79 | ); 80 | } else { 81 | $contentLength = null; 82 | $methodOptions = array( 83 | CURLOPT_HTTPGET => true 84 | ); 85 | } 86 | 87 | 88 | $options = array( 89 | CURLOPT_HTTPHEADER => array( 90 | "Content-Type: application/x-www-form-urlencoded; charset=" . $charset, 91 | $contentLength, 92 | 'lib-description: php:' . PagSeguroLibrary::getVersion(), 93 | 'language-engine-description: php:' . PagSeguroLibrary::getPHPVersion() 94 | ), 95 | CURLOPT_URL => $url, 96 | CURLOPT_RETURNTRANSFER => true, 97 | CURLOPT_HEADER => false, 98 | CURLOPT_SSL_VERIFYPEER => false, 99 | CURLOPT_CONNECTTIMEOUT => $timeout, 100 | //CURLOPT_TIMEOUT => $timeout 101 | ); 102 | 103 | if (!is_null(PagSeguroLibrary::getModuleVersion())) { 104 | array_push($options[CURLOPT_HTTPHEADER], 'module-description: ' . PagSeguroLibrary::getModuleVersion()); 105 | } 106 | 107 | if (!is_null(PagSeguroLibrary::getCMSVersion())) { 108 | array_push($options[CURLOPT_HTTPHEADER], 'cms-description: ' . PagSeguroLibrary::getCMSVersion()); 109 | } 110 | 111 | $options = ($options + $methodOptions); 112 | 113 | $curl = curl_init(); 114 | curl_setopt_array($curl, $options); 115 | $resp = curl_exec($curl); 116 | $info = curl_getinfo($curl); 117 | $error = curl_errno($curl); 118 | $errorMessage = curl_error($curl); 119 | curl_close($curl); 120 | 121 | $this->setStatus((int) $info['http_code']); 122 | $this->setResponse((String) $resp); 123 | 124 | if ($error) { 125 | throw new Exception("CURL can't connect: $errorMessage"); 126 | } else { 127 | return true; 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroCreditCardCheckout.class.php: -------------------------------------------------------------------------------- 1 | setBrand($data['brand']); 67 | } 68 | if (isset($data['token'])) { 69 | $this->setToken($data['token']); 70 | } 71 | if (isset($data['holder'])) { 72 | $this->setHolder($data['holder']); 73 | } 74 | if (isset($data['installment'])) { 75 | $this->setInstallment($data['installment']); 76 | } 77 | if (isset($data['billing'])) { 78 | $this->setBilling($data['billing']); 79 | } 80 | } 81 | } 82 | 83 | /*** 84 | * Sets the credit card brand 85 | * @param string $brand 86 | */ 87 | public function setBrand($brand) 88 | { 89 | $this->brand = $brand; 90 | } 91 | 92 | /*** 93 | * @return string the credit card brand 94 | */ 95 | public function getBrand() 96 | { 97 | return $this->brand; 98 | } 99 | 100 | /*** 101 | * Sets the credit card token 102 | * @param mixed $token 103 | */ 104 | public function setToken($token) 105 | { 106 | $this->token = $token; 107 | } 108 | 109 | /*** 110 | * @return mixed the credit card token 111 | */ 112 | public function getToken() 113 | { 114 | return $this->token; 115 | } 116 | 117 | /*** 118 | * Sets the PagSeguroCreditCardHolder 119 | * @param intanceof PagSeguroCreditCardHolder $holder 120 | */ 121 | public function setHolder($holder) 122 | { 123 | $this->holder = $holder; 124 | } 125 | 126 | /*** 127 | * @return PagSeguroCreditCardHolder object 128 | * @see PagSeguroCreditCardHolder 129 | */ 130 | public function getHolder() 131 | { 132 | return $this->holder; 133 | } 134 | 135 | /*** 136 | * Sets the PagSeguroInstallment 137 | * @param intanceof PagSeguroInstallment $installment 138 | */ 139 | public function setInstallment($installment) 140 | { 141 | $this->installment = $installment; 142 | } 143 | 144 | /*** 145 | * @return PagSeguroInstallment object 146 | * @see PagSeguroInstallment 147 | */ 148 | public function getInstallment() 149 | { 150 | return $this->installment; 151 | } 152 | 153 | /*** 154 | * Sets the PagSeguroBilling 155 | * @param intanceof PagSeguroBilling $billing 156 | */ 157 | public function setBilling($billing) 158 | { 159 | $this->billing = $billing; 160 | } 161 | 162 | /*** 163 | * @return PagSeguroBilling object 164 | * @see PagSeguroBilling 165 | */ 166 | public function getBilling() 167 | { 168 | return $this->billing; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroPreApprovalCharge.class.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2007-2014 PagSeguro Internet Ltda. 21 | * @license http://www.apache.org/licenses/LICENSE-2.0 22 | */ 23 | 24 | /*** 25 | * Represents a preApproval request 26 | */ 27 | class PagSeguroPreApprovalCharge 28 | { 29 | 30 | /*** 31 | * Products/items in this pre approval charge 32 | */ 33 | private $items; 34 | /** 35 | * @var 36 | */ 37 | private $reference; 38 | /** 39 | * @var 40 | */ 41 | private $preApprovalCode; 42 | 43 | /*** 44 | * @return array the items/products list in this payment request 45 | */ 46 | public function getItems() 47 | { 48 | return $this->items; 49 | } 50 | 51 | /*** 52 | * Sets the items/products list in this payment request 53 | * @param array $items 54 | */ 55 | public function setItems(array $items) 56 | { 57 | if (is_array($items)) { 58 | $i = array(); 59 | foreach ($items as $key => $item) { 60 | if ($item instanceof PagSeguroItem) { 61 | $i[$key] = $item; 62 | } else { 63 | if (is_array($item)) { 64 | $i[$key] = new PagSeguroItem($item); 65 | } 66 | } 67 | } 68 | $this->items = $i; 69 | } 70 | } 71 | 72 | /*** 73 | * Adds a new product/item in this payment request 74 | * 75 | * @param String $id 76 | * @param String $description 77 | * @param String $quantity 78 | * @param String $amount 79 | */ 80 | public function addItem( 81 | $id, 82 | $description = null, 83 | $quantity = null, 84 | $amount = null 85 | ) { 86 | $param = $id; 87 | if ($this->items == null) { 88 | $this->items = array(); 89 | } 90 | if (is_array($param)) { 91 | array_push($this->items, new PagSeguroItem($param)); 92 | } else { 93 | if ($param instanceof PagSeguroItem) { 94 | array_push($this->items, $param); 95 | } else { 96 | $item = new PagSeguroItem(); 97 | $item->setId($param); 98 | $item->setDescription($description); 99 | $item->setQuantity($quantity); 100 | $item->setAmount($amount); 101 | array_push($this->items, $item); 102 | } 103 | } 104 | } 105 | 106 | /** 107 | * @return mixed 108 | */ 109 | public function getReference() 110 | { 111 | return $this->reference; 112 | } 113 | 114 | /** 115 | * @param mixed $reference 116 | */ 117 | public function setReference($reference) 118 | { 119 | $this->reference = $reference; 120 | } 121 | 122 | /** 123 | * @return mixed 124 | */ 125 | public function getPreApprovalCode() 126 | { 127 | return $this->preApprovalCode; 128 | } 129 | 130 | /** 131 | * @param mixed $preApprovalCode 132 | */ 133 | public function setPreApprovalCode($preApprovalCode) 134 | { 135 | $this->preApprovalCode = $preApprovalCode; 136 | } 137 | 138 | /** 139 | * @param PagSeguroCredentials $credentials 140 | * @return array|null|PagSeguroParserData 141 | */ 142 | public function register(PagSeguroCredentials $credentials) 143 | { 144 | return PagSeguroPreApprovalService::paymentCharge($credentials, $this); 145 | } 146 | 147 | /*** 148 | * @return String a string that represents the current object 149 | */ 150 | public function toString() 151 | { 152 | 153 | $request = array(); 154 | $request['Reference'] = $this->reference; 155 | $request['PagSeguroPreApprovalCode'] = $this->preApprovalCode; 156 | 157 | return "PagSeguroPaymentCharge: " . var_export($request, true); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /catalog/controller/payment/PagSeguroLibrary/domain/PagSeguroItem.class.php: -------------------------------------------------------------------------------- 1 | setId($data['id']); 70 | } 71 | if (isset($data['description'])) { 72 | $this->setDescription($data['description']); 73 | } 74 | if (isset($data['quantity'])) { 75 | $this->setQuantity($data['quantity']); 76 | } 77 | if (isset($data['amount'])) { 78 | $this->setAmount($data['amount']); 79 | } 80 | if (isset($data['weight'])) { 81 | $this->setWeight($data['weight']); 82 | } 83 | if (isset($data['shippingCost'])) { 84 | $this->setShippingCost($data['shippingCost']); 85 | } 86 | } 87 | } 88 | 89 | /*** 90 | * @return integer the product identifier 91 | */ 92 | public function getId() 93 | { 94 | return $this->id; 95 | } 96 | 97 | /*** 98 | * Sets the product identifier 99 | * @param String $id 100 | */ 101 | public function setId($id) 102 | { 103 | $this->id = $id; 104 | } 105 | 106 | /*** 107 | * @return String the product description 108 | */ 109 | public function getDescription() 110 | { 111 | return $this->description; 112 | } 113 | 114 | /*** 115 | * Sets the product description 116 | * @param String $description 117 | */ 118 | public function setDescription($description) 119 | { 120 | $this->description = PagSeguroHelper::formatString($description, 255); 121 | } 122 | 123 | /*** 124 | * @return integer the quantity 125 | */ 126 | public function getQuantity() 127 | { 128 | return $this->quantity; 129 | } 130 | 131 | /*** 132 | * Sets the quantity 133 | * @param String $quantity 134 | */ 135 | public function setQuantity($quantity) 136 | { 137 | $this->quantity = $quantity; 138 | } 139 | 140 | /*** 141 | * @return the unit amount for this item 142 | */ 143 | public function getAmount() 144 | { 145 | return $this->amount; 146 | } 147 | 148 | /*** 149 | * sets the unit amount fot this item 150 | * @param String $amount 151 | */ 152 | public function setAmount($amount) 153 | { 154 | $this->amount = $amount; 155 | } 156 | 157 | /*** 158 | * @return float the weight 159 | */ 160 | public function getWeight() 161 | { 162 | return $this->weight; 163 | } 164 | 165 | /*** 166 | * Sets the single unit weight 167 | * @param String $weight 168 | */ 169 | public function setWeight($weight) 170 | { 171 | $this->weight = $weight; 172 | } 173 | 174 | /*** 175 | * @return float the unit shipping cost for this item 176 | */ 177 | public function getShippingCost() 178 | { 179 | return $this->shippingCost; 180 | } 181 | 182 | /*** 183 | * Sets the unit shipping cost for this item 184 | * @param String $shippingCost 185 | */ 186 | public function setShippingCost($shippingCost) 187 | { 188 | $this->shippingCost = $shippingCost; 189 | } 190 | } 191 | --------------------------------------------------------------------------------