Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Authorize.Net Gateway
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Nexus
* @since 17 Mar 2014
* @version SVN_VERSION_NUMBER
@@ -32,56 +32,72 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
/**
* Check the gateway can process this...
*
* @param $amount \IPS\nexus\Money The amount
* @param $billingAddress \IPS\GeoLocation The billing address
* @param $amount \IPS\nexus\Money The amount
* @param $billingAddress \IPS\GeoLocation|NULL The billing address, which may be NULL if one if not provided
* @param $customer \IPS\nexus\Customer The customer (Default NULL value is for backwards compatibility - it should always be provided.)
* @param array $recurrings Details about recurring costs
* @return bool
*/
public function checkValidity( \IPS\nexus\Money $amount, \IPS\GeoLocation $billingAddress )
public function checkValidity( \IPS\nexus\Money $amount, \IPS\GeoLocation $billingAddress = NULL, \IPS\nexus\Customer $customer = NULL, $recurrings = array() )
{
$settings = json_decode( $this->settings, TRUE );
/* If we don't know the processor, we can only go off the default checks */
if ( !$settings['processor'] )
{
return parent::checkValidity( $amount, $billingAddress );
return parent::checkValidity( $amount, $billingAddress, $customer, $recurrings );
}
$currencies = array();
/* European processors require a full name and billing address */
if ( in_array( $settings['processor'], array( 8, 9, 10, 11, 12, 13 ) ) )
{
if ( !$customer->cm_first_name or !$customer->cm_last_name or !$billingAddress )
{
return FALSE;
}
}
/* GPN Canada and WorldPay Streamline Processing Platform also require a billing address */
if ( in_array( $settings['processor'], array( 4, 13 ) ) )
{
if ( !$billingAddress )
{
return FALSE;
}
}
/* For everything else, check the currencies they can handle... */
$currencies = array();
if ( in_array( $settings['processor'], array( 1, 2, 4, 5, 6, 7, 8, 13, 14 ) ) )
{
$currencies[] = 'USD';
}
if ( in_array( $settings['processor'], array( 1, 2, 4 ) ) )
{
$currencies[] = 'CAD';
}
if ( in_array( $settings['processor'], array( 8, 9, 10, 11, 12, 13 ) ) )
{
$currencies[] = 'GBP';
}
if ( in_array( $settings['processor'], array( 8, 9, 11, 13 ) ) )
{
$currencies[] = 'EUR';
}
if ( in_array( $settings['processor'], array( 14, 15 ) ) )
{
$currencies[] = 'AUD';
}
if ( in_array( $settings['processor'], array( 14 ) ) )
{
$currencies[] = 'NZD';
}
if ( !in_array( $amount->currency, $currencies ) )
{
return FALSE;
}
return parent::checkValidity( $amount, $billingAddress );
/* Still here? We're good - pass to parent for general checks */
return parent::checkValidity( $amount, $billingAddress, $customer, $recurrings );
}
/**
@@ -113,9 +129,11 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
*
* @param \IPS\nexus\Invoice $invoice Invoice
* @param \IPS\nexus\Money $amount The amount to pay now
* @param \IPS\Member $member The member the payment screen is for (if in the ACP charging to a member's card) or NULL for currently logged in member
* @param array $recurrings Details about recurring costs
* @return array
*/
public function paymentScreen( \IPS\nexus\Invoice $invoice, \IPS\nexus\Money $amount )
public function paymentScreen( \IPS\nexus\Invoice $invoice, \IPS\nexus\Money $amount, \IPS\Member $member = NULL, $recurrings = array() )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_gateways.js', 'nexus', 'global' ) );
@@ -146,7 +164,7 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
{
$types = array( \IPS\nexus\CreditCard::TYPE_AMERICAN_EXPRESS, \IPS\nexus\CreditCard::TYPE_DINERS_CLUB, \IPS\nexus\CreditCard::TYPE_DISCOVER, \IPS\nexus\CreditCard::TYPE_JCB, \IPS\nexus\CreditCard::TYPE_MASTERCARD, \IPS\nexus\CreditCard::TYPE_VISA );
}
$options = array( 'types' => $types );
$options = array( 'types' => $types, 'member' => $member );
/* If we're using DPM, we include all that data in here */
if ( $settings['method'] == 'DPM' )
@@ -165,7 +183,7 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
'x_version' => '3.1',
'x_type' => 'AUTH_ONLY',
'x_method' => 'CC',
'x_amount' => $amount->amount,
'x_amount' => (string) $amount->amount,
'x_currency_code' => $amount->currency,
'x_fp_hash' => hash_hmac( 'md5', "{$settings['login']}^{$invoice->id}^{$timestamp}^{$amount->amount}^{$amount->currency}", $settings['tran_key'] ),
'x_fp_sequence' => $invoice->id,
@@ -208,10 +226,11 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
* @param \IPS\nexus\Transaction $transaction Transaction
* @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them
* @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made
* @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever
* @throws \LogicException Message will be displayed to user
* @param array $recurrings Details about recurring costs
* @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever
* @throws \LogicException Message will be displayed to user
*/
public function auth( \IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL )
public function auth( \IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL, $recurrings = array() )
{
$card = is_array( $values ) ? $values[ $this->id . '_card' ] : $values;
@@ -226,15 +245,18 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
/* Authorize */
$profiles = $card->member->cm_profiles;
$xml = $card->create( 'createCustomerProfileTransactionRequest' );
$xml = $card->createAuthenticationXml( 'createCustomerProfileTransactionRequest' );
$xml->addChild( 'transaction', array(
'profileTransAuthOnly' => array(
'amount' => $transaction->amount->amount,
'amount' => (string) $transaction->amount->amount,
'customerProfileId' => $profiles[ $card->method->id ],
'customerPaymentProfileId' => $card->data,
),
) );
$response = $this->_handleResponse( explode( ',', $card->api( $xml )->directResponse ) );
/* Change $card to the actual \IPS\nexus\CreditCard object so we get the last 4 digits correctly */
$card = $card->card;
}
/* New Card */
@@ -250,18 +272,18 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
$response = $this->api( array(
'x_type' => 'AUTH_ONLY',
'x_method' => 'CC',
'x_amount' => $transaction->amount->amount,
'x_amount' => (string) $transaction->amount->amount,
'x_currency_code' => $transaction->amount->currency,
'x_card_num' => $card->number,
'x_exp_date' => str_pad( $card->expMonth, 2, '0', STR_PAD_LEFT ) . '-' . $card->expYear,
'x_card_code' => $card->ccv,
'x_first_name' => $transaction->member->cm_first_name,
'x_last_name' => $transaction->member->cm_last_name,
'x_address' => implode( ', ', $transaction->invoice->billaddress->addressLines ),
'x_city' => $transaction->invoice->billaddress->city,
'x_state' => $transaction->invoice->billaddress->region,
'x_zip' => $transaction->invoice->billaddress->postalCode,
'x_country' => $transaction->invoice->billaddress->country,
'x_address' => $transaction->invoice->billaddress ? implode( ', ', $transaction->invoice->billaddress->addressLines ) : '',
'x_city' => $transaction->invoice->billaddress ? $transaction->invoice->billaddress->city : '',
'x_state' => $transaction->invoice->billaddress ? $transaction->invoice->billaddress->region : '',
'x_zip' => $transaction->invoice->billaddress ? $transaction->invoice->billaddress->postalCode : '',
'x_country' => $transaction->invoice->billaddress ? $transaction->invoice->billaddress->country : '',
'x_phone' => $transaction->member->cm_phone,
'x_email' => $transaction->member->email,
'x_email_customer' => 'FALSE',
@@ -339,15 +361,24 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
* @throws \Exception
*/
public function refund( \IPS\nexus\Transaction $transaction, $amount = NULL )
{
$extra = json_decode( $transaction->extra, TRUE );
$this->api( array(
'x_type' => 'CREDIT',
'x_trans_id' => $transaction->gw_id,
'x_amount' => $amount ?: $transaction->amount->amount,
'x_card_num' => $extra['lastFour']
) );
{
try
{
$this->api( array(
'x_type' => 'CREDIT',
'x_trans_id' => $transaction->gw_id,
'x_amount' => (string) ( $amount ?: $transaction->amount->amount ),
'x_card_num' => $transaction->extra['lastFour']
) );
}
catch( \IPS\nexus\Gateway\AuthorizeNet\Exception $e )
{
/* If the transaction is unsettled (error code 54 from the API), then we need to void it instead */
if ( $e->getCode() == 54 )
{
$this->void( $transaction );
}
}
}
/* !ACP Configuration */
@@ -376,7 +407,7 @@ class _AuthorizeNet extends \IPS\nexus\Gateway
) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'authorizenet_cim', $settings['cim'], FALSE, array(), NULL, NULL, NULL, 'authorizenet_cim' ) );
$form->add( new \IPS\Helpers\Form\Text( 'authorizenet_hash', $settings['hash'], FALSE, array(), NULL, NULL, NULL, 'authorizenet_hash' ) );
$form->add( new \IPS\Helpers\Form\Select( 'authorizenet_processor', $settings['processor'], FALSE, array( 'options' => array(
$form->add( new \IPS\Helpers\Form\Select( 'authorizenet_processor', isset( $settings['processor'] ) ? $settings['processor'] : '0', FALSE, array( 'options' => array(
0 => 'dont_know',
'North American Payment Processors' => array(
1 => 'Chase Paymentech Tampa Processing Platform',