/[drupal]/contributions/modules/uc_turkish_banks/uc_turkish_banks.module
ViewVC logotype

Diff of /contributions/modules/uc_turkish_banks/uc_turkish_banks.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Sun Jun 22 15:14:09 2008 UTC revision 1.3, Sun Jun 22 18:46:51 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: uc_turkish_banks.module,v 1.1 2008/06/22 08:50:09 bakyildiz Exp $  // $Id: uc_turkish_banks.module,v 1.2 2008/06/22 15:14:09 bakyildiz Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 7  Line 7 
7   *   *
8   * A module used to process payments using Banks in Turkey. Currently uses the EST e-secure payment service. This module currently supports instalments and as a paymant method uses 3D Secure OOS PAY.   * A module used to process payments using Banks in Turkey. Currently uses the EST e-secure payment service. This module currently supports instalments and as a paymant method uses 3D Secure OOS PAY.
9   *   *
10   *Türk Bankalari için ödeme eklentisidir. EST Güvenli e-ödeme servisi kullanmaktadir. Taksitli satisi desteklemektedir. Satis yöntemi olarak 3D Secure OOS PAY metodunu kullanmaktadir.   * Türk Bankalari için ödeme eklentisidir. EST Güvenli e-ödeme servisi kullanmaktadir. Taksitli satisi desteklemektedir. Satis yöntemi olarak 3D Secure OOS PAY metodunu kullanmaktadir.
11   *   *
12   *Support the following banks/ Asagidaki bankalar desteklenmektedir.   * Support the following banks / Asagidaki bankalar desteklenmektedir.
13   *   *
14   * 1. Is Bankasi   * 1. Is Bankasi
15   * 2. Akbank   * 2. Akbank
# Line 23  Line 23 
23   * 10. Denizbank   * 10. Denizbank
24   */   */
25    
26   /**  /**
27   * Implementation of hook_menu().   * Implementation of hook_menu().
28   */   */
29  function uc_turkish_banks_menu($may_cache) {  function uc_turkish_banks_menu($may_cache) {
# Line 54  function uc_turkish_banks_menu($may_cach Line 54  function uc_turkish_banks_menu($may_cach
54        'type' => MENU_DEFAULT_LOCAL_TASK,        'type' => MENU_DEFAULT_LOCAL_TASK,
55      );      );
56    
57       $items[] = array(      $items[] = array(
58            'path' => 'admin/store/settings/banks/add',            'path' => 'admin/store/settings/banks/add',
59            'title' => t('Add New Bank'),            'title' => t('Add New Bank'),
60            'description' => t('Add a New Bank'),            'description' => t('Add a New Bank'),
# Line 395  function uc_turkish_banks_add_form($acti Line 395  function uc_turkish_banks_add_form($acti
395        '#weight' => 21,        '#weight' => 21,
396      );      );
397      return $form;      return $form;
   
398  }  }
399    
400  /**  /**
# Line 434  function uc_turkish_banks_add_form_submi Line 433  function uc_turkish_banks_add_form_submi
433    else {    else {
434      // Otherwise we try to update the coupon with matching coupon id      // Otherwise we try to update the coupon with matching coupon id
435            if (db_query("UPDATE {uc_turkish_banks} SET bankname = '%s', clientid = '%s',username = '%s',password = '%s',bankurl = '%s',storekey = '%s',processtype = '%s',cardname = '%s',valid_until = %d WHERE cid = %d",            if (db_query("UPDATE {uc_turkish_banks} SET bankname = '%s', clientid = '%s',username = '%s',password = '%s',bankurl = '%s',storekey = '%s',processtype = '%s',cardname = '%s',valid_until = %d WHERE cid = %d",
436                   $form['bankname'],$form['clientid'],$form['username'],$form['password'],$form['bankurl'],$form['storekey'],$form['processtype'],$form['cardname'],$valid_until,$form['cid']))                   $form['bankname'],$form['clientid'],$form['username'],$form['password'],$form['bankurl'],$form['storekey'],$form['processtype'],$form['cardname'],$valid_until,$form['cid'])) {
     {  
437        $message = "Bank updated succssfully";        $message = "Bank updated succssfully";
438            }            }
439            else {            else {
# Line 461  function uc_turkish_banks_load($cid) { Line 459  function uc_turkish_banks_load($cid) {
459  /**  /**
460   * Delete confirm   * Delete confirm
461   */   */
   
