diff --git a/README.md b/README.md new file mode 100644 index 0000000..06139ab --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# telepay-php-example + +## with this repo you can install telepay-php library without use composer diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..e1505ea --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-return array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..d50e0c9 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,350 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..b26f1b1 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($vendorDir . '/telepaycash/sdk-telepay-php/src'), + 'Examples\\' => array($vendorDir . '/telepaycash/sdk-telepay-php/examples'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..6595872 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,57 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit6be902a253cbebadfd3b7764c353b083::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..b11a045 --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,44 @@ + + array ( + 'TelePay\\' => 8, + ), + 'E' => + array ( + 'Examples\\' => 9, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'TelePay\\' => + array ( + 0 => __DIR__ . '/..' . '/telepaycash/sdk-telepay-php/src', + ), + 'Examples\\' => + array ( + 0 => __DIR__ . '/..' . '/telepaycash/sdk-telepay-php/examples', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit6be902a253cbebadfd3b7764c353b083::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit6be902a253cbebadfd3b7764c353b083::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit6be902a253cbebadfd3b7764c353b083::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..c1fab79 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,64 @@ +{ + "packages": [ + { + "name": "telepaycash/sdk-telepay-php", + "version": "v1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/TelePay-cash/telepay-php.git", + "reference": "e1b8dc8a2aba32b1e9b2015405b874e1e1944a74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TelePay-cash/telepay-php/zipball/e1b8dc8a2aba32b1e9b2015405b874e1e1944a74", + "reference": "e1b8dc8a2aba32b1e9b2015405b874e1e1944a74", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0.3" + }, + "time": "2023-02-05T13:55:02+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "TelePay\\": "src/", + "Examples\\": "examples/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raubel", + "email": "raubel1993@gmail.com" + }, + { + "name": "Carlos Lugones", + "email": "contact@carloslugones.com" + } + ], + "description": "Library to receive payments with TelePay", + "keywords": [ + "payments", + "rest", + "sdk", + "telepay", + "toncoin" + ], + "support": { + "issues": "https://github.com/TelePay-cash/telepay-php/issues", + "source": "https://github.com/TelePay-cash/telepay-php/tree/v1.2.0" + }, + "install-path": "../telepaycash/sdk-telepay-php" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..174090b --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,32 @@ + array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => NULL, + 'name' => '__root__', + 'dev' => true, + ), + 'versions' => array( + '__root__' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => NULL, + 'dev_requirement' => false, + ), + 'telepaycash/sdk-telepay-php' => array( + 'pretty_version' => 'v1.2.0', + 'version' => '1.2.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../telepaycash/sdk-telepay-php', + 'aliases' => array(), + 'reference' => 'e1b8dc8a2aba32b1e9b2015405b874e1e1944a74', + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..f79e574 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70000)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.0.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/telepaycash/sdk-telepay-php/LICENSE b/vendor/telepaycash/sdk-telepay-php/LICENSE new file mode 100644 index 0000000..c17af1c --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 TelePay.cash + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/telepaycash/sdk-telepay-php/README.md b/vendor/telepaycash/sdk-telepay-php/README.md new file mode 100644 index 0000000..cc7e9c2 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/README.md @@ -0,0 +1,473 @@ +# PHP SDK for the TelePay API + +![TelePay PHP](https://github.com/TelePay-cash/telepay-php/blob/main/docs/cover.png?raw=true) + +TelePay client library for the PHP language, so you can easely process cryptocurrency payments using the REST API. + +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) +[![CI](https://github.com/TelePay-cash/telepay-php/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/TelePay-cash/telepay-php/actions/workflows/ci.yml) +[![Last commit](https://img.shields.io/github/last-commit/telepay-cash/telepay-php.svg?style=flat-square)](https://github.com/telepay-cash/telepay-php/commits) +[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/telepay-cash/telepay-php?style=flat-square)](https://github.com/telepay-cash/telepay-php/commits) +[![Github Stars](https://img.shields.io/github/stars/telepay-cash/telepay-php?style=flat-square&logo=github&)](https://github.com/telepay-cash/telepay-php/stargazers) +[![Github Forks](https://img.shields.io/github/forks/telepay-cash/telepay-php?style=flat-square&logo=github)](https://github.com/telepay-cash/telepay-php/network/members) +[![Github Watchers](https://img.shields.io/github/watchers/telepay-cash/telepay-php?style=flat-square&logo=github)](https://github.com/telepay-cash/telepay-php) +[![GitHub contributors](https://img.shields.io/github/contributors/telepay-cash/telepay-php?label=code%20contributors&style=flat-square)](https://github.com/telepay-cash/telepay-php/graphs/contributors) +[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-squeare&logo=telegram&logoColor=white)](https://t.me/TelePayCash) +[![Blog](https://img.shields.io/badge/RSS-FFA500?style=flat-square&logo=rss&logoColor=white)](https://blog.telepay.cash) + +## Installation + +Install the package with composer: + +```bash +composer require telepaycash/sdk-telepay-php +``` + +## Using the library + +Import the library classes using the Composer autoload: + +```php +require 'vendor/autoload.php'; + +use TelePay\TelePayClient; +use TelePay\TelePayEnvironment; +``` + +Configure the TelePay client using the secret of your merchant + +```php +$clientSecret = "YOUR API SECRET KEY"; + +$environment = new TelePayEnvironment($clientSecret); + +$telepay = new TelePayClient($environment); +``` + +**Get your current merchant** + +```php +$me = $telepay->getMe(); +print_r($me); +``` + +Response + +```php +Array +( + [version] => 1.0 + [merchant] => Array + ( + [name] => MyMerchant + [url] => https://mymerchant.com/ + [logo_url] => https://ik.imagekit.io/telepay/merchants/descarga_-k4ehiTd5.jpeg + [logo_thumbnail_url] => https://ik.imagekit.io/telepay/tr:n-media_library_thumbnail/merchants/descarga_-k4ehiTd5.jpeg + [verified] => + [username] => merchant_username + [public_profile] => https://telepay.cash/to/merchant_username + [owner] => Array + ( + [first_name] => Raubel + [last_name] => Guerra + [username] => raubel1993 + ) + + [created_at] => 2022-04-13T00:51:37.802614Z + [updated_at] => + ) +) +``` +[Read docs](https://telepay.readme.io/reference/getme) + +**Get the balance of all merchant wallets** + +```php +$balances = $telepay->getAllBalances(); +print_r($balances); +``` + +Response + +```php +Array +( + [wallets] => Array + ( + [0] => Array + ( + [asset] => TON + [blockchain] => TON + [balance] => 10.005 + [network] => mainnet + ) + + [1] => Array + ( + [asset] => TON + [blockchain] => TON + [balance] => 0 + [network] => testnet + ) + + ) + +) +``` +[Read docs](https://telepay.readme.io/reference/getbalance) + +**Get the balance of one of the merchant wallets** + +```php +$asset = new TelePayAssetInput("TON", "TON", "mainnet"); +$balance = $telepay->getBalance($asset); +print_r($balance); +``` + +Response + +```php +Array +( + [wallets] => Array + ( + [0] => Array + ( + [asset] => TON + [blockchain] => TON + [balance] => 0 + [network] => mainnet + ) + + ) + +) +``` +[Read docs](https://telepay.readme.io/reference/getbalance-1) + +**Get the assets** + +Get assets suported by TelePay. [Read docs](https://telepay.readme.io/reference/getassets) + +```php +$assets = $telepay->getAssets(); +print_r($assers); +``` + +Response + +```php +Array +( + [assets] => Array + ( + [0] => Array + ( + [asset] => TON + [blockchain] => TON + [usd_price] => 1.050999999999999934 + [url] => https://ton.org + [networks] => Array + ( + [0] => mainnet + [1] => testnet + ) + + [coingecko_id] => the-open-network + ) + + ) + +) +``` + +You can get the detail of a single asset. [Read docs](https://telepay.readme.io/reference/getasset) + +```php +$asset = new TelePayAssetInput("TON", "TON", "mainnet"); +$assetDetail = $telepay->getAsset($asset); +``` + +**Create one invoice** + +```php +$orderId = 56; +$invoice = new TelePayInvoiceInput("TON", "TON", "testnet", "0.2"); +$invoice->setDescription("Test using SDK TelePay PHP"); +$invoice->setMetadata([ + "my_reference_id" => $orderId, + "other_metadata" => "any value" +]); +$invoice->setSuccessUrl("https://www.example.com/payment_success?order_id=$orderId"); +$invoice->setCancelUrl("https://www.example.com/payment_cancelled?order_id=$orderId"); + +$respCreateInvoice = $telepay->createInvoice($invoice); +print_r($respCreateInvoice); +``` + +Response + +```php +Array +( + [number] => YJ1EJO9PLA + [asset] => TON + [blockchain] => TON + [network] => mainnet + [status] => pending + [amount] => 2.000000000000000000 + [amount_remaining] => 0.000000000000000000 + [amount_real] => 0.000000000000000000 + [description] => Test using SDK TelePay PHP + [metadata] => Array + ( + [my_reference_id] => 56 + [other_metadata] => any value + ) + + [checkout_url] => https://telepay.cash/checkout/YJ1EJO9PLA + [onchain_url] => ton://transfer/UQDoFjaqMtuxkJV-caGiEdxMxjkTAWU9oskjpfAA1uwHbe4u?amount=2000000000 + [success_url] => https://www.example.com/payment_success?order_id=56 + [cancel_url] => https://www.example.com/payment_cancelled?order_id=56 + [explorer_url] => + [expires_at] => 2022-06-28T00:09:52.038782Z + [created_at] => 2022-06-27T14:09:52.038908Z + [updated_at] => +) +``` +[Read docs](https://telepay.readme.io/reference/createinvoice) + +**View invoices** + +Find many invoices. [Read docs](https://telepay.readme.io/reference/getinvoices) + +```php +$invoicesResponse = $telepay->getInvoices(); +``` + +Find one invoice by number. [Read docs](https://telepay.readme.io/reference/getinvoice) + +```php +$invoiceNumber = "UIOAXSSFNB"; +$respGetInvoice = $telepay->getInvoice($invoiceNumber); +``` + +**Cancel invoice** + +```php +$invoiceNumber = "8N1DLRKV5S"; +$respCancelInvoice = $telepay->cancelInvoice($invoiceNumber); +print_r($respCancelInvoice); +``` + +Response + +```php +Array +( + [number] => YJ1EJO9PLA + [asset] => TON + [blockchain] => TON + [network] => mainnet + [status] => cancelled + [amount] => 2.000000000000000000 + [amount_remaining] => 0.000000000000000000 + [amount_real] => 0.000000000000000000 + [description] => Test using SDK TelePay PHP + [metadata] => Array + ( + [other_metadata] => any value + [my_reference_id] => 56 + ) + [checkout_url] => https://telepay.cash/checkout/YJ1EJO9PLA + [onchain_url] => + [success_url] => https://www.example.com/payment_success?order_id=56 + [cancel_url] => https://www.example.com/payment_cancelled?order_id=56 + [explorer_url] => + [expires_at] => 2022-06-28T00:09:52.038782Z + [created_at] => 2022-06-27T14:09:52.038908Z + [updated_at] => 2022-06-27T14:09:53.205920Z +) +``` + +**Delete invoice** + +```php +$invoiceNumber = "8N1DLRKV5S"; +$respDeleteInvoice = $telepay->deleteInvoice($invoiceNumber); +print_r($respDeleteInvoice); +``` + +Response + +```php +Array +( + [success] => invoice.deleted + [message] => Invoice deleted. +) +``` + +**Transfer** + +```php +$transfer = new TelePayTransferInput("TON", "TON", "mainnet", "0.00005", "raubel1993"); +$transfer->setMessage("Debt settled"); + +$respTransfer= $telepay->transfer($transfer); +print_r($respTransfer); +``` + +Response + +```php +Array +( + [success] => transfer.ok + [message] => Transfer performed. +) +``` +[Read docs](https://telepay.readme.io/reference/transfer) + +**Withdraw Fee** + +```php +$withdraw = new TelePayWithdrawInput("TON", "TON", "mainnet", "0.2", "EQCwLtwjII1yBfO3m6T9I7__6CUXj60ZFmN3Ww2aiLQLicsO"); +$withdraw->setMessage("for my savings account"); + +$respWithdrawFee = $telepay->getWithdrawFee($withdraw); +print_r($respWithdrawFee); +``` + +Response + +```php +Array +( + [blockchain_fee] => 0.001824 + [processing_fee] => 0.01 + [total] => 0.011824 +) +``` + +**Withdraw** + +```php +$withdraw = new TelePayWithdrawInput("TON", "TON", "mainnet", "0.2", "EQCwLtwjII1yBfO3m6T9I7__6CUXj60ZFmN3Ww2aiLQLicsO"); +$withdraw->setMessage("for my savings account"); + +$respWithdraw = $telepay->withdraw($withdraw); +print_r($respWithdraw); +``` + +Response + +```php +Array +( + [success] => 1 +) +``` + +**View webhooks** + +Find many webhooks. [Read docs](https://telepay.readme.io/reference/getwebhooks) + +```php +$webhooksResponse = $telepay->getWebhooks(); +``` + +Find one webhook by Id. [Read docs](https://telepay.readme.io/reference/getwebhook) + +```php +$webhookId = 325; +$webhookResponse = $telepay->getWebhook($webhookId); +print_r($webhookResponse); +``` + +Response + +```php +Array +( + [id] => 325 + [url] => https://www.example.com/webhook + [secret] => secret + [events] => Array + ( + [0] => invoice.completed + ) + + [active] => 1 +) +``` + +**Create or update a webhook** + +For create a webhook is required the url, a secret and the events associated. [Read docs](https://telepay.readme.io/reference/createwebhook) + +```php +$urlWebhook = "https://www.example.com/webhook"; +$secretWebhook = "secret"; +$eventsWebhook = [ + TelePayEvents::INVOICE_COMPLETED +]; +$webhookInput = new TelePayWebhookInput($urlWebhook, $secretWebhook, $eventsWebhook); + +$responseCreateWebhook = $telepay->createWebhook($webhookInput); +``` + +For update a webhook is required a webhookId and the new params. [Read docs](https://telepay.readme.io/reference/updatewebhook) + +```php +$webhookId = 325; +$responseUpdateWebhook = $telepay->updateWebhook($webhookId, $webhookInput); +``` + +**Activate or deativate a webhook** + +```php +$webhookId = 325; + +$telepay->activateWebhook($webhookId); + +$telepay->deactivateWebhook($webhookId); +``` + +**Delete a webhook** + +```php +$webhookId = 325; + +$telepay->deleteWebhook($webhookId); +``` + +## Tests + +All endpoint responses were tested. +To run the tests yourself, you need your TelePay merchant secret with at least 3 testnet toncoins, +a Telepay user who will receive the test transfer, and a testnet wallet which will receive the test withdraw. + +```bash +TELEPAY_SECRET_API_KEY= USERNAME_TELEPAY_TRANSFER= WHITDRAW_TO_WALLET= composer tests +``` + +## Contributors ✨ + +The library is made by ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + +

