[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    www/cms/drupal5/modules/akademy
From:       Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date:       2008-05-29 15:08:06
Message-ID: 1212073686.818541.6201.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 814177 by mkruisselbrink:

change paypal payment code to directly submit the form when javascript is enabled


 M  +30 -11    akademy.module  


--- trunk/www/cms/drupal5/modules/akademy/akademy.module #814176:814177
@@ -1303,8 +1303,22 @@
       akademy_set_message(t("You didn't configure any paying accommodation or \
option. You can still change that until registration closes."));  } else {
       akademy_set_message(t("Your participation at Akademy 2008 will cost \
@total_cost. Please note that your registration won't be final until the payment has \
                been received.", array('@total_cost' => ($costs['total']/100).' \
                euro')), 'error');
-      $payment_methods = theme('item_list', array(l('Paypal', 'payment/paypal'), \
l('European bank transfer', 'payment/bank')), NULL, 'ul' ); +      $payment_methods = \
theme('item_list', array(l('Paypal', 'payment/paypal', array('id' => 'paypal_link')), \
l('European bank transfer', 'payment/bank')), NULL, 'ul' );  $html .= theme('box', \
'Payment methods', $payment_methods); +
+      // add form for paypal payment
+      $html .= drupal_get_form('akademy_paypal_form_build', FALSE);
+
+      // and add javascript to change the paypal link to submit the form instead of \
going to the paypal page +      drupal_add_js(<<<EOS
+\$(function(){
+    \$('#paypal_link').bind('click', function(e) {
+        \$('#akademy-paypal-form').get(0).submit()
+        return false
+    })
+})
+EOS
+      , 'inline', 'footer');
     }
   }
 
@@ -1369,7 +1383,7 @@
 }
 
 # Paypal payment form build
-function akademy_paypal_form_build() {
+function akademy_paypal_form_build($havebutton = TRUE) {
     global $user;
 
     if (!$user->uid) {
@@ -1387,6 +1401,7 @@
             );
         }
         else {
+            $form['#id'] = 'akademy-paypal-form';
             $costs = akademy_gather_costs($user->registrant);
             # we save amounts in cents
             $amount = $costs['total']/100;
@@ -1394,9 +1409,11 @@
             $html .= t("<p>You will be charged ". akademy_format_money($amount * \
100). ".</p>");  
             $form['#action'] = simple_paypal_get_url();
-            $form['pre'] = array(
-                '#value' => $html,
-            );
+            if ($havebutton) {
+                $form['pre'] = array(
+                    '#value' => $html,
+                );
+            }
             $form['business'] = array(
                 '#type' => 'hidden',
                 '#name' => 'business',
@@ -1414,7 +1431,7 @@
             );
             $form['cmd'] = array(
                 '#type' => 'hidden',
-                '#value' => '_xclick',
+                '#value' => '_cart',
                 '#name' => 'cmd',
             );
             $form['no_shipping'] = array(
@@ -1437,11 +1454,13 @@
                 '#value' => url('payment/ipn', NULL, NULL, TRUE),
                 '#name' => 'notify_url',
             );
-            $form['submit'] = array(
-                '#type' => 'submit',
-                '#value' => t('Pay'),
-                '#name' => 'submit',
-            );
+            if ($havebutton) {
+                $form['submit'] = array(
+                    '#type' => 'submit',
+                    '#value' => t('Pay'),
+                    '#name' => 'submit',
+                );
+            }
 
             $i = 1;
             foreach( $costs['accommodation'] as $a )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic