Documentation TYPO3 par Ameos

payment_DIBS.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is 
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 * 
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license 
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 * 
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00041 if (!is_object($this) || !is_object($this->cObj))       die('$this and $this->cObj must be objects!');
00042 
00043 
00044 // $lConf = $this->basketExtra["payment."]["handleScript."];            // Loads the handleScript TypoScript into $lConf.
00045 $lConf = $conf;
00046 $localTemplateCode = $this->cObj->fileResource($lConf[templateFile] ? $lConf[templateFile] : "EXT:tt_products/pi/payment_DIBS_template.tmpl");          // Fetches the DIBS template file
00047 $localTemplateCode = $this->cObj->substituteMarkerArrayCached($localTemplateCode, $this->globalMarkerArray);
00048 
00049 $orderUid = $this->getBlankOrderUid();          // Gets an order number, creates a new order if no order is associated with the current session
00050 
00051 switch(t3lib_div::_GP("products_cmd"))  {
00052         case "cardno":
00053                 $tSubpart = $lConf["soloe"] ? "###DIBS_SOLOE_TEMPLATE###" : "###DIBS_CARDNO_TEMPLATE###";               // If solo-e is selected, use different subpart from template
00054                 $content=$this->getBasket($tSubpart,$localTemplateCode);                // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00055 
00056                 $markerArray=array();
00057                 $markerArray["###HIDDEN_FIELDS###"] = '
00058 <input type=hidden name=merchant value="'.$lConf["merchant"].'">
00059 <input type=hidden name=amount value="'.round($this->calculatedSums_tax["total"]*100).'">
00060 <input type=hidden name=currency value="'.$lConf["currency"].'">                <!--Valuta som angivet i ISO4217, danske kroner=208-->
00061 <input type=hidden name=orderid value="'.$this->getOrderNumber($orderUid).'">           <!--Butikkens ordrenummer der skal knyttes til denne transaktion-->
00062 <input type=hidden name=uniqueoid value="1">
00063 <input type=hidden name="accepturl" value="https://payment.architrade.com/cgi-ssl/relay.cgi/'.$lConf["relayURL"].'&products_cmd=accept&products_finalize=1&HTTP_COOKIE='.rawurlencode("fe_typo_user=".$GLOBALS["TSFE"]->fe_user->id).'">
00064 <input type=hidden name="declineurl" value="https://payment.architrade.com/cgi-ssl/relay.cgi/'.$lConf["relayURL"].'&products_cmd=decline&products_finalize=1&HTTP_COOKIE='.rawurlencode("fe_typo_user=".$GLOBALS["TSFE"]->fe_user->id).'">';    
00065                 if ($lConf["soloe"])    {
00066                 $markerArray["###HIDDEN_FIELDS###"].= '
00067 <input type=hidden name="cancelurl" value="https://payment.architrade.com/cgi-ssl/relay.cgi/'.$lConf["relayURL"].'&products_cmd=cancel&products_finalize=1&HTTP_COOKIE='.rawurlencode("fe_typo_user=".$GLOBALS["TSFE"]->fe_user->id).'">';
00068                 }
00069                 if ($lConf["test"])     {
00070                         $markerArray["###HIDDEN_FIELDS###"].= '
00071                                 <input type=hidden name=test value="foo">
00072                         ';
00073                 }
00074                 if ($lConf["cardType"] && !$lConf["soloe"])     {
00075                                 /*
00076                                 Examples:
00077                                         DK                      Dankort
00078                                         V-DK            Visa-Dankort
00079                                         MC(DK)          Mastercard/Eurocard udstedt i Danmark
00080                                         VISA            Visakort udstedt i udlandet
00081                                         MC                      Mastercard/Eurocard udstedt i udlandet
00082                                         DIN(DK)         Diners Club, Danmark
00083                                         DIN             Diners Club, international
00084                                 */
00085                 
00086                         $markerArray["###HIDDEN_FIELDS###"].= '
00087                                 <input type=hidden name=cardtype value="'.$lConf["cardType"].'">
00088                         ';
00089                 }
00090                 if ($lConf["account"])  {               // DIBS account feature
00091                         $markerArray["###HIDDEN_FIELDS###"].= '
00092                                 <input type=hidden name=account value="'.$lConf["account"].'">
00093                         ';
00094                 }
00095                 
00096                 
00097                                 // Adds order info to hiddenfields.
00098                 if ($lConf["addOrderInfo"])     {       
00099                         $theFields="";
00100                                 // Delivery info
00101                         reset($this->deliveryInfo);
00102                         $cc=0;
00103                         while(list($field,$value)=each($this->deliveryInfo))            {
00104                                 $value = trim($value);
00105                                 if ($value)     {
00106                                         $cc++;
00107                                         $theFields.=chr(10).'<input type=hidden name="delivery'.$cc.'.'.$field.'" value="'.htmlspecialchars($value).'">';
00108                                 }
00109                         }
00110                         
00111                                 // Order items
00112                         reset($this->calculatedBasket);
00113                         $theFields.='
00114 <input type=hidden name="ordline1-1" value="Varenummer">
00115 <input type=hidden name="ordline1-2" value="Beskrivelse">
00116 <input type=hidden name="ordline1-3" value="Antal">
00117 <input type=hidden name="ordline1-4" value="Pris">
00118 ';                              
00119                         $cc=1;
00120                         while(list(,$rec)=each($this->calculatedBasket))                {
00121                                 $cc++;
00122                                 $theFields.='
00123 <input type=hidden name="ordline'.$cc.'-1" value="'.htmlspecialchars($rec["rec"]["itemnumber"]).'">
00124 <input type=hidden name="ordline'.$cc.'-2" value="'.htmlspecialchars($rec["rec"]["title"]).'">
00125 <input type=hidden name="ordline'.$cc.'-3" value="'.$rec["count"].'">
00126 <input type=hidden name="ordline'.$cc.'-4" value="'.$this->priceFormat($rec["totalTax"]).'">';
00127                         }
00128                 
00129                         $theFields.='
00130 <input type=hidden name="priceinfo1.Shipping" value="'.$this->priceFormat($this->calculatedSums_tax["shipping"]).'">';
00131                         $theFields.='
00132 <input type=hidden name="priceinfo2.Payment" value="'.$this->priceFormat($this->calculatedSums_tax["payment"]).'">';
00133                         $theFields.='
00134 <input type=hidden name="priceinfo3.Tax" value="'.$this->priceFormat($this->calculatedSums_tax["total"]-$this->calculatedSums_no_tax["total"]).'">';
00135                         $markerArray["###HIDDEN_FIELDS###"].=$theFields;
00136                 }
00137                 $content= $this->cObj->substituteMarkerArrayCached($content, $markerArray);
00138         break;          
00139         case "decline":
00140                 $markerArray=array();
00141                 $markerArray["###REASON_CODE###"] = t3lib_div::_GP("reason");
00142                 $content=$this->getBasket("###DIBS_DECLINE_TEMPLATE###",$localTemplateCode, $markerArray);              // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00143         break;
00144         case "cancel":
00145                 $content=$this->getBasket("###DIBS_SOLOE_CANCEL_TEMPLATE###",$localTemplateCode, $markerArray);         // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00146         break;
00147         case "accept":
00148                 $content=$this->getBasket("###DIBS_ACCEPT_TEMPLATE###",$localTemplateCode);             // This is just done to calculate stuff
00149 
00150                         // DIBS md5 keys
00151                 $k1=$lConf["k1"];
00152                 $k2=$lConf["k2"];
00153         
00154                         // Checking transaction
00155                 $amount=round($this->calculatedSums_tax["total"]*100);
00156                 $currency="208";
00157                 $transact=t3lib_div::_GP("transact");
00158                 $md5key= md5($k2.md5($k1."transact=".$transact."&amount=".$amount."&currency=".$currency));
00159                 $authkey=t3lib_div::_GP("authkey");
00160                 if ($md5key != $authkey)        {
00161                         $content=$this->getBasket("###DIBS_DECLINE_MD5_TEMPLATE###",$localTemplateCode);                // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00162                 } elseif (t3lib_div::_GP("orderid")!=$this->getOrderNumber($orderUid)) {
00163                         $content=$this->getBasket("###DIBS_DECLINE_ORDERID_TEMPLATE###",$localTemplateCode);            // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00164                 } else {
00165                         $markerArray=array();
00166                         $markerArray["###TRANSACT_CODE###"] = t3lib_div::_GP("transact");
00167 
00168                         $content=$this->getBasket("###BASKET_ORDERCONFIRMATION_TEMPLATE###","",$markerArray);
00169                         $this->finalizeOrder($orderUid,$markerArray);   // Important: finalizeOrder MUST come after the call of prodObj->getBasket, because this function, getBasket, calculates the order! And that information is used in the finalize-function
00170                 }
00171 /*
00172                 debug($md5key,1);
00173                 debug($authkey,1);
00174                 debug("transact");
00175                 debug(t3lib_div::_GP("transact"));
00176                 debug($GLOBALS["TSFE"]->fe_user->id);
00177 //                              echo phpinfo(); 
00178 */
00179         break;
00180         default:        
00181                 if ($lConf["relayURL"]) {
00182                         $markerArray=array();
00183                         $markerArray["###REDIRECT_URL###"] = 'https://payment.architrade.com/cgi-ssl/relay.cgi/'.$lConf["relayURL"].'&products_cmd=cardno&products_finalize=1&HTTP_COOKIE='.rawurlencode("fe_typo_user=".$GLOBALS["TSFE"]->fe_user->id);
00184                         $content=$this->getBasket("###DIBS_REDIRECT_TEMPLATE###",$localTemplateCode, $markerArray);             // This not only gets the output but also calculates the basket total, so it's NECESSARY!
00185                 } else {
00186                         $content = "NO .relayURL given!!";
00187                 }
00188         break;
00189 }
00190 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6