You are here

function uc_recurring_hosted_paypal_wpp_update 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_update()

Updates a PayPal subscription; for simplicity's sake, Credit Card information except for expiration date cannot be updated at this time.

Parameters

$order: The order object.

$fee: The recurring fee object.

$updates: An array of data to update using key/ value pairs from the NVP API for PayPal.

Return value

TRUE or FALSE indicating the success of the update.

1 call to uc_recurring_hosted_paypal_wpp_update()
uc_recurring_hosted_paypal_wpp_update_form_submit in modules/uc_recurring_hosted/uc_recurring_hosted.module
Update form submission callback

File

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

Code

function uc_recurring_hosted_paypal_wpp_update($order, $fee, $updates = array()) {
  global $user;
  watchdog('uc_recurring_paypal_wpp_update', print_r($fee, 1), NULL, WATCHDOG_DEBUG);
  $profile = uc_recurring_hosted_subscription_load($fee->rfid);

  // Build an NVP request.
  $nvp_request = array(
    'METHOD' => 'UpdateRecurringPaymentsProfile',
    'PROFILEID' => $profile->subscription_id,
  ) + $updates;

  // Post the request, and parse the response.
  $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp'), UC_PAYPAL_RECURRING_API);
  if ($nvp_response['ACK'] != 'Success' && $nvp_response['ACK'] != 'SuccessWithWarning') {
    watchdog('uc_recurring', 'Failed to update recurring profile @id', array(
      '@id' => $profile->subscription_id,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  $message = t('<b>PayPal Recurring Profile Updated</b><br /><b>Field(s) Updated: </b>@fields<br /><b>Recurring Profile ID: </b>@profile_id', array(
    '@fields' => implode(',', array_keys($updates)),
    '@profile_id' => $profile->subscription_id,
  ));
  uc_order_comment_save($order->order_id, $user->uid, $message, 'admin');
  return TRUE;
}