462  function uc_turkish_banks_delete_confirm($cid) {  function uc_turkish_banks_delete_confirm($cid) {
463   $form['cid'] = array('#type' => 'value', '#value' => $cid);   $form['cid'] = array('#type' => 'value', '#value' => $cid);
464    return confirm_form($form,    return confirm_form($form,
# Line 489  function uc_turkish_banks_delete_confirm Line 486  function uc_turkish_banks_delete_confirm
486    
487  // BURASI MUALLAK BAKILACAK....  // BURASI MUALLAK BAKILACAK....
488  function uc_turkish_banks_order($op, $arg1, $arg2) {  function uc_turkish_banks_order($op, $arg1, $arg2) {
489    switch($op) {    switch ($op) {
490          case 'save':          case 'save':
491            list($bank_temp,$amount_temp,$bank_cid,$taksit)=explode('|', $_SESSION['taksit']);            list($bank_temp,$amount_temp,$bank_cid,$taksit)=explode('|', $_SESSION['taksit']);
492            //print "TEST:".$_SESSION['bank_cid'].' '. $bank.' '.$amount ;            //print "TEST:".$_SESSION['bank_cid'].' '. $bank.' '.$amount ;
# Line 513  function uc_turkish_banks_order($op, $ar Line 510  function uc_turkish_banks_order($op, $ar
510          }          }
511  }  }
512    
513   /**  /**
514   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
515   */   */
516  function uc_turkish_banks_form_alter($form_id, &$form) {  function uc_turkish_banks_form_alter($form_id, &$form) {
# Line 526  function uc_turkish_banks_form_alter($fo Line 523  function uc_turkish_banks_form_alter($fo
523        $form['#suffix'] = '</td><td>'. drupal_get_form('uc_turkish_banks_form', $order) .'</td></tr></table>';        $form['#suffix'] = '</td><td>'. drupal_get_form('uc_turkish_banks_form', $order) .'</td></tr></table>';
524      }      }
525    }    }
526    if ($form_id == 'uc_cart_checkout_form'){    if ($form_id == 'uc_cart_checkout_form') {
527      drupal_add_js(drupal_get_path('module', 'uc_turkish_banks') .'/uc_turkish_banks.js');      drupal_add_js(drupal_get_path('module', 'uc_turkish_banks') .'/uc_turkish_banks.js');
528    }    }
529  }  }
# Line 575  function uc_line_item_instalment($op, $a Line 572  function uc_line_item_instalment($op, $a
572  }  }
573    
574    
575   /**  /**
576   * Implementation of hook_payment_method().   * Implementation of hook_payment_method().
577   */   */
578  function uc_turkish_banks_payment_method() {  function uc_turkish_banks_payment_method() {
# Line 597  function uc_turkish_banks_payment_method Line 594  function uc_turkish_banks_payment_method
594    
595    return $methods;    return $methods;
596  }  }
597    
   
   
   
598  /*******************************************************************************  /*******************************************************************************
599   * Callback Functions, Forms, and Tables   * Callback Functions, Forms, and Tables
600   ******************************************************************************/   ******************************************************************************/
# Line 809  function uc_turkish_banks_complete($cart Line 803  function uc_turkish_banks_complete($cart
803    $index1=0;    $index1=0;
804    $index2=0;    $index2=0;
805    
806    while($index1 < strlen($hashparams))    while ($index1 < strlen($hashparams)) {
   {  
807      $index2 = strpos($hashparams,":",$index1);      $index2 = strpos($hashparams,":",$index1);
808      $vl = $_POST[substr($hashparams,$index1,$index2- $index1)];      $vl = $_POST[substr($hashparams,$index1,$index2- $index1)];
809      if($vl == null)      if ($vl == NULL) {
810        $vl = "";        $vl = "";
811        }
812      $paramsval = $paramsval . $vl;      $paramsval = $paramsval . $vl;
813      $index1 = $index2 + 1;      $index1 = $index2 + 1;
814    }    }
# Line 848  function uc_turkish_banks_complete($cart Line 842  function uc_turkish_banks_complete($cart
842      drupal_goto('cart/checkout/review');      drupal_goto('cart/checkout/review');
843    }    }
844  }  }
   
845    
846  /*******************************************************************************  /*******************************************************************************
847   * Hook Functions (Ubercart)   * Hook Functions (Ubercart)
# Line 866  function uc_turkish_banks_payment_gatewa Line 859  function uc_turkish_banks_payment_gatewa
859    return $gateways;    return $gateways;
860  }  }
861    
   
862  /*******************************************************************************  /*******************************************************************************
863   * Callback Functions, Forms, and Tables   * Callback Functions, Forms, and Tables
864   ******************************************************************************/   ******************************************************************************/
# Line 922  function uc_turkish_banks_settings_form( Line 914  function uc_turkish_banks_settings_form(
914  }  }
915    
916  function uc_turkish_banks_charge($order_id, $amount, $data) {  function uc_turkish_banks_charge($order_id, $amount, $data) {
   
   
   
917    if (!function_exists('curl_init')) {    if (!function_exists('curl_init')) {
918      drupal_set_message(t('The Garanti Bank service requires cURL.  Please talk to your system administrator to get this configured.'));      drupal_set_message(t('The Garanti Bank service requires cURL.  Please talk to your system administrator to get this configured.'));
919      return array('success' => FALSE);      return array('success' => FALSE);
920    }    }
921    
922      // XML request sablonu
  // XML request sablonu  
923          $request= "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>".          $request= "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>".
924          "<CC5Request>".          "<CC5Request>".
925          "<Name>{NAME}</Name>".          "<Name>{NAME}</Name>".
# Line 1023  function uc_turkish_banks_charge($order_ Line 1011  function uc_turkish_banks_charge($order_
1011    }    }
1012    curl_close($ch);    curl_close($ch);
1013    
   
