Index: worldpay.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ecommerce/contrib/worldpay/worldpay.module,v
retrieving revision 1.2
diff -u -r1.2 worldpay.module
--- worldpay.module	4 Mar 2006 00:34:55 -0000	1.2
+++ worldpay.module	16 Mar 2006 17:26:42 -0000
@@ -20,42 +20,109 @@
  * Implementation of hook_settings().
  */
 function worldpay_settings() {
-	
-    $output = '';
-    // Installation ID (instId)
-    $group = form_textfield(t('Installation ID (instId)'), 'worldpay_instId',
-    variable_get('worldpay_instId', '00000'), 20, 255,
-    t('WorldPay Installation ID. This should be set to your unique ID, which was given to 
-       you by WorldPay.'));
+
+  $output = '';
+  // Installation ID (instId)
+  $form['worldpay_instId'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Installation ID (instId)'),
+    '#default_value' => variable_get('worldpay_instId', '00000'),
+    '#size' => 20,
+    '#maxlength' => 255,
+    '#description' => t('WorldPay Installation ID. This should be set to your unique ID, which was given to you by WorldPay.'),
+  );
 
   // Testing Mode (testMode)
-    $testMode_codes = array('0' => 'Live payment processing (0)', '100' => 'Test mode (100) - return success', '101' => 'Test mode (101) - return failure');
-    $group .= form_select(t('Testing Mode (testMode)'), 'worldpay_testMode', 
-    variable_get('worldpay_testMode', '100'), $testMode_codes,
-    t('WorldPay testMode code. Set to 0 for live shop, 100 or 101 for testing.'));
+  $testMode_codes = array('0' => 'Live payment processing (0)', '100' => 'Test mode (100) - return success', '101' => 'Test mode (101) - return failure');
+  $form['worldpay_testMode'] = array(
+    '#type' => 'select',
+    '#title' => t('Testing Mode (testMode)'),
+    '#default_value' => variable_get('worldpay_testMode', '100'),
+    '#options' => $testMode_codes,
+    '#description' => t('WorldPay testMode code. Set to 0 for live shop, 100 or 101 for testing.'),
+  );
 
   // Currency code (currency)
-    $currency_codes = array('USD' => 'USD - U.S. Dollars', 'EUR' => 'EUR - Euros', 'AUD' => 'AUD - Australian Dollars', 'CAD' => 'CAD - Canadian Dollars', 'GBP'=> 'GBP - Pounds Sterling');
-    $group .= form_select(t('Currency code (currency)'), 'worldpay_currency_code', 
-    variable_get('worldpay_currency_code', 'GBP'), $currency_codes, t('The currecy code that WorldPay should process the payment in.'));
+  $currency_codes = array('USD' => 'USD - U.S. Dollars', 'EUR' => 'EUR - Euros', 'AUD' => 'AUD - Australian Dollars', 'CAD' => 'CAD - Canadian Dollars', 'GBP'=> 'GBP - Pounds Sterling');
+  $form['worldpay_currency_code'] = array(
+    '#type' => 'select',
+    '#title' => t('Currency code (currency)'),
+    '#default_value' => variable_get('worldpay_currency_code', 'EUR'),
+    '#options' => $currency_codes,
+    '#description' => t('The currecy code that WorldPay should process the payment in.'),
+  );
 
   // WorldPay Minimum Amount
-    $group .= form_textfield(t('WorldPay Minimum Amount'), 'worldpay_min_amount',
-    variable_get('worldpay_min_amount', '5.00'), 10, 10, t('The minimum purchase amount (gross) that will be accepted for WorldPay payments.'));
-    $output .= form_group(t('Main settings'),$group);
+  $form['worldpay_min_amount'] = array(
+    '#type' => 'textfield',
+    '#title' => t('WorldPay Minimum Amount'),
+    '#default_value' => variable_get('worldpay_min_amount', '5.00'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#description' => t('The minimum purchase amount (gross) that will be accepted for WorldPay payments.'),
+  );
+  $form[] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Main settings'),
+  );
 
   // WorldPay processing form settings
-    $group = form_textarea(t("Worldpay Submission Form (top)"), "worldpay_submit_form_top", variable_get("worldpay_submit_form_top", "<P>Name: %name</p><P>Address: %address</p><p>Order description: %order_description</p><p>Total amount: %total_amount, </p><p>reference number: %order_reference_number</p>"), 60, 10, t("Paste your HTML here for the top of your Worldpay submission form. This is the confirmation page users will see before being directed to the Worldpay secure server and complete their transaction. Available variables are: %name, %address, %order_description, %total_amount, %order_reference_number"));
-    $group .= form_textarea(t("Make Payment Button help text"), "worldpay_submit_button_text", variable_get("worldpay_submit_button_text", "You will now be transferred to the Worldpay secure server to enter your credit or debit card details.Please click on the MAKE PAYMENT button now:"), 60, 4, t("Edit the text you would like to display to users before clicking on the MAKE PAYMENT button."));
-    $group .= form_textfield(t('Make Payment button title'), 'worldpay_button_label', variable_get('worldpay_button_label', 'Make Payment'), 70, 70, t('Change the text that appears on your MAKE PAYMENT button'));
-    $group .= form_textarea(t("Worldpay Submission Form (bottom)"), "worldpay_submit_form_bottom", variable_get("worldpay_submit_form_bottom", "We accept payment using all the credit and debit cards shown below, however we would appreciate it if you can pay using a debit card as we incur a smaller transaction charge."), 60, 5, t("Paste your HTML here for the bottom of the Worldpay submission form. this text appears below the MAKE PAYMENT button and above the auto-generated credit & debit card icons your Worldpay account is able to accept."));
-
-      // WorldPay processing URL      
-    $group .= form_textfield(t('WorldPay processing URL'), 'worldpay_url',variable_get('worldpay_url', 'https://select.worldpay.com/wcc/purchase'), 60, 180, t('URL of the secure payment page customers are sent to for payment processing (Select Junior). If unsure leave at default setting.'));
+  $form["worldpay_submit_form_top"] = array(
+    '#type' => 'textarea',
+    '#title' => t("Worldpay Submission Form (top)"),
+    '#default_value' => variable_get("worldpay_submit_form_top", "<P>Name: %name</p><P>Address: %address</p><p>Order description: %order_description</p><p>Total amount: %total_amount, </p><p>reference number: %order_reference_number</p>"),
+    '#cols' => 60,
+    '#rows' => 10,
+    '#description' => t("Paste your HTML here for the top of your Worldpay submission form. This is the confirmation page users will see before being directed to the Worldpay secure server and complete their transaction. Available variables are: %name, %address, %order_description, %total_amount, %order_reference_number"),
+  );
+  $form["worldpay_submit_button_text"] = array(
+    '#type' => 'textarea',
+    '#title' => t("Make Payment Button help text"),
+    '#default_value' => variable_get("worldpay_submit_button_text", "You will now be transferred to the Worldpay secure server to enter your credit or debit card details.Please click on the MAKE PAYMENT button now:"),
+    '#cols' => 60,
+    '#rows' => 4,
+    '#description' => t("Edit the text you would like to display to users before clicking on the MAKE PAYMENT button."),
+  );
+  $form['worldpay_button_label'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Make Payment button title'),
+    '#default_value' => variable_get('worldpay_button_label', 'Make Payment'),
+    '#size' => 70,
+    '#maxlength' => 70,
+    '#description' => t('Change the text that appears on your MAKE PAYMENT button'),
+  );
+  $form["worldpay_submit_form_bottom"] = array(
+    '#type' => 'textarea',
+    '#title' => t("Worldpay Submission Form (bottom)"),
+    '#default_value' => variable_get("worldpay_submit_form_bottom", "We accept payment using all the credit and debit cards shown below, however we would appreciate it if you can pay using a debit card as we incur a smaller transaction charge."),
+    '#cols' => 60,
+    '#rows' => 5,
+    '#description' => t("Paste your HTML here for the bottom of the Worldpay submission form. this text appears below the MAKE PAYMENT button and above the auto-generated credit & debit card icons your Worldpay account is able to accept."),
+  );
+
+  // WorldPay processing URL      
+  $form['worldpay_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('WorldPay processing URL'),
+    '#default_value' => variable_get('worldpay_url', 'https://select.worldpay.com/wcc/purchase'),
+    '#size' => 60,
+    '#maxlength' => 180,
+    '#description' => t('URL of the secure payment page customers are sent to for payment processing (Select Junior). If unsure leave at default setting.'),
+  );
   // WorldPay callback URL
-    $group .= form_textfield(t('Thank you page/WorldPay callback URL'), 'worldpay_callback_url',variable_get('worldpay_callback_url', 'node'), 60, 180, t('<P><strong>BASIC USAGE (recommended):</strong> Redirect users to a specific thank you page and process your orders manually from Worldpay emails and your worldpay account.</p><P><strong>ADVANCED USAGE:</strong> Insert <strong>worldpay_callback</strong> as the link that is used for processing payment confirmation (Select Junior). This also needs to be configured in the settings on the WorldPay server as the full URL. Please refer to the README.TXT that came with the worldpay.module for more detailed instructions.</p>'));
-    $output .= form_group(t('Worldpay checkout settings'),$group);
-    return $output;
+  $form['worldpay_callback_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Thank you page/WorldPay callback URL'),
+    '#default_value' => variable_get('worldpay_callback_url', 'node'),
+    '#size' => 60,
+    '#maxlength' => 180,
+    '#description' => t('<P><strong>BASIC USAGE (recommended):</strong> Redirect users to a specific thank you page and process your orders manually from Worldpay emails and your worldpay account.</p><P><strong>ADVANCED USAGE:</strong> Insert <strong>worldpay_callback</strong> as the link that is used for processing payment confirmation (Select Junior). This also needs to be configured in the settings on the WorldPay server as the full URL. Please refer to the README.TXT that came with the worldpay.module for more detailed instructions.</p>'),
+  );
+  $form[] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Worldpay checkout settings'),
+  );
+  return $form;
 }
 
 
@@ -111,9 +178,7 @@
  */
 function worldpay_verify_checkout($data) {
   if (variable_get('worldpay_min_amount', '0') > $data['gross']) {
-    //form_set_error('gross', t('Your purchase total must be at least %min-purchase-amount for online Credit card purchases.', array('%min-purchase-amount' => payment_format(variable_get('paypal_min_amount', '0')))));
-    form_set_error('gross', t('Your purchase total must be at least £%min-purchase-amount for online Credit card purchases.', array('%min-purchase-amount' => variable_get('worldpay_min_amount', '0'))));
-    //form_set_error('gross', t('We apologise that credit and debit card purchases can not yet be accepted online.  This should be available in the next few days.  Thank you for your patience.  Please choose an alternate payment method.'));
+    form_set_error('gross', t('Your purchase total must be at least %min-purchase-amount for online Credit card purchases.', array('%min-purchase-amount' => variable_get('worldpay_min_amount', '0'))));
   }
 }
 
