You are here

function uc_recurring_hosted_paypal_wpp_profile_creation_form_submit in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 modules/uc_recurring_hosted/uc_recurring_hosted.module \uc_recurring_hosted_paypal_wpp_profile_creation_form_submit()

@todo Please document this function.

See also

http://drupal.org/node/1354

File

modules/uc_recurring_hosted/uc_recurring_hosted.module, line 1355
Provides hosted gateway specific code for recurring payments, specifically Authorize.net ARB and Paypal WPS

Code

function uc_recurring_hosted_paypal_wpp_profile_creation_form_submit($form, &$form_state) {
  $fee = uc_recurring_fee_user_load($form_state['values']['rfid']);
  $order = uc_order_load($fee->order_id);
  $order->payment_details = $form_state['values']['cc_data'];

  //update the billing details
  $order->billing_first_name = $form_state['values']['billing_first_name'];
  $order->billing_last_name = $form_state['values']['billing_last_name'];
  $order->billing_street1 = $form_state['values']['billing_street1'];
  $order->billing_street2 = $form_state['values']['billing_street2'];
  $order->billing_city = $form_state['values']['billing_city'];
  $order->billing_country = $form_state['values']['billing_country'];
  $order->billing_zone = $form_state['values']['billing_zone'];
  $order->billing_postal_code = $form_state['values']['billing_postal_code'];
  $result = uc_recurring_hosted_paypal_wpp_process($order, $fee);
  if ($result) {

    // TODO Please review the conversion of this statement to the D7 database API syntax.

    /* db_query("UPDATE {uc_recurring_users} SET billing_assigned = 1 WHERE rfid = %d", $fee->rfid) */
    db_update('uc_recurring_users')
      ->fields(array(
      'billing_assigned' => 1,
    ))
      ->condition('rfid', $fee->rfid)
      ->execute();
    $cc_data = array(
      'cc_number' => substr($order->payment_details['cc_number'], -4),
      'cc_exp_month' => $order->payment_details['cc_exp_month'],
      'cc_exp_year' => $order->payment_details['cc_exp_year'],
      'cc_type' => $order->payment_details['cc_type'],
    );
    _save_cc_data_to_order($cc_data, $order->order_id);
    uc_order_save($order);
    $form_state['redirect'] = 'user/' . $order->uid . '/recurring/create/complete';
  }
  else {
    drupal_set_message(t('Recurring fee was not processed successfully. Please try again or contact customer service.'), 'error');
  }
}