From a09e667971c2a610e0b49ec49e1cee2f28aef3be Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 23 Sep 2021 11:58:13 +0100 Subject: [PATCH] Add billingStateProvince and standardized property names --- Civi/Payment/PropertyBag.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Civi/Payment/PropertyBag.php b/Civi/Payment/PropertyBag.php index 25e4a1d369..f0cfa1e59a 100644 --- a/Civi/Payment/PropertyBag.php +++ b/Civi/Payment/PropertyBag.php @@ -26,13 +26,23 @@ class PropertyBag implements \ArrayAccess { protected static $propMap = [ 'amount' => TRUE, + 'total_amount' => 'amount', 'billingStreetAddress' => TRUE, + 'billing_street_address' => 'billingStreetAddress', + 'street_address' => 'billingStreetAddress', 'billingSupplementalAddress1' => TRUE, 'billingSupplementalAddress2' => TRUE, 'billingSupplementalAddress3' => TRUE, 'billingCity' => TRUE, + 'billing_city' => 'billingCity', + 'city' => 'billingCity', 'billingPostalCode' => TRUE, + 'billing_postal_code' => 'billingPostalCode', + 'postal_code' => 'billingPostalCode', 'billingCounty' => TRUE, + 'billingStateProvince' => TRUE, + 'billing_state_province' => 'billingStateProvince', + 'state_province' => 'billingStateProvince', 'billingCountry' => TRUE, 'contactID' => TRUE, 'contact_id' => 'contactID', @@ -264,7 +274,7 @@ class PropertyBag implements \ArrayAccess { if ($newName === NULL) { if ($silent) { // Only for use by offsetExists - return; + return NULL; } throw new \InvalidArgumentException("Unknown property '$prop'."); } @@ -300,7 +310,7 @@ class PropertyBag implements \ArrayAccess { * * @return PropertyBag $this object so you can chain set setters. */ - protected function set($prop, $label, $value) { + protected function set($prop, $label = 'default', $value) { $this->props[$label][$prop] = $value; return $this; } @@ -591,6 +601,27 @@ class PropertyBag implements \ArrayAccess { return $this->set('billingCounty', $label, (string) $input); } + /** + * BillingStateProvince getter. + * + * @return string + */ + public function getBillingStateProvince($label = 'default') { + return $this->get('billingStateProvince', $label); + } + + /** + * BillingStateProvince setter. + * + * Nb. we can't validate this unless we have the country ID too, so we don't. + * + * @param string $input + * @param string $label e.g. 'default' + */ + public function setBillingStateProvince($input, $label = 'default') { + return $this->set('billingStateProvince', $label, (string) $input); + } + /** * BillingCountry getter. * -- 2.25.1