Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF Use the new prepareParamsForPaymentProcessor function in more places #15281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions CRM/Event/Form/Participant.php
Expand Up @@ -1228,9 +1228,7 @@ public function submit($params) {

if ($this->_mode) {
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);

$this->_params = $this->prepareParamsForPaymentProcessor($this->_params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter that now these are only being set if !empty($params["billing_state_province_id-{$this->_bltID}"]) and similarly for country id?

and that
$params['state_province']
and
$params['country']

are now being set as well? I assume not but just wanted to double check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is the fact that we were not previous testing for empty values the problem!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stesi561 The fact we weren't checking for empty values would potentially cause PHP notices. And missing params that are now being set means we might now be saving data that might not have been saved previously (or the payment processor had to implement custom handling to look for the parameter) - eg. for Country.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this change won't clash with custom handling in payment processors. The dummy processor was already saving address data. However if this is a change of behaviour I think it's possibly worth referencing in the PR description?

$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
Expand Down
9 changes: 1 addition & 8 deletions CRM/Event/Form/Registration/Confirm.php
Expand Up @@ -90,15 +90,8 @@ public function preProcess() {
if (!$this->preProcessExpress()) {
//process only primary participant params.
$registerParams = $this->_params[0];
if (isset($registerParams["billing_state_province_id-{$this->_bltID}"])
&& $registerParams["billing_state_province_id-{$this->_bltID}"]
) {
$registerParams["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($registerParams["billing_state_province_id-{$this->_bltID}"]);
}
$registerParams = $this->prepareParamsForPaymentProcessor($registerParams);

if (isset($registerParams["billing_country_id-{$this->_bltID}"]) && $registerParams["billing_country_id-{$this->_bltID}"]) {
$registerParams["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($registerParams["billing_country_id-{$this->_bltID}"]);
}
if (isset($registerParams['credit_card_exp_date'])) {
$registerParams['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($registerParams);
$registerParams['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($registerParams);
Expand Down
11 changes: 1 addition & 10 deletions CRM/Event/Form/Registration/Register.php
Expand Up @@ -1105,17 +1105,8 @@ public function postProcess() {
$this->set('contributeMode', 'direct');

// This code is duplicated multiple places and should be consolidated.
if (isset($params["state_province_id-{$this->_bltID}"]) &&
$params["state_province_id-{$this->_bltID}"]
) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
$params = $this->prepareParamsForPaymentProcessor($params);

if (isset($params["country_id-{$this->_bltID}"]) &&
$params["country_id-{$this->_bltID}"]
) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
}
if (isset($params['credit_card_exp_date'])) {
$params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($params);
$params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($params);
Expand Down