/[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.7, Mon Jun 23 04:57:36 2008 UTC revision 1.8, Tue Nov 11 19:29:24 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: uc_turkish_banks.module,v 1.6 2008/06/22 20:39:58 bakyildiz Exp $  // $Id: uc_turkish_banks.module,v 1.7 2008/06/23 04:57:36 bakyildiz Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 154  function uc_turkish_banks_instalments_di Line 154  function uc_turkish_banks_instalments_di
154    return $output;    return $output;
155  }  }
156    
157  function uc_turkish_banks_instalments_add_form($action, $cid = null) {  function uc_turkish_banks_instalments_add_form($action, $cid = NULL) {
158    $form['uc_turkish_banks_instalments'] = array('#type' => 'fieldset',    $form['uc_turkish_banks_instalments'] = array('#type' => 'fieldset',
159      '#title' => t('Instalments'),      '#title' => t('Instalments'),
160      '#collapsible' => true,      '#collapsible' => TRUE,
161      '#collapsed' => false,      '#collapsed' => FALSE,
162      '#weight' => 0,      '#weight' => 0,
163    );    );
164    $form['cid'] = array('#type' => 'value',    $form['cid'] = array('#type' => 'value',
# Line 170  function uc_turkish_banks_instalments_ad Line 170  function uc_turkish_banks_instalments_ad
170      '#default_value' => $value['instalment'],      '#default_value' => $value['instalment'],
171      '#size' => 3,      '#size' => 3,
172      '#weight' => -3,      '#weight' => -3,
173      '#required' => true,      '#required' => TRUE,
174    );    );
175    $form['uc_turkish_banks_instalments']['instalment_ratio'] = array('#type' => 'textfield',    $form['uc_turkish_banks_instalments']['instalment_ratio'] = array('#type' => 'textfield',
176      '#title' => t('Ratio'),      '#title' => t('Ratio'),
177      '#default_value' => $value['instalment_ratio'],      '#default_value' => $value['instalment_ratio'],
178      '#size' => 5,      '#size' => 5,
179      '#weight' => -2,      '#weight' => -2,
180      '#required' => true,      '#required' => TRUE,
181    );    );
182    $valid_until = getdate($value['valid_until']);    $valid_until = getdate($value['valid_until']);
183    $default_valid_until= array(    $default_valid_until= array(
# Line 284  function uc_turkish_banks_display() { Line 284  function uc_turkish_banks_display() {
284    
285    $header = array(array('data' => 'Bank Name', 'width' => '100'), 'Card Name', 'Valid Until', 'Ops');    $header = array(array('data' => 'Bank Name', 'width' => '100'), 'Card Name', 'Valid Until', 'Ops');
286    $output .= theme('table', $header, $rows, array('width' => '100%'));    $output .= theme('table', $header, $rows, array('width' => '100%'));
287    if ($output == null) {    if ($output == NULL) {
288      $output = "<p>There are currently no bank in the system.</p>";      $output = "<p>There are currently no bank in the system.</p>";
289    }    }
290    return $output;    return $output;
# Line 293  function uc_turkish_banks_display() { Line 293  function uc_turkish_banks_display() {
293  /**  /**
294   *  Form builder for product attributes.   *  Form builder for product attributes.
295   */   */
296  function uc_turkish_banks_add_form($action, $cid = null) {  function uc_turkish_banks_add_form($action, $cid = NULL) {
297    if ($action == 'edit') {    if ($action == 'edit') {
298      // If the action is edit, we load the coupon from the database with default values      // If the action is edit, we load the coupon from the database with default values
299      $value = uc_turkish_banks_load($cid);      $value = uc_turkish_banks_load($cid);
# Line 314  function uc_turkish_banks_add_form($acti Line 314  function uc_turkish_banks_add_form($acti
314    }    }
315    $form['bank'] = array('#type' => 'fieldset',    $form['bank'] = array('#type' => 'fieldset',
316      '#title' => t('Genel Tanimlar'),      '#title' => t('Genel Tanimlar'),
317      '#collapsible' => true,      '#collapsible' => TRUE,
318      '#collapsed' => false,      '#collapsed' => FALSE,
319      '#weight' => 0,      '#weight' => 0,
320    );    );
321    
# Line 324  function uc_turkish_banks_add_form($acti Line 324  function uc_turkish_banks_add_form($acti
324      '#default_value' => $value['bankname'],      '#default_value' => $value['bankname'],
325      '#size' => 30,      '#size' => 30,
326      '#weight' => -3,      '#weight' => -3,
327      '#required' => true,      '#required' => TRUE,
328    );    );
329    $form['bank']['clientid'] = array('#type' => 'textfield',    $form['bank']['clientid'] = array('#type' => 'textfield',
330      '#title' => t('Client Id'),      '#title' => t('Client Id'),
331      '#default_value' => $value['clientid'],      '#default_value' => $value['clientid'],
332      '#size' => 30,      '#size' => 30,
333      '#weight' => -2,      '#weight' => -2,
334      '#required' => true,      '#required' => TRUE,
335    );    );
336    $form['bank']['username'] = array('#type' => 'textfield',    $form['bank']['username'] = array('#type' => 'textfield',
337      '#title' => t('Username'),      '#title' => t('Username'),
338      '#default_value' => $value['username'],      '#default_value' => $value['username'],
339      '#size' => 20,      '#size' => 20,
340      '#weight' => -1,      '#weight' => -1,
341      '#required' => true,      '#required' => TRUE,
342    );    );
343    $form['bank']['password'] = array('#type' => 'textfield',    $form['bank']['password'] = array('#type' => 'textfield',
344      '#title' => t('Password'),      '#title' => t('Password'),
345      '#default_value' => $value['password'],      '#default_value' => $value['password'],
346      '#size' => 20,      '#size' => 20,
347      '#weight' => 0,      '#weight' => 0,
348      '#required' => true,      '#required' => TRUE,
349    );    );
350    $form['bank']['storekey'] = array('#type' => 'textfield',    $form['bank']['storekey'] = array('#type' => 'textfield',
351      '#title' => t('Store Key'),      '#title' => t('Store Key'),
352      '#default_value' => $value['storekey'],      '#default_value' => $value['storekey'],
353      '#size' => 20,      '#size' => 20,
354      '#weight' => 1,      '#weight' => 1,
355      '#required' => true,      '#required' => TRUE,
356    );    );
357    $form['bank']['bankurl'] = array('#type' => 'textfield',    $form['bank']['bankurl'] = array('#type' => 'textfield',
358      '#title' => t('Bank URL'),      '#title' => t('Bank URL'),
359      '#default_value' => $value['bankurl'],      '#default_value' => $value['bankurl'],
360      '#size' => 100,      '#size' => 100,
361      '#weight' => 1,      '#weight' => 1,
362      '#required' => true,      '#required' => TRUE,
363    );    );
364    $form['bank']['processtype'] = array('#type' => 'select',    $form['bank']['processtype'] = array('#type' => 'select',
365      '#title' => t('Process Type'),      '#title' => t('Process Type'),
# Line 370  function uc_turkish_banks_add_form($acti Line 370  function uc_turkish_banks_add_form($acti
370        'PreAuth' => t('PreAuth'),        'PreAuth' => t('PreAuth'),
371      ),      ),
372      '#weight' => 1,      '#weight' => 1,
373      '#required' => true,      '#required' => TRUE,
374    );    );
375    
376    $form['bank']['cardname'] = array('#type' => 'textfield',    $form['bank']['cardname'] = array('#type' => 'textfield',
# Line 378  function uc_turkish_banks_add_form($acti Line 378  function uc_turkish_banks_add_form($acti
378      '#default_value' => $value['cardname'],      '#default_value' => $value['cardname'],
379      '#size' => 30,      '#size' => 30,
380      '#weight' => 2,      '#weight' => 2,
381      '#required' => true,      '#required' => TRUE,
382    );    );
383    
384    $form['bank']['valid_until'] = array('#type' => 'select',    $form['bank']['valid_until'] = array('#type' => 'select',
# Line 424  function uc_turkish_banks_add_form_submi Line 424  function uc_turkish_banks_add_form_submi
424    if (!isset($form['cid'])) {    if (!isset($form['cid'])) {
425      if (db_query("INSERT INTO {uc_turkish_banks} (bankname, clientid, username, password, bankurl, storekey, processtype, cardname, valid_until)      if (db_query("INSERT INTO {uc_turkish_banks} (bankname, clientid, username, password, bankurl, storekey, processtype, cardname, valid_until)
426        VALUES ('%s','%s','%s','%s','%s','%s','%s','%s', '%d')",        VALUES ('%s','%s','%s','%s','%s','%s','%s','%s', '%d')",
427        $form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until))        $form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until)) {
     {  
428        $message = "New bank {$form['name']} added succesfully";        $message = "New bank {$form['name']} added succesfully";
429      }      }
430      else {      else {
# Line 435  function uc_turkish_banks_add_form_submi Line 434  function uc_turkish_banks_add_form_submi
434    else {    else {
435      // Otherwise we try to update the coupon with matching coupon id      // Otherwise we try to update the coupon with matching coupon id
436      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",
437        $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'])) {
     {  
438        $message = "Bank updated succssfully";        $message = "Bank updated succssfully";
439      }      }
440      else {      else {
# Line 663  function uc_payment_method_banks($op, &$ Line 661  function uc_payment_method_banks($op, &$
661                      if (x > 0)                      if (x > 0)
662                      {                      {
663                        for (i=temp.options.length-1;i>0;i--)                        for (i=temp.options.length-1;i>0;i--)
664                          temp.options[i]=null                          temp.options[i]=NULL
665                        for (k=0;k<group[x].length;k++)                        for (k=0;k<group[x].length;k++)
666                        {                        {
667                          temp.options[k]=new Option(group[x][k].text,group[x][k].value)                          temp.options[k]=new Option(group[x][k].text,group[x][k].value)
# Line 671  function uc_payment_method_banks($op, &$ Line 669  function uc_payment_method_banks($op, &$
669                      }                      }
670                      remove_line_item("instalment");                      remove_line_item("instalment");
671                      render_line_items();                      render_line_items();
672                      temp.options[0].selected=true                      temp.options[0].selected=TRUE
673                    }                    }
674                    //-->                    //-->
675                    </script>';                    </script>';
# Line 841  function uc_turkish_banks_complete($cart Line 839  function uc_turkish_banks_complete($cart
839  function uc_turkish_banks_payment_gateway() {  function uc_turkish_banks_payment_gateway() {
840    $gateways[] = array(    $gateways[] = array(
841      'id' => 'banks',      'id' => 'banks',
842      'title' => t('Garanti bankssi'),      'title' => t('Garanti Bank'),
843      'description' => t('Process credit card payments using Garanti bankssi'),      'description' => t('Process credit card payments using Garanti Bank Gateway'),
844      'settings' => 'uc_turkish_banks_settings_form',      'settings' => 'uc_turkish_banks_settings_form',
845      'credit' => 'uc_turkish_banks_charge',      'credit' => 'uc_turkish_banks_charge',
846    );    );
# Line 858  function uc_turkish_banks_payment_gatewa Line 856  function uc_turkish_banks_payment_gatewa
856   * Callback for payment gateway settings.   * Callback for payment gateway settings.
857   */   */
858  function uc_turkish_banks_settings_form() {  function uc_turkish_banks_settings_form() {
859    $form['banks_settings'] = array(    $form['bank']['bankname'] = array('#type' => 'textfield',
860      '#type' => 'fieldset',      '#title' => t('Bank Name'),
861      '#title' => t('Banka Ayarlari'),      '#default_value' => variable_get('bankname', ''),
862    );      '#size' => 30,
863    $form['banks_settings']['banks_settings_name'] = array(      '#weight' => -3,
864      '#type' => 'textfield',      '#required' => TRUE,
     '#title' => t('Name'),  
     '#default_value' => variable_get('banks_settings_name', ''),  
     '#description' => t('Sanal pos api kullanici adi.'),  
865    );    );
866    $form['banks_settings']['banks_settings_password'] = array(    $form['bank']['clientid'] = array('#type' => 'textfield',
867      '#type' => 'textfield',      '#title' => t('Client Id'),
868        '#default_value' => variable_get('clientid', ''),
869        '#size' => 30,
870        '#weight' => -2,
871        '#required' => TRUE,
872      );
873      $form['bank']['username'] = array('#type' => 'textfield',
874        '#title' => t('Username'),
875        '#default_value' => variable_get('username', ''),
876        '#size' => 20,
877        '#weight' => -1,
878        '#required' => TRUE,
879      );
880      $form['bank']['password'] = array('#type' => 'textfield',
881      '#title' => t('Password'),      '#title' => t('Password'),
882      '#default_value' => variable_get('banks_settings_password', ''),      '#default_value' => variable_get('password', ''),
883      '#description' => t('Sanal pos api kullanicisi sifresi.'),      '#size' => 20,
884        '#weight' => 0,
885        '#required' => TRUE,
886    );    );
887    $form['banks_settings']['banks_settings_clientid'] = array(    $form['bank']['storekey'] = array('#type' => 'textfield',
888      '#type' => 'textfield',      '#title' => t('Store Key'),
889      '#title' => t('Client Id'),      '#default_value' => variable_get('storekey', ''),
890      '#default_value' => variable_get('banks_settings_clientid', ''),      '#size' => 20,
891      '#description' => t('Sanal pos magaza numarasi.'),      '#weight' => 1,
892        '#required' => TRUE,
893    );    );
894    $form['banks_settings']['banks_settings_type'] = array(    $form['bank']['bankurl'] = array('#type' => 'textfield',
895      '#type' => 'select',      '#title' => t('Bank URL'),
896      '#title' => t('Islem Tipi'),      '#default_value' => variable_get('bankurl', ''),
897      '#default_value' => variable_get('banks_settings_type', ''),      '#size' => 100,
898      '#description' => t('Auth: Satys PreAuth On Otorizasyon.'),      '#weight' => 1,
899      '#options' => array(      '#required' => TRUE,
       'Auth' => t('Satis'),  
       'PreAuth' => t('On Otorizasyon'),  
     ),  
      '#default_value' => variable_get('banks_transaction_mode', 'Auth'),  
900    );    );
901    $form['banks_settings']['banks_transaction_mode'] = array(    $form['bank']['processtype'] = array('#type' => 'select',
902      '#type' => 'select',      '#title' => t('Process Type'),
903      '#title' => t('Transaction mode'),      '#default_value' => variable_get('processtype', ''),
904      '#description' => t('Islem yapilacak ortam.'),      '#description' => t('Auth: Authorize and capture immediately PreAuth: Only Authorize.'),
905      '#options' => array(      '#options' => array(
906        'uretim' => t('Uretim'),        'Auth' => t('Auth'),
907        'test' => t('Test'),        'PreAuth' => t('PreAuth'),
908      ),      ),
909      '#default_value' => variable_get('banks_transaction_mode', 'test'),      '#weight' => 1,
910        '#required' => TRUE,
911      );
912    
913      $form['bank']['cardname'] = array('#type' => 'textfield',
914        '#title' => t('Card Name'),
915        '#default_value' => variable_get('cardname', ''),
916        '#size' => 30,
917        '#weight' => 2,
918        '#required' => TRUE,
919    );    );
920    return $form;    return $form;
921  }  }
922    
923  function uc_turkish_banks_charge($order_id, $amount, $data) {  function uc_turkish_banks_charge($order_id, $amount, $data) {
924    
925    if (!function_exists('curl_init')) {    if (!function_exists('curl_init')) {
926      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.'));
927      return array('success' => FALSE);      return array('success' => FALSE);
928    }    }
   
929    // XML request sablonu    // XML request sablonu
930    $request = "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>".    $request = "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>".
931    "<CC5Request>".    "<CC5Request>".
# Line 958  function uc_turkish_banks_charge($order_ Line 974  function uc_turkish_banks_charge($order_
974    "</ShipTo>".    "</ShipTo>".
975    "<Extra></Extra>".    "<Extra></Extra>".
976    "</CC5Request>";    "</CC5Request>";
977    
978      $order = uc_order_load($order_id);
979    $taksit = 0;    $taksit = 0;
980      $url = variable_get('bankurl', '');
981    
982    $request = str_replace("{NAME}", variable_get('banks_settings_name', ''), $request);    $request = str_replace("{NAME}", variable_get('username', ''), $request);
983    $request = str_replace("{PASSWORD}", variable_get('banks_settings_password', ''), $request);    $request = str_replace("{PASSWORD}", variable_get('password', ''), $request);
984    $request = str_replace("{CLIENTID}", variable_get('banks_settings_clientid', ''), $request);    $request = str_replace("{CLIENTID}", variable_get('clientid', ''), $request);
985    $request = str_replace("{IP}", GetHostByName($REMOTE_ADDR), $request);    $request = str_replace("{IP}", GetHostByName($REMOTE_ADDR), $request);
986    $request = str_replace("{OID}", $order_id, $request);    $request = str_replace("{OID}", $order_id, $request);
987    $request = str_replace("{TYPE}", variable_get('banks_transaction_mode', 'test'), $request);    $request = str_replace("{TYPE}", variable_get('processtype', 'test'), $request);
988    $request = str_replace("{CCNO}", $order->payment_details['cc_number'], $request);    $request = str_replace("{CCNO}", $order->payment_details['cc_number'], $request);
989    $request = str_replace("{CCTAR}", "$order->payment_details['cc_exp_month']/$order->payment_details['cc_exp_year']", $request);    $request = str_replace("{CCTAR}", "$order->payment_details['cc_exp_month']/$order->payment_details['cc_exp_year']", $request);
990    $request = str_replace("{CV2}", "$order->payment_details['cc_cvv']", $request);    $request = str_replace("{CV2}", "$order->payment_details['cc_cvv']", $request);
991    $request = str_replace("{TUTAR}", $amount, $request);    $request = str_replace("{TUTAR}", $amount, $request);
992    $request = str_replace("{TAKSIT}", $taksit, $request);    $request = str_replace("{TAKSIT}", $taksit, $request);
993    
   $transaction_mode = variable_get('banks_settings_transaction_mode', 'test');  
   if ($transaction_mode == 'test') {  
     $url = 'https://ccpos.garanti.com.tr/servlet/gar3Dgate';  
   }  
   else {  
     $url = 'https://ccpos.garanti.com.tr/servlet/gar3Dgate';  
   }  
   
994    $ch = curl_init();    // initialize curl handle    $ch = curl_init();    // initialize curl handle
995    curl_setopt($ch, CURLOPT_URL, $url); // set url to post to    curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
996    //curl_setopt($ch, CURLOPT_VERBOSE, 0);    //curl_setopt($ch, CURLOPT_VERBOSE, 0);
# Line 1061  function uc_turkish_banks_charge($order_ Line 1071  function uc_turkish_banks_charge($order_
1071        'uid' => $user->uid,        'uid' => $user->uid,
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.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2