1014    $Response ="";    $Response ="";
1015    $OrderId ="";    $OrderId ="";
1016    $AuthCode  ="";    $AuthCode  ="";
# Line 1032  function uc_turkish_banks_charge($order_ Line 1019  function uc_turkish_banks_charge($order_
1019    $HOSTMSG  ="";    $HOSTMSG  ="";
1020    
1021    $response_tag="Response";    $response_tag="Response";
1022    $posf = strpos (  $result, ("<" . $response_tag . ">") );    $posf = strpos($result, "<". $response_tag .">");
1023    $posl = strpos (  $result, ("</" . $response_tag . ">") ) ;    $posl = strpos($result, "</". $response_tag .">");
1024    $posf = $posf+ strlen($response_tag) +2 ;    $posf = $posf+ strlen($response_tag) +2 ;
1025    $Response = substr (  $result, $posf, $posl - $posf) ;    $Response = substr($result, $posf, $posl - $posf);
1026    
1027    $response_tag="OrderId";    $response_tag="OrderId";
1028    $posf = strpos (  $result, ("<" . $response_tag . ">") );    $posf = strpos($result, "<". $response_tag .">");
1029    $posl = strpos (  $result, ("</" . $response_tag . ">") ) ;    $posl = strpos($result, "</". $response_tag .">");
1030    $posf = $posf+ strlen($response_tag) +2 ;    $posf = $posf+ strlen($response_tag) +2;
1031    $OrderId = substr (  $result, $posf , $posl - $posf   ) ;    $OrderId = substr($result, $posf, $posl - $posf);
1032    
1033    $response_tag="AuthCode";    $response_tag="AuthCode";
1034    $posf = strpos (  $result, "<" . $response_tag . ">" );    $posf = strpos($result, "<". $response_tag .">");
1035    $posl = strpos (  $result, "</" . $response_tag . ">" ) ;    $posl = strpos($result, "</". $response_tag .">");
1036    $posf = $posf+ strlen($response_tag) +2 ;    $posf = $posf+ strlen($response_tag) +2;
1037    $AuthCode = substr (  $result, $posf , $posl - $posf   ) ;    $AuthCode = substr($result, $posf, $posl - $posf);
1038    
1039    $response_tag="ProcReturnCode";    $response_tag="ProcReturnCode";
1040    $posf = strpos (  $result, "<" . $response_tag . ">" );    $posf = strpos($result, "<". $response_tag .">");
1041    $posl = strpos (  $result, "</" . $response_tag . ">" ) ;    $posl = strpos($result, "</". $response_tag .">");
1042    $posf = $posf+ strlen($response_tag) +2 ;    $posf = $posf+ strlen($response_tag) +2;
1043    $ProcReturnCode = substr (  $result, $posf , $posl - $posf   ) ;    $ProcReturnCode = substr($result, $posf, $posl - $posf);
1044    
1045    $response_tag="ErrMsg";    $response_tag="ErrMsg";
1046    $posf = strpos (  $result, "<" . $response_tag . ">" );    $posf = strpos($result, "<". $response_tag .">");
1047    $posl = strpos (  $result, "</" . $response_tag . ">" ) ;    $posl = strpos($result, "</". $response_tag .">");
1048    $posf = $posf+ strlen($response_tag) +2 ;    $posf = $posf+ strlen($response_tag) +2;
1049    $ErrMsg = substr (  $result, $posf , $posl - $posf   ) ;    $ErrMsg = substr($result, $posf, $posl - $posf);
   
1050    
1051    $x_response_code = $Response;    $x_response_code = $Response;
1052    $x_response_text = $ErrMsg;    $x_response_text = $ErrMsg;
1053    $x_approval_code = $AuthCode;    $x_approval_code = $AuthCode;
1054    
   
1055    if ($x_response_code != 'Approved') {    if ($x_response_code != 'Approved') {
1056      $message = t('Credit card declined: !amount', array('!amount' => uc_currency_format($amount)));      $message = t('Credit card declined: !amount', array('!amount' => uc_currency_format($amount)));
1057      $result = array(      $result = array(
# Line 1086  function uc_turkish_banks_charge($order_ Line 1071  function uc_turkish_banks_charge($order_
1071      );      );
1072    }    }
1073    
   
1074    uc_order_comment_save($order_id, $user->uid, $message, 'admin');    uc_order_comment_save($order_id, $user->uid, $message, 'admin');
   
1075    return $result;    return $result;
1076  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2