'
.$this->_displayPresentation()
.'
';
return $str;
}
public function hookPayment($params)
{
if ((self::$ID_MERCHANT === false || self::$ID_MERCHANT === '' || self::$ID_MERCHANT === NULL)
|| (self::$ACCEPTED_URL === false || self::$ACCEPTED_URL === '' || self::$ACCEPTED_URL === NULL))
return '';
$currency = new Currency(intval($params['cart']->id_currency));
$lang = new Language(intval($params['cart']->id_lang));
$customer = new Customer(intval($params['cart']->id_customer));
$address = new Address(intval($params['cart']->id_address_invoice));
$country = new Country(intval($address->id_country), intval($params['cart']->id_lang));
$products = $params['cart']->getProducts();
$dibsParams = array();
// Required
$dibsParams['merchant'] = self::$ID_MERCHANT; // id merchant send from DIBS e-mail
// don't cast to int !! It has strange behaviour (really strange)
// for example : When calculate a total amount of 557.05, the result is 55704 after casting !!
$dibsParams['amount'] = $params['cart']->getOrderTotal(true, Cart::BOTH) * 100; // The smallest unit of an amount, cent for EUR
$dibsParams['accepturl'] = self::$ACCEPTED_URL.'?id_cart='.(int)($params['cart']->id).'&id_module='.(int)($this->id).'&key='.$customer->secure_key; // The URL of the page to be displayed if the purchase is approved.
$dibsParams['orderid'] = $params['cart']->id.'_'.date('YmdHis'); // The shop's order number for this particular puchase. It can be seen later when payment is captured, and will in some instances appear on the customer's bank statement (max. 50 characters, both numerals and letters may be used).
$currency_num = 0;
// for 1.3 compatibility
if (!isset($currency->iso_code_num) OR $currency->iso_code_num == '')
{
$array_currency_iso_num = array(
'DKK' => 208,
'EUR' => 978,
'USD' => 840,
'GBP' => 826,
'SEK' => 752,
'AUD' => 036,
'CAD' => 124,
'ISK' => 352,
'JPY' => 392,
'NZD' => 554,
'NOK' => 578,
'CHF' => 756,
'TRY' => 949,
);
$currency_num = $array_currency_iso_num[$currency->iso_code];
}
else
$currency_num = $currency->iso_code_num;
$dibsParams['currency'] = (int)$currency_num; // Currency specification as indicated in ISO4217 where the EUR is no. 978
// optional
if (self::$TESTING === 1)
$dibsParams['test'] = 'yes'; // optional - This field is used when tests are being conducted on the shop (e.g. test=yes). When this field is declared, the transaction is not dispatched to the card issuer, but is instead handled by the DIBS test module. See also Step 5 of the 10 Step Guide for more information. During your initial integration with DIBS, there is no need to insert this parameter, since all default transactions will hit the DIBS test system until DIBS has approved integration. Should the test system be used at a later date, this will be activated at DIBS (contact DIBS support for reactivating the test mode of your shop).
$dibsParams['lang'] = in_array(strtolower($lang->iso_code), self::$accepted_lang) ? $lang->iso_code : ''; // optional - This parameter determines the language in which the page will be opened. The following values are accepted: da=Danish en=English es=Spanish fi=Finnish fo=Faroese fr=French it=Italian nl=Dutch no=Norwegian pl=Polish (simplified) sv=Swedish Default language is Danish.
$dibsParams['color'] = self::$MORE_SETTINGS['flexwin_color']; // optional - The basic color theme of FlexWin. There is currently a choice of "sand", "grey" and "blue". The default value is "blue".
$dibsParams['cancelurl'] = self::$CANCELLED_URL; // optional - The URL of the page to be displayed if the customer cancels the payment.
$dibsParams['uniqueoid'] = (int)($params['cart']->id).'_'.date('YmdHis').'_'.$params['cart']->secure_key; // optional - If this field exists, the orderid-field must be unique, i.e. there is no existing transaction with DIBS with the same order number. If such a transaction already exists, payment will be rejected with reason=7. Unless you are unable to generate unique order numbers, we strongly urge you to utilize this field.Note: Order numbers can be composed of a maximum of 50 characters (DIBS automatically removes surplus characters) and that uniqueoid is therefore unable to work as intended if order numbers consisting of more than 50 characters are used.
$dibsParams['callbackurl'] = self::$site_url.'modules/'.$this->name.'/validation.php'; // optional - An optional �server-to-server� call which tells the shop�s server that payment was a success. Can be used for many purposes, the most important of these being the ability to register the order in your own system without depending on the customer�s browser hitting a specific page of the shop. See also HTTP_COOKIE.
$md5_params = 'merchant='.self::$ID_MERCHANT.'&orderid='.$dibsParams['orderid'].'¤cy='.$dibsParams['currency'].'&amount='.$dibsParams['amount'];
$dibsParams['md5key'] = md5(self::$MORE_SETTINGS['k2'].md5(self::$MORE_SETTINGS['k1'].$md5_params)); // optional - This variable enables a MD5 key control of the values received by DIBS. This control confirms that the values sent to DIBS has not been tampered with during the transfer. The MD5 key is calculated as: MD5(key2 + MD5(key1 + "merchant=&orderid=&transact=")) Where key1 and key2 are shop specific keys available through the DIBS administration interface, and + is the concatenation operator. NB! MD5 key check must also be enabled through the DIBS administration interface in order to work. Further details on MD5-key control.
// @todo need more infos.
$dibsParams['account'] = ''; // optional - If multiple departments utilize the company's acquirer agreement with PBS, it may prove practical to keep the transactions separate at DIBS. An "account number" may be inserted in this field, so as to separate transactions at DIBS.
$dibsParams['calcfee'] = ''; // optional - If this parameter is set (e.g. calcfee=foo), the charge due to the transaction will automatically be calculated and affixed, i.e., the charge payable to the acquirer (e.g. PBS)
$dibsParams['capturenow'] = ''; // optional - If this field exists, an "instant capture" is carried out, i.e. the amount is immediately transferred from the customer's account to the shop's account. This function can only be utilized in the event that there is no actual physical delivery of any items. Contact DIBS when using this function. (Note that instant capture requires unique order numbers - also see the description of uniqueoid above).
$dibsParams['ip'] = ''; // optional - DIBS retains the IP-number from which a card transaction is carried out. The IP-number is used for �fraud control�, etc. Some implementations may send the IP number of the shop to DIBS rather than that of the customer's machine. In order to provide the same services to shops which utilize such a program for their DIBS hookup, we offer the option of sending the "ip" parameter.
$dibsParams['paytype'] = ''; // optional - Regarding the start-up of the DIBS FlexWin, the user can be limited to the use of just one particular payment form. This is accomplished by using the parameter "paytype". This function can be used if you wish for example to use integration method 3 for payment cards and method 1 for eDankort. Furthermore, this function can be used if you wish to control the user's selections of method of payment from your own website. You can also specify a list of payment methods that will be shown in the Flexwin. This list should be a comma separated with no spaces in between. Example: See our list of possible paytypes.
$dibsParams['maketicket'] = ''; // optional - This parameter is intended for FlexWin, and actually performs two transactions. First it performs a regular authorisation. If, and only if, it is accepted, it is followed by a ticket registration. Both a transaction and a ticket value are returned to "accepturl" if it is specified. If "callbackurl" is specified, DIBS will perform two separate calls, corresponding to performing two transactions - one call to the regular authorisation, and another to the ticket registration. Both cases return a "transact" parameter value (e.g. transact="78901234"). In calls to "callbackurl" containing "preauth", the ticket value is composed of the "transact" parameter value. "maketicket" implicitly sets the "preauth" parameter - however, you should avoid to explicitly specify any "preauth" parameter. You cannot use "uniqueoid", "capturenow" or "md5key" along with "maketicket". Currently "maketicket" does not work with 3Dsecure.
$dibsParams['postype'] = ''; // optional - "postype" (one 't') is used when one wishes to register the transaction origin. For normal internet transaction it is not required to include "postype", as it is automatically set to SSL. Possible values are: ssl = internet transactions, magnetic = magnetic stripe read, and signature is available, magnosig = magnetic stripe read, and no signature is available, mail = mail order, manual = manually entered, phone = phone order, signature = card and signature available, manually entered.
$dibsParams['ticketrule'] = ''; // optional - Set the value of this parameter to the same as defined by you in DIBS Admin.
$dibsParams['preauth'] = ''; // optional - When preauth=true is sent as part of the request to auth.cgi the DIBS server identifies the authorisation as a ticket authorisation rather than a normal transaction. Please note that the pre-authorised transaction is NOT available among the transactions in the DIBS administration interface. When using MD5 the Authkey must be calculated from the string transact=12345678&preauth=true¤cy=123
// @todo Since Prestashop manage vouchers, ask if necessary to use this params
$dibsParams['voucher'] = ''; // optional - If set to "yes", then the list of payment types on the first page of FlexWin will contain vouchers, too. If FlexWin is called with a paytype, which would lead directly to the payment form, the customer is given the choice of entering a voucher code first.
$dibsParams['split'] = ''; // optional - "split" is used for splitting up a transaction into two or more sub-transactions. This enables part of an order to be paid for when shipped in part. It requires that the amount and currency of the part payments are known at the time of the order, and are posted to the DIBS server as: split=2&amount1=&amount2=
// to erase optional params which are not filled
$dibsParams = array_filter($dibsParams);
/* Order Information as "complex model" :
* -------------------------------------- */
// delivery params
$dibsParams['delivery1.Name'] = $address->firstname.' '.$address->lastname;
$dibsParams['delivery2.Address'] = $address->address1;
$dibsParams['delivery3.Address2'] = $address->address2;
$dibsParams['delivery4.Postcode'] = $address->postcode;
$dibsParams['delivery5.City'] = $address->city;
$dibsParams['delivery6.Comment'] = $address->other;
$dibsParams['delivery7.Phone'] = $address->phone;
$dibsParams['delivery8.Company'] = $address->company;
// order line (product list)
$dibsParams['ordline0-1'] = 'Product ref / Product Id';
$dibsParams['ordline0-2'] = 'Name';
$dibsParams['ordline0-3'] = 'Description';
$dibsParams['ordline0-4'] = 'Unit price with tax';
$dibsParams['ordline0-5'] = 'Total price with tax';
$dibsParams['ordline0-6'] = 'Quantity';
$dibsParams['ordline0-7'] = 'Weight';
$dibsParams['ordline0-8'] = 'ecotax';
$count_products = 1;
foreach ($products as $key => $product)
{
$dibsParams['ordline'.$count_products.'-1'] = 'ref.'.($product['reference'] != '' ? $product['reference'] : 'NC' ).'/id.'.$product['id_product'];
$dibsParams['ordline'.$count_products.'-2'] = $product['name'];
$dibsParams['ordline'.$count_products.'-3'] = strip_tags($product['description_short']);
$dibsParams['ordline'.$count_products.'-4'] = $product['price_wt'];
$dibsParams['ordline'.$count_products.'-5'] = $product['total_wt'];
$dibsParams['ordline'.$count_products.'-6'] = $product['cart_quantity'];
$dibsParams['ordline'.$count_products.'-7'] = $product['weight'];
$dibsParams['ordline'.$count_products.'-8'] = $product['ecotax'];
$count_products++;
}
// Price info
$dibsParams['priceinfo1.Deliverycosts'] = $params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING);
$dibsParams['priceinfo2.ProductsAmount'] = $params['cart']->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
$dibsParams['priceinfo3.AmountWithoutTax'] = $params['cart']->getOrderTotal(false, Cart::BOTH);
$dibsParams['priceinfo4.AmountTotalTax'] = (float)($params['cart']->getOrderTotal(true, Cart::BOTH) - $params['cart']->getOrderTotal(false, Cart::BOTH));
$this->smarty->assign('p', $dibsParams);
$this->smarty->assign('logo_color', self::$MORE_SETTINGS['logo_color']);
return $this->display(__FILE__, 'dibs.tpl');
}
}