| 3 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* @package php_share
|
|
|
5 |
* @author Lars Tiefland <tiefland@weban.de>
|
|
|
6 |
* @copyright 2010 Webagentur Niewerth
|
|
|
7 |
* @license propietary http://www.weban.de
|
|
|
8 |
* @version $Rev: 643 $
|
|
|
9 |
* @filesource
|
|
|
10 |
*
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
*
|
|
|
15 |
* @package php_share
|
|
|
16 |
* @author Lars Tiefland <tiefland@weban.de>
|
|
|
17 |
* @copyright 2010 Webagentur Niewerth
|
|
|
18 |
*/
|
|
|
19 |
|
|
|
20 |
// SVN: $Id: ideal.php 643 2011-08-29 08:27:14Z tiefland $
|
|
|
21 |
|
|
|
22 |
require_once "creditcard.interface.php";
|
|
|
23 |
|
|
|
24 |
class ideal implements creditcard
|
|
|
25 |
{
|
|
|
26 |
protected $ini;
|
|
|
27 |
|
|
|
28 |
function __construct()
|
|
|
29 |
{
|
|
|
30 |
if ( !is_array( $_SESSION["INI"] ) )
|
|
|
31 |
{
|
|
|
32 |
$this->ini = $GLOBALS["INI"];
|
|
|
33 |
}
|
|
|
34 |
else
|
|
|
35 |
{
|
|
|
36 |
$this->ini = $_SESSION["INI"];
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
function getCreditcardStatus( $bestellId )
|
|
|
40 |
{
|
|
|
41 |
$sha_arr = array();
|
|
|
42 |
$sha = "";
|
|
|
43 |
define( "ZUGANG", $this->ini["ideal"]["zugang"] );
|
|
|
44 |
define( "SECRET", $this->ini["ideal"]["secret"] );
|
|
|
45 |
$srv = "ideal";
|
|
|
46 |
if ( $this->ini["ideal"]["test"] == 1 )
|
|
|
47 |
{
|
|
|
48 |
$srv = "idealtest";
|
|
|
49 |
}
|
|
|
50 |
$srv .= '.rabobank.nl';
|
|
|
51 |
$url = 'https://' . $srv . '/ideal/mpiPayInitRabo.do';
|
|
|
52 |
$title = "Bestelling : " . $bestellId;
|
|
|
53 |
$title = htmlentities( $title );
|
|
|
54 |
$name = $_SESSION["SHOP"]["buy"]["Persdata"]["Vorname"] . " " .
|
|
|
55 |
$_SESSION["SHOP"]["buy"]["Persdata"]["Nachname"];
|
|
|
56 |
$b_url = $this->ini["absoluteURL"];
|
|
|
57 |
$b_url_s = ( $this->ini["ssl_buy"] ) ? str_replace( "http://",
|
|
|
58 |
"https://", $b_url ) : $b_url;
|
|
|
59 |
$cancelurl = $b_url_s . "/cancel_" . $bestellId . "_ideal.html";
|
|
|
60 |
$accepturl = $b_url_s . "/accept_" . $bestellId . "_ideal.html";
|
|
|
61 |
$exceptionurl = $b_url_s . "/except_" . $bestellId .
|
|
|
62 |
"_ideal.html";
|
|
|
63 |
$email = $_SESSION["SHOP"]["buy"]["Persdata"]["email"];
|
|
|
64 |
$summe = round( getBasketSumme(), 2 ) * 100;
|
|
|
65 |
if ( $_SESSION["brutto"] == true && $this->ini["netto_preise"] ==
|
|
|
66 |
1 )
|
|
|
67 |
{
|
|
|
68 |
$summe = round( getBasketSummeBrutto(), 2 ) * 100;
|
|
|
69 |
}
|
|
|
70 |
$until = date( "Y-m-d\TH:i:s\Z", strtotime( "+10 minutes" ) );
|
|
|
71 |
$sha_arr[] = SECRET;
|
|
|
72 |
$sha_arr[] = ZUGANG;
|
|
|
73 |
$sha_arr[] = 0;
|
|
|
74 |
$sha_arr[] = $summe;
|
|
|
75 |
$sha_arr[] = $bestellId;
|
|
|
76 |
$sha_arr[] = "ideal";
|
|
|
77 |
$sha_arr[] = $until;
|
|
|
78 |
$sha_arr[] = 1;
|
|
|
79 |
$sha_arr[] = $title;
|
|
|
80 |
$sha_arr[] = 1;
|
|
|
81 |
$sha_arr[] = $summe;
|
|
|
82 |
//SHA-String bauen
|
|
|
83 |
$sha = implode( "", $sha_arr );
|
|
|
84 |
$clean_shaString = HTML_entity_decode( $sha );
|
|
|
85 |
$not_allowed = array( "\t", "\n", "\r", " " );
|
|
|
86 |
$clean_shaString = str_replace( $not_allowed, "", $clean_shaString );
|
|
|
87 |
$shaSign = $this->genCheckSum( $clean_shaString );
|
|
|
88 |
$erg = '
|
|
|
89 |
<form method="post" action="' . $url .
|
|
|
90 |
'" id="zahlung" name="ideal">
|
|
|
91 |
<input type="hidden" name="merchantID" value="' . ZUGANG .
|
|
|
92 |
'">
|
|
|
93 |
<input type="hidden" name="subID" value="0">
|
|
|
94 |
<input type="hidden" name="amount" value="' . $summe .
|
|
|
95 |
'" >
|
|
|
96 |
<input type="hidden" name="purchaseID" value="' . $bestellId .
|
|
|
97 |
'">
|
|
|
98 |
<input type="hidden" name="language" value="nl">
|
|
|
99 |
<input type="hidden" name="currency" value="EUR">
|
|
|
100 |
<input type="hidden" name="description" value="' . $title .
|
|
|
101 |
'">
|
|
|
102 |
<input type="hidden" name="hash" value="' . $shaSign .
|
|
|
103 |
'">
|
|
|
104 |
<input type="hidden" name="paymentType" value="ideal">
|
|
|
105 |
<input type="hidden" name="validUntil" value="' . $until .
|
|
|
106 |
'">
|
|
|
107 |
<input type="hidden" name="itemNumber1" value="1">
|
|
|
108 |
<input type="hidden" name="itemDescription1" value="' .
|
|
|
109 |
$title . '">
|
|
|
110 |
<input type="hidden" name="itemQuantity1" value="1">
|
|
|
111 |
<input type="hidden" name="itemPrice1" value="' . $summe .
|
|
|
112 |
'">
|
|
|
113 |
<input type="hidden" name="urlCancel" value="' . $cancelurl .
|
|
|
114 |
'">
|
|
|
115 |
<input type="hidden" name="urlSuccess" value="' . $accepturl .
|
|
|
116 |
'">
|
|
|
117 |
<input type="hidden" name="urlError" value="' . $exceptionurl .
|
|
|
118 |
'">
|
|
|
119 |
<input type="submit" value="Bevestig bestelling" id=submit2 name=submit2>
|
|
|
120 |
</form>
|
|
|
121 |
';
|
|
|
122 |
return $erg;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
function getCreditcardReturnStatus( $bestellId )
|
|
|
126 |
{
|
|
|
127 |
$table = ( $this->ini["dbConnect"]["order_db"] ) ? $this->ini["dbConnect"]["order_db"] .
|
|
|
128 |
"." : "";
|
|
|
129 |
$table .= "Bestellung";
|
|
|
130 |
if ( $_GET["action"] )
|
|
|
131 |
{
|
|
|
132 |
$query = "SELECT Bemerkung FROM $table WHERE id=$bestellId";
|
|
|
133 |
$res = mysql_query( $query );
|
|
|
134 |
$row = mysql_fetch_assoc( $res );
|
|
|
135 |
$bemerkung = $row["Bemerkung"];
|
|
|
136 |
}
|
|
|
137 |
switch ( $_GET["action"] )
|
|
|
138 |
{
|
|
|
139 |
case "cancel":
|
|
|
140 |
// Kreditkartenzahlung
|
|
|
141 |
$bemerkung .= "Die Zahlung wurde vom Kunden am " . date( "d.m.Y" ) .
|
|
|
142 |
" um " . date( "H:i" ) . " Uhr abgebrochen!\n";
|
|
|
143 |
$query = "UPDATE $table SET Bemerkung='$bemerkung' WHERE id=$bestellId";
|
|
|
144 |
$res = mysql_query( $query );
|
|
|
145 |
|
|
|
146 |
if ( $_SESSION["languageException"] )
|
|
|
147 |
{
|
|
|
148 |
$msg =
|
|
|
149 |
"You have canceled the payment. Therefore we will now cancel your order.";
|
|
|
150 |
}
|
|
|
151 |
else
|
|
|
152 |
{
|
|
|
153 |
$msg =
|
|
|
154 |
"Leider haben Sie die Zahlung abgebrochen. Daher werden wir Ihre Bestellung nun stornieren.";
|
|
|
155 |
}
|
|
|
156 |
break;
|
|
|
157 |
case "accept":
|
|
|
158 |
// Kreditkartenzahlung
|
|
|
159 |
$bemerkung .=
|
|
|
160 |
"Die Zahlung wurde von der Kreditkartenorganisation am " .
|
|
|
161 |
date( "d.m.Y" ) . " um " . date( "H:i" ) .
|
|
|
162 |
" Uhr genehmigt!\n";
|
|
|
163 |
$kk_info["code"] = "";
|
|
|
164 |
$kk_info["status"] = "offen";
|
|
|
165 |
$kk_info = serialize( $kk_info );
|
|
|
166 |
$query = "UPDATE $table SET Bemerkung='$bemerkung', kk_info='$kk_info' WHERE id=$bestellId";
|
|
|
167 |
$res = mysql_query( $query );
|
|
|
168 |
if ( $_SESSION["languageException"] )
|
|
|
169 |
{
|
|
|
170 |
$msg =
|
|
|
171 |
"Your credit card organization confirmed the successful payment";
|
|
|
172 |
}
|
|
|
173 |
else
|
|
|
174 |
{
|
|
|
175 |
$msg =
|
|
|
176 |
"Ihre Kreditkartenorganisation hat die erfolgreiche Bezahlung bestätigt!";
|
|
|
177 |
}
|
|
|
178 |
break;
|
|
|
179 |
case "decline":
|
|
|
180 |
$bemerkung .=
|
|
|
181 |
"Die Zahlung wurde von der Kreditkartenorganisation am " .
|
|
|
182 |
date( "d.m.Y" ) . " um " . date( "H:i" ) .
|
|
|
183 |
" Uhr abgelehnt!\n";
|
|
|
184 |
$query = "UPDATE $table SET Bemerkung='$bemerkung' WHERE id=$bestellId";
|
|
|
185 |
$res = mysql_query( $query );
|
|
|
186 |
if ( $_SESSION["languageException"] )
|
|
|
187 |
{
|
|
|
188 |
$msg =
|
|
|
189 |
"Unfortunately your credit card organization refused the payment. Therefore we will now cancel your order.";
|
|
|
190 |
}
|
|
|
191 |
else
|
|
|
192 |
{
|
|
|
193 |
$msg =
|
|
|
194 |
"Leider hat Ihre Kreditkartenorganisation die Bezahlung verweigert. Daher werden wir Ihre Bestellung nun stornieren.";
|
|
|
195 |
}
|
|
|
196 |
break;
|
|
|
197 |
case "except":
|
|
|
198 |
$bemerkung .=
|
|
|
199 |
"Der Status der Zahlung wurde von der Kreditkartenorganisation am " .
|
|
|
200 |
date( "d.m.Y" ) . " um " . date( "H:i" ) .
|
|
|
201 |
" Uhr als unklar definiert!\n";
|
|
|
202 |
$query = "UPDATE $table SET Bemerkung='$bemerkung' WHERE id=$bestellId";
|
|
|
203 |
$res = mysql_query( $query );
|
|
|
204 |
if ( $_SESSION["languageException"] )
|
|
|
205 |
{
|
|
|
206 |
$msg =
|
|
|
207 |
"The status of the payment was defined as unclear by your credit card organization. Therefore we will cancel your order in 7 days.";
|
|
|
208 |
}
|
|
|
209 |
else
|
|
|
210 |
{
|
|
|
211 |
$msg =
|
|
|
212 |
"Der Status der zahlung wurde von der Kreditkartenorganisation als unklar definiert. Daher werden wir Ihre Bestellung in 7 Tagen stornieren.";
|
|
|
213 |
}
|
|
|
214 |
break;
|
|
|
215 |
}
|
|
|
216 |
return array( "error" => !$res, "meld" => $msg );
|
|
|
217 |
}
|
|
|
218 |
function genCheckSum( $src )
|
|
|
219 |
{
|
|
|
220 |
switch ( $this->ini["ideal"]["sha_algo"] )
|
|
|
221 |
{
|
|
|
222 |
case "sha512":
|
|
|
223 |
$data = hash( "sha512", $src );
|
|
|
224 |
break;
|
|
|
225 |
case "sha256":
|
|
|
226 |
$data = hash( "sha256", $src );
|
|
|
227 |
break;
|
|
|
228 |
case "sha1":
|
|
|
229 |
default:
|
|
|
230 |
$data = sha1( $src );
|
|
|
231 |
break;
|
|
|
232 |
}
|
|
|
233 |
return $data;
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
?>
|