Loading Common/StaticToInstance.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php /** * Converts a static class to use instances */ namespace Minds\Common; class StaticToInstance { /** @var $class */ private $class; public function __construct($class) { $this->setClass($class); } /** * Set the class in question * @return StripeStaticToOO */ public function setClass($class) { $this->class = new \ReflectionClass($class); return clone $this; } /** * Call the static functions as OO style * @param string $method * @param array $arguments * @return midex */ public function __call($method, $arguments) { $instance = $this->class->newInstanceWithoutConstructor(); return $instance::$method(...$arguments); } } Controllers/Cli/Stripe.php 0 → 100644 +70 −0 Original line number Diff line number Diff line <?php namespace Minds\Controllers\Cli; use Minds\Core; use Minds\Core\Di\Di; use Minds\Cli; use Minds\Interfaces; use Minds\Exceptions; use Minds\Entities; use Minds\Core\Data\ElasticSearch\Prepared; use Minds\Core\Analytics\Iterators\SignupsOffsetIterator; use Minds\Core\Boost\Network\Manager; use Minds\Core\Util\BigNumber; use Minds\Helpers\Counters; class Stripe extends Cli\Controller implements Interfaces\CliControllerInterface { private $db; private $es; private $elasticRepository; private $pendingBulkInserts = []; public function __construct() { error_reporting(E_ALL); ini_set('display_errors', 1); } public function help($command = null) { $this->out('TBD'); } public function exec() { echo "1"; } public function get_payment_intent() { $intent = new Core\Payments\Stripe\Intents\PaymentIntent(); $intent->setAmount(2000); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->add($intent); var_dump($intent); } public function get_setup_intent() { $intent = new Core\Payments\Stripe\Intents\SetupIntent(); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->add($intent); var_dump($intent->getClientSecret()); } public function get_setup_intent_payment_method() { $id = $this->getOpt('id'); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->get($id); var_dump($intent); } } Controllers/api/v1/channel.php +0 −8 Original line number Diff line number Diff line Loading @@ -304,14 +304,6 @@ class channel implements Interfaces\Api $channel->enabled = 'no'; $channel->save(); $customer = (new Core\Payments\Customer()) ->setUser($channel); $stripe = Core\Di\Di::_()->get('StripePayments'); $customer = $stripe->getCustomer($customer); if ($customer) { $stripe->deleteCustomer($customer); } (new Core\Data\Sessions())->destroyAll($channel->guid); } Loading Controllers/api/v2/payments/stripe/connect.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php /** * */ namespace Minds\Controllers\api\v2\payments\stripe; use Minds\Api\Factory; use Minds\Common\Cookie; use Minds\Core\Di\Di; use Minds\Core\Config; use Minds\Core\Session; use Minds\Interfaces; use Minds\Core\Payments\Stripe; class connect implements Interfaces\Api { public function get($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); $account = $connectManager->getByUser($user); return Factory::response([ 'account' => $account->export(), ]); } public function post($pages) { return Factory::response([]); } public function put($pages) { return Factory::response([]); } public function delete($pages) { $user = Session::getLoggedInUser(); $account = new Stripe\Connect\Account(); $account->setUserGuid($user->getGuid()) ->setUser($user) ->setId($user->getMerchant()['id']); $connectManager = new Stripe\Connect\Manager(); $connectManager->delete($account); return Factory::response([]); } } Controllers/api/v2/payments/stripe/connect/bank.php 0 → 100644 +65 −0 Original line number Diff line number Diff line <?php /** * */ namespace Minds\Controllers\api\v2\payments\stripe\connect; use Minds\Api\Factory; use Minds\Common\Cookie; use Minds\Core\Di\Di; use Minds\Core\Config; use Minds\Core\Session; use Minds\Interfaces; use Minds\Core\Payments\Stripe; class bank implements Interfaces\Api { public function get($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); return Factory::response([ ]); } public function post($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); $account = $connectManager->getByUser($user); if (!$account) { return Factory::response([ 'status' => 'error', 'message' => 'You must have a USD account to add a bank account', ]); } $account->setAccountNumber($_POST['accountNumber']) ->setCountry($_POST['country']) ->setRoutingNumber($_POST['routingNumber']); try { $connectManager->addBankAccount($account); } catch (\Exception $e) { return Factory::response([ 'status' => 'error', 'message' => $e->getMessage(), ]); } return Factory::response([]); } public function put($pages) { return Factory::response([]); } public function delete($pages) { return Factory::response([]); } } Loading
Common/StaticToInstance.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php /** * Converts a static class to use instances */ namespace Minds\Common; class StaticToInstance { /** @var $class */ private $class; public function __construct($class) { $this->setClass($class); } /** * Set the class in question * @return StripeStaticToOO */ public function setClass($class) { $this->class = new \ReflectionClass($class); return clone $this; } /** * Call the static functions as OO style * @param string $method * @param array $arguments * @return midex */ public function __call($method, $arguments) { $instance = $this->class->newInstanceWithoutConstructor(); return $instance::$method(...$arguments); } }
Controllers/Cli/Stripe.php 0 → 100644 +70 −0 Original line number Diff line number Diff line <?php namespace Minds\Controllers\Cli; use Minds\Core; use Minds\Core\Di\Di; use Minds\Cli; use Minds\Interfaces; use Minds\Exceptions; use Minds\Entities; use Minds\Core\Data\ElasticSearch\Prepared; use Minds\Core\Analytics\Iterators\SignupsOffsetIterator; use Minds\Core\Boost\Network\Manager; use Minds\Core\Util\BigNumber; use Minds\Helpers\Counters; class Stripe extends Cli\Controller implements Interfaces\CliControllerInterface { private $db; private $es; private $elasticRepository; private $pendingBulkInserts = []; public function __construct() { error_reporting(E_ALL); ini_set('display_errors', 1); } public function help($command = null) { $this->out('TBD'); } public function exec() { echo "1"; } public function get_payment_intent() { $intent = new Core\Payments\Stripe\Intents\PaymentIntent(); $intent->setAmount(2000); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->add($intent); var_dump($intent); } public function get_setup_intent() { $intent = new Core\Payments\Stripe\Intents\SetupIntent(); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->add($intent); var_dump($intent->getClientSecret()); } public function get_setup_intent_payment_method() { $id = $this->getOpt('id'); $intentManager = new Core\Payments\Stripe\Intents\Manager(); $intent = $intentManager->get($id); var_dump($intent); } }
Controllers/api/v1/channel.php +0 −8 Original line number Diff line number Diff line Loading @@ -304,14 +304,6 @@ class channel implements Interfaces\Api $channel->enabled = 'no'; $channel->save(); $customer = (new Core\Payments\Customer()) ->setUser($channel); $stripe = Core\Di\Di::_()->get('StripePayments'); $customer = $stripe->getCustomer($customer); if ($customer) { $stripe->deleteCustomer($customer); } (new Core\Data\Sessions())->destroyAll($channel->guid); } Loading
Controllers/api/v2/payments/stripe/connect.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php /** * */ namespace Minds\Controllers\api\v2\payments\stripe; use Minds\Api\Factory; use Minds\Common\Cookie; use Minds\Core\Di\Di; use Minds\Core\Config; use Minds\Core\Session; use Minds\Interfaces; use Minds\Core\Payments\Stripe; class connect implements Interfaces\Api { public function get($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); $account = $connectManager->getByUser($user); return Factory::response([ 'account' => $account->export(), ]); } public function post($pages) { return Factory::response([]); } public function put($pages) { return Factory::response([]); } public function delete($pages) { $user = Session::getLoggedInUser(); $account = new Stripe\Connect\Account(); $account->setUserGuid($user->getGuid()) ->setUser($user) ->setId($user->getMerchant()['id']); $connectManager = new Stripe\Connect\Manager(); $connectManager->delete($account); return Factory::response([]); } }
Controllers/api/v2/payments/stripe/connect/bank.php 0 → 100644 +65 −0 Original line number Diff line number Diff line <?php /** * */ namespace Minds\Controllers\api\v2\payments\stripe\connect; use Minds\Api\Factory; use Minds\Common\Cookie; use Minds\Core\Di\Di; use Minds\Core\Config; use Minds\Core\Session; use Minds\Interfaces; use Minds\Core\Payments\Stripe; class bank implements Interfaces\Api { public function get($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); return Factory::response([ ]); } public function post($pages) { $user = Session::getLoggedInUser(); $connectManager = new Stripe\Connect\Manager(); $account = $connectManager->getByUser($user); if (!$account) { return Factory::response([ 'status' => 'error', 'message' => 'You must have a USD account to add a bank account', ]); } $account->setAccountNumber($_POST['accountNumber']) ->setCountry($_POST['country']) ->setRoutingNumber($_POST['routingNumber']); try { $connectManager->addBankAccount($account); } catch (\Exception $e) { return Factory::response([ 'status' => 'error', 'message' => $e->getMessage(), ]); } return Factory::response([]); } public function put($pages) { return Factory::response([]); } public function delete($pages) { return Factory::response([]); } }