Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -9,7 +9,7 @@
* @since 17 Mar 2014
*/
define('REPORT_EXCEPTIONS', TRUE);
\define('REPORT_EXCEPTIONS', TRUE);
require_once '../../../../init.php';
try
@@ -26,37 +26,83 @@ try
{
/* Load Gateway */
$gateway = \IPS\nexus\Gateway::load( \IPS\Request::i()->payment_method );
$settings = json_decode( $gateway->settings, TRUE );
/* Check MD5 hash */
if ( !\IPS\Login::compareHashes( mb_strtoupper( md5( $settings['hash'] . $settings['login'] . \IPS\Request::i()->x_trans_id . \IPS\Request::i()->x_amount ) ), \IPS\Request::i()->x_MD5_Hash ) )
if ( !( $gateway instanceof \IPS\nexus\Gateway\AuthorizeNet ) )
{
throw new \Exception( $invoice->member->language()->addToStack('gateway_err') );
}
$settings = json_decode( $gateway->settings, TRUE );
/* Check hash */
$message = '^' . implode( '^', array(
\IPS\Request::i()->x_trans_id,
\IPS\Request::i()->x_test_request,
\IPS\Request::i()->x_response_code,
\IPS\Request::i()->x_auth_code,
\IPS\Request::i()->x_cvv2_resp_code,
\IPS\Request::i()->x_cavv_response,
\IPS\Request::i()->x_avs_code,
\IPS\Request::i()->x_method,
\IPS\Request::i()->x_account_number,
\IPS\Request::i()->x_amount,
\IPS\Request::i()->x_company,
\IPS\Request::i()->x_first_name,
\IPS\Request::i()->x_last_name,
\IPS\Request::i()->x_address,
\IPS\Request::i()->x_city,
\IPS\Request::i()->x_state,
\IPS\Request::i()->x_zip,
\IPS\Request::i()->x_country,
\IPS\Request::i()->x_phone,
\IPS\Request::i()->x_fax,
\IPS\Request::i()->x_email,
\IPS\Request::i()->x_ship_to_company,
\IPS\Request::i()->x_ship_to_first_name,
\IPS\Request::i()->x_ship_to_last_name,
\IPS\Request::i()->x_ship_to_address,
\IPS\Request::i()->x_ship_to_city,
\IPS\Request::i()->x_ship_to_state,
\IPS\Request::i()->x_ship_to_zip,
\IPS\Request::i()->x_ship_to_country,
\IPS\Request::i()->x_invoice_num,
) ) . '^';
if ( isset( \IPS\Request::i()->x_SHA2_Hash ) and isset( $settings['signature_key'] ) and $settings['signature_key'] and \IPS\Login::compareHashes( mb_strtoupper( hash_hmac( 'sha512', $message, hex2bin( $settings['signature_key'] ) ) ), \IPS\Request::i()->x_SHA2_Hash ) )
{
// SHA hash is okay
}
elseif ( isset( \IPS\Request::i()->x_MD5_Hash ) and isset( $settings['hash'] ) and $settings['hash'] and \IPS\Login::compareHashes( mb_strtoupper( md5( $settings['hash'] . $settings['login'] . \IPS\Request::i()->x_trans_id . \IPS\Request::i()->x_amount ) ), \IPS\Request::i()->x_MD5_Hash ) )
{
// MD5 hash is okay
}
else
{
throw new \Exception( $invoice->member->language()->addToStack('gateway_err') );
}
/* Was it accepted? */
if ( \IPS\Request::i()->x_response_code != 1 )
{
\IPS\Session\Front::i();
throw new \IPS\nexus\Gateway\AuthorizeNet\Exception( \IPS\Request::i()->x_response_reason_code );
}
/* Create a transaction */
$transaction = new \IPS\nexus\Transaction;
$transaction->member = \IPS\Member::load( \IPS\Request::i()->x_cust_id );
$transaction->invoice = $invoice;
$transaction->method = $gateway;
$transaction->amount = \IPS\Request::i()->x_amount;
$transaction->amount = new \IPS\nexus\Money( \IPS\Request::i()->x_amount, $invoice->currency );
$transaction->currency = $invoice->currency;
$transaction->gw_id = \IPS\Request::i()->x_trans_id;
$transaction->ip = \IPS\Request::i()->x_customer_ip;
$transaction->ip = isset( \IPS\Request::i()->x_customer_ip ) ? \IPS\Request::i()->x_customer_ip : \IPS\Request::i()->ipAddress();
$extra = $transaction->extra;
$extra['lastFour'] = str_replace( 'X', '', \IPS\Request::i()->x_account_number );
$transaction->extra = $extra;
$transaction->auth = \IPS\DateTime::create()->add( new \DateInterval( 'P30D' ) );
/* Create a MaxMind request */
$maxMind = NULL;
if ( \IPS\Settings::i()->maxmind_key and ( !\IPS\Settings::i()->maxmind_gateways or \IPS\Settings::i()->maxmind_gateways == '*' or in_array( $transaction->method->id, explode( ',', \IPS\Settings::i()->maxmind_gateways ) ) ) )
if ( \IPS\Settings::i()->maxmind_key and ( !\IPS\Settings::i()->maxmind_gateways or \IPS\Settings::i()->maxmind_gateways == '*' or \in_array( $transaction->method->id, explode( ',', \IPS\Settings::i()->maxmind_gateways ) ) ) )
{
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request;
$maxMind->setTransaction( $transaction );