File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -462,7 +462,7 @@ private function camelFieldName($fieldName) {
462462 *
463463 * @param array $params
464464 *
465- * @return array
465+ * @return array|null
466466 */
467467 private function getCreditCardObjectParams ($ params ) {
468468 $ billingID = $ locationTypes = CRM_Core_BAO_LocationType::getBilling ();
@@ -516,6 +516,10 @@ private function getCreditCardObjectParams($params) {
516516 }
517517 }
518518 }
519+ if (empty (array_filter ($ cardFields )) && $ this ->getProcessorTypeMetadata ('is_pass_null_for_empty_card ' )) {
520+ // sagepay hack - see https://github.com/thephpleague/omnipay-sagepay/issues/157#issuecomment-757448484
521+ return NULL ;
522+ }
519523 return $ cardFields ;
520524 }
521525
@@ -578,7 +582,12 @@ protected function getCreditCardOptions(array $params): array {
578582 $ creditCardOptions = array_merge ($ creditCardOptions , $ this ->getProcessorPassThroughFields ());
579583
580584 CRM_Utils_Hook::alterPaymentProcessorParams ($ this , $ params , $ creditCardOptions );
581- $ creditCardOptions ['card ' ] = array_merge ($ creditCardOptions ['card ' ], $ this ->getSensitiveCreditCardObjectOptions ($ params ));
585+ // This really is a hack just for sagepay. I meant to filter all
586+ // empty but other processors expect it to be an object. Test cover exists.
587+ // https://github.com/thephpleague/omnipay-sagepay/pull/158
588+ if (!empty ($ creditCardOptions ['card ' ])) {
589+ $ creditCardOptions ['card ' ] = array_merge ($ creditCardOptions ['card ' ], $ this ->getSensitiveCreditCardObjectOptions ($ params ));
590+ }
582591 return $ creditCardOptions ;
583592 }
584593
You can’t perform that action at this time.
0 commit comments