Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

@@ -209,7 +209,7 @@ class _Braintree extends \IPS\nexus\Gateway
'line1' => isset( $invoice->shipaddress->addressLines[0] ) ? $invoice->shipaddress->addressLines[0] : NULL,
'line2' => isset( $invoice->shipaddress->addressLines[1] ) ? $invoice->shipaddress->addressLines[1] : NULL,
'city' => $invoice->shipaddress->city,
'state' => $invoice->shipaddress->region,
'state' => $settings['type'] === 'paypal' ? $this->_payPalState( $invoice->shipaddress ) : $invoice->shipaddress->region,
'postalCode' => $invoice->shipaddress->postalCode,
'countryCode' => $invoice->shipaddress->country,
'phone' => $invoice->member->cm_phone,
@@ -259,7 +259,7 @@ class _Braintree extends \IPS\nexus\Gateway
'lastName' => $invoice->member->cm_last_name,
'streetAddress' => $invoice->billaddress ? implode( ', ', $invoice->billaddress->addressLines ) : NULL,
'locality' => $invoice->billaddress ? $invoice->billaddress->city : NULL,
'region' => $invoice->billaddress ? $invoice->billaddress->region : NULL,
'region' => $invoice->billaddress ? ( $settings['type'] === 'paypal' ? $this->_payPalState( $invoice->billaddress ) : $invoice->billaddress->region ) : NULL,
'postalCode' => $invoice->billaddress ? $invoice->billaddress->postalCode : NULL,
'countryCodeAlpha2' => $invoice->billaddress ? $invoice->billaddress->country : NULL,
'phoneNumber' => preg_replace( '/[^0-9]/', '', $invoice->member->cm_phone ),
@@ -358,7 +358,7 @@ class _Braintree extends \IPS\nexus\Gateway
'lastName' => $transaction->invoice->member->cm_last_name,
'locality' => $transaction->invoice->billaddress->city,
'postalCode' => $transaction->invoice->billaddress->postalCode,
'region' => $transaction->invoice->billaddress->region,
'region' => $settings['type'] === 'paypal' ? $this->_payPalState( $transaction->invoice->billaddress ) : $transaction->invoice->billaddress->region,
'streetAddress' => implode( ', ', $transaction->invoice->billaddress->addressLines )
);
@@ -392,7 +392,7 @@ class _Braintree extends \IPS\nexus\Gateway
'lastName' => $transaction->invoice->member->cm_last_name,
'locality' => $transaction->invoice->shipaddress->city,
'postalCode' => $transaction->invoice->shipaddress->postalCode,
'region' => $transaction->invoice->shipaddress->region,
'region' => $settings['type'] === 'paypal' ? $this->_payPalState( $transaction->invoice->billaddress ) : $transaction->invoice->billaddress->region,
'streetAddress' => implode( ', ', $transaction->invoice->shipaddress->addressLines )
);
@@ -985,5 +985,28 @@ class _Braintree extends \IPS\nexus\Gateway
return $errorMessage;
}
/**
* Get short code for PayPal State
*
* @param \IPS\GeoLocation $address
* @return string
*/
protected function _payPalState( \IPS\GeoLocation $address ): string
{
/* PayPal requires short codes for states */
$state = $address->region;
if ( isset( \IPS\nexus\Customer\Address::$stateCodes[ $address->country ] ) )
{
if ( !array_key_exists( $state, \IPS\nexus\Customer\Address::$stateCodes[ $address->country ] ) )
{
$_state = array_search( $address->region, \IPS\nexus\Customer\Address::$stateCodes[ $address->country ] );
if ( $_state !== FALSE )
{
$state = $_state;
}
}
}
return $state;
}
}