├── 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 |
-------------------------------------------------------------------------------- /.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 |(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 |
';
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 |
';
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 |
--------------------------------------------------------------------------------