PageRenderTime 209ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/vmpayment/heidelpay/heidelpay/heidelpay_response.php

https://bitbucket.org/isaacoheneayisi/ecommerce
PHP | 190 lines | 163 code | 17 blank | 10 comment | 33 complexity | f10dfab6f6719190b62a0fc88fce0a69 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Heidelpay response page for Heidelpay plugin
  4. * @author Heidelberger Paymenrt GmbH <Jens Richter>
  5. * @version 13.07
  6. * @package VirtueMart
  7. * @subpackage payment
  8. * @copyright Copyright (C) Heidelberger Payment GmbH
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  10. */
  11. include('../../../../configuration.php');
  12. $config = new JConfig();
  13. //echo $config->password ;
  14. foreach ($_POST as $key => $value) {
  15. $key = preg_replace('/_x$/', '', trim($key));
  16. $_POST[$key] = $value;
  17. }
  18. foreach ($_GET as $key => $value) {
  19. $key = preg_replace('/_x$/', '', trim($key));
  20. $_GET[$key] = $value;
  21. }
  22. if ( $_SERVER['SERVER_PORT'] == "443" ) {
  23. $Protocol = "https://";
  24. } else {
  25. $Protocol = "http://";
  26. }
  27. $PATH = preg_replace('@plugins\/vmpayment\/heidelpay\/heidelpay\/heidelpay_response\.php@','', $_SERVER['SCRIPT_NAME']);
  28. $URL = $_SERVER['HTTP_HOST'] . $PATH ;
  29. $redirectURL = $Protocol.$URL.'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on='.$_GET['on'].'&pm='.$_GET['pm'].'&Itemid='.$_GET['Itemid'];
  30. $cancelURL = $Protocol.$URL.'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on='.$_GET['on'].'&pm='.$_GET['pm'].'&Itemid='.$_GET['Itemid'];
  31. function updateHeidelpay($orderID, $connect) {
  32. $comment="";
  33. if ( preg_match('/^[A-Za-z0-9 -]+$/', $orderID , $str)) {
  34. $link = mysql_connect($connect->host, $connect->user , $connect->password);
  35. mysql_set_charset('utf8',$link);
  36. mysql_select_db($connect->db);
  37. $result = mysql_query("SELECT virtuemart_order_id FROM ".$connect->dbprefix."virtuemart_orders"." WHERE order_number = '".mysql_real_escape_string($orderID)."';");
  38. $row = mysql_fetch_object($result);
  39. $paymentCode = explode('.' , $_POST['PAYMENT_CODE']);
  40. if ($_POST['PROCESSING_RESULT'] == "NOK") {
  41. $comment = $_POST['PROCESSING_RETURN'];
  42. } elseif ($paymentCode[0] == "PP" or $paymentCode[0] == "IV") {
  43. if($_POST['ACCOUNT_BRAND'] == 'BILLSAFE'){
  44. if (strtoupper ($_POST['CRITERION_LANG']) == 'DE') {
  45. $comment = '<b>Bitte &uuml;berweisen Sie uns den Betrag von '.$_POST['CRITERION_BILLSAFE_CURRENCY'].' '.sprintf('%1.2f', $_POST['CRITERION_BILLSAFE_AMOUNT']).' auf folgendes Konto:</b>
  46. <br /><br/>
  47. Kontoinhaber : '.$_POST['CRITERION_BILLSAFE_RECIPIENT'].'<br />
  48. Konto-Nr. : '.$_POST['CRITERION_BILLSAFE_ACCOUNTNUMBER'].'<br />
  49. Bankleitzahl: '.$_POST['CRITERION_BILLSAFE_BANKCODE'].'<br />
  50. Bank: '.$_POST['CRITERION_BILLSAFE_BANKNAME'].'<br />
  51. IBAN: '.$_POST['CRITERION_BILLSAFE_IBAN'].'<br />
  52. BIC: '.$_POST['CRITERION_BILLSAFE_BIC'].'<br />
  53. <br />
  54. <b>Geben sie bitte im Verwendungszweck UNBEDINGT die Identifikationsnummer<br />
  55. '.$_POST['CRITERION_BILLSAFE_REFERENCE'].'<br />
  56. und NICHTS ANDERES an.</b><br /><br/>'.
  57. $_POST['CRITERION_BILLSAFE_LEGALNOTE'].'<br />
  58. Bitte &uuml;berweisen Sie den ausstehenden Betrag '.$_POST['CRITERION_BILLSAFE_PERIOD'].' Tage nach dem Sie &uuml;ber den Versand informiert wurden.';
  59. } else {
  60. $comment = '<b>Please transfer the amount of '.$_POST['CRITERION_BILLSAFE_CURRENCY'].' '.sprintf('%1.2f', $_POST['CRITERION_BILLSAFE_AMOUNT']).' to the following account:</b>
  61. <br /><br/>
  62. Account holder: '.$_POST['CRITERION_BILLSAFE_RECIPIENT'].'<br />
  63. Account No.: '.$_POST['CRITERION_BILLSAFE_ACCOUNTNUMBER'].'<br />
  64. Bank Code: '.$_POST['CRITERION_BILLSAFE_BANKCODE'].'<br />
  65. Bank: '.$_POST['CRITERION_BILLSAFE_BANKNAME'].'<br />
  66. IBAN: '.$_POST['CRITERION_BILLSAFE_IBAN'].'<br />
  67. BIC: '.$_POST['CRITERION_BILLSAFE_BIC'].'<br />
  68. <br />
  69. <b>When you transfer the money you HAVE TO use the identification number<br />
  70. '.$_POST['CRITERION_BILLSAFE_REFERENCE'].'<br />
  71. as the descriptor and nothing else. Otherwise we cannot match your transaction!</b><br /><br />'.
  72. $_POST['CRITERION_BILLSAFE_LEGALNOTE'].'<br />
  73. Please remit the outstanding amount '.$_POST['CRITERION_BILLSAFE_PERIOD'].' days after you have been notified about shipping';
  74. }
  75. }else{
  76. if (strtoupper ($_POST['CRITERION_LANG']) == 'DE') {
  77. $comment = '<b>Bitte &uuml;berweisen Sie uns den Betrag von '.$_POST['CLEARING_CURRENCY'].' '.$_POST['PRESENTATION_AMOUNT'].' auf folgendes Konto:</b>
  78. <br /><br/>
  79. Land : '.$_POST['CONNECTOR_ACCOUNT_COUNTRY'].'<br />
  80. Kontoinhaber : '.$_POST['CONNECTOR_ACCOUNT_HOLDER'].'<br />
  81. Konto-Nr. : '.$_POST['CONNECTOR_ACCOUNT_NUMBER'].'<br />
  82. Bankleitzahl: '.$_POST['CONNECTOR_ACCOUNT_BANK'].'<br />
  83. IBAN: '.$_POST['CONNECTOR_ACCOUNT_IBAN'].'<br />
  84. BIC: '.$_POST['CONNECTOR_ACCOUNT_BIC'].'<br />
  85. <br />
  86. <b>Geben sie bitte im Verwendungszweck UNBEDINGT die Identifikationsnummer<br />
  87. '.$_POST['IDENTIFICATION_SHORTID'].'<br />
  88. und NICHTS ANDERES an.</b><br />';
  89. } else {
  90. $comment = '<b>Please transfer the amount of '.$_POST['CLEARING_CURRENCY'].' '.$_POST['PRESENTATION_AMOUNT'].' to the following account:</b>
  91. <br /><br/>
  92. Country: '.$_POST['CONNECTOR_ACCOUNT_COUNTRY'].'<br />
  93. Account holder: '.$_POST['CONNECTOR_ACCOUNT_HOLDER'].'<br />
  94. Account No.: '.$_POST['CONNECTOR_ACCOUNT_NUMBER'].'<br />
  95. Bank Code: '.$_POST['CONNECTOR_ACCOUNT_BANK'].'<br />
  96. IBAN: '.$_POST['CONNECTOR_ACCOUNT_IBAN'].'<br />
  97. BIC: '.$_POST['CONNECTOR_ACCOUNT_BIC'].'<br />
  98. <br />
  99. <b>When you transfer the money you HAVE TO use the identification number<br />
  100. '.$_POST['IDENTIFICATION_SHORTID'].'<br />
  101. as the descriptor and nothing else. Otherwise we cannot match your transaction!</b><br />';
  102. }
  103. }
  104. if($_POST['ACCOUNT_BRAND'] == 'BARPAY'){
  105. $comment = '(-'.$_POST['CRITERION_BARPAY_PAYCODE_URL'].'-)
  106. </b><br />
  107. </b><br />
  108. Drucken Sie den Barcode aus oder speichern Sie diesen auf Ihrem mobilen Endger&auml;t.
  109. Gehen Sie nun zu einer Kasse der 18.000 Akzeptanzstellen in Deutschland und bezahlen
  110. Sie ganz einfach in bar. In dem Augenblick, wenn der Rechnungsbetrag beglichen wird,
  111. erh&auml;lt der Online-H&auml;ndler die Information &uuml;ber den Zahlungseingang.Die bestellte Ware
  112. oder Dienstleistung geht umgehend in den Versand';
  113. }
  114. }elseif($paymentCode[0] == "DD"){
  115. if(strtoupper ($_POST['CRITERION_LANG']) == 'DE'){
  116. $identCreditor = '';
  117. if($_POST['IDENTIFICATION_CREDITOR_ID'] != ''){
  118. $identCreditor = 'und die Gl&auml;ubiger ID: '.$_POST['IDENTIFICATION_CREDITOR_ID'].'<br />';
  119. }
  120. $comment = 'Der Betrag wird in den n&auml;chsten Tagen von folgendem Konto abgebucht:<br /><br />
  121. IBAN: '.$_POST['ACCOUNT_IBAN'].'<br />
  122. BIC: '.$_POST['ACCOUNT_BIC'].'<br />
  123. Die Abbuchung enth&auml;lt die Mandatsreferenz-ID: '.$_POST['ACCOUNT_IDENTIFICATION'].'<br />
  124. '.$identCreditor.'
  125. <br />Bitte sorgen Sie f&uuml;r ausreichende Deckung auf dem entsprechenden Konto.';
  126. }else{
  127. $identCreditor = '';
  128. if($_POST['IDENTIFICATION_CREDITOR_ID'] != ''){
  129. $identCreditor = 'and the creditor identifier: '.$_POST['IDENTIFICATION_CREDITOR_ID'].'<br />';
  130. }
  131. $comment = 'The amount will be debited from this account within the next days:<br /><br />
  132. IBAN: '.$_POST['ACCOUNT_IBAN'].'<br />
  133. BIC: '.$_POST['ACCOUNT_BIC'].'<br />
  134. The booking contains the mandate reference ID: '.$_POST['ACCOUNT_IDENTIFICATION'].'<br />
  135. '.$identCreditor.'
  136. <br />Please ensure that there will be sufficient funds on the corresponding account.';
  137. }
  138. }
  139. if (!empty($row->virtuemart_order_id)) {
  140. $sql = "INSERT ".$connect->dbprefix."virtuemart_payment_plg_heidelpay SET " .
  141. "virtuemart_order_id = \"".mysql_real_escape_string($row->virtuemart_order_id). "\"," .
  142. "order_number = \"".mysql_real_escape_string($_GET['on']). "\"," .
  143. "virtuemart_paymentmethod_id = \"".mysql_real_escape_string($_GET['pm']). "\"," .
  144. "unique_id = \"".mysql_real_escape_string($_POST['IDENTIFICATION_UNIQUEID']). "\"," .
  145. "short_id = \"".mysql_real_escape_string($_POST['IDENTIFICATION_SHORTID']). "\"," .
  146. "payment_code = \"".mysql_real_escape_string($_POST['PROCESSING_REASON_CODE']). "\"," .
  147. "comment = \"".mysql_real_escape_string($comment). "\"," .
  148. "payment_methode = \"".mysql_real_escape_string($paymentCode[0]). "\"," .
  149. "payment_type = \"".mysql_real_escape_string($paymentCode[1]). "\"," .
  150. "transaction_mode = \"".mysql_real_escape_string($_POST['TRANSACTION_MODE']). "\"," .
  151. "payment_name = \"".mysql_real_escape_string($_POST['CRITERION_PAYMENT_NAME']). "\"," .
  152. "processing_result = \"".mysql_real_escape_string($_POST['PROCESSING_RESULT']). "\"," .
  153. "secret_hash = \"".mysql_real_escape_string($_POST['CRITERION_SECRET']). "\"," .
  154. "response_ip = \"".mysql_real_escape_string($_SERVER['REMOTE_ADDR']). "\";" ;
  155. $dbEerror = mysql_query($sql);
  156. }
  157. }
  158. }
  159. $returnvalue=$_POST['PROCESSING_RESULT'];
  160. if (!empty($returnvalue)){
  161. if (strstr($returnvalue,"ACK")) {
  162. print $redirectURL;
  163. updateHeidelpay($_POST['IDENTIFICATION_TRANSACTIONID'], $config);
  164. } else if ($_POST['FRONTEND_REQUEST_CANCELLED'] == 'true'){
  165. print $cancelURL ;
  166. } else {
  167. updateHeidelpay($_POST['IDENTIFICATION_TRANSACTIONID'], $config);
  168. print $redirectURL;
  169. }
  170. } else {
  171. echo 'FAIL';
  172. }
  173. ?>