Skip to content

Commit

Permalink
Add handling for sagePay intolerance for empty card
Browse files Browse the repository at this point in the history
Hopefully thephpleague/omnipay-sagepay#158
will be merged but for now SagePay assumes that an empty card is an ignore-everything-else-card
  • Loading branch information
eileenmcnaughton committed Jan 10, 2021
1 parent 279badd commit ba89546
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CRM/Core/Payment/OmnipayMultiProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ private function camelFieldName($fieldName) {
*
* @param array $params
*
* @return array
* @return array|null
*/
private function getCreditCardObjectParams($params) {
$billingID = $locationTypes = CRM_Core_BAO_LocationType::getBilling();
Expand Down Expand Up @@ -516,6 +516,10 @@ private function getCreditCardObjectParams($params) {
}
}
}
if (empty(array_filter($cardFields))) {
// sagepay hack - see https://github.com/thephpleague/omnipay-sagepay/issues/157#issuecomment-757448484
return NULL;
}
return $cardFields;
}

Expand Down Expand Up @@ -578,7 +582,9 @@ protected function getCreditCardOptions(array $params): array {
$creditCardOptions = array_merge($creditCardOptions, $this->getProcessorPassThroughFields());

CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $creditCardOptions);
$creditCardOptions['card'] = array_merge($creditCardOptions['card'], $this->getSensitiveCreditCardObjectOptions($params));
if (!empty($creditCardOptions['card'])) {
$creditCardOptions['card'] = array_merge($creditCardOptions['card'], $this->getSensitiveCreditCardObjectOptions($params));
}
return $creditCardOptions;
}

Expand Down

0 comments on commit ba89546

Please sign in to comment.