Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -45,7 +45,7 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
/* Create Table */
|
||||
$table = \IPS\nexus\Transaction::table( array( array( 't_status<>?', \IPS\nexus\Transaction::STATUS_PENDING ) ), \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=transactions' ), 't' );
|
||||
$table->filters = array(
|
||||
'tstatus_hold' => array( '( t_status=? OR t_status=? )', \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW ),
|
||||
'trans_attention_required' => array( '( t_status=? OR t_status=? OR t_status=? )', \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ),
|
||||
);
|
||||
$table->advancedSearch = array(
|
||||
't_id' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
@@ -58,6 +58,10 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
$table->quickSearch = 't_id';
|
||||
|
||||
/* Display */
|
||||
if ( isset( \IPS\Request::i()->attn ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( '( t_status=? OR t_status=? OR t_status=? )', \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) ) )
|
||||
{
|
||||
$table->filter = 'trans_attention_required';
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_payments_transactions');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
}
|
||||
@@ -105,7 +109,7 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
$method = $transaction->method;
|
||||
|
||||
/* Can we approve it? */
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_PENDING, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ) ) )
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'transaction_status_err', '2X186/A', 403, '' );
|
||||
}
|
||||
@@ -163,7 +167,7 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
$method = $transaction->method;
|
||||
|
||||
/* Can we flag it? */
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_PENDING, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_HELD ) ) )
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_HELD ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'transaction_status_err', '2X186/B', 403, '' );
|
||||
}
|
||||
@@ -176,11 +180,14 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
$transaction->save();
|
||||
|
||||
/* Log it */
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'status',
|
||||
'status' => \IPS\nexus\Transaction::STATUS_REVIEW,
|
||||
'id' => $transaction->id
|
||||
) );
|
||||
if( $transaction->member )
|
||||
{
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'status',
|
||||
'status' => \IPS\nexus\Transaction::STATUS_REVIEW,
|
||||
'id' => $transaction->id
|
||||
) );
|
||||
}
|
||||
|
||||
/* Create a support request? */
|
||||
if ( \IPS\Settings::i()->nexus_revw_sa != -1 )
|
||||
@@ -248,7 +255,7 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
$method = $transaction->method;
|
||||
|
||||
/* Can we void it? */
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_PENDING, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ) ) and ( !$transaction->auth or !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW ) ) ) )
|
||||
if ( !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ) ) and ( !$transaction->auth or !in_array( $transaction->status, array( \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW ) ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'transaction_status_err', '2X186/5', 403, '' );
|
||||
}
|
||||
@@ -302,12 +309,18 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
/* What are the refund methods? */
|
||||
$refundMethods = array();
|
||||
$refundMethodToggles = array( 'credit' => array( 'refund_amount' ) );
|
||||
$refundReasons = array();
|
||||
if ( $method and $method::SUPPORTS_REFUNDS )
|
||||
{
|
||||
$refundMethods['gateway'] = $method->_title;
|
||||
$refundMethodToggles['gateway'] = array();
|
||||
if ( $method::SUPPORTS_PARTIAL_REFUNDS )
|
||||
{
|
||||
$refundMethodToggles['gateway'] = array( 'refund_amount' );
|
||||
$refundMethodToggles['gateway'][] = 'refund_amount';
|
||||
}
|
||||
if ( $refundReasons = $method::refundReasons() )
|
||||
{
|
||||
$refundMethodToggles['gateway'][] = 'refund_reason';
|
||||
}
|
||||
}
|
||||
$refundMethods['credit'] = 'refund_method_credit';
|
||||
@@ -316,7 +329,20 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'refund_method', ( $method and $method::SUPPORTS_REFUNDS ) ? 'gateway' : 'credit', TRUE, array( 'options' => $refundMethods, 'toggles' => $refundMethodToggles ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'refund_amount', ( $transaction->status === \IPS\nexus\Transaction::STATUS_PART_REFUNDED ? $transaction->amount->amount->subtract( $transaction->partial_refund->amount ) : 0 ), TRUE, array( 'unlimited' => 0, 'unlimitedLang' => \IPS\Member::loggedIn()->language()->addToStack( 'refund_full', FALSE, array( 'sprintf' => array( $transaction->amount ) ) ), 'max' => (string) $transaction->amount->amount->subtract( $transaction->partial_refund->amount ), 'decimals' => TRUE ), NULL, NULL, $transaction->amount->currency, 'refund_amount' ) );
|
||||
if ( $refundReasons )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'refund_reason', NULL, FALSE, array( 'options' => $refundReasons ), NULL, NULL, NULL, 'refund_reason' ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'refund_amount', 0, TRUE, array(
|
||||
'unlimited' => 0,
|
||||
'unlimitedLang' => (
|
||||
$transaction->status === \IPS\nexus\Transaction::STATUS_PART_REFUNDED
|
||||
? \IPS\Member::loggedIn()->language()->addToStack( 'refund_full_remaining', FALSE, array( 'sprintf' => array( new \IPS\nexus\Money( $transaction->amount->amount->subtract( $transaction->partial_refund->amount ), $transaction->currency ) ) ) )
|
||||
: \IPS\Member::loggedIn()->language()->addToStack( 'refund_full', FALSE, array( 'sprintf' => array( $transaction->amount ) ) )
|
||||
),
|
||||
'max' => (string) $transaction->amount->amount->subtract( $transaction->partial_refund->amount ),
|
||||
'decimals' => TRUE
|
||||
), NULL, NULL, $transaction->amount->currency, 'refund_amount' ) );
|
||||
if ( $transaction->invoice !== NULL and $transaction->invoice->status === \IPS\nexus\Invoice::STATUS_PAID )
|
||||
{
|
||||
$field = new \IPS\Helpers\Form\Radio( 'refund_invoice_status', \IPS\nexus\Invoice::STATUS_PENDING, TRUE, array(
|
||||
@@ -340,7 +366,7 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
/* Refund */
|
||||
try
|
||||
{
|
||||
$transaction->refund( $values['refund_method'], $values['refund_amount'] );
|
||||
$transaction->refund( $values['refund_method'], $values['refund_amount'], isset( $values['refund_reason'] ) ? $values['refund_reason'] : NULL );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
@@ -358,12 +384,15 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$transaction->invoice->markUnpaid( $values['refund_invoice_status'] );
|
||||
|
||||
$transaction->invoice->member->log( 'invoice', array(
|
||||
'type' => 'status',
|
||||
'new' => $values['refund_invoice_status'],
|
||||
'id' => $transaction->invoice->id,
|
||||
'title' => $transaction->invoice->title
|
||||
) );
|
||||
if( $transaction->invoice->member )
|
||||
{
|
||||
$transaction->invoice->member->log( 'invoice', array(
|
||||
'type' => 'status',
|
||||
'new' => $values['refund_invoice_status'],
|
||||
'id' => $transaction->invoice->id,
|
||||
'title' => $transaction->invoice->title
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Send Email */
|
||||
@@ -406,11 +435,14 @@ class _transactions extends \IPS\Dispatcher\Controller
|
||||
/* Log it */
|
||||
try
|
||||
{
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'delete',
|
||||
'id' => $transaction->id,
|
||||
'method' => $transaction->method->id
|
||||
) );
|
||||
if( $transaction->member )
|
||||
{
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'delete',
|
||||
'id' => $transaction->id,
|
||||
'method' => $transaction->method->id
|
||||
) );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user