-
Notifications
You must be signed in to change notification settings - Fork 0
/
ideal_payment_api_connector.inc.php
executable file
·109 lines (92 loc) · 3.07 KB
/
ideal_payment_api_connector.inc.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
<?php
// $Id$
/**
* @file
* iDEAL payment module for Ubercart. No extra gateway needed.
* Include For iDEAL ING/PB Advanced Connector
*
* Development by Qrios | http://www.qrios.nl | c.kodde {at} qrios {dot} nl
*
*
*/
function ideal_payment_api_dirreq_call() {
$path_module = drupal_get_path('module', 'ideal_payment_api');
////Set errors on so we can see if there is a PHP error goes wrong
//ini_set('display_errors',1);
//error_reporting(E_ALL & ~E_NOTICE);
//include connector
require_once($path_module.'/lib/iDEALConnector.php');
// Initialise connector
$iDEALConnector = new iDEALConnector();
//Process directory request
$response = $iDEALConnector->GetIssuerList();
if ($response->errCode) {
$return.=t('Payment through iDEAL gateway not possible.').' ';
$return.=t('Error message iDEAL').': ';
$return.= $response->errMsg .'('. $response->errCode .')';
}
else {
//Get issuerlist
$issuerArray = $response->issuerShortList;
if (count($issuerArray) == 0) {
$return.=t('List with banks not available, payment through iDEAL gateway not possible.');
}
else {
$return = $issuerArray;
}
}
/*END ThinMPI code for DirReq*/
return $return;
}
/**
* Calls a transaction request
*/
function ideal_payment_api_transreq_call($order) {
//Get user ID
global $user;
if ($user) {
$user_id = $user->uid;
}
$path_module = drupal_get_path('module', 'ideal_payment_api');
require_once($path_module.'/lib/iDEALConnector.php');
$iDEALConnector = new iDEALConnector();
$order['description'] = check_plain($order['description']);
if (drupal_strlen($order['description']) > 32) {//@TODO: run this trough a general error handler.
$order['description_orig'] = $order['description'];
$order['description'] = drupal_substr($order['description'], 0, 32);
watchdog('ideal_api', t('iDEAL decription too long. Changed from %orig to %shortened', array('%orig' => $order['description_orig'], '%shortened' => $order['description'])));
}
//issuerid is min. 4 chars, add leading 0's
$order['issuer_id'] = str_pad($order['issuer_id'], 4, '0', STR_PAD_LEFT);
//Send TransactionRequest
$response = $iDEALConnector->RequestTransaction(
$order['issuer_id'],
$order['order_id'],
$order['amount'],
$order['description'],
$order['order_id'],
$iDEALConnector->config['EXPIRATIONPERIOD'],
$iDEALConnector->config['MERCHANTRETURNURL']
);
if (!$response->errCode) {
return $response;
}
else {
watchdog('ideal_api', $response->errCode.': '.$response->errMsg, NULL, WATCHDOG_ERROR);
return $response;
}
}
/**
* Calls the STATUS request
**/
function ideal_payment_api_statreq_call($order) {
//include connector
$path_module = drupal_get_path('module', 'ideal_payment_api');
require_once($path_module.'/lib/iDEALConnector.php');
//Initialise connector
$iDEALConnector = new iDEALConnector();
//Create StatusRequest
$response = $iDEALConnector->RequestTransactionStatus($order['transaction_id']);
//$transID = str_pad($transaction_id, 16, "0"); //Delete??
return $response;
}