Raubel Guerra

💻

Carlos Lugones

🧑‍🏫
+ + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/vendor/telepaycash/sdk-telepay-php/composer.json b/vendor/telepaycash/sdk-telepay-php/composer.json new file mode 100644 index 0000000..b494c39 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/composer.json @@ -0,0 +1,38 @@ +{ + "name": "telepaycash/sdk-telepay-php", + "description": "Library to receive payments with TelePay", + "keywords": ["telepay", "payments", "rest", "sdk", "toncoin"], + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "TelePay\\": "src/", + "Examples\\":"examples/" + } + }, + "autoload-dev": { + "psr-4": { + "Test\\":"tests/" + } + }, + "require": { + "php": ">=7.0" + }, + "authors": [ + { + "name": "Raubel", + "email": "raubel1993@gmail.com" + }, + { + "name": "Carlos Lugones", + "email": "contact@carloslugones.com" + } + ], + "scripts": { + "tests": "./vendor/bin/phpunit", + "tests-coverage": "./vendor/bin/phpunit --coverage-html coverage" + }, + "require-dev": { + "phpunit/phpunit": "^10.0.3" + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/docs/cover.png b/vendor/telepaycash/sdk-telepay-php/docs/cover.png new file mode 100644 index 0000000..48c718f Binary files /dev/null and b/vendor/telepaycash/sdk-telepay-php/docs/cover.png differ diff --git a/vendor/telepaycash/sdk-telepay-php/examples/1-getters.php b/vendor/telepaycash/sdk-telepay-php/examples/1-getters.php new file mode 100644 index 0000000..e14190d --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/1-getters.php @@ -0,0 +1,44 @@ +getMe(); +$merchant = $me['merchant']; +$merchantName = $merchant['name']; +$merchantUrl = $merchant['url']; +$merchantUsername = $merchant['username']; +$merchantPublicProfile = $merchant['public_profile']; + +$balance = $telepay->getAllBalances(); +$wallets = $balance['wallets']; +echo "My wallets: \n"; +foreach ($wallets as $wallet) { + echo "Asset: ".$wallet['asset'] + ." Blockchain: ".$wallet['blockchain'] + ." Networks: ".$wallet['network'] + ." balance: ".$wallet['balance'] + ."\n"; +} + +$invoicesResponse = $telepay->getInvoices(); +$invoices = $invoicesResponse['invoices']; +echo "My invoices: \n"; +foreach ($invoices as $invoice) { + echo "Number: ".$invoice['number']."\n" + ." description: ".$invoice['description']."\n" + ."Asset: ".$invoice['asset']."\n" + ." Blockchain: ".$invoice['blockchain']."\n" + ." Networks: ".$invoice['network']."\n" + ." status: ".$invoice['status']."\n" + ." amount: ".$invoice['amount']."\n" + ."\n"; +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/examples/2-createInvoice.php b/vendor/telepaycash/sdk-telepay-php/examples/2-createInvoice.php new file mode 100644 index 0000000..fb8ad90 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/2-createInvoice.php @@ -0,0 +1,30 @@ +setDescription("Test using SDK TelePay PHP"); +$invoice->setMetadata([ + "my_reference_id" => $orderId, + "other_metadata" => "any value" +]); +$invoice->setSuccessUrl("https://www.example.com/payment_success?order_id=$orderId"); +$invoice->setCancelUrl("https://www.example.com/payment_cancelled?order_id=$orderId"); + +$respCreateInvoice = $telepay->createInvoice($invoice); +$invoiceNumber = $respCreateInvoice['number']; +print_r($respCreateInvoice); + +$respGetInvoice = $telepay->getInvoice($invoiceNumber); +print_r($respGetInvoice); \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/examples/3-transfer.php b/vendor/telepaycash/sdk-telepay-php/examples/3-transfer.php new file mode 100644 index 0000000..f905f88 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/3-transfer.php @@ -0,0 +1,29 @@ +setMessage("Debt settled"); + + $respTransfer= $telepay->transfer($transfer); + print_r($respTransfer); +} catch (TelePayException $th) { + print_r([ + "statusCode" => $th->getStatusCode(), + "error" => $th->getError(), + "message" => $th->getMessage(), + ]); +}catch (\Throwable $th) { + throw $th; +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/examples/4-withdraw.php b/vendor/telepaycash/sdk-telepay-php/examples/4-withdraw.php new file mode 100644 index 0000000..4f27445 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/4-withdraw.php @@ -0,0 +1,21 @@ +setMessage("for my savings account"); + +$respWithdrawFee = $telepay->getWithdrawFee($withdraw); +print_r($respWithdrawFee); + +$respWithdraw = $telepay->withdraw($withdraw); +print_r($respWithdraw); diff --git a/vendor/telepaycash/sdk-telepay-php/examples/5-cancelAndDeleteInvoice.php b/vendor/telepaycash/sdk-telepay-php/examples/5-cancelAndDeleteInvoice.php new file mode 100644 index 0000000..0d10a36 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/5-cancelAndDeleteInvoice.php @@ -0,0 +1,33 @@ +setDescription("Test using SDK TelePay PHP"); +$invoice->setMetadata([ + "my_reference_id" => $orderId, + "other_metadata" => "any value" +]); +$invoice->setSuccessUrl("https://www.example.com/payment_success?order_id=$orderId"); +$invoice->setCancelUrl("https://www.example.com/payment_cancelled?order_id=$orderId"); + +$respCreateInvoice = $telepay->createInvoice($invoice); +print_r($respCreateInvoice); + +$invoiceNumber = $respCreateInvoice['number']; + +$respCancelInvoice = $telepay->cancelInvoice($invoiceNumber); +print_r($respCancelInvoice); + +$respDeleteInvoice = $telepay->deleteInvoice($invoiceNumber); +print_r($respDeleteInvoice); \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/examples/6-webhook.php b/vendor/telepaycash/sdk-telepay-php/examples/6-webhook.php new file mode 100644 index 0000000..3bd81ac --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/6-webhook.php @@ -0,0 +1,51 @@ +getWebhooks(); +foreach ($responseGetAllWebhooks['webhooks'] as $webhook) { + $telepay->deleteWebhook($webhook['id']); +} + +$webhookInput = new TelePayWebhookInput($urlWebhook, $secretWebhook, $eventsWebhook); + +$responseCreateWebhook = $telepay->createWebhook($webhookInput); +print_r($responseCreateWebhook); + +$responseGetOneWebhook = $telepay->getWebhook($responseCreateWebhook['id']); +print_r($responseGetOneWebhook); + +$responseGetAllWebhooks = $telepay->getWebhooks(); +print_r($responseGetAllWebhooks); + +$responseDeactivateWebhook = $telepay->deactivateWebhook($responseCreateWebhook['id']); +print_r($responseDeactivateWebhook); + +$webhookInput->setSecret("new secret"); +$webhookInput->setActive(false); +$responseUpdateWebhook = $telepay->updateWebhook($responseCreateWebhook['id'], $webhookInput); +print_r($responseUpdateWebhook); + +$responseActivateWebhook = $telepay->activateWebhook($responseCreateWebhook['id']); +print_r($responseActivateWebhook); + +$responseDeleteWebhook = $telepay->deleteWebhook($responseCreateWebhook['id']); +print_r($responseDeleteWebhook); + + + diff --git a/vendor/telepaycash/sdk-telepay-php/examples/7-assets.php b/vendor/telepaycash/sdk-telepay-php/examples/7-assets.php new file mode 100644 index 0000000..92c208b --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/examples/7-assets.php @@ -0,0 +1,22 @@ +getAssets(); +print_r($assetsResponse); + +echo "Asset detail"; +$asset = new TelePayAssetInput("TON", "TON", "mainnet"); +$assetDetail = $telepay->getAsset($asset); +print_r($assetDetail); \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/phpunit.xml b/vendor/telepaycash/sdk-telepay-php/phpunit.xml new file mode 100644 index 0000000..a80f590 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/phpunit.xml @@ -0,0 +1,9 @@ + + + + + + tests + + + diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayAssetInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayAssetInput.php new file mode 100644 index 0000000..f3009dd --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayAssetInput.php @@ -0,0 +1,68 @@ +setAsset($asset); + $this->setBlockchain($blockchain); + if($network) { + $this->setNetwork($network); + } + } + public function getBodyPrepared() + { + $body = array( + "asset" => $this->asset, + "blockchain" => $this->blockchain, + "network" => $this->network + ); + return $body; + } + + public function getAsset() + { + return $this->asset; + } + public function setAsset($asset) + { + $this->asset = $asset; + } + public function getBlockchain() + { + return $this->blockchain; + } + public function setBlockchain($blockchain) + { + $this->blockchain = $blockchain; + } + public function getNetwork() + { + return $this->network; + } + public function setNetwork($network) + { + $this->network = $network; + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayBaseInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayBaseInput.php new file mode 100644 index 0000000..16e8b40 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayBaseInput.php @@ -0,0 +1,69 @@ +setAsset($asset); + $this->setBlockchain($blockchain); + $this->setNetwork($network); + $this->setAmount($amount); + } + + public function getAsset() + { + return $this->asset; + } + public function setAsset($asset) + { + $this->asset = $asset; + } + public function getBlockchain() + { + return $this->blockchain; + } + public function setBlockchain($blockchain) + { + $this->blockchain = $blockchain; + } + public function getNetwork() + { + return $this->network; + } + public function setNetwork($network) + { + $this->network = $network; + } + public function getAmount() + { + return $this->amount; + } + public function setAmount($amount) + { + $this->amount = $amount; + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayClient.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayClient.php new file mode 100644 index 0000000..48d844f --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayClient.php @@ -0,0 +1,331 @@ +environment = $environment; + } + + /** + * Info about the current merchant + */ + public function getMe() + { + static $merchantCache; + if (!$merchantCache) { + $url = $this->environment->getBaseUrl() . "getMe"; + $response = $this->makeRequest($url); + $merchantCache = $response; + } + return $merchantCache; + } + + /** + * Get your merchant wallet balance, specifying the asset + * @param TelePayAssetInput $asset + */ + public function getBalance($asset) + { + $url = $this->environment->getBaseUrl() . "getBalance"; + $assetBody = $asset->getBodyPrepared(); + $response = $this->makeRequest($url, $assetBody, 'POST'); + return $response; + } + + /** + * Get your merchant wallet assets with corresponding balance + */ + public function getAllBalances() + { + $url = $this->environment->getBaseUrl() . "getBalance"; + $response = $this->makeRequest($url); + return $response; + } + + /** + * Get assets suported by TelePay + */ + public function getAssets() + { + static $assetCache; + if (!$assetCache) { + $url = $this->environment->getBaseUrl() . "getAssets"; + $response = $this->makeRequest($url); + $assetCache = $response; + } + return $assetCache; + } + + /** + * Get asset details + * @param TelePayAssetInput $asset + */ + public function getAsset($asset) + { + $url = $this->environment->getBaseUrl() . "getAsset"; + $assetBody = $asset->getBodyPrepared(); + $response = $this->makeRequest($url, $assetBody, 'GET'); + return $response; + } + + /** + * Get your merchant invoices + */ + public function getInvoices() + { + $url = $this->environment->getBaseUrl() . "getInvoices"; + $response = $this->makeRequest($url); + return $response; + } + + /** + * Get invoice details, by its number + * @param Int $invoiceNumber + */ + public function getInvoice($invoiceNumber) + { + $url = $this->environment->getBaseUrl() . "getInvoice/" . $invoiceNumber; + $response = $this->makeRequest($url); + return $response; + } + + /** + * Creates an invoice, associated to your merchant + * @param TelePayInvoiceInput $invoice + */ + public function createInvoice($invoice) + { + $this->validate($invoice->getAsset(), $invoice->getBlockchain(), $invoice->getNetwork()); + $url = $this->environment->getBaseUrl() . "createInvoice"; + $invoiceBody = $invoice->getBodyPrepared(); + $response = $this->makeRequest($url, $invoiceBody, "POST"); + return $response; + } + + /** + * Cancel invoice, by its number + * @param Int $invoiceNumber + */ + public function cancelInvoice($invoiceNumber) + { + $url = $this->environment->getBaseUrl() . "cancelInvoice/" . $invoiceNumber; + $response = $this->makeRequest($url, null, "POST"); + return $response; + } + + /** + * Delete invoice, by its number + * @param Int $invoiceNumber + */ + public function deleteInvoice($invoiceNumber) + { + $url = $this->environment->getBaseUrl() . "deleteInvoice/" . $invoiceNumber; + $response = $this->makeRequest($url, null, "POST"); + return $response; + } + + /** + * Transfer funds between internal wallets. Off-chain operation + * @param TelePayTransferInput $transfer + */ + public function transfer($transfer) + { + $this->validate($transfer->getAsset(), $transfer->getBlockchain(), $transfer->getNetwork()); + $url = $this->environment->getBaseUrl() . "transfer"; + $transferBody = $transfer->getBodyPrepared(); + $response = $this->makeRequest($url, $transferBody, "POST"); + return $response; + } + + /** + * Get estimated withdraw fee, composed of blockchain fee and processing fee + * @param TelePayWithdrawInput $withdraw + */ + public function getWithdrawFee($withdraw) + { + $this->validate($withdraw->getAsset(), $withdraw->getBlockchain(), $withdraw->getNetwork()); + $url = $this->environment->getBaseUrl() . "getWithdrawFee"; + $withdrawBody = $withdraw->getBodyPrepared(); + $response = $this->makeRequest($url, $withdrawBody, "POST"); + return $response; + } + + /** + * Withdraw funds from merchant wallet to external wallet. On-chain operation + * @param TelePayWithdrawInput $withdraw + */ + public function withdraw($withdraw) + { + $this->validate($withdraw->getAsset(), $withdraw->getBlockchain(), $withdraw->getNetwork()); + $url = $this->environment->getBaseUrl() . "withdraw"; + $withdrawBody = $withdraw->getBodyPrepared(); + set_time_limit(60); + $response = $this->makeRequest($url, $withdrawBody, "POST"); + return $response; + } + + /** + * Get webhooks + */ + public function getWebhooks() + { + $url = $this->environment->getBaseUrl() . "getWebhooks"; + $response = $this->makeRequest($url); + return $response; + } + + /** + * Get webhook details + * @param int $webhookId + */ + public function getWebhook($webhookId) + { + $url = $this->environment->getBaseUrl() . "getWebhook/" . $webhookId; + $response = $this->makeRequest($url); + return $response; + } + + /** + * Create a new webhook + * @param TelePayWebhookInput $webhook + */ + public function createWebhook($webhook) + { + $url = $this->environment->getBaseUrl() . "createWebhook"; + $webhookBody = $webhook->getBodyPrepared(); + $response = $this->makeRequest($url, $webhookBody, "POST"); + return $response; + } + + /** + * Update a webhook + * @param int $webhookId + * @param TelePayWebhookInput $webhook + */ + public function updateWebhook($webhookId, $webhook) + { + $url = $this->environment->getBaseUrl() . "updateWebhook/" . $webhookId; + $webhookBody = $webhook->getBodyPrepared(); + unset($webhookBody['active']); + $response = $this->makeRequest($url, $webhookBody, "POST"); + return $response; + } + + /** + * Deletes a webhook + * @param int $webhookId + */ + public function deleteWebhook($webhookId) + { + $url = $this->environment->getBaseUrl() . "deleteWebhook/" . $webhookId; + $response = $this->makeRequest($url, [], "POST"); + return $response; + } + + /** + * Activates a webhook + * @param int $webhookId + */ + public function activateWebhook($webhookId) + { + $url = $this->environment->getBaseUrl() . "activateWebhook/" . $webhookId; + $response = $this->makeRequest($url, [], "POST"); + return $response; + } + + /** + * Deactivates a webhook + * @param int $webhookId + */ + public function deactivateWebhook($webhookId) + { + $url = $this->environment->getBaseUrl() . "deactivateWebhook/" . $webhookId; + $response = $this->makeRequest($url, [], "POST"); + return $response; + } + + /** + * Validate asset, blockchain and network combination + * @param string $asset + * @param string $blockchain + * @param string $network + * @return void + * @throws TelePayException + */ + public function validate($asset, $blockchain, $network) + { + $assetsResponse = $this->getAssets(); + $combinationExist = false; + foreach ($assetsResponse['assets'] as $assetItem) { + if ($assetItem['asset'] != $asset || $assetItem['blockchain'] != $blockchain) { + continue; + } + foreach ($assetItem['networks'] as $networkItem) { + if ($networkItem == $network) { + $combinationExist = true; + break; + } + } + if ($combinationExist) { + break; + } + } + if (!$combinationExist) { + throw new TelePayException( + "The combination of asset $asset, blockchain $blockchain and network $network does not exist", + 401, + "INVALID_ASSET_BLOCKCHAIN_NETWORK_COMBINATION" + ); + } + } + + private function makeRequest($url, $body = [], $verb = "GET") + { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'Accept: application/json', + 'Content-Type: application/json', + 'AUTHORIZATION: ' . $this->environment->getClientSecret() + )); + if ($body) { + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body)); + } + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $verb); + $response = json_decode(curl_exec($curl), true); + $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close($curl); + if ($httpCode != 200 && $httpCode != 201) { + if (isset($response['error'])) { + throw new TelePayException($response['message'], $httpCode, $response['error']); + } + throw new TelePayException(json_encode($response), $httpCode); + } + return $response; + } + + /** + * Validate Webhooks signature + * @param string $data + * @param string $signature + * @return boolean + */ + public function validateSignature($data, $signature) + { + $data = str_replace(["\"", "null"], ["'", "None"], $data); + $hashSecret = hash('sha1', $this->environment->getClientSecret()); + $hashData = hash('sha512', utf8_encode($data)); + $mySignature = hash('sha512', ($hashSecret . $hashData)); + return $mySignature === $signature; + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayEnvironment.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayEnvironment.php new file mode 100644 index 0000000..f67fe17 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayEnvironment.php @@ -0,0 +1,21 @@ +clientSecret = $clientSecret; + } + public function getClientSecret() + { + return $this->clientSecret; + } + + public function getBaseUrl() + { + return "https://api.telepay.cash/rest/"; + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayEvents.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayEvents.php new file mode 100644 index 0000000..6582aa4 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayEvents.php @@ -0,0 +1,43 @@ +statusCode = $status; + $this->error = $error; + parent::__construct($message); + } + + public function getName() + { + return 'TelePay Exception'; + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function getError() + { + return $this->error; + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayInvoiceInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayInvoiceInput.php new file mode 100644 index 0000000..f00297a --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayInvoiceInput.php @@ -0,0 +1,113 @@ +setExpiresAt(600); + } + + public function getBodyPrepared() + { + $body = array( + "asset" => $this->asset, + "blockchain" => $this->blockchain, + "network" => $this->network, + "amount" => $this->amount, + "expires_at" => $this->expires_at + ); + if ($this->description) { + $body["description"] = $this->description; + } + if ($this->metadata) { + $body["metadata"] = $this->metadata; + } + if ($this->success_url) { + $body["success_url"] = $this->success_url; + } + if ($this->cancel_url) { + $body["cancel_url"] = $this->cancel_url; + } + return $body; + } + + public function getDescription() + { + return $this->description; + } + public function setDescription($description) + { + $this->description = $description; + } + public function getMetadata() + { + return $this->metadata; + } + public function setMetadata($metadata) + { + $this->metadata = $metadata; + } + public function getSuccessUrl() + { + return $this->success_url; + } + public function setSuccessUrl($success_url) + { + $this->success_url = $success_url; + } + public function getCancelUrl() + { + return $this->cancel_url; + } + public function setCancelUrl($cancel_url) + { + $this->cancel_url = $cancel_url; + } + public function getExpiresAt() + { + return $this->expires_at; + } + public function setExpiresAt($expires_at) + { + $this->expires_at = $expires_at; + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayTransferInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayTransferInput.php new file mode 100644 index 0000000..3de32b8 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayTransferInput.php @@ -0,0 +1,65 @@ +setUsername($username); + } + public function getBodyPrepared() + { + $body = array( + "asset" => $this->asset, + "blockchain" => $this->blockchain, + "network" => $this->network, + "amount" => $this->amount, + "username" => $this->username + ); + if ($this->message) { + $body["message"] = $this->message; + } + return $body; + } + + public function getUsername() + { + return $this->username; + } + public function setUsername($username) + { + $this->username = $username; + } + public function getMessage() + { + return $this->message; + } + public function setMessage($message) + { + $this->message = $message; + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayWebhookInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayWebhookInput.php new file mode 100644 index 0000000..d05b50c --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayWebhookInput.php @@ -0,0 +1,103 @@ +setUrl($url); + $this->setSecret($secret); + $this->setEvents($events); + $this->setActive($active); + } + public function getBodyPrepared() + { + $body = [ + "url" => $this->url, + "secret" => $this->secret, + "events" => $this->events, + ]; + if ($this->active !== null) { + $body["active"] = $this->active; + } + return $body; + } + + /** + * Set and get the url. + */ + public function getUrl() + { + return $this->url; + } + public function setUrl($url) + { + $this->url = $url; + } + + /** + * Set and get the secret. + */ + public function getSecret() + { + return $this->secret; + } + public function setSecret($secret) + { + $this->secret = $secret; + } + + /** + * Set and get the events. + */ + public function getEvents() + { + return $this->events; + } + public function setEvents($events) + { + if (!is_array($events)) { + $events = [$events]; + } + foreach ($events as $event) { + TelePayEvents::validate($event); + } + $this->events = $events; + } + + /** + * Set and get the active. + */ + public function getActive() + { + return $this->active; + } + public function setActive($active) + { + $this->active = $active; + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/src/TelePayWithdrawInput.php b/vendor/telepaycash/sdk-telepay-php/src/TelePayWithdrawInput.php new file mode 100644 index 0000000..b3d18f5 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/src/TelePayWithdrawInput.php @@ -0,0 +1,66 @@ +setToAddress($to_address); + } + public function getBodyPrepared() + { + $body = array( + "asset" => $this->asset, + "blockchain" => $this->blockchain, + "network" => $this->network, + "amount" => $this->amount, + "to_address" => $this->to_address + ); + if ($this->message) { + $body["message"] = $this->message; + } + return $body; + } + + public function getToAddress() + { + return $this->to_address; + } + public function setToAddress($to_address) + { + $this->to_address = $to_address; + } + + public function getMessage() + { + return $this->message; + } + public function setMessage($message) + { + $this->message = $message; + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Asset/AssetsTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Asset/AssetsTest.php new file mode 100644 index 0000000..1208cd3 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Asset/AssetsTest.php @@ -0,0 +1,41 @@ +getAssets(); + + $this->assertNotNull($assets); + $this->assertArrayHasKey('assets', $assets); + + $assets = $assets['assets']; + $this->assertIsArray($assets); + $this->assertGreaterThanOrEqual(1, count($assets)); + foreach ($assets as $asset) { + $this->assertArrayHasKey('asset', $asset); + $this->assertNotNull($asset['asset']); + + $this->assertArrayHasKey('blockchain', $asset); + $this->assertNotNull($asset['blockchain']); + + $this->assertArrayHasKey('url', $asset); + $this->assertNotNull($asset['url']); + + $this->assertArrayHasKey('networks', $asset); + + $networks = $asset['networks']; + $this->assertIsArray($networks); + foreach ($networks as $network) { + $this->assertIsString($network); + } + } + } +} \ No newline at end of file diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Invoice/InvoiceTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Invoice/InvoiceTest.php new file mode 100644 index 0000000..0eb579c --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Invoice/InvoiceTest.php @@ -0,0 +1,234 @@ + 20, + "other_metadata" => "any value" + ]; + private $success_url = "https://www.example.com/payment_success?order_id=20"; + private $cancel_url = "https://www.example.com/payment_cancelled?order_id=20"; + + public function testCreateInvoiceSuccessfull() + { + $telepay = TestInit::client(); + + $newInvoice = new TelePayInvoiceInput($this->asset, $this->blockchain, $this->network, $this->amount); + $newInvoice->setDescription($this->description); + $newInvoice->setMetadata($this->metadata); + $newInvoice->setSuccessUrl($this->success_url); + $newInvoice->setCancelUrl($this->cancel_url); + + $invoice = $telepay->createInvoice($newInvoice); + + $this->assertNotNull($invoice); + $this->assertArrayHasKey('number', $invoice); + $this->assertNotNull($invoice['number']); + + $this->assertArrayHasKey('asset', $invoice); + $this->assertNotNull($invoice['asset']); + $this->assertEquals($this->asset, $invoice['asset']); + + $this->assertArrayHasKey('blockchain', $invoice); + $this->assertNotNull($invoice['blockchain']); + $this->assertEquals($this->blockchain, $invoice['blockchain']); + + $this->assertArrayHasKey('network', $invoice); + $this->assertNotNull($invoice['network']); + $this->assertEquals($this->network, $invoice['network']); + + $this->assertArrayHasKey('amount', $invoice); + $this->assertNotNull($invoice['amount']); + $this->assertTrue( $this->amount == $invoice['amount']); + + $this->assertArrayHasKey('description', $invoice); + $this->assertNotNull($invoice['description']); + $this->assertEquals($this->description, $invoice['description']); + + $this->assertArrayHasKey('metadata', $invoice); + $this->assertNotNull($invoice['metadata']); + $this->assertEquals($this->metadata, $invoice['metadata']); + + $this->assertArrayHasKey('success_url', $invoice); + $this->assertNotNull($invoice['success_url']); + $this->assertEquals($this->success_url, $invoice['success_url']); + + $this->assertArrayHasKey('cancel_url', $invoice); + $this->assertNotNull($invoice['cancel_url']); + $this->assertEquals($this->cancel_url, $invoice['cancel_url']); + + $this->assertArrayHasKey('status', $invoice); + $this->assertNotNull($invoice['status']); + $this->assertEquals('pending', $invoice['status']); + + $this->assertArrayHasKey('checkout_url', $invoice); + $this->assertNotNull($invoice['checkout_url']); + + $this->assertArrayHasKey('onchain_url', $invoice); + $this->assertNotNull($invoice['onchain_url']); + + return $invoice['number']; + } + + public function testCreateInvoiceFail() + { + $telepay = TestInit::client(); + + $unexistentAsset = "UNEXISTENT"; + + $newInvoice = new TelePayInvoiceInput($unexistentAsset, $this->blockchain, $this->network, $this->amount); + $newInvoice->setDescription($this->description); + $newInvoice->setMetadata($this->metadata); + $newInvoice->setSuccessUrl($this->success_url); + $newInvoice->setCancelUrl($this->cancel_url); + + try { + $telepay->createInvoice($newInvoice); + $this->fail('TelePayException was not thrown'); + } catch (TelePayException $exception) { + $this->assertEquals(401, $exception->getStatusCode()); + $this->assertEquals('INVALID_ASSET_BLOCKCHAIN_NETWORK_COMBINATION', $exception->getError()); + } + } + + /** + * @depends testCreateInvoiceSuccessfull + */ + public function testGetInvoiceByNumber($invoiceNumber) + { + $telepay = TestInit::client(); + $invoice = $telepay->getInvoice($invoiceNumber); + + $this->assertNotNull($invoice); + $this->assertArrayHasKey('number', $invoice); + $this->assertNotNull($invoice['number']); + + $this->assertArrayHasKey('asset', $invoice); + $this->assertNotNull($invoice['asset']); + $this->assertEquals($this->asset, $invoice['asset']); + + $this->assertArrayHasKey('blockchain', $invoice); + $this->assertNotNull($invoice['blockchain']); + $this->assertEquals($this->blockchain, $invoice['blockchain']); + + $this->assertArrayHasKey('network', $invoice); + + $this->assertArrayHasKey('amount', $invoice); + $this->assertNotNull($invoice['amount']); + $this->assertEquals((float) $this->amount, $invoice['amount']); + + $this->assertArrayHasKey('description', $invoice); + $this->assertNotNull($invoice['description']); + $this->assertEquals($this->description, $invoice['description']); + + $this->assertArrayHasKey('metadata', $invoice); + $this->assertNotNull($invoice['metadata']); + $this->assertEquals($this->metadata, $invoice['metadata']); + + $this->assertArrayHasKey('success_url', $invoice); + $this->assertNotNull($invoice['success_url']); + $this->assertEquals($this->success_url, $invoice['success_url']); + + $this->assertArrayHasKey('cancel_url', $invoice); + $this->assertNotNull($invoice['cancel_url']); + $this->assertEquals($this->cancel_url, $invoice['cancel_url']); + + $this->assertArrayHasKey('status', $invoice); + $this->assertNotNull($invoice['status']); + $this->assertEquals('pending', $invoice['status']); + + $this->assertArrayHasKey('checkout_url', $invoice); + $this->assertNotNull($invoice['checkout_url']); + + $this->assertArrayHasKey('onchain_url', $invoice); + $this->assertNotNull($invoice['onchain_url']); + + return $invoiceNumber; + } + + /** + * @depends testGetInvoiceByNumber + */ + public function testCancelInvoiceByNumber($invoiceNumber) + { + $telepay = TestInit::client(); + $invoice = $telepay->cancelInvoice($invoiceNumber); + + $this->assertNotNull($invoice); + $this->assertArrayHasKey('number', $invoice); + $this->assertNotNull($invoice['number']); + + $this->assertArrayHasKey('asset', $invoice); + $this->assertNotNull($invoice['asset']); + $this->assertEquals($this->asset, $invoice['asset']); + + $this->assertArrayHasKey('blockchain', $invoice); + $this->assertNotNull($invoice['blockchain']); + $this->assertEquals($this->blockchain, $invoice['blockchain']); + + $this->assertArrayHasKey('network', $invoice); + $this->assertEquals($this->network, $invoice['network']); + + $this->assertArrayHasKey('amount', $invoice); + $this->assertNotNull($invoice['amount']); + $this->assertEquals((float) $this->amount, $invoice['amount']); + + $this->assertArrayHasKey('description', $invoice); + $this->assertNotNull($invoice['description']); + $this->assertEquals($this->description, $invoice['description']); + + $this->assertArrayHasKey('metadata', $invoice); + $this->assertNotNull($invoice['metadata']); + $this->assertEquals($this->metadata, $invoice['metadata']); + + $this->assertArrayHasKey('success_url', $invoice); + $this->assertNotNull($invoice['success_url']); + $this->assertEquals($this->success_url, $invoice['success_url']); + + $this->assertArrayHasKey('cancel_url', $invoice); + $this->assertNotNull($invoice['cancel_url']); + $this->assertEquals($this->cancel_url, $invoice['cancel_url']); + + $this->assertArrayHasKey('status', $invoice); + $this->assertNotNull($invoice['status']); + $this->assertEquals('cancelled', $invoice['status']); + + $this->assertArrayHasKey('checkout_url', $invoice); + $this->assertNotNull($invoice['checkout_url']); + + $this->assertArrayHasKey('onchain_url', $invoice); + $this->assertNotNull($invoice['onchain_url']); + + + $checkInvoice = $telepay->getInvoice($invoiceNumber); + $this->assertNotNull($checkInvoice); + $this->assertArrayHasKey('status', $checkInvoice); + $this->assertEquals('cancelled', $checkInvoice['status']); + + return $invoiceNumber; + } + + /** + * @depends testCancelInvoiceByNumber + */ + public function testDeleteInvoiceByNumber($invoiceNumber) + { + $telepay = TestInit::client(); + $response = $telepay->deleteInvoice($invoiceNumber); + $this->assertNotNull($response); + $this->assertEquals('invoice.deleted', $response['success']); + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Merchant/MerchantTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Merchant/MerchantTest.php new file mode 100644 index 0000000..1e6986c --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Merchant/MerchantTest.php @@ -0,0 +1,40 @@ +getMe(); + $this->assertNotNull($me); + $this->assertArrayHasKey('version', $me); + $this->assertArrayHasKey('merchant', $me); + + $merchant = $me['merchant']; + $this->assertArrayHasKey('name', $merchant); + $this->assertArrayHasKey('url', $merchant); + $this->assertArrayHasKey('logo_url', $merchant); + $this->assertArrayHasKey('logo_thumbnail_url', $merchant); + $this->assertArrayHasKey('verified', $merchant); + $this->assertArrayHasKey('username', $merchant); + $this->assertArrayHasKey('public_profile', $merchant); + + $this->assertArrayHasKey('owner', $merchant); + + $owner = $merchant['owner']; + $this->assertNotNull($owner); + $this->assertArrayHasKey('first_name', $owner); + $this->assertArrayHasKey('last_name', $owner); + $this->assertArrayHasKey('username', $owner); + + $this->assertArrayHasKey('created_at', $merchant); + $this->assertArrayHasKey('updated_at', $merchant); + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/tests/TestInit.php b/vendor/telepaycash/sdk-telepay-php/tests/TestInit.php new file mode 100644 index 0000000..674905c --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/TestInit.php @@ -0,0 +1,19 @@ +asset, $this->blockchain, $this->network, $this->amount, $this->getUsername()); + $transfer->setMessage($this->message); + + $respTransfer = $telepay->transfer($transfer); + + $this->assertNotNull($respTransfer); + $this->assertArrayHasKey('success', $respTransfer); + $this->assertEquals("transfer.ok", $respTransfer['success']); + } + + public function testTransferenceFail() + { + $telepay = TestInit::client(); + + $unexistentAsset = "UNEXISTENT"; + + $transfer = new TelePayTransferInput($unexistentAsset, $this->blockchain, $this->network, $this->amount, $this->getUsername()); + $transfer->setMessage($this->message); + + try { + $telepay->transfer($transfer); + $this->fail('TelePayException was not thrown'); + } catch (TelePayException $exception) { + $this->assertEquals(401, $exception->getStatusCode()); + $this->assertEquals('INVALID_ASSET_BLOCKCHAIN_NETWORK_COMBINATION', $exception->getError()); + } + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Wallet/WalletTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Wallet/WalletTest.php new file mode 100644 index 0000000..720cc85 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Wallet/WalletTest.php @@ -0,0 +1,66 @@ +getBalance($asset); + + $this->assertNotNull($balance); + $this->assertArrayHasKey('wallets', $balance); + + $wallets = $balance['wallets']; + $this->assertIsArray($wallets); + $this->assertEquals(1, count($wallets)); + + $wallet = $wallets[0]; + $this->assertArrayHasKey('asset', $wallet); + $this->assertNotNull($wallet['asset']); + + $this->assertArrayHasKey('blockchain', $wallet); + $this->assertNotNull($wallet['blockchain']); + + $this->assertArrayHasKey('balance', $wallet); + $this->assertNotNull($wallet['balance']); + + $this->assertArrayHasKey('network', $wallet); + + return $balance; + } + + public function testGetAllBalances() + { + $telepay = TestInit::client(); + + $balances = $telepay->getAllBalances(); + + $this->assertNotNull($balances); + $this->assertArrayHasKey('wallets', $balances); + + $wallets = $balances['wallets']; + $this->assertIsArray($wallets); + $this->assertGreaterThanOrEqual(1, count($wallets)); + foreach ($wallets as $wallet) { + $this->assertArrayHasKey('asset', $wallet); + $this->assertNotNull($wallet['asset']); + + $this->assertArrayHasKey('blockchain', $wallet); + $this->assertNotNull($wallet['blockchain']); + + $this->assertArrayHasKey('balance', $wallet); + $this->assertNotNull($wallet['balance']); + + $this->assertArrayHasKey('network', $wallet); + } + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Webhook/WebhookTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Webhook/WebhookTest.php new file mode 100644 index 0000000..fc30c83 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Webhook/WebhookTest.php @@ -0,0 +1,144 @@ +url, $this->secret, $this->events); + + $webhook = $telepay->createWebhook($newWebhook); + + $this->assertNotNull($webhook); + $this->assertArrayHasKey('id', $webhook); + $this->assertNotNull($webhook['id']); + + $this->assertArrayHasKey('url', $webhook); + $this->assertNotNull($webhook['url']); + $this->assertEquals($this->url, $webhook['url']); + + $this->assertArrayHasKey('secret', $webhook); + $this->assertNotNull($webhook['secret']); + $this->assertEquals($this->secret, $webhook['secret']); + + $this->assertArrayHasKey('active', $webhook); + $this->assertNotNull($webhook['active']); + + $this->assertArrayHasKey('events', $webhook); + $this->assertNotNull($webhook['events']); + $this->assertEquals($this->events, $webhook['events']); + + return $webhook['id']; + } + + /** + * @depends testCreateWebhookSuccessfull + */ + public function testGetWebhookByNumber($webhookNumber) + { + $telepay = TestInit::client(); + $webhook = $telepay->getWebhook($webhookNumber); + + $this->assertNotNull($webhook); + $this->assertArrayHasKey('id', $webhook); + $this->assertNotNull($webhook['id']); + + $this->assertArrayHasKey('url', $webhook); + $this->assertNotNull($webhook['url']); + $this->assertEquals($this->url, $webhook['url']); + + $this->assertArrayHasKey('secret', $webhook); + $this->assertNotNull($webhook['secret']); + $this->assertEquals($this->secret, $webhook['secret']); + + $this->assertArrayHasKey('active', $webhook); + $this->assertNotNull($webhook['active']); + + $this->assertArrayHasKey('events', $webhook); + $this->assertNotNull($webhook['events']); + $this->assertEquals($this->events, $webhook['events']); + + return $webhookNumber; + } + + /** + * @depends testGetWebhookByNumber + */ + public function testDeactivateWebhook($webhookNumber) + { + $telepay = TestInit::client(); + + $webhook = $telepay->deactivateWebhook($webhookNumber); + + $this->assertNotNull($webhook); + $this->assertArrayHasKey('active', $webhook); + $this->assertEquals($webhook['active'], false); + + return $webhookNumber; + } + + /** + * @depends testDeactivateWebhook + */ + public function testUpdateWebhook($webhookNumber) + { + $telepay = TestInit::client(); + + $newSecret = "newSecret"; + $updateWebhook = new TelePayWebhookInput($this->url, $newSecret, $this->events, false); + + $webhook = $telepay->updateWebhook($webhookNumber, $updateWebhook); + + $this->assertNotNull($webhook); + $this->assertArrayHasKey('id', $webhook); + $this->assertEquals($webhook['id'], $webhookNumber); + $this->assertArrayHasKey('secret', $webhook); + $this->assertEquals($webhook['secret'], $newSecret); + $this->assertArrayHasKey('active', $webhook); + + return $webhookNumber; + } + + /** + * @depends testUpdateWebhook + */ + public function testActivateWebhook($webhookNumber) + { + $telepay = TestInit::client(); + + $webhook = $telepay->activateWebhook($webhookNumber); + + $this->assertNotNull($webhook); + $this->assertArrayHasKey('active', $webhook); + $this->assertEquals($webhook['active'], true); + + return $webhookNumber; + } + + /** + * @depends testActivateWebhook + */ + public function testDeleteWebhookByNumber($webhookNumber) + { + $telepay = TestInit::client(); + $response = $telepay->deleteWebhook($webhookNumber); + $this->assertNotNull($response); + $this->assertArrayHasKey('success', $response); + $this->assertEquals($response['success'], 'webhook.deleted'); + } +} diff --git a/vendor/telepaycash/sdk-telepay-php/tests/Withdraw/WithdrawTest.php b/vendor/telepaycash/sdk-telepay-php/tests/Withdraw/WithdrawTest.php new file mode 100644 index 0000000..0debdb3 --- /dev/null +++ b/vendor/telepaycash/sdk-telepay-php/tests/Withdraw/WithdrawTest.php @@ -0,0 +1,90 @@ +asset, $this->blockchain, $this->network, $this->amount, $this->getWallet()); + $withdraw->setMessage($this->message); + + $respWithdrawFee = $telepay->getWithdrawFee($withdraw); + + $this->assertNotNull($respWithdrawFee); + $this->assertArrayHasKey('blockchain_fee', $respWithdrawFee); + $this->assertNotNull($respWithdrawFee['blockchain_fee']); + $this->assertArrayHasKey('processing_fee', $respWithdrawFee); + $this->assertNotNull($respWithdrawFee['processing_fee']); + $this->assertArrayHasKey('total', $respWithdrawFee); + $this->assertNotNull($respWithdrawFee['total']); + } + + public function testWithdrawFeeFail() + { + $telepay = TestInit::client(); + + $unexistentAsset = "UNEXISTENT"; + + $withdraw = new TelePayWithdrawInput($unexistentAsset, $this->blockchain, $this->network, $this->amount, $this->getWallet()); + $withdraw->setMessage($this->message); + + try { + $telepay->getWithdrawFee($withdraw); + $this->fail('TelePayException was not thrown'); + } catch (TelePayException $exception) { + $this->assertEquals(401, $exception->getStatusCode()); + $this->assertEquals('INVALID_ASSET_BLOCKCHAIN_NETWORK_COMBINATION', $exception->getError()); + } + } + + public function testWithdrawSuccessfull() + { + $telepay = TestInit::client(); + + $withdraw = new TelePayWithdrawInput($this->asset, $this->blockchain, $this->network, $this->amount, $this->getWallet()); + $withdraw->setMessage($this->message); + + $respWithdraw = $telepay->withdraw($withdraw); + + $this->assertNotNull($respWithdraw); + $this->assertEquals('pending', $respWithdraw['status']); + } + + public function testWithdrawFail() + { + $telepay = TestInit::client(); + + $unexistentAsset = "UNEXISTENT"; + + $withdraw = new TelePayWithdrawInput($unexistentAsset, $this->blockchain, $this->network, $this->amount, $this->getWallet()); + $withdraw->setMessage($this->message); + + try { + $telepay->withdraw($withdraw); + $this->fail('TelePayException was not thrown'); + } catch (TelePayException $exception) { + $this->assertEquals(401, $exception->getStatusCode()); + $this->assertEquals('INVALID_ASSET_BLOCKCHAIN_NETWORK_COMBINATION', $exception->getError()); + } + } +}