Version 4.7.13

This commit is contained in:
Neo committed 2025-12-19 16:14:56 -08:00
1 parent fd22d99e69
commit 7124a02564
954 files changed
+29277 -59308

No files matched your search

@@ -23,21 +23,33 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Request
{
/**
* @brief Maxmind User ID
*/
protected ?string $id = NULL;
/**
* @brief Maxmind License Key
*/
protected ?string $licenseKey = NULL;
/**
* @brief Data that will be posted
*/
protected $data = array();
protected array $data = array();
/**
* Constructor
*
* @param bool $session Set session data (set to FALSE if this is being initiated outside the checkout sequence)
* @param NULL|string $maxmindKey MaxMind License Key (NULL to get from settings)
* @param NULL|string $maxmindId MaxMind User ID (NULL to get from settings)
* @return void
*/
public function __construct( $session=TRUE, $maxmindKey=NULL )
public function __construct( $session=TRUE, $maxmindKey=NULL, $maxmindId=NULL )
{
$this->data['license_key'] = $maxmindKey ?: \IPS\Settings::i()->maxmind_key;
$this->licenseKey = $maxmindKey ?: \IPS\Settings::i()->maxmind_key;
$this->id = $maxmindId ?: \IPS\Settings::i()->maxmind_id;
if ( $session )
{
@@ -65,7 +77,7 @@ class _Request
*/
public function setIpAddress( $ipAddress )
{
$this->data['i'] = $ipAddress;
$this->data['device']['ip_address'] = $ipAddress;
}
/**
@@ -87,8 +99,8 @@ class _Request
$this->setShippingAddress( $transaction->invoice->shipaddress );
}
$this->data['order_amount'] = (string) $transaction->amount->amount;
$this->data['order_currency'] = $transaction->amount->currency;
$this->data['order']['amount'] = (string) $transaction->amount->amount;
$this->data['order']['currency'] = $transaction->amount->currency;
}
/**
@@ -99,10 +111,9 @@ class _Request
*/
public function setBillingAddress( \IPS\GeoLocation $billingAddress )
{
$this->data['city'] = $billingAddress->city;
$this->data['region'] = $billingAddress->region;
$this->data['postal'] = $billingAddress->postalCode;
$this->data['country'] = $billingAddress->country;
$this->data['billing']['city'] = $billingAddress->city;
$this->data['billing']['postal'] = $billingAddress->postalCode;
$this->data['billing']['country'] = $billingAddress->country;
}
/**
@@ -113,11 +124,10 @@ class _Request
*/
public function setShippingAddress( \IPS\GeoLocation $shippingAddress )
{
$this->data['shipAddr'] = implode( ', ', $shippingAddress->addressLines );
$this->data['shipCity'] = $shippingAddress->city;
$this->data['shipRegion'] = $shippingAddress->region;
$this->data['shipPostal'] = $shippingAddress->postalCode;
$this->data['shipCountry'] = $shippingAddress->country;
$this->data['shipping']['address'] = implode( ', ', $shippingAddress->addressLines );
$this->data['shipping']['city'] = $shippingAddress->city;
$this->data['shipping']['postal'] = $shippingAddress->postalCode;
$this->data['shipping']['country'] = $shippingAddress->country;
}
/**
@@ -129,7 +139,7 @@ class _Request
public function setMember( \IPS\Member $member )
{
$this->_setEmailProperties( $member->email );
$this->data['usernameMD5'] = md5( $member->name );
$this->data['account']['username_md5'] = md5( $member->name );
}
/**
@@ -190,8 +200,8 @@ class _Request
$local = \substr( $local, 0, $alias );
}
$this->data['domain'] = $domain;
$this->data['emailMD5'] = md5( $local . '@' . $domain );
$this->data['email']['domain'] = $domain;
$this->data['email']['address'] = md5( $local . '@' . $domain );
}
/**
@@ -202,7 +212,7 @@ class _Request
*/
public function setPhone( $phoneNumber )
{
$this->data['custPhone'] = $phoneNumber;
$this->data['billing']['phone_number'] = $phoneNumber;
}
/**
@@ -213,10 +223,9 @@ class _Request
*/
public function setCard( $card )
{
$this->data['txn_type'] = 'creditcard';
$cardNumber = ( $card instanceof \IPS\nexus\CreditCard ) ? $card->number : $card;
$this->data['bin'] = mb_substr( $cardNumber, 0, 6 );
$this->data['credit_card']['issuer_id_number'] = mb_substr( $cardNumber, 0, 6 );
$this->data['credit_card']['last_digits'] = mb_substr( $cardNumber, -4 );
}
/**
@@ -227,7 +236,7 @@ class _Request
*/
public function setTransactionType( $type )
{
$this->data['txn_type'] = $type;
$this->data['event']['txn_type'] = $type;
}
/**
@@ -238,7 +247,7 @@ class _Request
*/
public function setAVS( $code )
{
$this->data['avs_result'] = $code;
$this->data['credit_card']['avs_result'] = $code;
}
/**
@@ -249,7 +258,7 @@ class _Request
*/
public function setCVV( $result )
{
$this->data['cvv_result'] = $result ? 'Y' : 'N';
$this->data['credit_card']['cvv_result'] = $result ? 'Y' : 'N';
}
/**
@@ -260,13 +269,13 @@ class _Request
*/
public function request()
{
$response = \IPS\Http\Url::external( 'https://minfraud.maxmind.com/app/ccv2r' )->request()->post( $this->data );
if ( isset( $response->httpHeaders['Content-Type'] ) and preg_match( '/; charset=(.+?)$/', $response->httpHeaders['Content-Type'], $matches ) )
$response = \IPS\Http\Url::external( 'https://minfraud.maxmind.com/minfraud/v2.0/insights' )->request()->login( $this->id, $this->licenseKey )->post( json_encode( $this->data ) );
if ( isset( $response->httpHeaders['Content-Type'] ) and preg_match( '/; charset=(.+?);$/', $response->httpHeaders['Content-Type'], $matches ) )
{
$response = mb_convert_encoding( $response, 'UTF-8', $matches[1] );
}
return new \IPS\nexus\Fraud\MaxMind\Response( (string) $response );
}
}
@@ -38,11 +38,7 @@ class _Response
{
if ( $data )
{
foreach ( explode( ';', $data ) as $row )
{
$exploded = explode( '=', $row );
$this->data[ $exploded[0] ] = $exploded[1];
}
$this->data = json_decode( $data, true );
}
}
@@ -98,7 +94,7 @@ class _Response
* @brief minFraud error codes
* @see https://dev.maxmind.com/minfraud/#Error_Reporting
*/
protected static $responseErrors = array( 'INVALID_LICENSE_KEY', 'IP_REQUIRED', 'IP_NOT_FOUND ', 'MAX_REQUESTS_REACHED', 'LICENSE_REQUIRED ');
protected static array $responseErrors = array( 'JSON_INVALID', 'REQUEST_INVALID', 'AUTHORIZATION_INVALID', 'ACCOUNT_ID_REQUIRED', 'LICENSE_KEY_REQUIRED', 'INSUFFICIENT_FUNDS', 'PERMISSION_REQUIRED' );
/**
* Does the response include an error?
@@ -107,7 +103,7 @@ class _Response
*/
public function error()
{
if ( $this->err AND \in_array($this->err, static::$responseErrors ) )
if ( $this->error AND \in_array( $this->code, static::$responseErrors ) )
{
return TRUE;
}
@@ -121,7 +117,7 @@ class _Response
*/
public function warning()
{
if ( $this->err AND !\in_array($this->err, static::$responseErrors ) )
if ( $this->error AND !\in_array($this->code, static::$responseErrors ) )
{
return TRUE;
}