public function __construct($mode, &$paymentProcessor) {
$this->_mode = $mode;
$this->_paymentProcessor = $paymentProcessor;
-
- if ($this->isPayPalType($this::PAYPAL_STANDARD)) {
- $this->_processorName = ts('PayPal Standard');
- }
- elseif ($this->isPayPalType($this::PAYPAL_EXPRESS)) {
- $this->_processorName = ts('PayPal Express');
- }
- elseif ($this->isPayPalType($this::PAYPAL_PRO)) {
- $this->_processorName = ts('PayPal Pro');
- }
- else {
- throw new PaymentProcessorException('CRM_Core_Payment_PayPalImpl: Payment processor type is not defined!');
- }
}
/**
$args['paymentAction'] = 'Sale';
$args['amt'] = $params['amount'];
$args['currencyCode'] = $params['currencyID'];
- $args['desc'] = CRM_Utils_Array::value('description', $params);
+ $args['desc'] = $params['description'] ?? NULL;
$args['invnum'] = $params['invoiceID'];
$args['returnURL'] = $this->getReturnSuccessUrl($params['qfKey']);
$args['cancelURL'] = $this->getCancelUrl($params['qfKey'], NULL);
'token' => 'token',
'payer_status' => 'payerstatus',
'payer_id' => 'payerid',
- 'first_name' => 'firstname',
- 'middle_name' => 'middlename',
- 'last_name' => 'lastname',
+ 'billing_first_name' => 'firstname',
+ 'billing_middle_name' => 'middlename',
+ 'billing_last_name' => 'lastname',
'street_address' => 'shiptostreet',
'supplemental_address_1' => 'shiptostreet2',
'city' => 'shiptocity',
$params['trxn_id'] = $result['transactionid'];
$params['gross_amount'] = $result['amt'];
$params['fee_amount'] = $result['feeamt'];
- $params['net_amount'] = CRM_Utils_Array::value('settleamt', $result);
+ $params['net_amount'] = $result['settleamt'] ?? NULL;
if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) {
$params['net_amount'] = number_format(($params['gross_amount'] - $params['fee_amount']), 2);
}
$args['billingfrequency'] = $params['frequency_interval'];
$args['billingperiod'] = ucwords($params['frequency_unit']);
$args['desc'] = $params['amount'] . " Per " . $params['frequency_interval'] . " " . $params['frequency_unit'];
- $args['totalbillingcycles'] = CRM_Utils_Array::value('installments', $params);
+ $args['totalbillingcycles'] = $params['installments'] ?? NULL;
$args['version'] = '56.0';
$args['profilereference'] = "i={$params['invoiceID']}" .
"&m=" .
$args['pwd'] = $this->_paymentProcessor['password'];
$args['version'] = 3.0;
$args['signature'] = $this->_paymentProcessor['signature'];
- $args['subject'] = CRM_Utils_Array::value('subject', $this->_paymentProcessor);
+ $args['subject'] = $this->_paymentProcessor['subject'] ?? NULL;
$args['method'] = $method;
}
$args['cvv2'] = $params['cvv2'];
$args['firstName'] = $params['first_name'];
$args['lastName'] = $params['last_name'];
- $args['email'] = CRM_Utils_Array::value('email', $params);
+ $args['email'] = $params['email'] ?? NULL;
$args['street'] = $params['street_address'];
$args['city'] = $params['city'];
$args['state'] = $params['state_province'];
$args['countryCode'] = $params['country'];
$args['zip'] = $params['postal_code'];
$args['desc'] = substr(CRM_Utils_Array::value('description', $params), 0, 127);
- $args['custom'] = CRM_Utils_Array::value('accountingCode', $params);
+ $args['custom'] = $params['accountingCode'] ?? NULL;
// add CiviCRM BN code
$args['BUTTONSOURCE'] = 'CiviCRM_SP';
$params['frequency_interval'] . " " .
$params['frequency_unit'];
$args['amt'] = $this->getAmount($params);
- $args['totalbillingcycles'] = CRM_Utils_Array::value('installments', $params);
+ $args['totalbillingcycles'] = $params['installments'] ?? NULL;
$args['version'] = 56.0;
$args['PROFILEREFERENCE'] = "" .
"i=" . $params['invoiceID'] . "&m=" . $component .
/* Success */
- $params['trxn_id'] = CRM_Utils_Array::value('transactionid', $result);
- $params['gross_amount'] = CRM_Utils_Array::value('amt', $result);
+ $params['trxn_id'] = $result['transactionid'] ?? NULL;
+ $params['gross_amount'] = $result['amt'] ?? NULL;
$params = array_merge($params, $this->doQuery($params));
return $params;
}
$args = [];
$this->initialize($args, 'ManageRecurringPaymentsProfileStatus');
- $args['PROFILEID'] = CRM_Utils_Array::value('subscriptionId', $params);
+ $args['PROFILEID'] = $params['subscriptionId'] ?? NULL;
$args['ACTION'] = 'Cancel';
- $args['NOTE'] = CRM_Utils_Array::value('reason', $params);
+ $args['NOTE'] = $params['reason'] ?? NULL;
$result = $this->invokeAPI($args);
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public static function handlePaymentNotification() {
+ public function handlePaymentNotification() {
$params = array_merge($_GET, $_REQUEST);
$q = explode('/', CRM_Utils_Array::value('q', $params, ''));
$lastParam = array_pop($q);
throw new CRM_Core_Exception("Could not find a processor with the given processor_id value '{$params['processor_id']}'.");
}
- $paymentProcessorType = CRM_Utils_Array::value('api.PaymentProcessorType.getvalue', $result['values'][0]);
+ $paymentProcessorType = $result['values'][0]['api.PaymentProcessorType.getvalue'] ?? NULL;
switch ($paymentProcessorType) {
case 'PayPal':
// "PayPal - Website Payments Pro"
// if recurring donations, add a few more items
if (!empty($params['is_recur'])) {
if (!$params['contributionRecurID']) {
- CRM_Core_Error::fatal(ts('Recurring contribution, but no database id'));
+ throw new CRM_Core_Exception(ts('Recurring contribution, but no database id'));
}
$paypalParams += [
't3' => ucfirst(substr($params['frequency_unit'], 0, 1)),
'src' => 1,
'sra' => 1,
- 'srt' => CRM_Utils_Array::value('installments', $params),
+ 'srt' => $params['installments'] ?? NULL,
'no_note' => 1,
'modify' => 0,
];
protected function mapPaypalParamsToCivicrmParams($fieldMap, $paypalParams) {
$params = [];
foreach ($fieldMap as $civicrmField => $paypalField) {
- $params[$civicrmField] = isset($paypalParams[$paypalField]) ? $paypalParams[$paypalField] : NULL;
+ $params[$civicrmField] = $paypalParams[$paypalField] ?? NULL;
}
return $params;
}