|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
HCSF - A multilingual CMS and Shopsystem |
|
5
|
|
|
Copyright (C) 2014 Marcus Haase - [email protected] |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU General Public License |
|
18
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace HaaseIT\HCSF\Controller\Shop; |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
use Zend\ServiceManager\ServiceManager; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class Paypal |
|
28
|
|
|
* @package HaaseIT\HCSF\Controller\Shop |
|
29
|
|
|
*/ |
|
30
|
|
|
class Paypal extends Base |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var \HaaseIT\Toolbox\Textcat |
|
34
|
|
|
*/ |
|
35
|
|
|
private $textcats; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Paypal constructor. |
|
39
|
|
|
* @param ServiceManager $serviceManager |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(ServiceManager $serviceManager) |
|
42
|
|
|
{ |
|
43
|
|
|
parent::__construct($serviceManager); |
|
44
|
|
|
$this->textcats = $serviceManager->get('textcats'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* |
|
49
|
|
|
*/ |
|
50
|
|
|
public function preparePage() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager); |
|
53
|
|
|
$this->P->cb_pagetype = 'content'; |
|
54
|
|
|
|
|
55
|
|
|
$iId = \filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT); |
|
56
|
|
|
$sql = 'SELECT * FROM orders '; |
|
57
|
|
|
$sql .= "WHERE o_id = :id AND o_paymentmethod = 'paypal' AND o_paymentcompleted = 'n'"; |
|
58
|
|
|
|
|
59
|
|
|
/** @var \PDOStatement $hResult */ |
|
60
|
|
|
$hResult = $this->serviceManager->get('db')->prepare($sql); |
|
61
|
|
|
$hResult->bindValue(':id', $iId, \PDO::PARAM_INT); |
|
62
|
|
|
|
|
63
|
|
|
$hResult->execute(); |
|
64
|
|
|
|
|
65
|
|
|
if ($hResult->rowCount() == 1) { |
|
66
|
|
|
$aOrder = $hResult->fetch(); |
|
67
|
|
|
$fGesamtbrutto = $this->helperShop->calculateTotalFromDB($aOrder); |
|
68
|
|
|
|
|
69
|
|
|
$sPaypalURL = $this->config->getShop('paypal')['url'] |
|
70
|
|
|
.'?cmd=_xclick&rm=2&custom=' |
|
71
|
|
|
.$iId.'&business='.$this->config->getShop('paypal')['business']; |
|
72
|
|
|
$sPaypalURL .= '¬ify_url=http://'.filter_input(INPUT_SERVER, 'SERVER_NAME').'/_misc/paypal_notify.html&item_name='.$this->textcats->T('misc_paypaypal_paypaltitle').' '.$iId; |
|
73
|
|
|
$sPaypalURL .= '¤cy_code='.$this->config->getShop('paypal')['currency_id'] |
|
74
|
|
|
.'&amount='.str_replace(',', '.', number_format($fGesamtbrutto, 2, '.', '')); |
|
75
|
|
|
if ($this->config->getShop('interactive_paymentmethods_redirect_immediately')) { |
|
76
|
|
|
$this->helper->redirectToPage($sPaypalURL); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$this->P->oPayload->cl_html = $this->textcats->T('misc_paypaypal_greeting').'<br><br>'; |
|
80
|
|
|
$this->P->oPayload->cl_html .= '<a href="'.$sPaypalURL.'">'.$this->textcats->T('misc_paypaypal').'</a>'; |
|
81
|
|
|
} else { |
|
82
|
|
|
$this->P->oPayload->cl_html = $this->textcats->T('misc_paypaypal_paymentnotavailable'); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|