<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2020 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2020
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
/**
}
if ((!$this->_crid && !$this->_coid && !$this->_mid) || (!$this->_subscriptionDetails)) {
- CRM_Core_Error::fatal('Required information missing.');
+ throw new CRM_Core_Exception('Required information missing.');
}
if (!$this->_paymentProcessor['object']->supports('updateSubscriptionBillingInfo')) {
- CRM_Core_Error::fatal(ts("%1 processor doesn't support updating subscription billing details.",
- array(1 => $this->_paymentProcessor['object']->_processorName)
+ throw new CRM_Core_Exception(ts("%1 processor doesn't support updating subscription billing details.",
+ [1 => $this->_paymentProcessor['title']]
));
}
$this->assign('paymentProcessor', $this->_paymentProcessor);
* Default values
*/
public function setDefaultValues() {
- $this->_defaults = array();
+ $this->_defaults = [];
if ($this->_subscriptionDetails->contact_id) {
- $fields = array();
+ $fields = [];
$names = array(
'first_name',
'middle_name',
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
// validate the payment instrument values (e.g. credit card number)
}
$fields["email-{$this->_bltID}"] = 1;
- $processorParams = array();
+ $processorParams = [];
foreach ($params as $key => $val) {
$key = str_replace('billing_', '', $key);
list($key) = explode('-', $key);
$processorParams['country'] = CRM_Core_PseudoConstant::country($params["billing_country_id-{$this->_bltID}"], FALSE);
$processorParams['month'] = $processorParams['credit_card_exp_date']['M'];
$processorParams['year'] = $processorParams['credit_card_exp_date']['Y'];
- $processorParams['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
+ $processorParams['subscriptionId'] = $this->getSubscriptionDetails()->processor_id;
$processorParams['amount'] = $this->_subscriptionDetails->amount;
$updateSubscription = $this->_paymentProcessor['object']->updateSubscriptionBillingInfo($message, $processorParams);
if (is_a($updateSubscription, 'CRM_Core_Error')) {
// format new address for display
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
- $addressParts[$part] = CRM_Utils_Array::value($part, $processorParams);
+ $addressParts[$part] = $processorParams[$part] ?? NULL;
}
$tplParams['address'] = CRM_Utils_Address::format($addressParts);
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
$key = "{$part}-{$this->_bltID}";
- $addressParts[$part] = CRM_Utils_Array::value($key, $this->_defaults);
+ $addressParts[$part] = $this->_defaults[$key] ?? NULL;
}
$this->_defaults['address'] = CRM_Utils_Address::format($addressParts);