Skip to content
This repository was archived by the owner on Apr 3, 2018. It is now read-only.

Commit c422a86

Browse files
committed
- add the first version of the payment module "datatrans"
0 parents  commit c422a86

9 files changed

+403
-0
lines changed

CHANGELOG.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
===================
2+
ISOTOPE - datatrans
3+
===================
4+
5+
Version 1.0.0 (2011-07-14)
6+
---------------------------
7+
- add the first version to the SVN Repository

PaymentDatatrans.php

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2+
3+
/**
4+
* Contao Open Source CMS
5+
* Copyright (C) 2005-2011 Leo Feyer
6+
*
7+
* Formerly known as TYPOlight Open Source CMS.
8+
*
9+
* This program is free software: you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation, either
12+
* version 3 of the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this program. If not, please visit the Free
21+
* Software Foundation website at <http://www.gnu.org/licenses/>.
22+
*
23+
* PHP version 5
24+
* @copyright Isotope eCommerce Workgroup 2009-2011
25+
* @author Andreas Schempp <[email protected]>
26+
* @author Leo Unglaub <[email protected]>
27+
* @license http://opensource.org/licenses/lgpl-3.0.html
28+
* @version $Id: $
29+
*/
30+
31+
32+
class PaymentDatatrans extends IsotopePayment
33+
{
34+
/**
35+
* Return a list of status options.
36+
*
37+
* @access public
38+
* @return array
39+
*/
40+
public function statusOptions()
41+
{
42+
return array('pending', 'processing', 'complete', 'on_hold');
43+
}
44+
45+
46+
/**
47+
* Server 2 Server check
48+
*/
49+
public function processPostSale()
50+
{
51+
$this->import('Input');
52+
53+
// stop if something went wrong
54+
if ($this->Input->post('status') != 'success')
55+
{
56+
$this->log('Order ID "' . $this->Input->post('refno') . '" has NOT succeedet. UPP Transaction Id: ' . $this->Input->post('uppTransactionId'), __METHOD__, TL_ERROR);
57+
return;
58+
}
59+
60+
$objOrder = new IsotopeOrder();
61+
62+
if (!$objOrder->findBy('id', $this->Input->post('refno')))
63+
{
64+
$this->log('Order ID "' . $this->Input->post('refno') . '" not found', __METHOD__, TL_ERROR);
65+
return;
66+
}
67+
68+
// check if the details are okay
69+
if ($this->Input->post('merchantId') == $this->datatrans_id)
70+
{
71+
// do the optional sign check
72+
if ($this->datatrans_sign == 1)
73+
{
74+
if ($this->datatrans_sign_value != $this->Input->post('sign'))
75+
{
76+
$this->log('Call without a valid sign id', __METHOD__, TL_ERROR);
77+
return;
78+
}
79+
}
80+
81+
// new in isotope 1.3
82+
if (version_compare(ISO_VERSION, '0.2', '>'))
83+
{
84+
$objOrder->checkout();
85+
}
86+
87+
$objOrder->date_payed = time();
88+
$objOrder->save();
89+
90+
}
91+
}
92+
93+
94+
/**
95+
* Check if the server to server check was sucessfull before we tag the order as payed
96+
* @return bool
97+
*/
98+
public function processPayment()
99+
{
100+
$objOrder = new IsotopeOrder();
101+
102+
if (!$objOrder->findBy('cart_id', $this->Isotope->Cart->id))
103+
{
104+
$this->log('Cart ID "' . $this->Isotope->Cart->id . '" not found', __METHOD__, TL_ERROR);
105+
$this->redirect($this->addToUrl('step=failed', true));
106+
}
107+
108+
if ($objOrder->date_payed > 0)
109+
return true;
110+
111+
$this->redirect($this->addToUrl('step=failed', true));
112+
}
113+
114+
115+
/**
116+
* Generate the submit form for datatrans and if javascript
117+
* is enabled redirect automaticly
118+
*
119+
* @return string
120+
*/
121+
public function checkoutForm()
122+
{
123+
$objOrder = new IsotopeOrder();
124+
125+
if (!$objOrder->findBy('cart_id', $this->Isotope->Cart->id))
126+
{
127+
$this->redirect($this->addToUrl('step=failed', true));
128+
}
129+
130+
$this->loadLanguageFile('tl_iso_payment_modules');
131+
$arrParams = array
132+
(
133+
'merchantId' => $objOrder->Payment->datatrans_id,
134+
'amount' => $this->Isotope->Cart->grandTotal,
135+
'currency' => $this->Isotope->Config->currency,
136+
'refno' => $objOrder->id, // Order or transaction ID
137+
'mod' => 'pay',
138+
'id' => $this->id
139+
);
140+
141+
// add the security sign
142+
if ($this->datatrans_sign == 1)
143+
{
144+
$arrParams['sign'] = $this->datatrans_sign_value;
145+
}
146+
147+
$objTemplate = new FrontendTemplate('iso_payment_datatrans');
148+
$objTemplate->params = $arrParams;
149+
$objTemplate->action = 'https://pilot.datatrans.biz/upp/jsp/upStart.jsp'; // Live URL: https://payment.datatrans.biz/upp/jsp/upStart.jsp
150+
$objTemplate->slabel = $GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_label_pay'];
151+
$objTemplate->id = $this->id;
152+
153+
return $objTemplate->parse();
154+
}
155+
}
156+
157+
158+
?>

