Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
Whitespace-only changes.
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Send/Discard handler for pending support replies
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 25 Apr 2014
|
||||
*/
|
||||
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Dispatcher\External::i();
|
||||
|
||||
try
|
||||
{
|
||||
$reply = \IPS\nexus\Support\Reply::load( \IPS\Request::i()->id );
|
||||
if ( !\IPS\Login::compareHashes( md5( $reply->item()->email_key . $reply->date ), (string) \IPS\Request::i()->key ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X206/1', 404, '' );
|
||||
}
|
||||
|
||||
if ( $reply->type !== \IPS\nexus\Support\Reply::REPLY_PENDING )
|
||||
{
|
||||
\IPS\Output::i()->error( 'support_reply_not_pending', '1X206/2', 403, '' );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->send )
|
||||
{
|
||||
$reply->sendPending();
|
||||
}
|
||||
else
|
||||
{
|
||||
$reply->delete();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->blankTemplate( \IPS\Theme::i()->getTemplate( 'support', 'nexus', 'front' )->pendingDone( \IPS\Request::i()->send ? 'support_pending_sent' : 'support_pending_discarded' ) ) );
|
||||
@@ -12,6 +12,8 @@
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
require_once '../../../../init.php';
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
$invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->x_invoice_num );
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
require_once '../../../../init.php';
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
$webhookNotification = NULL;
|
||||
$transaction = NULL;
|
||||
foreach ( \IPS\nexus\Gateway::roots() as $method )
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Session\Front::i();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
/**
|
||||
* PayPal Webhook Handler
|
||||
*/
|
||||
|
||||
@@ -71,10 +71,11 @@ try
|
||||
$transaction->billing_agreement = $billingAgreement;
|
||||
$transaction->save();
|
||||
|
||||
/* Just save that we're waiting for the webhook */
|
||||
/* Just save that we're waiting for the webhook, but also try again in a few minutes because PayPal is flakey */
|
||||
$transaction->status = \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING;
|
||||
$transaction->save();
|
||||
$transaction->sendNotification();
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='gatewayPending'" );
|
||||
\IPS\Output::i()->redirect( $transaction->url() );
|
||||
}
|
||||
|
||||
@@ -101,11 +102,49 @@ try
|
||||
$billingAgreement->save();
|
||||
$transaction->billing_agreement = $billingAgreement;
|
||||
$transaction->save();
|
||||
|
||||
/* Get the initial setup transaction if possible */
|
||||
$haveInitialTransaction = FALSE;
|
||||
$transactions = $transaction->method->api( "payments/billing-agreements/{$billingAgreement->gw_id}/transactions?start_date=" . date( 'Y-m-d', time() - 86400 ) . '&end_date=' . date( 'Y-m-d' ), NULL, 'get' );
|
||||
foreach ( $transactions['agreement_transaction_list'] as $t )
|
||||
{
|
||||
if ( $t['status'] == 'Completed' )
|
||||
{
|
||||
$transaction->gw_id = $t['transaction_id'];
|
||||
$transaction->save();
|
||||
|
||||
if ( $fraudResult and $fraudResult !== \IPS\nexus\Transaction::STATUS_PAID )
|
||||
{
|
||||
$transaction->executeFraudAction( $fraudResult, TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'paid',
|
||||
'status' => $transaction::STATUS_PAID,
|
||||
'id' => $transaction->id,
|
||||
'invoice_id' => $transaction->invoice->id,
|
||||
'invoice_title' => $transaction->invoice->title,
|
||||
) );
|
||||
|
||||
$memberJustCreated = $transaction->approve();
|
||||
if ( $memberJustCreated )
|
||||
{
|
||||
\IPS\Session::i()->setMember( $memberJustCreated );
|
||||
\IPS\Member\Device::loadOrCreate( $memberJustCreated, FALSE )->updateAfterAuthentication( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->sendNotification();
|
||||
\IPS\Output::i()->redirect( $transaction->url() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Just save that we're waiting for the webhook */
|
||||
$transaction->status = \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING;
|
||||
$transaction->save();
|
||||
$transaction->sendNotification();
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='gatewayPending'" );
|
||||
\IPS\Output::i()->redirect( $transaction->url() );
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Session\Front::i();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
/* Get the invoice */
|
||||
try
|
||||
{
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Session\Front::i();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
/* Little IN_DEV helper to prevent firing this until we've triggered the webhooks */
|
||||
if ( \IPS\IN_DEV and !isset( \IPS\Request::i()->indevconfirm ) )
|
||||
{
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Session\Front::i();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
/**
|
||||
* Stripe Webhook Handler
|
||||
*/
|
||||
@@ -113,7 +115,7 @@ class stripeWebhookHandler
|
||||
private function chargeSucceeded()
|
||||
{
|
||||
/* Check the status */
|
||||
if ( $this->transaction->status !== \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING )
|
||||
if ( !\in_array( $this->transaction->status, [ \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING, IPS\nexus\Transaction::STATUS_PENDING ] ) )
|
||||
{
|
||||
if ( $this->transaction->status === \IPS\nexus\Transaction::STATUS_PAID )
|
||||
{
|
||||
@@ -183,7 +185,7 @@ class stripeWebhookHandler
|
||||
private function chargeSucceededNew()
|
||||
{
|
||||
/* Check the status */
|
||||
if ( $this->transaction->status !== \IPS\nexus\Transaction::STATUS_PENDING )
|
||||
if ( !\in_array( $this->transaction->status, [ \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING, IPS\nexus\Transaction::STATUS_PENDING ] ) )
|
||||
{
|
||||
if ( $this->transaction->status === \IPS\nexus\Transaction::STATUS_PAID )
|
||||
{
|
||||
@@ -195,6 +197,12 @@ class stripeWebhookHandler
|
||||
}
|
||||
}
|
||||
|
||||
/* If the invoice this is for is already paid, this may be a duplicate charge, so don't capture */
|
||||
if ( $this->transaction->invoice->status === \IPS\nexus\Invoice::STATUS_PAID )
|
||||
{
|
||||
throw new \Exception('INVOICE_ALREADY_PAID');
|
||||
}
|
||||
|
||||
/* Validate the charge with Stripe */
|
||||
try
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ class Api
|
||||
*/
|
||||
public function error( $code, $message )
|
||||
{
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'errorCode' => $code, 'errorMessage' => $message ) ), 400, 'application/json' );
|
||||
}
|
||||
|
||||
@@ -180,6 +181,7 @@ class Api
|
||||
|
||||
\IPS\nexus\Customer::load( $key->member )->log( 'lkey', array( 'type' => 'activated', 'key' => $key->key, 'ps_id' => $key->purchase->id ), FALSE );
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'response' => 'OKAY', 'usage_id' => $k ) ), 200, 'application/json' );
|
||||
}
|
||||
|
||||
@@ -200,9 +202,9 @@ class Api
|
||||
{
|
||||
case 102:
|
||||
case 103:
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'INACTIVE' ) ), 200, 'application/json' );
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'INACTIVE' ) ), 200, 'application/json', \IPS\Output::getCacheHeaders( time(), 360 ) );
|
||||
case 104:
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'EXPIRED' ) ), 200, 'application/json' );
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'EXPIRED' ) ), 200, 'application/json', \IPS\Output::getCacheHeaders( time(), 360 ) );
|
||||
|
||||
default:
|
||||
throw $e;
|
||||
@@ -223,7 +225,7 @@ class Api
|
||||
$key->activate_data = $activateData;
|
||||
$key->save();
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'ACTIVE', 'uses' => $key->uses, 'max_uses' => $key->max_uses ) ), 200, 'application/json' );
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'ACTIVE', 'uses' => $key->uses, 'max_uses' => $key->max_uses ) ), 200, 'application/json', \IPS\Output::getCacheHeaders( time(), 360 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +270,7 @@ class Api
|
||||
'customer_email' => \IPS\nexus\Customer::load( $key->member )->email,
|
||||
'uses' => $key->uses,
|
||||
'max_uses' => $key->max_uses
|
||||
) ), 200, 'application/json' );
|
||||
) ), 200, 'application/json', \IPS\Output::getCacheHeaders( time(), 360 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,6 +296,7 @@ class Api
|
||||
$key->activate_data = $activateData;
|
||||
$key->save();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
\IPS\Output::i()->sendOutput( json_encode( array( 'status' => 'OKAY' ) ), 200, 'application/json' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
require_once '../../../../init.php';
|
||||
\IPS\Dispatcher\External::i();
|
||||
|
||||
\IPS\Output::i()->pageCaching = FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
$server = \IPS\nexus\Hosting\Server::load( \IPS\Request::i()->server );
|
||||
|
||||
Reference in new issue
Block a user