diff --git a/modules/wps/commerce_paypal_wps.module b/modules/wps/commerce_paypal_wps.module index 1e6146d..a5a20d4 100644 --- a/modules/wps/commerce_paypal_wps.module +++ b/modules/wps/commerce_paypal_wps.module @@ -5,6 +5,23 @@ * Implements PayPal Website Payments Standard in Drupal Commerce checkout. */ +/** + * Implements hook_form_alter(). + */ +function commerce_paypal_wps_form_alter(&$form, &$form_state, $form_id) { + // If the form is a checkout form. + if (preg_match('/^commerce_checkout_form/', $form_id)) { + // If the checkout form contains the PayPal WPS payment option. + if (!empty($form['commerce_payment']['payment_method']['#options']['paypal_wps|commerce_payment_paypal_wps'])) { + // Theme the paypal icons and add them to the radio button for PayPal WPS. + $icons = commerce_paypal_icons(); + $display_title = t('!logo PayPal - pay securely without sharing your financial information', array('!logo' => $icons['paypal'])); + $display_title .= '
'; + $form['commerce_payment']['payment_method']['#options']['paypal_wps|commerce_payment_paypal_wps'] = $display_title; + $form['#attached']['css'][] = drupal_get_path('module', 'commerce_paypal_wps') . '/theme/commerce_paypal_wps.css'; + } + } +} /** * Implements hook_commerce_payment_method_info(). @@ -12,15 +29,11 @@ function commerce_paypal_wps_commerce_payment_method_info() { $payment_methods = array(); - $icons = commerce_paypal_icons(); - $display_title = t('!logo PayPal - pay securely without sharing your financial information', array('!logo' => $icons['paypal'])); - $display_title .= ' '; - $payment_methods['paypal_wps'] = array( 'base' => 'commerce_paypal_wps', 'title' => t('PayPal WPS'), 'short_title' => t('PayPal'), - 'display_title' => $display_title, + 'display_title' => t('PayPal Website Payments Standard'), 'description' => t('PayPal Website Payments Standard'), 'terminal' => FALSE, 'offsite' => TRUE, @@ -127,10 +140,8 @@ function commerce_paypal_wps_redirect_form($form, &$form_state, $order, $payment $settings = array( // Return to the previous page when payment is canceled 'cancel_return' => url('checkout/' . $order->order_id . '/payment/back/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)), - // Return to the payment redirect page for processing successful payments 'return' => url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)), - // Specify the current payment method instance ID in the notify_url 'payment_method' => $payment_method['instance_id'], ); @@ -272,44 +283,31 @@ function commerce_paypal_wps_order_form($form, &$form_state, $order, $settings) $data = array( // Specify the checkout experience to present to the user. 'cmd' => '_cart', - // Signify we're passing in a shopping cart from our system. 'upload' => 1, - // The store's PayPal e-mail address 'business' => $settings['business'], - // The path PayPal should send the IPN to 'notify_url' => commerce_paypal_ipn_url($settings['payment_method']), - // Set the correct character set 'charset' => 'utf-8', - // Do not display a comments prompt at PayPal 'no_note' => 1, - // Do not display a shipping address prompt at PayPal 'no_shipping' => 1, - // Return to the review page when payment is canceled 'cancel_return' => $settings['cancel_return'], - // Return to the payment redirect page for processing successful payments 'return' => $settings['return'], - // Return to this site with payment data in the POST 'rm' => 2, - // The type of payment action PayPal should take with this order 'paymentaction' => $settings['payment_action'], - // Set the currency and language codes 'currency_code' => in_array($currency_code, array_keys(commerce_paypal_wps_currencies())) ? $currency_code : $settings['currency_code'], 'lc' => $settings['language'], - // Use the timestamp to generate a unique invoice number 'invoice' => commerce_paypal_ipn_invoice($order), - // Define a single item in the cart representing the whole order 'amount_1' => round(commerce_currency_amount_to_decimal($amount, $currency_code), 2), 'item_name_1' => t('Order @order_number at @store', array('@order_number' => $order->order_number, '@store' => variable_get('site_name', url('