You are here

function commerce_paypal_wpp_submit_form in Commerce PayPal 7

Same name and namespace in other branches
  1. 7.2 modules/wpp/commerce_paypal_wpp.module \commerce_paypal_wpp_submit_form()

Payment method callback: checkout form.

File

modules/wpp/commerce_paypal_wpp.module, line 181
Implements PayPal Website Payments Pro in Drupal Commerce checkout.

Code

function commerce_paypal_wpp_submit_form($payment_method, $pane_values, $checkout_pane, $order) {
  module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');
  $payment_method['settings'] += commerce_paypal_wpp_default_settings();

  // Prepare the fields to include on the credit card form.
  $fields = array();

  // Include the card security code field if specified.
  if ($payment_method['settings']['code']) {
    $fields['code'] = '';
  }

  // Add the credit card types array if necessary.
  $card_types = array_diff(array_values($payment_method['settings']['card_types']), array(
    0,
  ));
  if (!empty($card_types)) {
    $fields['type'] = $card_types;
  }

  // Add the start date and issue number if processing a Maestro or Solo card.
  if (in_array('maestro', $card_types) || in_array('solo', $card_types)) {
    $fields += array(
      'start_month' => '',
      'start_year' => '',
      'issue' => '',
    );
  }
  return commerce_payment_credit_card_form($fields);
}