README.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
===================
2+
ISOTOPE - datatrans
3+
===================
4+
5+
To install the payment module simply copy the folder into system/modules/ and run
6+
a database update. After the update, go to the Isotope config and add a new payment method.
7+
8+
After this please log in your datatrans admin panel and insert the correct url's.
9+
- URL Post: http://domain.tld/system/modules/isotope/postsale.php
10+
- URL Success: http://domain.tld/your-checkout-site/step/complete.html
11+
- URL Error: http://domain.tld/your-checkout-site/step/failed.html
12+
13+
14+
For more security please activate the sign parameter security. Only with this your payment
15+
process is 100% secured. You can generate the sign parameter in the datatrans admin panel.

config/config.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2+
3+
/**
4+
* Contao Open Source CMS
5+
* Copyright (C) 2005-2011 Leo Feyer
6+
*
7+
* Formerly known as TYPOlight Open Source CMS.
8+
*
9+
* This program is free software: you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation, either
12+
* version 3 of the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this program. If not, please visit the Free
21+
* Software Foundation website at <http://www.gnu.org/licenses/>.
22+
*
23+
* PHP version 5
24+
* @copyright Isotope eCommerce Workgroup 2009-2011
25+
* @author Leo Unglaub <[email protected]>
26+
* @license http://opensource.org/licenses/lgpl-3.0.html
27+
* @version $Id: $
28+
*/
29+
30+
31+
/**
32+
* Payment modules
33+
*/
34+
$GLOBALS['ISO_PAY']['datatrans'] = 'PaymentDatatrans';
35+
36+
?>

config/database.sql

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- **********************************************************
2+
-- * *
3+
-- * IMPORTANT NOTE *
4+
-- * *
5+
-- * Do not import this file manually but use the TYPOlight *
6+
-- * install tool to create and maintain database tables! *
7+
-- * *
8+
-- **********************************************************
9+
10+
11+
--
12+
-- Table `tl_iso_payment_modules`
13+
--
14+
15+
CREATE TABLE `tl_iso_payment_modules` (
16+
`datatrans_id` varchar(100) NOT NULL default '',
17+
`datatrans_sign` char(1) NOT NULL default '0',
18+
`datatrans_sign_value` varchar(100) NOT NULL default '',
19+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

dca/tl_iso_payment_modules.php

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2+
3+
/**
4+
* Contao Open Source CMS
5+
* Copyright (C) 2005-2011 Leo Feyer
6+
*
7+
* Formerly known as TYPOlight Open Source CMS.
8+
*
9+
* This program is free software: you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation, either
12+
* version 3 of the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this program. If not, please visit the Free
21+
* Software Foundation website at <http://www.gnu.org/licenses/>.
22+
*
23+
* PHP version 5
24+
* @copyright Isotope eCommerce Workgroup 2009-2011
25+
* @author Leo Unglaub <[email protected]>
26+
* @license http://opensource.org/licenses/lgpl-3.0.html
27+
* @version $Id: $
28+
*/
29+
30+
/**
31+
* Palettes
32+
*/
33+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['palettes']['__selector__'][] = 'datatrans_sign';
34+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['palettes']['datatrans'] = '{type_legend},name,label,type;{config_legend},new_order_status,trans_type,postsale_mail,minimum_total,maximum_total,countries,shipping_modules,product_types;{gateway_legend},datatrans_id,datatrans_sign;{expert_legend:hide},guests,protected;{enabled_legend},enabled';
35+
36+
37+
/**
38+
* Subpalettes
39+
*/
40+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['subpalettes']['datatrans_sign'] = 'datatrans_sign_value';
41+
42+
43+
/**
44+
* Fields
45+
*/
46+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['fields']['datatrans_id'] = array
47+
(
48+
'label' => &$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_id'],
49+
'exclude' => true,
50+
'inputType' => 'text',
51+
'eval' => array('mandatory'=>true, 'maxlength'=>100, 'rgxp'=>'digit', 'tl_class'=>'w50')
52+
);
53+
54+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['fields']['datatrans_sign'] = array
55+
(
56+
'label' => &$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_sign'],
57+
'exclude' => true,
58+
'inputType' => 'checkbox',
59+
'eval' => array('tl_class'=>'clr', 'submitOnChange'=>true)
60+
);
61+
62+
$GLOBALS['TL_DCA']['tl_iso_payment_modules']['fields']['datatrans_sign_value'] = array
63+
(
64+
'label' => &$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_sign_value'],
65+
'exclude' => true,
66+
'inputType' => 'text',
67+
'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
68+
);
69+
?>
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2+
3+
/**
4+
* Contao Open Source CMS
5+
* Copyright (C) 2005-2011 Leo Feyer
6+
*
7+
* Formerly known as TYPOlight Open Source CMS.
8+
*
9+
* This program is free software: you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation, either
12+
* version 3 of the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this program. If not, please visit the Free
21+
* Software Foundation website at <http://www.gnu.org/licenses/>.
22+
*
23+
* PHP version 5
24+
* @copyright Isotope eCommerce Workgroup 2009-2011
25+
* @author Leo Unglaub <[email protected]>
26+
* @license http://opensource.org/licenses/lgpl-3.0.html
27+
* @version $Id: $
28+
*/
29+
30+
/**
31+
* Fields
32+
*/
33+
$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_id'] = array('Merchant-ID', 'Bitte geben Sie ihre Datatrans Merchant-ID ein.');
34+
$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_sign'] = array('sign Parameter', 'Aktivieren Sie diese Checkbox um einen "sign" Parameter zu verwenden.');
35+
$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_sign_value'] = array('sign Wert', 'Bitte geben Sie den gleichen "sign" Wert ein, wie in datatrans Control Panel.');
36+
37+
38+
/**
39+
* MSC
40+
*/
41+
$GLOBALS['TL_LANG']['tl_iso_payment_modules']['datatrans_label_pay'] = 'Jetzt mit Datatrans bezahlen';
42+
?>

0 commit comments

Comments
 (0)