Fout na nieuw certificaat voor ING
Na een nieuw certificaat van ING in de certificaat map te hebben geplaatst kunnen klanten niet meer via ideal betalen.
Kan iemand mij vertellen wat er fout gaat? Ik werk met de onderstaande code.
Alvast hartelijk dank!
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
<?php
class Gateway extends GatewayCore
{
// Load iDEAL settings
public function __construct()
{
$this->init();
}
// Setup payment
public function doSetup()
{
$sHtml = '';
// Look for proper GET's en POST's
if(empty($_GET['order_id']) || empty($_GET['order_code']))
{
$sHtml .= '<p>Invalid issuer request.</p>';
}
else
{
$sOrderId = $_GET['order_id'];
$sOrderCode = $_GET['order_code'];
// Lookup transaction
if($this->getRecordByOrder($sOrderId, $sOrderCode))
{
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Transaction already completed</p>';
}
elseif((strcmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
header('Location: ' . $this->oRecord['transaction_url']);
exit;
}
else
{
$oIssuerRequest = new IssuerRequest();
$oIssuerRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oIssuerRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oIssuerRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oIssuerRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oIssuerRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$aIssuerList = $oIssuerRequest->doRequest();
$sIssuerList = '';
if($oIssuerRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oIssuerRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing IssuerRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oIssuerRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing IssuerRequest on ' . date('Y-m-d, H:i:s') . '.';
$this->save();
foreach($aIssuerList as $k => $v)
{
$sIssuerList .= '<option value="' . $k . '">' . htmlspecialchars($v) . '</option>';
}
$sHtml .= '
<form action="' . htmlspecialchars(GatewayCore::getRootUrl() . 'transaction.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '" method="post" id="checkout">
<p><b>Kies uw bank</b><br><select name="issuer_id" style="margin: 6px; width: 200px;">' . $sIssuerList . '</select><br><input type="submit" value="Verder"></p>.
</form>';
}
}
else
{
$sHtml .= '<p>Invalid issuer request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Execute payment
public function doTransaction()
{
$sHtml = '';
// Look for proper GET's en POST's
if(empty($_POST['issuer_id']) || empty($_GET['order_id']) || empty($_GET['order_code']))
{
$sHtml .= '<p>Invalid transaction request.</p>';
}
else
{
$sIssuerId = $_POST['issuer_id'];
$sOrderId = $_GET['order_id'];
$sOrderCode = $_GET['order_code'];
// Lookup transaction
if($this->getRecordByOrder($sOrderId, $sOrderCode))
{
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Transaction already completed</p>';
}
elseif((strcmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
header('Location: ' . $this->oRecord['transaction_url']);
exit;
}
else
{
$oTransactionRequest = new TransactionRequest();
$oTransactionRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oTransactionRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oTransactionRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oTransactionRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oTransactionRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oTransactionRequest->setOrderId($this->oRecord['order_id']);
$oTransactionRequest->setOrderDescription($this->oRecord['transaction_description']);
$oTransactionRequest->setOrderAmount($this->oRecord['transaction_amount']);
$oTransactionRequest->setIssuerId($sIssuerId);
$oTransactionRequest->setEntranceCode($this->oRecord['transaction_code']);
$oTransactionRequest->setReturnUrl(GatewayCore::getRootUrl() . 'return.php');
// Find TransactionID
$sTransactionId = $oTransactionRequest->doRequest();
if($oTransactionRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oTransactionRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing TransactionRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oTransactionRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
$sTransactionUrl = $oTransactionRequest->getTransactionUrl();
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing TransactionRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ' . $sTransactionId;
$this->oRecord['transaction_id'] = $sTransactionId;
$this->oRecord['transaction_url'] = $sTransactionUrl;
$this->oRecord['transaction_status'] = 'OPEN';
$this->oRecord['transaction_date'] = time();
$this->save();
// die('<a href="' . $oTransactionRequest->getTransactionUrl() . '">' . $oTransactionRequest->getTransactionUrl() . '</a>');
$oTransactionRequest->doTransaction();
}
}
else
{
$sHtml .= '<p>Invalid transaction request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Catch return
public function doReturn()
{
$sHtml = '';
if(empty($_GET['trxid']) || empty($_GET['ec']))
{
$sHtml .= '<p>Invalid return request.</p>';
}
else
{
$sTransactionId = $_GET['trxid'];
$sTransactionCode = $_GET['ec'];
// Lookup record
if($this->getRecordByTransaction($sTransactionId, $sTransactionCode))
{
// Transaction already finished
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
if($this->oRecord['transaction_success_url'])
{
header('Location: ' . $this->oRecord['transaction_success_url']);
exit;
}
else
{
$sHtml .= '<p>Uw betaling is met succes ontvangen.<br><input style="margin: 6px;" type="button" value="Terug naar de website" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl(1)) . '\'"></p>';
}
}
else
{
// Check status
$oStatusRequest = new StatusRequest();
$oStatusRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oStatusRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oStatusRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oStatusRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oStatusRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oStatusRequest->setTransactionId($sTransactionId);
$this->oRecord['transaction_status'] = $oStatusRequest->doRequest();
if($oStatusRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oStatusRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oStatusRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . ' for #' . $this->oRecord['transaction_id'] . '. Recieved: ' . $this->oRecord['transaction_status'];
$this->save();
// Handle status change
if(function_exists('gateway_update_order_status'))
{
gateway_update_order_status($this->oRecord, 'doReturn');
}
// Set status message
if(strcasecmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Uw betaling is met succes ontvangen.<br><input style="margin: 6px;" type="button" value="Terug naar de website" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl(1)) . '\'"></p>';
}
elseif((strcasecmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
$sHtml .= '<p>Uw betaling is nog niet afgerond.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars($this->oRecord['transaction_url']) . '\'"></p>';
}
else
{
if(strcasecmp($this->oRecord['transaction_status'], 'CANCELLED') === 0)
{
$sHtml .= '<p>Uw betaling is geannuleerd. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
elseif(strcasecmp($this->oRecord['transaction_status'], 'EXPIRED') === 0)
{
$sHtml .= '<p>Uw betaling is mislukt. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
else // if(strcasecmp($this->oRecord['transaction_status'], 'FAILURE') === 0)
{
$sHtml .= '<p>Uw betaling is mislukt. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">ik kan niet via iDEAL betalen</a></p>';
}
}
if($this->oRecord['transaction_success_url'] && (strcasecmp($this->oRecord['transaction_status'], 'SUCCESS') === 0))
{
header('Location: ' . $this->oRecord['transaction_success_url']);
exit;
}
}
}
else
{
$sHtml .= '<p>Invalid return request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Catch report
public function doReport()
{
GatewayCore::output('Invalid report request.');
}
// Validate all open transactions
public function doValidate()
{
$sql = "SELECT * FROM `" . DATABASE_PREFIX . "transactions` WHERE (`transaction_status` = 'OPEN') AND (`transaction_method` = '" . addslashes($this->aSettings['GATEWAY_METHOD']) . "') ORDER BY `id` ASC;";
$oRecordset = mysql_query($sql) or die('QUERY: ' . $sql . '<br><br>ERROR: ' . mysql_error() . '<br><br>FILE: ' . __FILE__ . '<br><br>LINE: ' . __LINE__);
$sHtml = '<b>Controle van openstaande transacties.</b><br>';
if(mysql_num_rows($oRecordset))
{
while($oRecord = mysql_fetch_assoc($oRecordset))
{
// Execute status request
$oStatusRequest = new StatusRequest();
$oStatusRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oStatusRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oStatusRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oStatusRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oStatusRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oStatusRequest->setTransactionId($oRecord['transaction_id']);
$oRecord['transaction_status'] = $oStatusRequest->doRequest();
if(empty($oRecord['transaction_log']) == false)
{
$oRecord['transaction_log'] .= "\n\n";
}
if($oStatusRequest->hasErrors())
{
$oRecord['transaction_status'] = 'FAILURE';
$oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oStatusRequest->getErrors(), true);
}
else
{
$oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . ' for #' . $oRecord['transaction_id'] . '. Recieved: ' . $oRecord['transaction_status'];
}
$this->save($oRecord);
// Add to body
$sHtml .= '<br>#' . $oRecord['transaction_id'] . ' : ' . $oRecord['transaction_status'];
// Handle status change
if(function_exists('gateway_update_order_status'))
{
gateway_update_order_status($oRecord, 'doValidate');
}
}
$sHtml .= '<br><br><br>Alle openstaande transacties zijn bijgewerkt.';
}
else
{
$sHtml .= '<br>Er zijn geen openstaande transacties gevonden.';
}
GatewayCore::output('<p>' . $sHtml . '</p><p> </p><p><input type="button" value="Venster sluiten" onclick="javascript: window.close();"></p>');
}
}
?>
class Gateway extends GatewayCore
{
// Load iDEAL settings
public function __construct()
{
$this->init();
}
// Setup payment
public function doSetup()
{
$sHtml = '';
// Look for proper GET's en POST's
if(empty($_GET['order_id']) || empty($_GET['order_code']))
{
$sHtml .= '<p>Invalid issuer request.</p>';
}
else
{
$sOrderId = $_GET['order_id'];
$sOrderCode = $_GET['order_code'];
// Lookup transaction
if($this->getRecordByOrder($sOrderId, $sOrderCode))
{
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Transaction already completed</p>';
}
elseif((strcmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
header('Location: ' . $this->oRecord['transaction_url']);
exit;
}
else
{
$oIssuerRequest = new IssuerRequest();
$oIssuerRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oIssuerRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oIssuerRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oIssuerRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oIssuerRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$aIssuerList = $oIssuerRequest->doRequest();
$sIssuerList = '';
if($oIssuerRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oIssuerRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing IssuerRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oIssuerRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing IssuerRequest on ' . date('Y-m-d, H:i:s') . '.';
$this->save();
foreach($aIssuerList as $k => $v)
{
$sIssuerList .= '<option value="' . $k . '">' . htmlspecialchars($v) . '</option>';
}
$sHtml .= '
<form action="' . htmlspecialchars(GatewayCore::getRootUrl() . 'transaction.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '" method="post" id="checkout">
<p><b>Kies uw bank</b><br><select name="issuer_id" style="margin: 6px; width: 200px;">' . $sIssuerList . '</select><br><input type="submit" value="Verder"></p>.
</form>';
}
}
else
{
$sHtml .= '<p>Invalid issuer request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Execute payment
public function doTransaction()
{
$sHtml = '';
// Look for proper GET's en POST's
if(empty($_POST['issuer_id']) || empty($_GET['order_id']) || empty($_GET['order_code']))
{
$sHtml .= '<p>Invalid transaction request.</p>';
}
else
{
$sIssuerId = $_POST['issuer_id'];
$sOrderId = $_GET['order_id'];
$sOrderCode = $_GET['order_code'];
// Lookup transaction
if($this->getRecordByOrder($sOrderId, $sOrderCode))
{
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Transaction already completed</p>';
}
elseif((strcmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
header('Location: ' . $this->oRecord['transaction_url']);
exit;
}
else
{
$oTransactionRequest = new TransactionRequest();
$oTransactionRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oTransactionRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oTransactionRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oTransactionRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oTransactionRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oTransactionRequest->setOrderId($this->oRecord['order_id']);
$oTransactionRequest->setOrderDescription($this->oRecord['transaction_description']);
$oTransactionRequest->setOrderAmount($this->oRecord['transaction_amount']);
$oTransactionRequest->setIssuerId($sIssuerId);
$oTransactionRequest->setEntranceCode($this->oRecord['transaction_code']);
$oTransactionRequest->setReturnUrl(GatewayCore::getRootUrl() . 'return.php');
// Find TransactionID
$sTransactionId = $oTransactionRequest->doRequest();
if($oTransactionRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oTransactionRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing TransactionRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oTransactionRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
$sTransactionUrl = $oTransactionRequest->getTransactionUrl();
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing TransactionRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ' . $sTransactionId;
$this->oRecord['transaction_id'] = $sTransactionId;
$this->oRecord['transaction_url'] = $sTransactionUrl;
$this->oRecord['transaction_status'] = 'OPEN';
$this->oRecord['transaction_date'] = time();
$this->save();
// die('<a href="' . $oTransactionRequest->getTransactionUrl() . '">' . $oTransactionRequest->getTransactionUrl() . '</a>');
$oTransactionRequest->doTransaction();
}
}
else
{
$sHtml .= '<p>Invalid transaction request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Catch return
public function doReturn()
{
$sHtml = '';
if(empty($_GET['trxid']) || empty($_GET['ec']))
{
$sHtml .= '<p>Invalid return request.</p>';
}
else
{
$sTransactionId = $_GET['trxid'];
$sTransactionCode = $_GET['ec'];
// Lookup record
if($this->getRecordByTransaction($sTransactionId, $sTransactionCode))
{
// Transaction already finished
if(strcmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
if($this->oRecord['transaction_success_url'])
{
header('Location: ' . $this->oRecord['transaction_success_url']);
exit;
}
else
{
$sHtml .= '<p>Uw betaling is met succes ontvangen.<br><input style="margin: 6px;" type="button" value="Terug naar de website" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl(1)) . '\'"></p>';
}
}
else
{
// Check status
$oStatusRequest = new StatusRequest();
$oStatusRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oStatusRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oStatusRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oStatusRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oStatusRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oStatusRequest->setTransactionId($sTransactionId);
$this->oRecord['transaction_status'] = $oStatusRequest->doRequest();
if($oStatusRequest->hasErrors())
{
if($this->aSettings['TEST_MODE'])
{
GatewayCore::output('<code>' . var_export($oStatusRequest->getErrors(), true) . '</code>');
}
else
{
$this->oRecord['transaction_status'] = 'FAILURE';
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oStatusRequest->getErrors(), true);
$this->save();
$sHtml = '<p>Door een technische storing kunnen er momenteel helaas geen betalingen via iDEAL woren verwerkt. Onze excusses voor het ongemak.</p>';
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">terug naar de website</a></p>';
}
GatewayCore::output($sHtml);
}
}
if(empty($this->oRecord['transaction_log']) == false)
{
$this->oRecord['transaction_log'] .= "\n\n";
}
$this->oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . ' for #' . $this->oRecord['transaction_id'] . '. Recieved: ' . $this->oRecord['transaction_status'];
$this->save();
// Handle status change
if(function_exists('gateway_update_order_status'))
{
gateway_update_order_status($this->oRecord, 'doReturn');
}
// Set status message
if(strcasecmp($this->oRecord['transaction_status'], 'SUCCESS') === 0)
{
$sHtml .= '<p>Uw betaling is met succes ontvangen.<br><input style="margin: 6px;" type="button" value="Terug naar de website" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl(1)) . '\'"></p>';
}
elseif((strcasecmp($this->oRecord['transaction_status'], 'OPEN') === 0) && !empty($this->oRecord['transaction_url']))
{
$sHtml .= '<p>Uw betaling is nog niet afgerond.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars($this->oRecord['transaction_url']) . '\'"></p>';
}
else
{
if(strcasecmp($this->oRecord['transaction_status'], 'CANCELLED') === 0)
{
$sHtml .= '<p>Uw betaling is geannuleerd. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
elseif(strcasecmp($this->oRecord['transaction_status'], 'EXPIRED') === 0)
{
$sHtml .= '<p>Uw betaling is mislukt. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
else // if(strcasecmp($this->oRecord['transaction_status'], 'FAILURE') === 0)
{
$sHtml .= '<p>Uw betaling is mislukt. Probeer opnieuw te betalen.<br><input style="margin: 6px;" type="button" value="Verder" onclick="javascript: document.location.href = \'' . htmlspecialchars(GatewayCore::getRootUrl() . 'setup.php?order_id=' . $this->oRecord['order_id'] . '&order_code=' . $this->oRecord['order_code']) . '\'"></p>';
}
if($this->oRecord['transaction_payment_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_payment_url']) . '">kies een andere betaalmethode</a></p>';
}
elseif($this->oRecord['transaction_failure_url'])
{
$sHtml .= '<p><a href="' . htmlentities($this->oRecord['transaction_failure_url']) . '">ik kan niet via iDEAL betalen</a></p>';
}
}
if($this->oRecord['transaction_success_url'] && (strcasecmp($this->oRecord['transaction_status'], 'SUCCESS') === 0))
{
header('Location: ' . $this->oRecord['transaction_success_url']);
exit;
}
}
}
else
{
$sHtml .= '<p>Invalid return request.</p>';
}
}
GatewayCore::output($sHtml);
}
// Catch report
public function doReport()
{
GatewayCore::output('Invalid report request.');
}
// Validate all open transactions
public function doValidate()
{
$sql = "SELECT * FROM `" . DATABASE_PREFIX . "transactions` WHERE (`transaction_status` = 'OPEN') AND (`transaction_method` = '" . addslashes($this->aSettings['GATEWAY_METHOD']) . "') ORDER BY `id` ASC;";
$oRecordset = mysql_query($sql) or die('QUERY: ' . $sql . '<br><br>ERROR: ' . mysql_error() . '<br><br>FILE: ' . __FILE__ . '<br><br>LINE: ' . __LINE__);
$sHtml = '<b>Controle van openstaande transacties.</b><br>';
if(mysql_num_rows($oRecordset))
{
while($oRecord = mysql_fetch_assoc($oRecordset))
{
// Execute status request
$oStatusRequest = new StatusRequest();
$oStatusRequest->setSecurePath($this->aSettings['CERTIFICATE_PATH']);
$oStatusRequest->setCachePath($this->aSettings['TEMP_PATH']);
$oStatusRequest->setPrivateKey($this->aSettings['PRIVATE_KEY_PASS'], $this->aSettings['PRIVATE_KEY_FILE'], $this->aSettings['PRIVATE_CERTIFICATE_FILE']);
$oStatusRequest->setMerchant($this->aSettings['MERCHANT_ID'], $this->aSettings['SUB_ID']);
$oStatusRequest->setAquirer($this->aSettings['GATEWAY_NAME'], $this->aSettings['TEST_MODE']);
$oStatusRequest->setTransactionId($oRecord['transaction_id']);
$oRecord['transaction_status'] = $oStatusRequest->doRequest();
if(empty($oRecord['transaction_log']) == false)
{
$oRecord['transaction_log'] .= "\n\n";
}
if($oStatusRequest->hasErrors())
{
$oRecord['transaction_status'] = 'FAILURE';
$oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . '. Recieved: ERROR' . "\n" . var_export($oStatusRequest->getErrors(), true);
}
else
{
$oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . ' for #' . $oRecord['transaction_id'] . '. Recieved: ' . $oRecord['transaction_status'];
}
$this->save($oRecord);
// Add to body
$sHtml .= '<br>#' . $oRecord['transaction_id'] . ' : ' . $oRecord['transaction_status'];
// Handle status change
if(function_exists('gateway_update_order_status'))
{
gateway_update_order_status($oRecord, 'doValidate');
}
}
$sHtml .= '<br><br><br>Alle openstaande transacties zijn bijgewerkt.';
}
else
{
$sHtml .= '<br>Er zijn geen openstaande transacties gevonden.';
}
GatewayCore::output('<p>' . $sHtml . '</p><p> </p><p><input type="button" value="Venster sluiten" onclick="javascript: window.close();"></p>');
}
}
?>
Wat leestekens en interpunctie toegevoegd zodat de tekst beter is te lezen en professioneler overkomt. Zou je hier voortaan zelf op willen letten?
Gewijzigd op 11/07/2011 20:36:10 door Niels K
Kan je ons iets meer informatie verschaffen? Krijg je bijvoorbeeld foutmeldingen? En zoja, welke precies?
Alvast bedankt.
Niels
Heb toen gebeld met IDEAL helpdesk . Van hun moest ik het oude certificaat verwijderen. Dat heb ik dus gedaan , nu staat er , Door een tegnishe storingen is het niet mogelijk via IDEAL te betalen , kies een andere optie.
Dan bel je toch nog een keer.
Anders wordt het debuggen...
Gewijzigd op 11/07/2011 21:33:58 door Niels K
GatewayCore::output('<code>' . var_export($oIssuerRequest->getErrors(), true) . '</code>');
Hans boogaard op 11/07/2011 21:44:36:
GatewayCore::output('<code>' . var_export($oIssuerRequest->getErrors(), true) . '</code>');
Eh ja? Okee? En nu?