Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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: 761 $
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: sofortueberweisung.php 761 2011-10-12 14:04:34Z tiefland $
21
 
22
    require_once "creditcard.interface.php";
23
 
24
    class sofortueberweisung 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
            if ( isset( $this->ini["ueberweisung"]["zugang"] ) && $this->
42
                ini["ueberweisung"]["zugang"] )
43
            {
44
                define( "ZUGANG", $this->ini["ueberweisung"]["zugang"] );
45
                define( "SECRET", $this->ini["ueberweisung"]["secret"] );
46
                define( "PROJECT", $this->ini["ueberweisung"]["project"] );
47
                $reason_1 = $this->ini["ueberweisung"]["reason_1"];
48
                $reason_2 = $this->ini["ueberweisung"]["reason_2"] . $bestellId;
49
                $summe = getBasketSumme();
50
                if ( $_SESSION["brutto"] == true && $this->ini["netto_preise"] ==
51
                    1 )
52
                {
53
                    $summe = getBasketSummeBrutto();
54
                }
55
                $b_url = $this->ini["absoluteURL"];
56
                $b_url_s = ( $this->ini["ssl_buy"] ) ? str_replace( "http://",
57
                    "https://", $b_url ) : $b_url;
58
                $p_url = "https://www.sofortueberweisung.de/payment/start";
59
                $data = array( ZUGANG, PROJECT, '', '', '', '', $summe,
60
                    'EUR', $reason_1, $reason_2, $bestellId, '', '', '', '',
61
                    '', SECRET, );
62
                $data_implode = implode( '|', $data );
63
                $hash = $this->genCheckSum( $data_implode );
64
                $out = '
65
                    <form action="' . $p_url .
66
                    '" method="post" name="sofort" id="zahlung">
67
                        <input type="hidden" name="user_id" value="' .
68
                    ZUGANG . '">
69
                        <input type="hidden" name="project_id" value="' .
70
                    PROJECT . '">
71
                        <input type="hidden" name="amount" value="' . $summe .
72
                    '">
73
                        <input type="hidden" name="reason_1" value="' . $reason_1 .
74
                    '">
75
                        <input type="hidden" name="reason_2" value="' . $reason_2 .
76
                    '">
77
                        <input type="hidden" name="user_variable_0" value="' .
78
                    $bestellId . '">
79
                        <input type="hidden" name="currency_id" value="EUR">
80
                        <input type="hidden" name="hash" value="' . $hash .
81
                    '">
82
                        <input type="image" src="/images/webelemente/lockbox_150x65.png" />
83
                    </form>
84
                ';
85
                return $out;
86
            }
87
            return false;
88
        }
89
 
90
        function getCreditCardReturnStatus( $bestellId )
91
        {
92
            $table = ( $this->ini["dbConnect"]["order_db"] ) ? $this->ini["dbConnect"]["order_db"] .
93
                "." : "";
94
            $table .= "Bestellung";
95
            $query = "SELECT Bemerkung FROM $table WHERE id=$bestellId";
96
            $res = mysql_query( $query, $GLOBALS["order_dbh"] );
97
            $row = mysql_fetch_assoc( $res );
98
            $bemerkung = $row["Bemerkung"];
99
 
100
            switch ( $_GET["action"] )
101
            {
102
                case "cancel":
103
                    $res = false;
104
                    $status = "abgebrochen";
105
                    $bemerkung .=
106
                        "Die Zahlung auf sofortueberweisung.de wurde vom Kunden am " .
107
                        date( "d.m.Y" ) . " um " . date( "H:i" ) .
108
                        " Uhr abgebrochen!\n";
109
                    if ( USE_TRANSLATION2 === true )
110
                    {
111
                        $msg = $GLOBALS["langstrings"]["buy"]["sofort_canceled"];
112
                    } elseif ( $_SESSION["languageException"] )
113
                    {
114
                        $msg =
115
                            "You have canceled the payment. Click on the button to choose an other payment method.";
116
                    }
117
                    else
118
                    {
119
                        $msg =
120
                            "Sie haben die Zahlung abgebrochen. Klicken Sie auf den Button, um eine andere Zahlweise auszuwählen.";
121
                    }
122
                    break;
123
                case "accept":
124
                    $res = true;
125
                    $bemerkung .=
126
                        "Die Zahlung wurde von sofortueberweisung.de am " .
127
                        date( "d.m.Y" ) . " um " . date( "H:i" ) .
128
                        " Uhr genehmigt!\n";
129
                    if ( USE_TRANSLATION2 === true )
130
                    {
131
                        $msg = $GLOBALS["langstrings"]["buy"]["sofort_accepted"];
132
                    } elseif ( $_SESSION["languageException"] )
133
                    {
134
                        $msg =
135
                            "sofortueberweisung.de has confirmed your payment";
136
                    }
137
                    else
138
                    {
139
                        $msg =
140
                            "sofortüberweisung.de hat die erfolgreiche Bezahlung bestätigt!";
141
                    }
142
                    break;
143
                case "decline":
144
                    $status = "abgelehnt";
145
                    $_SESSION["zahlarten"]["ueberweisung"] = false;
146
                    $res = false;
147
                    $bemerkung .=
148
                        "Die Zahlung wurde von der sofortüberweisung.de am " .
149
                        date( "d.m.Y" ) . " um " . date( "H:i" ) .
150
                        " Uhr abgelehnt!\n";
151
                    break;
152
                case "except":
153
                    $status = "unklar";
154
                    $bemerkung .=
155
                        "Der Status der Zahlung wurde von sofortüberweisung.de am " .
156
                        date( "d.m.Y" ) . " um " . date( "H:i" ) .
157
                        " Uhr als unklar definiert!\n";
158
                    break;
159
            }
160
            $ret = array( "error" => !$res );
161
            $query = "
162
                UPDATE
163
                    $table
164
                SET
165
                    Bemerkung='$bemerkung'
166
                WHERE
167
                    id=$bestellId
168
            ";
169
            mysql_query( $query, $GLOBALS["order_dbh"] );
170
            if ( $ret["error"] )
171
            {
172
                $msg = $this->_getMsg( $ret, $status, $bestellId );
173
            }
174
            $ret["meld"] = $msg;
175
            return $ret;
176
        }
