function _uc_recurring_uc_cybersource_update_paymentprofile in UC Recurring Payments and Subscriptions 6.2
Same name and namespace in other branches
- 7.2 includes/uc_recurring.uc_cybersource.inc \_uc_recurring_uc_cybersource_update_paymentprofile()
Update the payment profile
1 call to _uc_recurring_uc_cybersource_update_paymentprofile()
- uc_recurring_cybersource_update_form_submit in includes/
uc_recurring.uc_cybersource.inc - Implements update form submit for the cybersource CIM gateway.
File
- includes/
uc_recurring.uc_cybersource.inc, line 266 - Uc recurring implementation for the CyberSource module.
Code
function _uc_recurring_uc_cybersource_update_paymentprofile($order, $subscription_id) {
module_load_include('inc', 'uc_cybersource', 'uc_cybersource.soap');
try {
$soapClient = new CyberSourceSoapClient(_uc_recurring_cybersource_soap_wsdl_url(), array());
$login = _uc_cybersource_soap_login_data();
// Create the request with some meta data.
$request = new stdClass();
$request->merchantID = $login['merchant_id'];
$request->merchantReferenceCode = $order->order_id;
$paySubscriptionUpdateService = new stdClass();
$paySubscriptionUpdateService->run = 'true';
$request->paySubscriptionUpdateService = $paySubscriptionUpdateService;
$recurringSubscriptionInfo = new stdClass();
$recurringSubscriptionInfo->subscriptionID = $subscription_id;
$request->recurringSubscriptionInfo = $recurringSubscriptionInfo;
$request->billTo = _uc_recurring_cybersource_billto_obj($order);
$request->card = _uc_recurring_cybersource_card_obj($order);
$reply = $soapClient
->runTransaction($request);
} catch (SoapFault $exception) {
// Log and display errors if Ubercart is unable to connect via SOAP.
watchdog('uc_cybersource', 'Unable to connect to CyberSource via SOAP.', array(), WATCHDOG_ERROR);
drupal_set_message(t('We apologize for the delay, but we are unable to process your credit card at this time. Please <a href="!url">contact sales</a> to complete your order.', array(
'!url' => url('contact'),
)), 'error');
}
// Process a reply from CyberSource.
if (isset($reply->paySubscriptionUpdateReply)) {
if ($reply->paySubscriptionUpdateReply->reasonCode == 100) {
uc_order_comment_save($order->order_id, 0, t('CyberSource: Subscription @subscription_id updated.', array(
'@subscription_id' => $subscription_id,
)), 'admin');
return;
}
else {
uc_order_comment_save($order->order_id, 0, t('<b>Attempt to update CyberSource subscription profile failed.</b><br /><b>Reason:</b> @code', array(
'@code' => $reply->paySubscriptionCreateReply->reasonCode,
)), 'admin');
return t('Subscription update failed with code @code', array(
'@code' => $reply->paySubscriptionCreateReply->reasonCode,
));
}
}
uc_order_comment_save($order->order_id, 0, t('CyberSource: Subscription @subscription_id update failed: invalid reply.', array(
'@subscription_id' => $subscription_id,
)), 'admin');
return t('Subscription update failed due to an invalid reply.');
}