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

Diff of /contributions/modules/uc_paygate/uc_paygate.module

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

revision 1.2, Wed Sep 24 10:08:54 2008 UTC revision 1.2.2.1, Sun Nov 2 19:23:01 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: uc_paygate.module,v 1.1 2008/09/12 16:28:57 maxheadroom Exp $  // $Id:$
3    
4  /**  /**
5   * @file   * @file
6   * Integrates paygate.co.za's redirected payment service.   * Integrates paygate.co.za's redirected payment service.
7   *   *
8   * Development by Web-n-things.   * Development by Web-n-things.
9     * Updated/Ported by Jonathan Wagener - Amoebasys (www.amoebasys.com).
10     * Core: Drupal 6
11   */   */
12    
13  /*******************************************************************************  /*******************************************************************************
# Line 15  Line 17 
17  /**  /**
18   * Implementation of hook_menu().   * Implementation of hook_menu().
19   */   */
20  function uc_paygate_menu($may_cache) {  function uc_paygate_menu()
21    if ($may_cache) {  {
22      $items[] = array(    $items['cart/paygate/complete'] = array(
23      'path' => 'cart/paygate/complete',      'title' => 'PayGate transaction result',
24      'title' => t('PayGate transaction result'),      'page callback' => 'uc_paygate_complete',
25      'callback' => 'uc_paygate_complete',      'access arguments' => array('access content'),
     'access' => user_access('access content'),  
26      'type' => MENU_CALLBACK,      'type' => MENU_CALLBACK,
27      );    );
   }  
28    
29    return $items;    return $items;
30  }  }
# Line 32  function uc_paygate_menu($may_cache) { Line 32  function uc_paygate_menu($may_cache) {
32  /**  /**
33   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
34   */   */
35  function uc_paygate_form_alter($form_id, &$form) {  function uc_paygate_form_alter(&$form, $form_state, $form_id)
36    if ($form_id == 'uc_cart_checkout_review_form' && ($order_id = intval($_SESSION['cart_order'])) > 0) {  {
37      $order = uc_order_load($order_id);    // normally a switch is used because you may want to alter more than
38      // one form and it is easy to add a new case for each form.
39      if ($order->payment_method == 'paygate') {    switch ($form_id)
40        unset($form['submit']);    {
41        $form['#prefix'] = '<table style="display: inline; padding-top: 1em;"><tr><td>';      // this is our form_id.
42        $form['#suffix'] = '</td><td>'. drupal_get_form('uc_paygate_form', $order) .'</td></tr></table>';      case 'uc_cart_checkout_review_form':
43      }        if ($form_id == 'uc_cart_checkout_review_form' && ($order_id = intval($_SESSION['cart_order'])) > 0)
44          {
45            $order = uc_order_load($order_id);
46    
47            if ($order->payment_method == 'paygate') {
48              unset($form['submit']);
49              $form['#prefix'] = '<table style="display: inline; padding-top: 1em;"><tr><td>';
50              $form['#suffix'] = '</td><td>'. drupal_get_form('uc_paygate_form', $order) .'</td></tr></table>';
51            }
52          }
53          break;
54    }    }
55  }  }
56    
# Line 58  function uc_paygate_payment_method() { Line 68  function uc_paygate_payment_method() {
68    $title .= '<br /><img src="'. $path .'/paygate_small.gif" style="position: relative; left: 2.5em;">';    $title .= '<br /><img src="'. $path .'/paygate_small.gif" style="position: relative; left: 2.5em;">';
69    
70    $methods[] = array(    $methods[] = array(
71    'id' => 'paygate',      'id' => 'paygate',
72    'name' => t('PayGate'),      'name' => 'PayGate',
73    'title' => $title,      'title' => $title,
74    'desc' => t('Redirect to PayGate for payment.'),      'desc' => 'Redirect to PayGate for payment.',
75    'callback' => 'uc_payment_method_paygate',      'callback' => 'uc_payment_method_paygate',
76    'weight' => 3,      'weight' => 3,
77    'checkout' => TRUE,      'checkout' => TRUE,
78    'no_gateway' => TRUE,      'no_gateway' => TRUE,
79    );    );
80    
81    return $methods;    return $methods;
# Line 132  function uc_payment_method_paygate($op, Line 142  function uc_payment_method_paygate($op,
142        $form['paygate_settings']['paygate_return_url'] = array(        $form['paygate_settings']['paygate_return_url'] = array(
143        '#type' => 'textfield',        '#type' => 'textfield',
144        '#title' => t('Return URL'),        '#title' => t('Return URL'),
145        '#default_value' => variable_get('paygate_return_url', url('cart/paygate/complete/'. uc_cart_get_id(), NULL, NULL, TRUE)),        '#default_value' => variable_get('paygate_return_url', url('cart/paygate/complete/'. $order->order_id, array('absolute' => TRUE))),
146        '#description' => t('The URL to where PayGate must return after a transaction.'),        '#description' => t('The URL to where PayGate must return after a transaction.'),
147        );        );
148    
# Line 186  function uc_paygate_form($order) { Line 196  function uc_paygate_form($order) {
196    $REFERENCE = $order->order_id;    $REFERENCE = $order->order_id;
197    $AMOUNT = ($order->order_total)*100; //Paygate requires amount to be in cents    $AMOUNT = ($order->order_total)*100; //Paygate requires amount to be in cents
198    $CURRENCY =  'ZAR';    $CURRENCY =  'ZAR';
199    $RETURN_URL = url('cart/paygate/complete/', NULL, NULL, TRUE);    $RETURN_URL = url('cart/paygate/complete/');
200    $TRANSACTION_DATE = date('Y-m-d H:i');    $TRANSACTION_DATE = date('Y-m-d H:i');
201    $EMAIL = substr($order->primary_email, 0, 64);    $EMAIL = substr($order->primary_email, 0, 64);
202    
# Line 194  function uc_paygate_form($order) { Line 204  function uc_paygate_form($order) {
204      $CHECKSUM = md5($checksum_data);      $CHECKSUM = md5($checksum_data);
205    
206      $data = array(      $data = array(
207      'PAYGATE_ID'=>$PAYGATE_ID,      'PAYGATE_ID' => $PAYGATE_ID,
208      'REFERENCE'=>$REFERENCE,      'REFERENCE' => $REFERENCE,
209      'AMOUNT'=>$AMOUNT,      'AMOUNT' => $AMOUNT,
210      'CURRENCY'=>$CURRENCY,      'CURRENCY' => $CURRENCY,
211      'RETURN_URL'=>$RETURN_URL,      'RETURN_URL' => $RETURN_URL,
212      'TRANSACTION_DATE'=>$TRANSACTION_DATE,      'TRANSACTION_DATE' => $TRANSACTION_DATE,
213      'EMAIL'=>$EMAIL,      'EMAIL' => $EMAIL,
214      'CHECKSUM'=>$CHECKSUM      'CHECKSUM' => $CHECKSUM
215      );      );
216    
217    $form['#action'] = 'https://www.paygate.co.za/paywebv2/process.trans';    $form['#action'] = 'https://www.paygate.co.za/paywebv2/process.trans';
# Line 220  function uc_paygate_form($order) { Line 230  function uc_paygate_form($order) {
230    
231  function uc_paygate_complete($cart_id = 0) {  function uc_paygate_complete($cart_id = 0) {
232    if (!$_POST){    if (!$_POST){
233       return;      return;
234    }    }
235    if (variable_get(paygate_transaction_mode,'') == "Production"){    if (variable_get(paygate_transaction_mode,'') == "Production"){
236      $checksum_key = variable_get('paygate_checksum_key', '');      $checksum_key = variable_get('paygate_checksum_key', '');

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

  ViewVC Help
Powered by ViewVC 1.1.2