177
        function genCheckSum( $src )
178
        {
179
            switch ( $this->ini["ueberweisung"]["sha_algo"] )
180
            {
181
                case "sha512":
182
                default:
183
                    $data = hash( "sha512", $src );
184
                    break;
185
                case "sha256":
186
                    $data = hash( "sha256", $src );
187
                    break;
188
                case "sha1":
189
                    $data = sha1( $src );
190
                    break;
191
            }
192
            return $data;
193
        }
194
        private function _getMsg( $ret, $status, $bestellId )
195
        {
196
            if ( USE_TRANSLATION2 === true )
197
            {
198
                if ( $this->ini["change_order"] )
199
                {
200
                    $abschluss = $GLOBALS["langstrings"]["buy"]["click_button"];
201
                }
202
                else
203
                {
204
                    $abschluss = $GLOBALS["langstrings"]["buy"]["cancel_order"];
205
                }
206
            } elseif ( $_SESSION["languageException"] )
207
            {
208
                if ( $this->ini["change_order"] )
209
                {
210
                    $abschluss =
211
                        "Click on the button to choose an other payment method.";
212
                }
213
                else
214
                {
215
                    $abschluss = "Therefore we will now cancel your order.";
216
                }
217
            }
218
            else
219
            {
220
                if ( $this->ini["change_order"] )
221
                {
222
                    $abschluss =
223
                        "Klicken Sie auf den Button, um eine andere Zahlweise auszuwählen.";
224
                }
225
                else
226
                {
227
                    $abschluss =
228
                        "Deshalb werden wir nun Ihre Bestellung nun stornieren.";
229
                }
230
            }
231
            switch ( $status )
232
            {
233
                case "abgebrochen":
234
                    if ( USE_TRANSLATION2 === true )
235
                    {
236
                        $msg = $GLOBALS["langstrings"]["buy"]["order_canceled"];
237
                    } elseif ( $_SESSION["languageException"] )
238
                    {
239
                        $msg = "You have canceled the payment. ";
240
                    }
241
                    else
242
                    {
243
                        $msg = "Sie haben die Zahlung abgebrochen. ";
244
                    }
245
                    break;
246
                case "abgelehnt":
247
                    if ( USE_TRANSLATION2 === true )
248
                    {
249
                        $msg = $GLOBALS["langstrings"]["buy"]["sofort_declined"];
250
                    } elseif ( $_SESSION["languageException"] )
251
                    {
252
                        $msg =
253
                            "Unfortunately sofortuebwerweisung.de refused the payment. ";
254
                    }
255
                    else
256
                    {
257
                        $msg =
258
                            "Leider hat sofortüberweisung.de die Bezahlung verweigert. ";
259
                    }
260
                    break;
261
                case "unklar":
262
                    if ( USE_TRANSLATION2 === true )
263
                    {
264
                        $msg = $GLOBALS["langstrings"]["buy"]["sofort_excepted"];
265
                    } elseif ( $_SESSION["languageException"] )
266
                    {
267
                        "The status of the payment was defined as unclear by sofortueberweisung.de. ";
268
                    }
269
                    else
270
                    {
271
                        $msg =
272
                            "Der Status der zahlung wurde von sofortüberweisung.de als unklar definiert. ";
273
                    }
274
                    break;
275
            }
276
            $msg .= $abschluss;
277
            if ( $ret["error"] && $this->ini["change_order"] )
278
            {
279
                $msg .= '
280
                    <form method="post" action="/">
281
                        <input type="hidden" name="best_id" value="' . $bestellId .
282
                    '">
283
                        <input type="hidden" name="email" value="' . $_SESSION["SHOP"]["buy"]["Persdata"]["email"] .
284
                    '">
285
                        <input type="hidden" name="mode" value="change_order">
286
                        <input type="submit" value="Zahlart / Bestellung &auml;ndern">
287
                    </form>
288
                ';
289
            }
290
            return $msg;
291
        }
292
    }
293
?>