| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- require_once 'Config/Settings.class.php';
- require_once 'Config/Database.class.php';
- // includes the autoloader for libraries installed with composer
- require __DIR__ . '/External/Braintree/lib/autoload.php';
- /**
- *
- */
- abstract class Broker {
- //
- protected $Name = "";
- protected $Database;
- protected $DatabaseConnection;
- protected $Config = null;
- /**
- *
- */
- public function __construct($name) {
- $this->Name = $name;
- // create database handle
- $this->Database = new \Config\Database('imagingx_docassyst');
- try {
- $this->DatabaseConnection = $this->Database->getConnection();
- }
- catch (Exception $e) {
- throw $e;
- }
- // read config
- $statement = $this->DatabaseConnection->prepare(
- "SELECT config FROM broker WHERE name = '$this->Name'"
- );
- $statement->execute();
- $results = $statement->fetchAll(\PDO::FETCH_ASSOC);
- if(count($results) == 0) {
- throw new \Exception("BraintreeBroker init failed");
- }
- else {
- $this->Config = json_decode($results[0]['config']);
- }
- $this->init();
- }
- /**
- *
- */
- abstract protected function init();
- /**
- *
- */
- abstract public function getToken($User);
- /**
- *
- */
- abstract public function submit($User, $token, $amount);
- }
|