Skip to content

Commit

Permalink
Merge pull request #9399 from jitendrapurohit/CRM-19621
Browse files Browse the repository at this point in the history
CRM-19621: Contribution confirm page does not display state/country
  • Loading branch information
monishdeb authored Nov 16, 2016
2 parents ecb3ba9 + dd22a91 commit cd86a3b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
22 changes: 16 additions & 6 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,23 @@ public function preProcess() {
if (!empty($this->_membershipBlock)) {
$this->_params['selectMembership'] = $this->get('selectMembership');
}
if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$this->_params = array_merge($this->_params, $preApprovalParams);
if (!empty($this->_paymentProcessor)) {
if ($this->_paymentProcessor['object']->supports('preApproval')) {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$this->_params = array_merge($this->_params, $preApprovalParams);

// We may have fetched some billing details from the getPreApprovalDetails function so we
// want to ensure we set this after that function has been called.
CRM_Core_Payment_Form::mapParams($this->_bltID, $preApprovalParams, $this->_params, FALSE);
// We may have fetched some billing details from the getPreApprovalDetails function so we
// want to ensure we set this after that function has been called.
CRM_Core_Payment_Form::mapParams($this->_bltID, $preApprovalParams, $this->_params, FALSE);
}

// Set text version of state & country if present.
if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
$this->_params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
}
if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
$this->_params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
}
}

$this->_params['is_pay_later'] = $this->get('is_pay_later');
Expand Down
7 changes: 0 additions & 7 deletions CRM/Core/Payment/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,6 @@ public static function validateCreditCard($values, &$errors, $processorID = NULL
* @param bool $reverse
*/
public static function mapParams($id, $src, &$dst, $reverse = FALSE) {
// Set text version of state & country if present.
if (isset($src["billing_state_province_id-{$id}"])) {
$src["billing_state_province-{$id}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($src["billing_state_province_id-{$id}"]);
}
if (isset($src["billing_country_id-{$id}"])) {
$src["billing_country-{$id}"] = CRM_Core_PseudoConstant::countryIsoCode($src["billing_country_id-{$id}"]);;
};
$map = array(
'first_name' => 'billing_first_name',
'middle_name' => 'billing_middle_name',
Expand Down
4 changes: 4 additions & 0 deletions CRM/Utils/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ public static function getFormattedBillingAddressFieldsFromParameters($params, $
$addressFields = array();
foreach ($addressParts as $name => $field) {
$addressFields[$name] = CRM_Utils_Array::value($field, $params);
//Include values which prepend 'billing_' to country and state_province.
if (empty($params[$field])) {
$addressFields[$name] = CRM_Utils_Array::value('billing_' . $field, $params);
}
}
return CRM_Utils_Address::format($addressFields);
}
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/WebTest/Contribute/OnlineContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public function testOnlineContributionAdd() {
$this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $firstName . "billing");
$this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $lastName . "billing");

$stateText = CRM_Core_PseudoConstant::stateProvinceAbbreviation(1004);
$countryText = CRM_Core_PseudoConstant::countryIsoCode(1228);
$billingDetails = array('15 Main St.', 'San Jose', '94129', $stateText, $countryText);
foreach ($billingDetails as $field) {
$this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_address-section']", $field);
}

$this->click("_qf_Confirm_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());

Expand Down

0 comments on commit cd86a3b

Please sign in to comment.