Plugin Directory

Changeset 3190331


Ignore:
Timestamp:
11/16/2024 06:05:21 PM (17 months ago)
Author:
tkc49
Message:

Update to version 1.5.0 from GitHub

Location:
ht-pay-jp-for-kintone
Files:
56 added
2 deleted
84 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ht-pay-jp-for-kintone/tags/1.5.0/composer.lock

    r2685245 r3190331  
    22    "_readme": [
    33        "This file locks the dependencies of your project to a known state",
    4         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
     4        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
    55        "This file is @generated automatically"
    66    ],
     
    99        {
    1010            "name": "payjp/payjp-php",
    11             "version": "1.0.5",
     11            "version": "1.7.0",
    1212            "source": {
    1313                "type": "git",
    1414                "url": "https://github.com/payjp/payjp-php.git",
    15                 "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd"
     15                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175"
    1616            },
    1717            "dist": {
    1818                "type": "zip",
    19                 "url": "https://api.github.com/repos/payjp/payjp-php/zipball/57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    20                 "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
     19                "url": "https://api.github.com/repos/payjp/payjp-php/zipball/f8fe3185fc0a481214c35421f051d8cc50f3f175",
     20                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175",
    2121                "shasum": ""
    2222            },
     
    2828            },
    2929            "require-dev": {
    30                 "phpunit/phpunit": "~4.0",
    31                 "satooshi/php-coveralls": "~0.6.1",
    32                 "squizlabs/php_codesniffer": "~2.0"
     30                "phpunit/phpunit": "~5.7 || ~9.5",
     31                "squizlabs/php_codesniffer": "~3.6"
    3332            },
    3433            "type": "library",
     
    6059                "payment processing"
    6160            ],
    62             "time": "2019-08-09T13:10:15+00:00"
     61            "support": {
     62                "issues": "https://github.com/payjp/payjp-php/issues",
     63                "source": "https://github.com/payjp/payjp-php/tree/1.7.0"
     64            },
     65            "time": "2024-11-13T05:21:09+00:00"
    6366        }
    6467    ],
     
    7073    "prefer-lowest": false,
    7174    "platform": [],
    72     "platform-dev": []
     75    "platform-dev": [],
     76    "plugin-api-version": "2.6.0"
    7377}
  • ht-pay-jp-for-kintone/tags/1.5.0/ht-payjp-for-kintone.php

    r2989122 r3190331  
    88 * Text Domain:     ht-pay-jp-for-kintone
    99 * Domain Path:     /languages
    10  * Version:         1.4.1
     10 * Version:         1.5.0
    1111 *
    1212 * @package         HT_Payjp_For_Kintone
  • ht-pay-jp-for-kintone/tags/1.5.0/includes/class-ht-payjp-for-kintone-Payment.php

    r2989122 r3190331  
    170170                );
    171171
     172            } catch ( \Payjp\Error\Card $e ) {
     173                // カード決済エラーの場合
     174                $abort = true;
     175                $submission->set_response( $contact_form->filter_message( __( 'Card payment failed. Please check your card information.', 'payjp-for-kintone' ) ) );
     176                ht_payjp_for_kintone_send_error_mail( $contact_form, $e->getMessage() );
     177
    172178            } catch ( \Payjp\Error\InvalidRequest $e ) {
    173 
     179                // その他のPAY.JPエラーの場合
    174180                $abort = true;
    175181                $submission->set_response( $contact_form->filter_message( $e->getMessage() ) );
  • ht-pay-jp-for-kintone/tags/1.5.0/readme.txt

    r2989122 r3190331  
    33Donate link:
    44Tags: Contact Form 7, kintone, PAY.JP, form data to kintone
    5 Requires at least: 4.5
    6 Tested up to: 6.3.2
    7 Stable tag: 1.4.1
     5Requires at least: 6.6
     6Tested up to: 6.7
     7Requires PHP: 7.4
     8Stable tag: 1.5.0
    89License: GPLv2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5354
    5455== Changelog ==
     56
     57= 1.5.0( 2024-11-17 ) =
     58
     59* Updated payjp/payjp-php version from 1.0.5 to 1.7.0
     60* Added error handling for \Payjp\Error\Card
    5561
    5662= 1.4.1( 2023-11-05 ) =
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/autoload.php

    r2149911 r3190331  
    33// autoload.php @generated by Composer
    44
     5if (PHP_VERSION_ID < 50600) {
     6    if (!headers_sent()) {
     7        header('HTTP/1.1 500 Internal Server Error');
     8    }
     9    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
     10    if (!ini_get('display_errors')) {
     11        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
     12            fwrite(STDERR, $err);
     13        } elseif (!headers_sent()) {
     14            echo $err;
     15        }
     16    }
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
     21}
     22
    523require_once __DIR__ . '/composer/autoload_real.php';
    624
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/ClassLoader.php

    r2149911 r3190331  
    3838 * @author Fabien Potencier <fabien@symfony.com>
    3939 * @author Jordi Boggiano <j.boggiano@seld.be>
    40  * @see    http://www.php-fig.org/psr/psr-0/
    41  * @see    http://www.php-fig.org/psr/psr-4/
     40 * @see    https://www.php-fig.org/psr/psr-0/
     41 * @see    https://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
    4444{
     45    /** @var \Closure(string):void */
     46    private static $includeFile;
     47
     48    /** @var string|null */
     49    private $vendorDir;
     50
    4551    // PSR-4
     52    /**
     53     * @var array<string, array<string, int>>
     54     */
    4655    private $prefixLengthsPsr4 = array();
     56    /**
     57     * @var array<string, list<string>>
     58     */
    4759    private $prefixDirsPsr4 = array();
     60    /**
     61     * @var list<string>
     62     */
    4863    private $fallbackDirsPsr4 = array();
    4964
    5065    // PSR-0
     66    /**
     67     * List of PSR-0 prefixes
     68     *
     69     * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
     70     *
     71     * @var array<string, array<string, list<string>>>
     72     */
    5173    private $prefixesPsr0 = array();
     74    /**
     75     * @var list<string>
     76     */
    5277    private $fallbackDirsPsr0 = array();
    5378
     79    /** @var bool */
    5480    private $useIncludePath = false;
     81
     82    /**
     83     * @var array<string, string>
     84     */
    5585    private $classMap = array();
     86
     87    /** @var bool */
    5688    private $classMapAuthoritative = false;
     89
     90    /**
     91     * @var array<string, bool>
     92     */
    5793    private $missingClasses = array();
     94
     95    /** @var string|null */
    5896    private $apcuPrefix;
    5997
     98    /**
     99     * @var array<string, self>
     100     */
     101    private static $registeredLoaders = array();
     102
     103    /**
     104     * @param string|null $vendorDir
     105     */
     106    public function __construct($vendorDir = null)
     107    {
     108        $this->vendorDir = $vendorDir;
     109        self::initializeIncludeClosure();
     110    }
     111
     112    /**
     113     * @return array<string, list<string>>
     114     */
    60115    public function getPrefixes()
    61116    {
    62117        if (!empty($this->prefixesPsr0)) {
    63             return call_user_func_array('array_merge', $this->prefixesPsr0);
     118            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
    64119        }
    65120
     
    67122    }
    68123
     124    /**
     125     * @return array<string, list<string>>
     126     */
    69127    public function getPrefixesPsr4()
    70128    {
     
    72130    }
    73131
     132    /**
     133     * @return list<string>
     134     */
    74135    public function getFallbackDirs()
    75136    {
     
    77138    }
    78139
     140    /**
     141     * @return list<string>
     142     */
    79143    public function getFallbackDirsPsr4()
    80144    {
     
    82146    }
    83147
     148    /**
     149     * @return array<string, string> Array of classname => path
     150     */
    84151    public function getClassMap()
    85152    {
     
    88155
    89156    /**
    90      * @param array $classMap Class to filename map
     157     * @param array<string, string> $classMap Class to filename map
     158     *
     159     * @return void
    91160     */
    92161    public function addClassMap(array $classMap)
     
    103172     * appending or prepending to the ones previously set for this prefix.
    104173     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     174     * @param string              $prefix  The prefix
     175     * @param list<string>|string $paths   The PSR-0 root directories
     176     * @param bool                $prepend Whether to prepend the directories
     177     *
     178     * @return void
    108179     */
    109180    public function add($prefix, $paths, $prepend = false)
    110181    {
     182        $paths = (array) $paths;
    111183        if (!$prefix) {
    112184            if ($prepend) {
    113185                $this->fallbackDirsPsr0 = array_merge(
    114                     (array) $paths,
     186                    $paths,
    115187                    $this->fallbackDirsPsr0
    116188                );
     
    118190                $this->fallbackDirsPsr0 = array_merge(
    119191                    $this->fallbackDirsPsr0,
    120                     (array) $paths
     192                    $paths
    121193                );
    122194            }
     
    127199        $first = $prefix[0];
    128200        if (!isset($this->prefixesPsr0[$first][$prefix])) {
    129             $this->prefixesPsr0[$first][$prefix] = (array) $paths;
     201            $this->prefixesPsr0[$first][$prefix] = $paths;
    130202
    131203            return;
     
    133205        if ($prepend) {
    134206            $this->prefixesPsr0[$first][$prefix] = array_merge(
    135                 (array) $paths,
     207                $paths,
    136208                $this->prefixesPsr0[$first][$prefix]
    137209            );
     
    139211            $this->prefixesPsr0[$first][$prefix] = array_merge(
    140212                $this->prefixesPsr0[$first][$prefix],
    141                 (array) $paths
     213                $paths
    142214            );
    143215        }
     
    148220     * appending or prepending to the ones previously set for this namespace.
    149221     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     222     * @param string              $prefix  The prefix/namespace, with trailing '\\'
     223     * @param list<string>|string $paths   The PSR-4 base directories
     224     * @param bool                $prepend Whether to prepend the directories
    153225     *
    154226     * @throws \InvalidArgumentException
     227     *
     228     * @return void
    155229     */
    156230    public function addPsr4($prefix, $paths, $prepend = false)
    157231    {
     232        $paths = (array) $paths;
    158233        if (!$prefix) {
    159234            // Register directories for the root namespace.
    160235            if ($prepend) {
    161236                $this->fallbackDirsPsr4 = array_merge(
    162                     (array) $paths,
     237                    $paths,
    163238                    $this->fallbackDirsPsr4
    164239                );
     
    166241                $this->fallbackDirsPsr4 = array_merge(
    167242                    $this->fallbackDirsPsr4,
    168                     (array) $paths
     243                    $paths
    169244                );
    170245            }
     
    176251            }
    177252            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    178             $this->prefixDirsPsr4[$prefix] = (array) $paths;
     253            $this->prefixDirsPsr4[$prefix] = $paths;
    179254        } elseif ($prepend) {
    180255            // Prepend directories for an already registered namespace.
    181256            $this->prefixDirsPsr4[$prefix] = array_merge(
    182                 (array) $paths,
     257                $paths,
    183258                $this->prefixDirsPsr4[$prefix]
    184259            );
     
    187262            $this->prefixDirsPsr4[$prefix] = array_merge(
    188263                $this->prefixDirsPsr4[$prefix],
    189                 (array) $paths
     264                $paths
    190265            );
    191266        }
     
    196271     * replacing any others previously set for this prefix.
    197272     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     273     * @param string              $prefix The prefix
     274     * @param list<string>|string $paths  The PSR-0 base directories
     275     *
     276     * @return void
    200277     */
    201278    public function set($prefix, $paths)
     
    212289     * replacing any others previously set for this namespace.
    213290     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     291     * @param string              $prefix The prefix/namespace, with trailing '\\'
     292     * @param list<string>|string $paths  The PSR-4 base directories
    216293     *
    217294     * @throws \InvalidArgumentException
     295     *
     296     * @return void
    218297     */
    219298    public function setPsr4($prefix, $paths)
     
    235314     *
    236315     * @param bool $useIncludePath
     316     *
     317     * @return void
    237318     */
    238319    public function setUseIncludePath($useIncludePath)
     
    257338     *
    258339     * @param bool $classMapAuthoritative
     340     *
     341     * @return void
    259342     */
    260343    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277360     *
    278361     * @param string|null $apcuPrefix
     362     *
     363     * @return void
    279364     */
    280365    public function setApcuPrefix($apcuPrefix)
     
    297382     *
    298383     * @param bool $prepend Whether to prepend the autoloader or not
     384     *
     385     * @return void
    299386     */
    300387    public function register($prepend = false)
    301388    {
    302389        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     390
     391        if (null === $this->vendorDir) {
     392            return;
     393        }
     394
     395        if ($prepend) {
     396            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     397        } else {
     398            unset(self::$registeredLoaders[$this->vendorDir]);
     399            self::$registeredLoaders[$this->vendorDir] = $this;
     400        }
    303401    }
    304402
    305403    /**
    306404     * Unregisters this instance as an autoloader.
     405     *
     406     * @return void
    307407     */
    308408    public function unregister()
    309409    {
    310410        spl_autoload_unregister(array($this, 'loadClass'));
     411
     412        if (null !== $this->vendorDir) {
     413            unset(self::$registeredLoaders[$this->vendorDir]);
     414        }
    311415    }
    312416
     
    315419     *
    316420     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     421     * @return true|null True if loaded, null otherwise
    318422     */
    319423    public function loadClass($class)
    320424    {
    321425        if ($file = $this->findFile($class)) {
    322             includeFile($file);
     426            $includeFile = self::$includeFile;
     427            $includeFile($file);
    323428
    324429            return true;
    325430        }
     431
     432        return null;
    326433    }
    327434
     
    368475    }
    369476
     477    /**
     478     * Returns the currently registered loaders keyed by their corresponding vendor directories.
     479     *
     480     * @return array<string, self>
     481     */
     482    public static function getRegisteredLoaders()
     483    {
     484        return self::$registeredLoaders;
     485    }
     486
     487    /**
     488     * @param  string       $class
     489     * @param  string       $ext
     490     * @return string|false
     491     */
    370492    private function findFileWithExtension($class, $ext)
    371493    {
     
    433555        return false;
    434556    }
     557
     558    /**
     559     * @return void
     560     */
     561    private static function initializeIncludeClosure()
     562    {
     563        if (self::$includeFile !== null) {
     564            return;
     565        }
     566
     567        /**
     568         * Scope isolated include.
     569         *
     570         * Prevents access to $this/self from included files.
     571         *
     572         * @param  string $file
     573         * @return void
     574         */
     575        self::$includeFile = \Closure::bind(static function($file) {
     576            include $file;
     577        }, null, null);
     578    }
    435579}
    436 
    437 /**
    438  * Scope isolated include.
    439  *
    440  * Prevents access to $this/self from included files.
    441  */
    442 function includeFile($file)
    443 {
    444     include $file;
    445 }
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/autoload_classmap.php

    r2149911 r3190331  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
    88return array(
     9    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    910);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/autoload_namespaces.php

    r2149911 r3190331  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/autoload_psr4.php

    r2149911 r3190331  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/autoload_real.php

    r2149911 r3190331  
    1414    }
    1515
     16    /**
     17     * @return \Composer\Autoload\ClassLoader
     18     */
    1619    public static function getLoader()
    1720    {
     
    2023        }
    2124
     25        require __DIR__ . '/platform_check.php';
     26
    2227        spl_autoload_register(array('ComposerAutoloaderInit9a018c6d859c504697980df115517622', 'loadClassLoader'), true, true);
    23         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    2429        spl_autoload_unregister(array('ComposerAutoloaderInit9a018c6d859c504697980df115517622', 'loadClassLoader'));
    2530
    26         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    27         if ($useStaticLoader) {
    28             require_once __DIR__ . '/autoload_static.php';
    29 
    30             call_user_func(\Composer\Autoload\ComposerStaticInit9a018c6d859c504697980df115517622::getInitializer($loader));
    31         } else {
    32             $map = require __DIR__ . '/autoload_namespaces.php';
    33             foreach ($map as $namespace => $path) {
    34                 $loader->set($namespace, $path);
    35             }
    36 
    37             $map = require __DIR__ . '/autoload_psr4.php';
    38             foreach ($map as $namespace => $path) {
    39                 $loader->setPsr4($namespace, $path);
    40             }
    41 
    42             $classMap = require __DIR__ . '/autoload_classmap.php';
    43             if ($classMap) {
    44                 $loader->addClassMap($classMap);
    45             }
    46         }
     31        require __DIR__ . '/autoload_static.php';
     32        call_user_func(\Composer\Autoload\ComposerStaticInit9a018c6d859c504697980df115517622::getInitializer($loader));
    4733
    4834        $loader->register(true);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/autoload_static.php

    r2149911 r3190331  
    2121    );
    2222
     23    public static $classMap = array (
     24        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
     25    );
     26
    2327    public static function getInitializer(ClassLoader $loader)
    2428    {
     
    2630            $loader->prefixLengthsPsr4 = ComposerStaticInit9a018c6d859c504697980df115517622::$prefixLengthsPsr4;
    2731            $loader->prefixDirsPsr4 = ComposerStaticInit9a018c6d859c504697980df115517622::$prefixDirsPsr4;
     32            $loader->classMap = ComposerStaticInit9a018c6d859c504697980df115517622::$classMap;
    2833
    2934        }, null, ClassLoader::class);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/composer/installed.json

    r2149911 r3190331  
    1 [
    2     {
    3         "name": "payjp/payjp-php",
    4         "version": "1.0.5",
    5         "version_normalized": "1.0.5.0",
    6         "source": {
    7             "type": "git",
    8             "url": "https://github.com/payjp/payjp-php.git",
    9             "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd"
    10         },
    11         "dist": {
    12             "type": "zip",
    13             "url": "https://api.github.com/repos/payjp/payjp-php/zipball/57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    14             "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    15             "shasum": ""
    16         },
    17         "require": {
    18             "ext-curl": "*",
    19             "ext-json": "*",
    20             "ext-mbstring": "*",
    21             "php": ">=5.6"
    22         },
    23         "require-dev": {
    24             "phpunit/phpunit": "~4.0",
    25             "satooshi/php-coveralls": "~0.6.1",
    26             "squizlabs/php_codesniffer": "~2.0"
    27         },
    28         "time": "2019-08-09T13:10:15+00:00",
    29         "type": "library",
    30         "extra": {
    31             "branch-alias": {
    32                 "dev-master": "0.1.*-dev"
    33             }
    34         },
    35         "installation-source": "dist",
    36         "autoload": {
    37             "psr-4": {
    38                 "Payjp\\": "lib/"
    39             }
    40         },
    41         "notification-url": "https://packagist.org/downloads/",
    42         "license": [
    43             "MIT"
     1{
     2        "packages": [
     3                {
     4                        "name": "payjp/payjp-php",
     5                        "version": "1.7.0",
     6                        "version_normalized": "1.7.0.0",
     7                        "source": {
     8                                "type": "git",
     9                                "url": "https://github.com/payjp/payjp-php.git",
     10                                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175"
     11                        },
     12                        "dist": {
     13                                "type": "zip",
     14                                "url": "https://api.github.com/repos/payjp/payjp-php/zipball/f8fe3185fc0a481214c35421f051d8cc50f3f175",
     15                                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175",
     16                                "shasum": ""
     17                        },
     18                        "require": {
     19                                "ext-curl": "*",
     20                                "ext-json": "*",
     21                                "ext-mbstring": "*",
     22                                "php": ">=5.6"
     23                        },
     24                        "require-dev": {
     25                                "phpunit/phpunit": "~5.7 || ~9.5",
     26                                "squizlabs/php_codesniffer": "~3.6"
     27                        },
     28                        "time": "2024-11-13T05:21:09+00:00",
     29                        "type": "library",
     30                        "extra": {
     31                                "branch-alias": {
     32                                        "dev-master": "0.1.*-dev"
     33                                }
     34                        },
     35                        "installation-source": "dist",
     36                        "autoload": {
     37                                "psr-4": {
     38                                        "Payjp\\": "lib/"
     39                                }
     40                        },
     41                        "notification-url": "https://packagist.org/downloads/",
     42                        "license": [
     43                                "MIT"
     44                        ],
     45                        "authors": [
     46                                {
     47                                        "name": "Payjp and contributors",
     48                                        "homepage": "https://github.com/payjp/payjp-php/graphs/contributors"
     49                                }
     50                        ],
     51                        "description": "Payjp PHP Library",
     52                        "homepage": "https://pay.jp/",
     53                        "keywords": [
     54                                "api",
     55                                "payjp",
     56                                "payment processing"
     57                        ],
     58                        "support": {
     59                                "issues": "https://github.com/payjp/payjp-php/issues",
     60                                "source": "https://github.com/payjp/payjp-php/tree/1.7.0"
     61                        },
     62                        "install-path": "../payjp/payjp-php"
     63                }
    4464        ],
    45         "authors": [
    46             {
    47                 "name": "Payjp and contributors",
    48                 "homepage": "https://github.com/payjp/payjp-php/graphs/contributors"
    49             }
    50         ],
    51         "description": "Payjp PHP Library",
    52         "homepage": "https://pay.jp/",
    53         "keywords": [
    54             "api",
    55             "payjp",
    56             "payment processing"
    57         ]
    58     }
    59 ]
     65        "dev": true,
     66        "dev-package-names": []
     67}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/.gitignore

    r2685245 r3190331  
    2121# Ignore PHPUnit coverage file
    2222clover.xml
     23
     24# Ignore PHPUnit cache file
     25.phpunit.result.cache
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/README.md

    r2149911 r3190331  
    11# PAY.JP for PHP
    22
    3 [![Build Status](https://travis-ci.org/payjp/payjp-php.svg?branch=master)](https://travis-ci.org/payjp/payjp-php)
     3[![Build Status](https://github.com/payjp/payjp-php/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/payjp/payjp-php/actions)
    44
    55## Requirements
     
    5353- Please see our official [documentation](https://pay.jp/docs/started).
    5454
     55## Retry on HTTP Status Code 429
     56
     57- See [Rate Limit Guideline](https://pay.jp/docs/guideline-rate-limit#2-%E3%83%AA%E3%83%88%E3%83%A9%E3%82%A4)
     58- When you exceeded rate-limit, you can retry request by setting `$maxRetry` 
     59  like `\Payjp\Payjp::setMaxRetry(3);` .
     60- The retry interval base value is `$retryInitialDelay` 
     61  Adjust the value like `\Payjp\Payjp::setRetryInitialDelay(4);` 
     62  The smaller is shorter.
     63- The retry interval calcurating is based on "Exponential backoff with equal jitter" algorithm. 
     64  See https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     65
     66## Logging
     67
     68- This library provides simple log output using `error_log` . You can set any logger that is compatible [PSR-3](https://www.php-fig.org/psr/psr-3/) logger interface. Like below
     69- `\Payjp\Payjp::setLogger($logger);`
     70- As the default behavior, this library output only error level information to stderr.
     71
     72### Logging Case
     73#### info
     74
     75- Every retry on HTTP Status Code 429
     76
     77#### error
     78
     79- When you access inaccessible or non-existing property
     80
    5581## Tests
    5682
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/VERSION

    r2149911 r3190331  
    1 1.0.5
     11.7.0
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/build.php

    r2149911 r3190331  
    3131
    3232$config = $autoload ? 'phpunit.xml' : 'phpunit.no_autoload.xml';
    33 passthru("./vendor/bin/phpunit -c $config", $returnStatus);
     33passthru("./vendor/bin/phpunit -c $config -d error_reporting=-1", $returnStatus);
    3434if ($returnStatus !== 0) {
    3535    exit(1);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/composer.json

    r2149911 r3190331  
    2222  },
    2323  "require-dev": {
    24     "phpunit/phpunit": "~4.0",
    25     "satooshi/php-coveralls": "~0.6.1",
    26     "squizlabs/php_codesniffer": "~2.0"
     24    "phpunit/phpunit": "~5.7 || ~9.5",
     25    "squizlabs/php_codesniffer": "~3.6"
    2726  },
    2827  "autoload": {
     
    3332      "dev-master": "0.1.*-dev"
    3433    }
     34  },
     35  "scripts": {
     36     "test": [
     37       "phpcs --standard=PSR2 -n lib tests *.php",
     38       "phpunit"
     39     ]
    3540  }
    3641}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/init.php

    r2149911 r3190331  
    44require(dirname(__FILE__) . '/lib/Payjp.php');
    55
    6 // Utilities
     6// Logger
     7require(dirname(__FILE__) . '/lib/Logger/LoggerInterface.php');
     8require(dirname(__FILE__) . '/lib/Logger/DefaultLogger.php');
     9
     10// UtilitiesL
    711require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
    812require(dirname(__FILE__) . '/lib/Util/Set.php');
     
    3135// Payjp API Resources
    3236require(dirname(__FILE__) . '/lib/Account.php');
     37require(dirname(__FILE__) . '/lib/ApplicationUrl.php');
     38require(dirname(__FILE__) . '/lib/Balance.php');
    3339require(dirname(__FILE__) . '/lib/Card.php');
    3440require(dirname(__FILE__) . '/lib/Charge.php');
     
    3743require(dirname(__FILE__) . '/lib/Event.php');
    3844require(dirname(__FILE__) . '/lib/Plan.php');
     45require(dirname(__FILE__) . '/lib/Statement.php');
     46require(dirname(__FILE__) . '/lib/StatementUrl.php');
    3947require(dirname(__FILE__) . '/lib/Subscription.php');
     48require(dirname(__FILE__) . '/lib/Tenant.php');
     49require(dirname(__FILE__) . '/lib/TenantTransfer.php');
     50require(dirname(__FILE__) . '/lib/Term.php');
     51require(dirname(__FILE__) . '/lib/ThreeDSecureRequest.php');
    4052require(dirname(__FILE__) . '/lib/Token.php');
    4153require(dirname(__FILE__) . '/lib/Transfer.php');
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/ApiRequestor.php

    r2149911 r3190331  
    3939    }
    4040
     41    // @var int Number of digit for randomized sleep time seconds
     42    private $digit_num_for_rand = 2;
     43
     44    /**
     45     * Based on "Exponential backoff with equal jitter" algorithm.
     46     * https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     47     *
     48     * @param int $retryCount
     49     *
     50     * @return int retry delay seconds.
     51     */
     52    private function getRetryDelay($retryCount)
     53    {
     54        $wait_half = min(Payjp::getRetryMaxDelay(), Payjp::getRetryInitialDelay() * pow(2, $retryCount)) / 2;
     55        $scale = pow(10, $this->digit_num_for_rand);
     56        return $wait_half + mt_rand(0, $wait_half * $scale) / $scale;
     57    }
     58
    4159    /**
    4260     * @param string $method
     
    5674            $headers = array();
    5775        }
    58         list($rbody, $rcode, $myApiKey) =
    59         $this->_requestRaw($method, $url, $params, $headers);
     76
     77        for ($i = 0; $i <= Payjp::getMaxRetry(); $i++) {
     78            list($rbody, $rcode, $myApiKey) = $this->_requestRaw($method, $url, $params, $headers);
     79            if ($rcode == 429 && $i != Payjp::getMaxRetry()) {
     80                $wait = $this->getRetryDelay($i);
     81                Payjp::getLogger()->info("Retry after {$wait} seconds.");
     82                usleep((int) $wait * 1000000);
     83            } else {
     84                break;
     85            }
     86        }
    6087        $resp = $this->_interpretResponse($rbody, $rcode);
    6188        return array($resp, $myApiKey);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/ApiResource.php

    r2149911 r3190331  
    77    private static $HEADERS_TO_PERSIST = array('Payjp-Account' => true, 'Payjp-Version' => true);
    88
    9     public static function baseUrl()
    10     {
    11         return Payjp::$apiBase;
    12     }
    13 
    149    /**
    1510     * @return ApiResource The refreshed resource.
     
    1712    public function refresh()
    1813    {
    19         $requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl());
     14        $requestor = new ApiRequestor($this->_opts->apiKey);
    2015        $url = $this->instanceUrl();
    2116
     
    6055    {
    6156        $base = static::className();
    62         return "/v1/${base}s";
     57        return "/v1/{$base}s";
    6358    }
    6459
     
    9388    }
    9489
     90    /**
     91     * @param string $method
     92     * @param string $url
     93     * @param array|null $params
     94     * @param RequestOptions|array|string|null $options
     95     *
     96     * @return list(array, RequestOptions)
     97     */
    9598    protected function _request($method, $url, $params = array(), $options = null)
    9699    {
     
    102105    {
    103106        $opts = Util\RequestOptions::parse($options);
    104         $requestor = new ApiRequestor($opts->apiKey, static::baseUrl());
     107        $requestor = new ApiRequestor($opts->apiKey);
    105108        list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
    106109        foreach ($opts->headers as $k => $v) {
     
    132135    {
    133136        self::_validateParams($params);
    134         $base = static::baseUrl();
    135137        $url = static::classUrl();
    136138
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Charge.php

    r2149911 r3190331  
    7575        return $this;
    7676    }
     77
     78    /**
     79     * @param array|null $params
     80     * @param array|string|null $options
     81     *
     82     * @return Charge The paid charge.
     83     */
     84    public function tdsFinish($params = null, $options = null)
     85    {
     86        $url = $this->instanceUrl() . '/tds_finish';
     87        list($response, $opts) = $this->_request('post', $url, $params, $options);
     88        $this->refreshFrom($response, $opts);
     89        return $this;
     90    }
    7791}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Customer.php

    r2149911 r3190331  
    1212                . "would be: \"Payjp\\Charge::create(array('amount' => 100, "
    1313                . "'currency' => 'usd', 'card' => array('number' => "
    14                                                                                         . "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
     14                . "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
    1515                    throw new Error\Api($message);
    1616        }
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Error/Base.php

    r2149911 r3190331  
    77abstract class Base extends Exception
    88{
     9    public $httpStatus;
     10    public $httpBody;
     11    public $jsonBody;
     12
    913    public function __construct(
    1014        $message,
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Error/Card.php

    r2149911 r3190331  
    55class Card extends Base
    66{
     7    public $param;
     8
    79    public function __construct(
    810        $message,
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Error/InvalidRequest.php

    r2149911 r3190331  
    55class InvalidRequest extends Base
    66{
     7    public $param;
     8
    79    public function __construct(
    810        $message,
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Payjp.php

    r2149911 r3190331  
    1616    // @var boolean Defaults to true.
    1717    public static $verifySslCerts = true;
     18
     19    // @var \Payjp\Logger\LoggerInterface Default logger will output to error_log().
     20    public static $logger = null;
     21
     22    // @var int Max retry count for over_capacity 429 response.
     23    public static $maxRetry = 0;
     24
     25    /**
     26     * The retry interval base value for over_capacity 429 response.
     27     * Based on "Exponential backoff with equal jitter" algorithm.
     28     * See https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     29     *
     30     * @var int
     31     */
     32    public static $retryInitialDelay = 2;
     33
     34    // @var int Max retry delay seconds for over_capacity 429 response.
     35    public static $retryMaxDelay = 32;
    1836
    1937    const VERSION = '1.0.0';
     
    6987        self::$verifySslCerts = $verify;
    7088    }
     89
     90    /**
     91     * @return \Payjp\Logger\LoggerInterface
     92     */
     93    public static function getLogger()
     94    {
     95        if (self::$logger == null) {
     96            return new \Payjp\Logger\DefaultLogger();
     97        }
     98        return self::$logger;
     99    }
     100
     101    /**
     102     * @param \Payjp\Logger\LoggerInterface $logger
     103     */
     104    public static function setLogger($logger)
     105    {
     106        self::$logger = $logger;
     107    }
     108    /**
     109     * @return int
     110     */
     111    public static function getMaxRetry()
     112    {
     113        return self::$maxRetry;
     114    }
     115
     116    /**
     117     * @param int $value
     118     */
     119    public static function setMaxRetry($value)
     120    {
     121        self::$maxRetry = $value;
     122    }
     123
     124    /**
     125     * @return int
     126     */
     127    public static function getRetryInitialDelay()
     128    {
     129        return self::$retryInitialDelay;
     130    }
     131
     132    /**
     133     * @param int $value
     134     */
     135    public static function setRetryInitialDelay($value)
     136    {
     137        self::$retryInitialDelay = $value;
     138    }
     139
     140    /**
     141     * @return int
     142     */
     143    public static function getRetryMaxDelay()
     144    {
     145        return self::$retryMaxDelay;
     146    }
     147
     148    /**
     149     * @param int $value
     150     */
     151    public static function setRetryMaxDelay($value)
     152    {
     153        self::$retryMaxDelay = $value;
     154    }
    71155}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/PayjpObject.php

    r2149911 r3190331  
    102102                    . "probably as a result of a save(). The attributes currently "
    103103                    . "available on this object are: $attrs";
    104             error_log($message);
     104            Payjp::getLogger()->error($message);
    105105            return null;
    106106        } else {
    107107            $class = get_class($this);
    108             error_log("Payjp Notice: Undefined property of $class instance: $k");
     108            Payjp::getLogger()->error("Payjp Notice: Undefined property of $class instance: $k");
    109109            return null;
    110110        }
     
    112112
    113113    // ArrayAccess methods
     114    #[\ReturnTypeWillChange]
    114115    public function offsetSet($k, $v)
    115116    {
     
    117118    }
    118119
     120    #[\ReturnTypeWillChange]
    119121    public function offsetExists($k)
    120122    {
     
    122124    }
    123125
     126    #[\ReturnTypeWillChange]
    124127    public function offsetUnset($k)
    125128    {
    126129        unset($this->$k);
    127130    }
     131
     132    #[\ReturnTypeWillChange]
    128133    public function offsetGet($k)
    129134    {
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Token.php

    r2149911 r3190331  
    2626        return self::_create($params, $opts);
    2727    }
     28
     29    /**
     30     * @param array|null $params
     31     * @param array|string|null $options
     32     *
     33     * @return Token The paid token.
     34     */
     35    public function tdsFinish($params = null, $options = null)
     36    {
     37        $url = $this->instanceUrl() . '/tds_finish';
     38        list($response, $opts) = $this->_request('post', $url, $params, $options);
     39        $this->refreshFrom($response, $opts);
     40        return $this;
     41    }
    2842}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Transfer.php

    r2149911 r3190331  
    77    /**
    88     * @param string $id The ID of the transfer to retrieve.
    9      * @param array|string|null $opts
     9     * @param RequestOptions|array|string|null $opts
    1010     *
    1111     * @return Transfer
     
    1818    /**
    1919     * @param array|null $params
    20      * @param array|string|null $opts
     20     * @param RequestOptions|array|string|null $opts
    2121     *
    2222     * @return Transfer[]
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Util/Set.php

    r2149911 r3190331  
    3838    }
    3939
     40    #[\ReturnTypeWillChange]
    4041    public function getIterator()
    4142    {
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/lib/Util/Util.php

    r2149911 r3190331  
    77abstract class Util
    88{
     9    // todo wanna use 'private const' (only PHP >= v7.1.0)
     10    private static $types = array(
     11        'application_url' => \Payjp\ApplicationUrl::class,
     12        'balance' => \Payjp\Balance::class,
     13        'card' => \Payjp\Card::class,
     14        'charge' => \Payjp\Charge::class,
     15        'customer' => \Payjp\Customer::class,
     16        'event' => \Payjp\Event::class,
     17        'list' => \Payjp\Collection::class,
     18        'plan' => \Payjp\Plan::class,
     19        'statement' => \Payjp\Statement::class,
     20        'statement_url' => \Payjp\StatementUrl::class,
     21        'subscription' => \Payjp\Subscription::class,
     22        'tenant' => \Payjp\Tenant::class,
     23        'token' => \Payjp\Token::class,
     24        'tenant_transfer' => \Payjp\TenantTransfer::class,
     25        'term' => \Payjp\Term::class,
     26        'transfer' => \Payjp\Transfer::class,
     27        'three_d_secure_request' => \Payjp\ThreeDSecureRequest::class,
     28    );
     29
    930    /**
    1031     * Whether the provided array (or other) is a list rather than a dictionary.
     
    3960        foreach ($values as $k => $v) {
    4061            // FIXME: this is an encapsulation violation
    41             if ($k[0] == '_') {
     62            if (is_string($k) && $k[0] == '_') {
    4263                continue;
    4364            }
     
    6283    public static function convertToPayjpObject($resp, $opts)
    6384    {
    64         $types = array(
    65             'account' => 'Payjp\\Account',
    66             'card' => 'Payjp\\Card',
    67             'charge' => 'Payjp\\Charge',
    68             'customer' => 'Payjp\\Customer',
    69             'list' => 'Payjp\\Collection',
    70             'event' => 'Payjp\\Event',
    71             'token' => 'Payjp\\Token',
    72             'transfer' => 'Payjp\\Transfer',
    73             'plan' => 'Payjp\\Plan',
    74             'subscription' => 'Payjp\\Subscription',
    75         );
    7685        if (self::isList($resp)) {
    7786            $mapped = array();
     
    8190            return $mapped;
    8291        } elseif (is_array($resp)) {
    83             if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
    84                 $class = $types[$resp['object']];
     92            if (isset($resp['object']) && is_string($resp['object']) && isset(self::$types[$resp['object']])) {
     93                $class = self::$types[$resp['object']];
    8594            } else {
    8695                $class = 'Payjp\\PayjpObject';
     
    101110    {
    102111        if (is_string($value) && mb_detect_encoding($value, "UTF-8", true) != "UTF-8") {
    103             return utf8_encode($value);
     112            if (\PHP_VERSION_ID >= 80200) {
     113                return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
     114            } else {
     115                return utf8_encode($value);
     116            }
    104117        } else {
    105118            return $value;
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/AccountTest.php

    r2149911 r3190331  
    77    private function managedAccountResponse($id)
    88    {
    9         return array(
    10             'accounts_enabled' => array('merchant', 'customer'),
     9        return [
     10            'accounts_enabled' => [
     11                'merchant',
     12                'customer',
     13            ],
    1114            'created' => 1432965397,
    12                 'customer' => array(
    13                         'cards' => array(
    14                                 'count' => 1,
    15                                 'data' => array(
    16                                         array(
    17                                                 'address_city' => '\u8d64\u5742',
    18                                                 'address_line1' => '7-4',
    19                                                 'address_line2' => '203',
    20                                                 'address_state' => '\u6e2f\u533a',
    21                                                 'address_zip' => '1070050',
    22                                                 'address_zip_check' => 'passed',
    23                                                 'brand' => 'Visa',
    24                                                 'country' => self::COUNTRY,
    25                                                 'created' => 1432965397,
    26                                                 'cvc_check' => 'passed',
    27                                                 'exp_month' => 12,
    28                                                 'exp_year' => 2016,
    29                                                 'fingerprint' => 'e1d8225886e3a7211127df751c86787f',
    30                                                 'id' => 'car_99abf74cb5527ff68233a8b836dd',
    31                                                 'last4' => '4242',
    32                                                 'livemode' => true,
    33                                                 'name' => 'Test Hodler',
    34                                                 'object' => 'card'
    35                                         )
    36                                 ),
    37                                 'object' => 'list',
    38                                 'url' => '/v1/accounts/cards'
    39                         ),
    40                         'created' => 1432965397,
    41                         'default_card' => null,
    42                         'description' => 'user customer',
    43                         'email' => null,
    44                         'id' => 'acct_cus_38153121efdb7964dd1e147',
    45                         'object' => 'customer'
    46                 ),
    47                 'email' => 'firstuser@mail.com',
    48                 'id' => $id,
    49                 'merchant' => array(
    50                         'bank_enabled' => false,
    51                         'brands_accepted' => array(
    52                                         'Visa',
    53                                         'American Express',
    54                                         'MasterCard',
    55                                         'JCB',
    56                                         'Diners Club'
    57                         ),
    58                         'business_type' => 'personal',
    59                         'charge_type' => null,
    60                         'contact_phone' => null,
    61                         'country' => 'JP',
    62                         'created' => 1432965397,
    63                         'currencies_supported' => array(
    64                                         self::CURRENCY
    65                         ),
    66                         'default_currency' => self::CURRENCY,
    67                         'details_submitted' => false,
    68                         'id' => 'acct_mch_002418151ef82e49f6edee1',
    69                         'livemode_activated_at' => 1432965401,
    70                         'livemode_enabled' => true,
    71                         'object' => 'merchant',
    72                         'product_detail' => null,
    73                         'product_name' => null,
    74                         'product_type' => null,
    75                         'site_published' => false,
    76                         'url' => null
    77                 ),
    78                 'object' => 'account'
    79                        
    80         );
     15            'customer' => [
     16                'cards' => [
     17                    'count' => 1,
     18                    'data' => [
     19                        [
     20                            'address_city' => '\u8d64\u5742',
     21                            'address_line1' => '7-4',
     22                            'address_line2' => '203',
     23                            'address_state' => '\u6e2f\u533a',
     24                            'address_zip' => '1070050',
     25                            'address_zip_check' => 'passed',
     26                            'brand' => 'Visa',
     27                            'country' => self::COUNTRY,
     28                            'created' => 1432965397,
     29                            'cvc_check' => 'passed',
     30                            'exp_month' => 12,
     31                            'exp_year' => 2016,
     32                            'fingerprint' => 'e1d8225886e3a7211127df751c86787f',
     33                            'id' => 'car_99abf74cb5527ff68233a8b836dd',
     34                            'last4' => '4242',
     35                            'livemode' => true,
     36                            'name' => 'Test Hodler',
     37                            'object' => 'card'
     38                        ]
     39                    ],
     40                    'object' => 'list',
     41                    'url' => '/v1/accounts/cards'
     42                ],
     43                'created' => 1432965397,
     44                'default_card' => null,
     45                'description' => 'user customer',
     46                'email' => null,
     47                'id' => 'acct_cus_38153121efdb7964dd1e147',
     48                'object' => 'customer'
     49            ],
     50            'email' => 'firstuser@mail.com',
     51            'id' => $id,
     52            'merchant' => [
     53                'bank_enabled' => false,
     54                'brands_accepted' => [
     55                    'Visa',
     56                    'American Express',
     57                    'MasterCard',
     58                    'JCB',
     59                    'Diners Club'
     60                ],
     61                'business_type' => 'personal',
     62                'charge_type' => null,
     63                'contact_phone' => null,
     64                'country' => 'JP',
     65                'created' => 1432965397,
     66                'currencies_supported' => [
     67                    self::CURRENCY
     68                ],
     69                'default_currency' => self::CURRENCY,
     70                'details_submitted' => false,
     71                'id' => 'acct_mch_002418151ef82e49f6edee1',
     72                'livemode_activated_at' => 1432965401,
     73                'livemode_enabled' => true,
     74                'object' => 'merchant',
     75                'product_detail' => null,
     76                'product_name' => null,
     77                'product_type' => null,
     78                'site_published' => false,
     79                'url' => null
     80            ],
     81            'object' => 'account'
     82        ];
    8183    }
    8284
    8385    public function testBasicRetrieve()
    8486    {
    85         $this->mockRequest('GET', '/v1/accounts', array(), $this->managedAccountResponse('acct_ABC'));
     87        $this->mockRequest('GET', '/v1/accounts', [], $this->managedAccountResponse('acct_ABC'));
    8688        $account = Account::retrieve();
    87        
     89
    8890        $this->assertSame('acct_ABC', $account->id);
    8991        $this->assertSame('acct_cus_38153121efdb7964dd1e147', $account->customer->id);
    9092        $this->assertSame('acct_mch_002418151ef82e49f6edee1', $account->merchant->id);
    9193    }
    92    
    93     public function testRetrieve()
    94     {
    95         $account = Account::retrieve();
    96     }
    9794}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/ApiRequestorTest.php

    r2149911 r3190331  
    55class ApiRequestorTest extends TestCase
    66{
     7    /**
     8     * @before
     9     */
     10    protected function setUpTestCase()
     11    {
     12        parent::setUpTestCase();
     13        # MaxRetryを戻してinitialDelayを短くする
     14        Payjp::setMaxRetry(0);
     15        Payjp::setRetryInitialDelay(0.1);
     16        Payjp::setRetryMaxDelay(32);
     17    }
     18
     19    /**
     20     * @after
     21     */
     22    protected function tearDownTestCase()
     23    {
     24        parent::tearDown();
     25        Payjp::setMaxRetry(0);
     26        $this->setMaxRetryForCi();
     27        Payjp::setRetryInitialDelay(2);
     28        Payjp::setRetryMaxDelay(32);
     29    }
     30
     31    private $errorResponse = array('rcode'=>500, 'rbody'=>array('error' => array(
     32        "code" => "payjp_wrong",
     33        "message" => "An unexpected error occurred.",
     34        "status" => 500,
     35        "type" => "server_error",
     36    )));
     37    private $rateLimitResponse = array('rcode'=>429, 'rbody'=>array('error' => array(
     38        "code" => "over_capacity",
     39        "message" => "The service is over capacity. Please try again later.",
     40        "status" => 429,
     41        "type" => "client_error",
     42    )));
     43    private $successResponse = array('rcode'=>200, 'rbody'=>array('data'=>array()));
     44
     45    private function setUpResponses($responses)
     46    {
     47        $userCallCount = 0;
     48        $mock = $this->setUpMockRequest();
     49        $mock->expects($this->exactly(count($responses)))
     50            ->method('request')
     51            // $userCallCount を使って、responses の中から適切なものを選択するために、参照渡しで渡す。
     52            ->willReturnCallback(static function () use ($responses, &$userCallCount) {
     53                $userCallCount++;
     54                $response = $responses[$userCallCount - 1];
     55                return array(json_encode($response['rbody']), $response['rcode']);
     56            });
     57    }
     58
     59    // _encodeObjects
     60
    761    public function testEncodeObjects()
    862    {
     
    2579        $this->assertSame($enc, array('customer' => "\xc3\xa9"));
    2680    }
     81
     82    // request retry
     83
     84    public function testRetryDisabled()
     85    {
     86        $this->setUpResponses(array($this->rateLimitResponse));
     87        $requestor = new ApiRequestor(self::API_KEY);
     88
     89        try {
     90            $response = $requestor->request('GET', '/v1/accounts');
     91        } catch (Error\Api $e) {
     92            $this->assertSame($e->getMessage(), $this->rateLimitResponse['rbody']['error']['message']);
     93            $this->assertSame($e->getHttpStatus(), $this->rateLimitResponse['rcode']);
     94        }
     95    }
     96
     97    public function testNoRetry()
     98    {
     99        $this->setUpResponses(array($this->errorResponse));
     100        $requestor = new ApiRequestor(self::API_KEY);
     101
     102        try {
     103            $response = $requestor->request('GET', '/v1/accounts');
     104        } catch (Error\Api $e) {
     105            $this->assertSame($e->getMessage(), $this->errorResponse['rbody']['error']['message']);
     106            $this->assertSame($e->getHttpStatus(), $this->errorResponse['rcode']);
     107        }
     108    }
     109
     110    public function testFullRetryAndSuccess()
     111    {
     112        Payjp::setMaxRetry(2);
     113        $this->setUpResponses(array($this->rateLimitResponse, $this->rateLimitResponse, $this->successResponse));
     114        $requestor = new ApiRequestor(self::API_KEY);
     115
     116        $response = $requestor->request('GET', '/v1/accounts');
     117
     118        $this->assertSame($response[0], $this->successResponse['rbody']);
     119    }
     120
     121    public function testFullRetryAndFailed()
     122    {
     123        Payjp::setMaxRetry(2);
     124        $this->setUpResponses(array($this->rateLimitResponse, $this->rateLimitResponse, $this->rateLimitResponse));
     125        $requestor = new ApiRequestor(self::API_KEY);
     126
     127        try {
     128            $response = $requestor->request('GET', '/v1/accounts');
     129        } catch (Error\Api $e) {
     130            $this->assertSame($e->getMessage(), $this->rateLimitResponse['rbody']['error']['message']);
     131            $this->assertSame($e->getHttpStatus(), $this->rateLimitResponse['rcode']);
     132        }
     133    }
     134
     135    public function testGetRetryDelay()
     136    {
     137        Payjp::setRetryInitialDelay(2);
     138        $reflector = new \ReflectionClass('Payjp\\ApiRequestor');
     139        $method = $reflector->getMethod('getRetryDelay');
     140        $method->setAccessible(true);
     141        $r = new ApiRequestor(self::API_KEY);
     142
     143        $this->assertTrue(1 <= $method->invoke($r, 0) && $method->invoke($r, 0) <= 2);
     144        $this->assertTrue(2 <= $method->invoke($r, 1) && $method->invoke($r, 1) <= 4);
     145        $this->assertTrue(4 <= $method->invoke($r, 2) && $method->invoke($r, 2) <= 8);
     146        # not over retryMaxDelay
     147        $this->assertTrue(16 <= $method->invoke($r, 4) && $method->invoke($r, 4) <= 32);
     148        $this->assertTrue(16 <= $method->invoke($r, 10) && $method->invoke($r, 10) <= 32);
     149    }
    27150}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/CardErrorTest.php

    r2149911 r3190331  
    1111        $params =  [
    1212            'card' => [
    13             "number" => "4242424242424242",
    14             "exp_month" => 6,
    15             "exp_year" => date('Y') + 3,
    16             "cvc" => "314"
     13                'number' => '4242424242424242',
     14                'exp_month' => 6,
     15                'exp_year' => date('Y') - 1,
     16                'cvc' => '314'
    1717            ]
    1818        ];
    1919
    20         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    21 
    22         $charge = array(
    23             'amount' => 100,
    24             'currency' => self::CURRENCY,
    25             'card' => $card->id
    26         );
    27 
    2820        try {
    29             Charge::create($charge);
     21            Token::create($params, ['payjp_direct_token_generate' => 'true']);
    3022        } catch (Error\Card $e) {
    3123            $this->assertSame(402, $e->getHttpStatus());
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/ChargeTest.php

    r2149911 r3190331  
    1919        $params =  [
    2020            'card' => [
    21             "number" => "4242424242424242",
    22             "exp_month" => "05",
    23             'exp_year' => date('Y') + 1
    24             ]
    25         ];
    26 
    27         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    28 
    29         $c = Charge::create(
    30             array(
    31                 'amount' => 100,
    32                 'currency' => self::CURRENCY,
    33                 'card' => $card->id
    34             )
    35         );
     21                'number' => '4242424242424242',
     22                'exp_month' => '05',
     23                'exp_year' => date('Y') + 1,
     24                'cvc' => '123',
     25            ]
     26        ];
     27
     28        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     29
     30        $c = Charge::create([
     31            'amount' => 100,
     32            'currency' => self::CURRENCY,
     33            'card' => $card->id,
     34        ]);
    3635        $this->assertTrue($c->paid);
    3736        $this->assertFalse($c->refunded);
     
    4544        $params =  [
    4645            'card' => [
    47             "number" => "4242424242424242",
    48             "exp_month" => 5,
    49             'exp_year' => date('Y') + 1
    50             ]
    51         ];
    52 
    53         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    54 
    55         $c = Charge::create(
    56             array(
    57                 'amount' => 100,
    58                 'currency' => self::CURRENCY,
    59                 'card' => $card->id
    60             ),
    61             array(
    62                 'idempotency_key' => self::generateRandomString(),
    63             )
    64         );
     46                'number' => '4242424242424242',
     47                'exp_month' => 5,
     48                'exp_year' => date('Y') + 1,
     49                'cvc' => '123',
     50            ]
     51        ];
     52
     53        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     54
     55        $c = Charge::create([
     56            'amount' => 100,
     57            'currency' => self::CURRENCY,
     58            'card' => $card->id
     59        ], [
     60            'idempotency_key' => self::generateRandomString(),
     61        ]);
    6562
    6663        $this->assertTrue($c->paid);
     
    7572        $params =  [
    7673            'card' => [
    77             "number" => "4242424242424242",
    78             "exp_month" => 5,
    79             "exp_year" => date('Y') + 1
    80             ]
    81         ];
    82 
    83         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    84 
    85         $c = Charge::create(
    86             array(
    87                 'amount' => 100,
    88                 'currency' => self::CURRENCY,
    89                 'card' => $card->id
    90             )
    91         );
     74                'number' => '4242424242424242',
     75                'exp_month' => 5,
     76                'exp_year' => date('Y') + 1,
     77                'cvc' => '123',
     78            ]
     79        ];
     80
     81        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     82
     83        $c = Charge::create([
     84            'amount' => 100,
     85            'currency' => self::CURRENCY,
     86            'card' => $card->id
     87        ]);
    9288        $d = Charge::retrieve($c->id);
    9389        $this->assertSame($d->id, $c->id);
     
    9995        self::authorizeFromEnv();
    10096
    101         $charges = Charge::all(
    102             array(
    103                     'limit' => 3,
    104                     'offset' => 10
    105             )
    106         );
     97        $charges = Charge::all([
     98            'limit' => 3,
     99            'offset' => 10
     100        ]);
    107101
    108102        $planID = 'gold-' . self::randomString();
     
    111105        $customer = self::createTestCustomer();
    112106
    113         $charge = Charge::create(
    114             array(
    115                     'amount' => 1000,
    116                     'currency' => self::CURRENCY,
    117                     'customer' => $customer->id
    118             )
    119         );
    120 
    121         $charges_2 = Charge::all(
    122             array(
    123                     'customer' => $customer->id
    124             )
    125         );
     107        $charge = Charge::create([
     108            'amount' => 1000,
     109            'currency' => self::CURRENCY,
     110            'customer' => $customer->id
     111        ]);
     112
     113        $charges_2 = Charge::all([
     114            'customer' => $customer->id
     115        ]);
    126116
    127117        $this->assertSame(1, count($charges_2['data']));
    128118        $this->assertSame($charge->id, $charges_2['data'][0]->id);
    129119
    130         $charge_2 = Charge::create(
    131             array(
    132                     'amount' => 1500,
    133                     'currency' => self::CURRENCY,
    134                     'customer' => $customer->id
    135             )
    136         );
    137 
    138         $charges_3 = Charge::all(
    139             array(
    140                     'limit' => 2,
    141                     'offset' => 0,
    142                     'customer' => $customer->id
    143             )
    144         );
     120        $charge_2 = Charge::create([
     121            'amount' => 1500,
     122            'currency' => self::CURRENCY,
     123            'customer' => $customer->id
     124        ]);
     125
     126        $charges_3 = Charge::all([
     127            'limit' => 2,
     128            'offset' => 0,
     129            'customer' => $customer->id
     130        ]);
    145131
    146132        $this->assertSame(2, count($charges_3['data']));
     
    154140        $params =  [
    155141            'card' => [
    156             "number" => "4242424242424242",
    157             "exp_month" => 5,
    158             "exp_year" => date('Y') + 1
    159             ]
    160         ];
    161 
    162         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    163 
    164         $charge = Charge::create(
    165             array(
    166                     'amount' => 100,
    167                     'currency' => self::CURRENCY,
    168                     'card' => $card->id
    169             )
    170         );
     142                'number' => '4242424242424242',
     143                'exp_month' => 5,
     144                'exp_year' => date('Y') + 1,
     145                'cvc' => '123',
     146            ]
     147        ];
     148
     149        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     150
     151        $charge = Charge::create([
     152            'amount' => 100,
     153            'currency' => self::CURRENCY,
     154            'card' => $card->id
     155        ]);
    171156
    172157        $charge->description = 'foo bar';
     
    185170        $params =  [
    186171            'card' => [
    187             "number" => "4242424242424242",
    188             "exp_month" => 5,
    189             "exp_year" => date('Y') + 1
    190             ]
    191         ];
    192 
    193         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    194 
    195         $charge = Charge::create(
    196             array(
    197                     'amount' => 100,
    198                     'currency' => self::CURRENCY,
    199                     'card' => $card->id,
    200                     'capture' => false
    201             )
    202         );
     172                'number' => '4242424242424242',
     173                'exp_month' => 5,
     174                'exp_year' => date('Y') + 1,
     175                'cvc' => '123',
     176            ]
     177        ];
     178
     179        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     180
     181        $charge = Charge::create([
     182            'amount' => 100,
     183            'currency' => self::CURRENCY,
     184            'card' => $card->id,
     185            'capture' => false
     186        ]);
    203187
    204188        $this->assertFalse($charge->captured);
     
    216200        $params =  [
    217201            'card' => [
    218             "number" => "4242424242424242",
    219             "exp_month" => 5,
    220             "exp_year" => date('Y') + 1
    221             ]
    222         ];
    223 
    224         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    225 
    226         $charge = Charge::create(
    227             array(
    228                     'amount' => 100,
    229                     'currency' => self::CURRENCY,
    230                     'card' => $card->id,
    231                     'capture' => false
    232             )
    233         );
     202                'number' => '4242424242424242',
     203                'exp_month' => 5,
     204                'exp_year' => date('Y') + 1,
     205                'cvc' => '123',
     206            ]
     207        ];
     208
     209        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     210
     211        $charge = Charge::create([
     212            'amount' => 100,
     213            'currency' => self::CURRENCY,
     214            'card' => $card->id,
     215            'capture' => false
     216        ]);
    234217
    235218        $this->assertFalse($charge->captured);
     
    247230        $params =  [
    248231            'card' => [
    249             "number" => "4242424242424242",
    250             "exp_month" => 5,
    251             "exp_year" => date('Y') + 1
    252             ]
    253         ];
    254 
    255         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    256 
    257         $charge = Charge::create(
    258             array(
    259                     'amount' => 100,
    260                     'currency' => self::CURRENCY,
    261                     'card' => $card->id,
    262             )
    263         );
     232                'number' => '4242424242424242',
     233                'exp_month' => 5,
     234                'exp_year' => date('Y') + 1,
     235                'cvc' => '123',
     236            ]
     237        ];
     238
     239        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     240
     241        $charge = Charge::create([
     242            'amount' => 100,
     243            'currency' => self::CURRENCY,
     244            'card' => $card->id,
     245        ]);
    264246
    265247        $this->assertTrue($charge->captured);
    266248
    267         $redundChargePart = $charge->refund(
    268             array(
    269                     'amount' => 50,
    270                     'refund_reason' => 'foo bar 1'
    271             )
    272         );
     249        $redundChargePart = $charge->refund([
     250            'amount' => 50,
     251            'refund_reason' => 'foo bar 1'
     252        ]);
    273253
    274254        $this->assertTrue($redundChargePart->refunded);
     
    279259        $this->assertSame(50, $charge->amount_refunded);
    280260
    281         $refundChargeAll = $charge->refund(
    282             array(
    283                     'refund_reason' => 'foo bar 2'
    284             )
    285         );
     261        $refundChargeAll = $charge->refund([
     262            'refund_reason' => 'foo bar 2'
     263        ]);
    286264
    287265        $this->assertTrue($refundChargeAll->refunded);
     
    293271    }
    294272
    295     /**
    296      * @expectedException Payjp\Error\Card
    297      */
    298273    public function testInvalidCard()
    299274    {
    300         self::authorizeFromEnv();
    301 
    302         $params =  [
    303             'card' => [
    304             "number" => "4242424242424241",
    305             "exp_month" => 5,
    306             "exp_year" => date('Y') + 1
    307             ]
    308         ];
    309 
    310         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    311 
    312         Charge::create(
    313             array(
    314                     'amount' => 100,
    315                     'currency' => self::CURRENCY,
    316                     'card' => $card->id
    317             )
    318         );
     275        $this->expectException('\Payjp\Error\Card');
     276
     277        self::authorizeFromEnv();
     278
     279        $params =  [
     280            'card' => [
     281                'number' => '4242424242424241',
     282                'exp_month' => 5,
     283                'exp_year' => date('Y') + 1,
     284                'cvc' => '123',
     285            ]
     286        ];
     287
     288        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     289
     290        Charge::create([
     291            'amount' => 100,
     292            'currency' => self::CURRENCY,
     293            'card' => $card->id
     294        ]);
    319295    }
    320296
     
    326302        $params =  [
    327303            'card' => [
    328             "number" => "4000000000000070",
    329             "exp_month" => '05',
    330             'exp_year' => (date('Y') + 1)
    331             ]
    332         ];
    333 
    334         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    335 
    336         $ch = Charge::create(
    337             array(
    338                     'amount' => 100,
    339                     'currency' => self::CURRENCY,
    340                     'card' => $card->id
    341             )
    342         );
    343 
    344         $this->assertSame("failed", $ch->card->address_zip_check);
     304                'number' => '4000000000000070',
     305                'exp_month' => '05',
     306                'exp_year' => (date('Y') + 1),
     307                'cvc' => '123',
     308            ]
     309        ];
     310
     311        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     312
     313        $ch = Charge::create([
     314            'amount' => 100,
     315            'currency' => self::CURRENCY,
     316            'card' => $card->id
     317        ]);
     318
     319        $this->assertSame('failed', $ch->card->address_zip_check);
    345320    }
    346321
     
    351326        $params =  [
    352327            'card' => [
    353             "number" => "4000000000000100",
    354             "exp_month" => '05',
    355             'exp_year' => (date('Y') + 1)
    356             ]
    357         ];
    358 
    359         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    360 
    361         $ch = Charge::create(
    362             array(
    363                     'amount' => 100,
    364                     'currency' => self::CURRENCY,
    365                     'card' => $card->id
    366             )
    367         );
    368 
    369         $this->assertSame("failed", $ch->card->cvc_check);
     328                'number' => '4000000000000100',
     329                'exp_month' => '05',
     330                'exp_year' => (date('Y') + 1),
     331                'cvc' => '123',
     332            ]
     333        ];
     334
     335        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     336
     337        $ch = Charge::create([
     338            'amount' => 100,
     339            'currency' => self::CURRENCY,
     340            'card' => $card->id
     341        ]);
     342
     343        $this->assertSame('failed', $ch->card->cvc_check);
    370344    }
    371345
     
    376350        $params =  [
    377351            'card' => [
    378             "number" => "4000000000000150",
    379             "exp_month" => '05',
    380             'exp_year' => (date('Y') + 1)
    381             ]
    382         ];
    383 
    384         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    385 
    386         $ch = Charge::create(
    387             array(
    388                     'amount' => 100,
    389                     'currency' => self::CURRENCY,
    390                     'card' => $card->id
    391             )
    392         );
    393 
    394         $this->assertSame("unavailable", $ch->card->cvc_check);
     352                'number' => '4000000000000150',
     353                'exp_month' => '05',
     354                'exp_year' => (date('Y') + 1),
     355                'cvc' => '123',
     356            ]
     357        ];
     358
     359        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     360
     361        $ch = Charge::create([
     362            'amount' => 100,
     363            'currency' => self::CURRENCY,
     364            'card' => $card->id
     365        ]);
     366
     367        $this->assertSame('unavailable', $ch->card->cvc_check);
    395368    }
    396369}
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/CustomerTest.php

    r2149911 r3190331  
    88    public function testCreate()
    99    {
    10         $attribute = array(
    11                         'email' => 'gdb@pay.jp',
    12                         'description' => 'foo bar'
    13         );
    14        
     10        $attribute = [
     11            'email' => 'gdb@pay.jp',
     12            'description' => 'foo bar'
     13        ];
     14
    1515        $customer = self::createTestCustomer($attribute);
    1616        $this->assertSame($attribute['email'], $customer->email);
    1717        $this->assertSame($attribute['description'], $customer->description);
    1818    }
    19        
     19
    2020    // GET/customers/:id
    2121    public function testRetrieve()
     
    2323        $customer = self::createTestCustomer();
    2424        $retrieve_customer = Customer::retrieve($customer->id);
    25        
    2625        $this->assertSame($customer->id, $retrieve_customer->id);
    2726    }
    28    
     27
    2928    // GET/customers/
    3029    public function testAll()
    3130    {
    32         $customers = Customer::all(
    33             array(
    34                 'limit' => 3,
    35                 'offset' => 10
    36             )
    37         );
    38     }
    39    
     31        $customers = Customer::all([
     32            'limit' => 3,
     33            'offset' => 10
     34        ]);
     35        $this->assertCount(3, $customers['data']);
     36    }
     37
    4038    // DELETE/customers/:id
    4139    public function testDeletion()
     
    4341        $customer = self::createTestCustomer();
    4442        $id = $customer->id;
    45        
     43
    4644        $delete_customer = $customer->delete();
    4745
     
    4947        $this->assertFalse($customer->livemode);
    5048        $this->assertTrue($customer->deleted);
    51        
     49
    5250        $this->assertNull($customer['active_card']);
    53        
     51
    5452        $this->assertSame($id, $delete_customer->id);
    5553        $this->assertFalse($delete_customer->livemode);
    5654        $this->assertTrue($delete_customer->deleted);
    57        
     55
    5856        $this->assertNull($delete_customer['active_card']);
    5957    }
    60        
     58
    6159    //POST /customers/:id
    6260    public function testSave()
     
    8381    }
    8482
    85     /**
    86      * @expectedException Payjp\Error\InvalidRequest
    87      */
    8883    public function testBogusAttribute()
    8984    {
     85        $this->expectException('\Payjp\Error\InvalidRequest');
    9086        $customer = self::createTestCustomer();
    9187        $customer->bogus = 'bogus';
     
    9389    }
    9490
    95     /**
    96      * @expectedException InvalidArgumentException
    97      */
    9891    public function testUpdateDescriptionEmpty()
    9992    {
     93        $this->expectException('\InvalidArgumentException');
    10094        $customer = self::createTestCustomer();
    10195        $customer->description = '';
    102        
    103         $customer->save();
    104        
     96
     97        $customer->save();
     98
    10599        $updatedCustomer = Customer::retrieve($customer->id);
    106100        $this->assertSame('123', $updatedCustomer->description);
    107101    }
    108        
     102
    109103    public function testUpdateDescriptionNull()
    110104    {
    111         $customer = self::createTestCustomer(array('description' => 'foo bar'));
     105        $customer = self::createTestCustomer(['description' => 'foo bar']);
    112106        $customer->description = null;
    113    
    114         $customer->save();
    115    
     107
     108        $customer->save();
     109
    116110        $updatedCustomer = Customer::retrieve($customer->id);
    117111        $this->assertSame('', $updatedCustomer->description);
    118112        $this->assertSame('', $customer->description);
    119113    }
    120    
     114
    121115    //POST /customers/:id/cards
    122116    //GET /customers/:id/cards
     
    124118    {
    125119        $customer = $this->createTestCustomer();
    126        
     120
    127121        $defaultCard = $customer->cards->data[0];
    128122
    129123        $params =  [
    130124            'card' => [
    131             "number" => "4242424242424242",
    132             "exp_month" => 12,
    133             "exp_year" => date('Y') + 3,
    134             "cvc" => "314"
     125                'number' => '4242424242424242',
     126                'exp_month' => 12,
     127                'exp_year' => date('Y') + 3,
     128                'cvc' => '314'
    135129            ]
    136130        ];
    137131
    138         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    139          
     132        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     133
    140134        $params2 =  [
    141135            'card' => [
    142             "number" => "4242424242424242",
    143             "exp_month" => 7,
    144             "exp_year" => date('Y') + 3,
    145             "cvc" => "314"
     136                'number' => '4242424242424242',
     137                'exp_month' => 7,
     138                'exp_year' => date('Y') + 3,
     139                'cvc' => '314'
    146140            ]
    147141        ];
    148142
    149         $card = Token::create($params2, $options = ['payjp_direct_token_generate' => 'true']);
    150        
    151         $createdCard = $customer->cards->create(array("card" => $token->id));
    152         $createdCard_2 = $customer->cards->create(array("card" => $card->id));
    153        
    154         $updatedCustomer = Customer::retrieve($customer->id);
    155         $cardList = $updatedCustomer->cards->all();
    156         $this->assertSame(count($cardList["data"]), 3);
    157 
    158         $this->assertSame($createdCard_2->id, $cardList["data"][0]->id);
    159         $this->assertSame($createdCard->id, $cardList["data"][1]->id);
    160         $this->assertSame($defaultCard->id, $cardList["data"][2]->id);
    161          
    162         $card = $customer->cards->retrieve($cardList["data"][1]->id);
    163         $this->assertSame($card->id, $cardList["data"][1]->id);
    164        
    165         $updatedCustomer = Customer::retrieve($customer->id);
    166         $cardList = $updatedCustomer->cards->all(
    167             array(
    168                 'limit' => 1,
    169                 'offset' => 1
    170             )
    171         );
    172         $this->assertSame(count($cardList["data"]), 1);
    173     }
    174    
     143        $card = Token::create($params2, ['payjp_direct_token_generate' => 'true']);
     144
     145        $createdCard = $customer->cards->create(['card' => $token->id]);
     146        $createdCard_2 = $customer->cards->create(['card' => $card->id]);
     147
     148        $updatedCustomer = Customer::retrieve($customer->id);
     149        $cardList = $updatedCustomer->cards->all();
     150        $this->assertSame(count($cardList['data']), 3);
     151
     152        $this->assertSame($createdCard_2->id, $cardList['data'][0]->id);
     153        $this->assertSame($createdCard->id, $cardList['data'][1]->id);
     154        $this->assertSame($defaultCard->id, $cardList['data'][2]->id);
     155
     156        $card = $customer->cards->retrieve($cardList['data'][1]->id);
     157        $this->assertSame($card->id, $cardList['data'][1]->id);
     158
     159        $updatedCustomer = Customer::retrieve($customer->id);
     160        $cardList = $updatedCustomer->cards->all([
     161            'limit' => 1,
     162            'offset' => 1
     163        ]);
     164        $this->assertSame(count($cardList['data']), 1);
     165    }
     166
    175167    //POST /customers/:id/cards/:card_id
    176168    public function testCustomerUpdateCard()
    177169    {
    178170        $customer = $this->createTestCustomer();
    179    
     171
    180172        $cards = $customer->cards->all();
    181         $this->assertSame(count($cards["data"]), 1);
    182    
     173        $this->assertSame(count($cards['data']), 1);
     174
    183175        $card = $cards['data'][0];
    184         $card->name = "Littleorc";
     176        $card->name = 'Littleorc';
    185177        $card->save();
    186    
    187         $updatedCustomer = Customer::retrieve($customer->id);
    188         $cardList = $updatedCustomer->cards->all();
    189         $this->assertSame($cardList["data"][0]->name, "Littleorc");
    190     }
    191    
     178
     179        $updatedCustomer = Customer::retrieve($customer->id);
     180        $cardList = $updatedCustomer->cards->all();
     181        $this->assertSame($cardList['data'][0]->name, 'Littleorc');
     182    }
     183
    192184    public function testCustomerDeleteCard()
    193185    {
    194186        $params =  [
    195187            'card' => [
    196             "number" => "4242424242424242",
    197             "exp_month" => 7,
    198             "exp_year" => date('Y') + 3,
    199             "cvc" => "314"
     188                'number' => '4242424242424242',
     189                'exp_month' => 7,
     190                'exp_year' => date('Y') + 3,
     191                'cvc' => '314'
    200192            ]
    201193        ];
    202194
    203195        $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    204    
     196
    205197        $customer = $this->createTestCustomer();
    206         $createdCard = $customer->cards->create(array("card" => $token->id));
    207    
    208         $updatedCustomer = Customer::retrieve($customer->id);
    209         $cardList = $updatedCustomer->cards->all();
    210         $this->assertSame(count($cardList["data"]), 2);
    211    
     198        $createdCard = $customer->cards->create(['card' => $token->id]);
     199
     200        $updatedCustomer = Customer::retrieve($customer->id);
     201        $cardList = $updatedCustomer->cards->all();
     202        $this->assertSame(count($cardList['data']), 2);
     203
    212204        $deleteStatus = $updatedCustomer->cards->retrieve($createdCard->id)->delete();
    213205        $this->assertTrue($deleteStatus->deleted);
    214    
     206
    215207        $postDeleteCustomer = Customer::retrieve($customer->id);
    216208        $postDeleteCards = $postDeleteCustomer->cards->all();
    217         $this->assertSame(count($postDeleteCards["data"]), 1);
    218        
    219         $cardList = $updatedCustomer->cards->all();
    220         $this->assertSame(count($cardList["data"]), 1);
    221     }
    222    
     209        $this->assertSame(count($postDeleteCards['data']), 1);
     210
     211        $cardList = $updatedCustomer->cards->all();
     212        $this->assertSame(count($cardList['data']), 1);
     213    }
     214
    223215    public function testCustomerSubscriptionAllRetrieve()
    224216    {
    225217        $planID = 'gold-' . self::randomString();
    226218        self::retrieveOrCreatePlan($planID);
    227        
    228         $customer = self::createTestCustomer();
    229        
    230         $subscription = Subscription::create(
    231             array(
    232                 'customer' => $customer->id,
    233                 'plan' => $planID
    234             )
    235         );
    236        
     219
     220        $customer = self::createTestCustomer();
     221
     222        $subscription = Subscription::create([
     223            'customer' => $customer->id,
     224            'plan' => $planID
     225        ]);
     226
    237227        $planID_2 = 'gold-2-' . self::randomString();
    238228        self::retrieveOrCreatePlan($planID_2);
    239229
    240         $subscription_2 = Subscription::create(
    241             array(
    242                 'customer' => $customer->id,
    243                 'plan' => $planID_2
    244             )
    245         );
    246        
     230        $subscription_2 = Subscription::create([
     231            'customer' => $customer->id,
     232            'plan' => $planID_2
     233        ]);
     234
    247235        $customerRetrive = Customer::retrieve($customer->id);
    248236        $subscriptions = $customerRetrive->subscriptions->all();
     
    250238        $this->assertSame($subscription_2->id, $subscriptions['data'][0]->id);
    251239        $this->assertSame($subscription->id, $subscriptions['data'][1]->id);
    252          
     240
    253241        $this->assertSame(2, count($subscriptions['data']));
    254242        $this->assertSame($customer->id, $subscriptions['data'][0]->customer);
    255243        $this->assertSame($planID_2, $subscriptions['data'][0]->plan->id);
    256        
     244
    257245        $subscriptionRetrieve = $customerRetrive->subscriptions->retrieve($subscription->id);
    258246        $this->assertSame($subscription->id, $subscriptionRetrieve->id);
    259247        $this->assertSame($planID, $subscriptionRetrieve->plan->id);
    260248    }
    261    
     249
    262250    public function testCustomerChargeAll()
    263251    {
    264252        $planID = 'gold-' . self::randomString();
    265253        self::retrieveOrCreatePlan($planID);
    266      
    267         $customer = self::createTestCustomer();
    268              
    269         $charge = Charge::create(
    270             array(
    271                 'amount' => 1000,
    272                 'currency' => self::CURRENCY,
    273                 'customer' => $customer->id
    274             )
    275         );
    276            
     254
     255        $customer = self::createTestCustomer();
     256
     257        $charge = Charge::create([
     258            'amount' => 1000,
     259            'currency' => self::CURRENCY,
     260            'customer' => $customer->id
     261        ]);
     262
    277263        $charges = $customer->charges();
    278            
     264
    279265        $this->assertSame(1, count($charges['data']));
    280266        $this->assertSame($charge->id, $charges['data'][0]->id);
    281267
    282         $charge_2 = Charge::create(
    283             array(
    284                 'amount' => 1500,
    285                 'currency' => self::CURRENCY,
    286                  'customer' => $customer->id
    287             )
    288         );
    289    
     268        $charge_2 = Charge::create([
     269            'amount' => 1500,
     270            'currency' => self::CURRENCY,
     271            'customer' => $customer->id
     272        ]);
     273
    290274        $charges_2 = $customer->charges();
    291                
     275
    292276        $this->assertSame(2, count($charges_2['data']));
    293277        $this->assertSame($charge_2->id, $charges_2['data'][0]->id);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/PayjpObjectTest.php

    r2149911 r3190331  
    4949        $converted = $s->__toArray();
    5050
    51         $this->assertInternalType('array', $converted);
     51        $this->assertSame('array', gettype($converted));
    5252        $this->assertArrayHasKey('foo', $converted);
    5353        $this->assertEquals('a', $converted['foo']);
     
    6464        $converted = $s->__toArray(true);
    6565
    66         $this->assertInternalType('array', $converted);
     66        $this->assertSame('array', gettype($converted));
    6767        $this->assertArrayHasKey('child', $converted);
    68         $this->assertInternalType('array', $converted['child']);
     68        $this->assertSame('array', gettype($converted['child']));
    6969        $this->assertArrayHasKey('foo', $converted['child']);
    7070        $this->assertEquals('a', $converted['child']['foo']);
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/PlanTest.php

    r2149911 r3190331  
    88    {
    99        self::authorizeFromEnv();
    10         $planID = 'gold-' . self::randomString();
    11         $p = Plan::create(array(
     10        $planId = 'gold-' . self::randomString();
     11        $p = Plan::create([
    1212            'amount'   => 2000,
    1313            'interval' => 'month',
    1414            'currency' => self::CURRENCY,
    1515            'name'     => 'Plan',
    16             'id'       => $planID
    17         ));
    18        
    19         $plan_retrieve = Plan::retrieve($planID);
    20         $this->assertSame($planID, $plan_retrieve->id);
    21                
    22         $planID_2 = 'foobar-2-' . self::randomString();
    23         $p_2 = Plan::create(
    24             array(
    25                 'amount'   => 3000,
    26                 'interval' => 'month',
    27                 'currency' => self::CURRENCY,
    28                 'name'     => 'Plan_2',
    29                 'id'       => $planID_2
    30             )
    31         );
     16            'id'       => $planId
     17        ]);
    3218
    33         $plans = Plan::all(
    34             array(
    35                 'limit' => 2,
    36                 'offset' => 0
    37             )
    38         );
     19        $plan_retrieve = Plan::retrieve($planId);
     20        $this->assertSame($planId, $plan_retrieve->id);
     21
     22        $planId_2 = 'foobar-2-' . self::randomString();
     23        $p_2 = Plan::create([
     24            'amount'   => 3000,
     25            'interval' => 'month',
     26            'currency' => self::CURRENCY,
     27            'name'     => 'Plan_2',
     28            'id'       => $planId_2
     29        ]);
     30
     31        $plans = Plan::all([
     32            'limit' => 2,
     33            'offset' => 0
     34        ]);
    3935        $this->assertSame(2, count($plans['data']));
    4036    }
     
    4339    {
    4440        self::authorizeFromEnv();
    45         $plan_ID = 'gold-' . self::randomString();
    46         $p = Plan::create(array(
     41        $planId = 'gold-' . self::randomString();
     42        $p = Plan::create([
    4743            'amount' => 2000,
    4844            'interval' => 'month',
    4945            'currency' => self::CURRENCY,
    5046            'name' => 'Plan',
    51             'id' => $plan_ID
    52         ));
     47            'id' => $planId
     48        ]);
    5349        $p->delete();
    5450        $this->assertTrue($p->deleted);
    55         $this->assertSame($plan_ID, $p->id);
     51        $this->assertSame($planId, $p->id);
    5652    }
    5753
     
    5955    {
    6056        try {
    61             $retrievedPlan = Plan::retrieve('0');
     57            Plan::retrieve('0');
    6258        } catch (Error\InvalidRequest $e) {
    63             // Can either succeed or 404, all other errors are bad
    64             if ($e->httpStatus !== 404) {
    65                 $this->fail();
    66             }
     59            $this->assertSame(404, $e->httpStatus);
    6760        }
    6861    }
     
    7164    {
    7265        self::authorizeFromEnv();
    73         $planID = 'gold-' . self::randomString();
    74         $p = Plan::create(array(
     66        $planId = 'gold-' . self::randomString();
     67        $p = Plan::create([
    7568            'amount'   => 2000,
    7669            'interval' => 'month',
    7770            'currency' => self::CURRENCY,
    7871            'name'     => 'Plan',
    79             'id'       => $planID
    80         ));
     72            'id'       => $planId
     73        ]);
    8174        $p->name = 'A new plan name';
    8275        $p->save();
    8376        $this->assertSame($p->name, 'A new plan name');
    8477
    85         $payjpPlan = Plan::retrieve($planID);
     78        $payjpPlan = Plan::retrieve($planId);
    8679        $this->assertSame($p->name, $payjpPlan->name);
    8780    }
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/RequestOptionsTest.php

    r2149911 r3190331  
    7171    }
    7272
    73     /**
    74      * @expectedException Payjp\Error\Api
    75      */
    7673    public function testWrongType()
    7774    {
     75        $this->expectException("\Payjp\Error\Api");
    7876        $opts = Util\RequestOptions::parse(5);
    7977    }
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/TestCase.php

    r2149911 r3190331  
    77 * objects.
    88 */
    9 class TestCase extends \PHPUnit_Framework_TestCase
     9class TestCase extends \PHPUnit\Framework\TestCase
    1010{
    1111    const API_KEY = 'sk_test_c62fade9d045b54cd76d7036';// public api key for test
     
    1313    const COUNTRY = 'JP';
    1414
    15     private $mock;
     15    protected $mock;
    1616
    1717    protected static function authorizeFromEnv()
     
    2525    }
    2626
    27     protected function setUp()
     27    protected static function setMaxRetryForCi()
    2828    {
     29        $maxRetry = getenv('MAX_RETRY');
     30        if ($maxRetry) {
     31            Payjp::setMaxRetry($maxRetry);
     32        }
     33    }
     34
     35    /**
     36     * @before
     37     */
     38    protected function setUpTestCase()
     39    {
     40        $this->setMaxRetryForCi();
    2941        ApiRequestor::setHttpClient(HttpClient\CurlClient::instance());
    3042        $this->mock = null;
    31         $this->call = 0;
    3243    }
    3344
     
    3546    {
    3647        $mock = $this->setUpMockRequest();
    37         $mock->expects($this->at($this->call++))
    38              ->method('request')
    39                  ->with(strtolower($method), 'https://api.pay.jp' . $path, $this->anything(), $params, false)
    40                  ->willReturn(array(json_encode($return), 200));
     48        $mock->expects($this->once())
     49            ->method('request')
     50            ->with(
     51                strtolower($method),
     52                'https://api.pay.jp' . $path,
     53                $this->anything(),
     54                $params,
     55                false
     56            )
     57            ->willReturn(array(json_encode($return), 200));
    4158    }
    4259
    43     private function setUpMockRequest()
    44     {
    45         if (!$this->mock) {
    46             self::authorizeFromEnv();
    47             $this->mock = $this->getMock('\Payjp\HttpClient\ClientInterface');
    48             ApiRequestor::setHttpClient($this->mock);
    49         }
    50         return $this->mock;
    51     }
    52 
    53     /**
    54      * Create a valid test charge.
    55      */
    56     protected static function createTestCharge(array $attributes = array())
     60    protected function setUpMockRequest()
    5761    {
    5862        self::authorizeFromEnv();
    59 
    60         $params =  [
    61             'card' => [
    62             "number" => "4242424242424242",
    63             "exp_month" => 6,
    64             "exp_year" => date('Y') + 3,
    65             "cvc" => "314"
    66             ]
    67         ];
    68 
    69         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    70 
    71         return Charge::create(
    72             $attributes + array(
    73                 'amount' => 2000,
    74                 'currency' => self::CURRENCY,
    75                 'description' => 'Charge for test@example.com',
    76                 'card' => $card
    77             )
    78         );
    79     }
    80 
    81     /**
    82      * Create a valid test charge.
    83      */
    84     protected static function createTestTransfer(array $attributes = array())
    85     {
    86         self::authorizeFromEnv();
    87 
    88         $recipient = self::createTestRecipient();
    89 
    90         return Transfer::create(
    91             $attributes + array(
    92                 'amount' => 2000,
    93                 'currency' => self::CURRENCY,
    94                 'description' => 'Transfer to test@example.com',
    95                 'recipient' => $recipient->id
    96             )
    97         );
     63        $this->mock = $this->createMock('\Payjp\HttpClient\ClientInterface');
     64        ApiRequestor::setHttpClient($this->mock);
     65        return $this->mock;
    9866    }
    9967
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/TokenTest.php

    r2149911 r3190331  
    1111        $this->assertSame($token->instanceUrl(), '/v1/tokens/abcd%2Fefgh');
    1212    }
    13    
     13
    1414    public function testCreate()
    1515    {
    1616        self::authorizeFromEnv();
    17    
     17
    1818        $params =  [
    1919            'card' => [
    20             "number" => "4242424242424242",
    21             "exp_month" => 6,
    22             "exp_year" => date('Y') + 3,
    23             "cvc" => "314"
     20                'number' => '4242424242424242',
     21                'exp_month' => 6,
     22                'exp_year' => date('Y') + 3,
     23                'cvc' => '314'
    2424            ]
    2525        ];
    26        
    27         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
     26
     27        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     28        $this->assertNotNull($token);
    2829    }
    29    
     30
    3031    public function testRetrieve()
    3132    {
     
    3435        $params =  [
    3536            'card' => [
    36             "number" => "4242424242424242",
    37             "exp_month" => 6,
    38             "exp_year" => date('Y') + 3,
    39             "cvc" => "314"
     37                'number' => '4242424242424242',
     38                'exp_month' => 6,
     39                'exp_year' => date('Y') + 3,
     40                'cvc' => '314'
    4041            ]
    4142        ];
    42        
    43         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    44          
     43
     44        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     45
    4546        $token_retrieve = Token::retrieve($token->id);
    46        
     47
    4748        $this->assertSame($token->id, $token_retrieve->id);
    4849    }
  • ht-pay-jp-for-kintone/tags/1.5.0/vendor/payjp/payjp-php/tests/TransferTest.php

    r2149911 r3190331  
    88    {
    99        self::authorizeFromEnv();
    10        
    11         $transfers = Transfer::all(
    12             array(
    13                 'limit' => 3,
    14                 'offset' => 0
    15             )
    16         );
     10
     11        $transfers = Transfer::all([
     12            'limit' => 3,
     13            'offset' => 0
     14        ]);
    1715
    1816        if (count($transfers['data'])) {
     
    2119        }
    2220    }
    23    
     21
    2422    public function testAllCharge()
    2523    {
    2624        self::authorizeFromEnv();
    27    
    28         $transfers = Transfer::all(
    29             array(
     25
     26        $transfers = Transfer::all([
     27            'limit' => 3,
     28            'offset' => 0
     29        ]);
     30
     31        if (count($transfers['data'])) {
     32            $transfer = Transfer::retrieve($transfers['data'][0]->id);
     33            $charges = $transfer->charges->all([
    3034                'limit' => 3,
    3135                'offset' => 0
    32             )
    33         );
    34    
    35         if (count($transfers['data'])) {
    36             $transfer = Transfer::retrieve($transfers['data'][0]->id);
    37             $charges = $transfer->charges->all(
    38                 array(
    39                     'limit' => 3,
    40                     'offset' => 0
    41                 )
    42             );
     36            ]);
     37            $this->markTestSkipped('Should be changed to mock.');
     38            // $this->assertTrue(count($charges['data']) > 0);
    4339        }
    4440    }
  • ht-pay-jp-for-kintone/trunk/composer.lock

    r2685245 r3190331  
    22    "_readme": [
    33        "This file locks the dependencies of your project to a known state",
    4         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
     4        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
    55        "This file is @generated automatically"
    66    ],
     
    99        {
    1010            "name": "payjp/payjp-php",
    11             "version": "1.0.5",
     11            "version": "1.7.0",
    1212            "source": {
    1313                "type": "git",
    1414                "url": "https://github.com/payjp/payjp-php.git",
    15                 "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd"
     15                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175"
    1616            },
    1717            "dist": {
    1818                "type": "zip",
    19                 "url": "https://api.github.com/repos/payjp/payjp-php/zipball/57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    20                 "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
     19                "url": "https://api.github.com/repos/payjp/payjp-php/zipball/f8fe3185fc0a481214c35421f051d8cc50f3f175",
     20                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175",
    2121                "shasum": ""
    2222            },
     
    2828            },
    2929            "require-dev": {
    30                 "phpunit/phpunit": "~4.0",
    31                 "satooshi/php-coveralls": "~0.6.1",
    32                 "squizlabs/php_codesniffer": "~2.0"
     30                "phpunit/phpunit": "~5.7 || ~9.5",
     31                "squizlabs/php_codesniffer": "~3.6"
    3332            },
    3433            "type": "library",
     
    6059                "payment processing"
    6160            ],
    62             "time": "2019-08-09T13:10:15+00:00"
     61            "support": {
     62                "issues": "https://github.com/payjp/payjp-php/issues",
     63                "source": "https://github.com/payjp/payjp-php/tree/1.7.0"
     64            },
     65            "time": "2024-11-13T05:21:09+00:00"
    6366        }
    6467    ],
     
    7073    "prefer-lowest": false,
    7174    "platform": [],
    72     "platform-dev": []
     75    "platform-dev": [],
     76    "plugin-api-version": "2.6.0"
    7377}
  • ht-pay-jp-for-kintone/trunk/ht-payjp-for-kintone.php

    r2989122 r3190331  
    88 * Text Domain:     ht-pay-jp-for-kintone
    99 * Domain Path:     /languages
    10  * Version:         1.4.1
     10 * Version:         1.5.0
    1111 *
    1212 * @package         HT_Payjp_For_Kintone
  • ht-pay-jp-for-kintone/trunk/includes/class-ht-payjp-for-kintone-Payment.php

    r2989122 r3190331  
    170170                );
    171171
     172            } catch ( \Payjp\Error\Card $e ) {
     173                // カード決済エラーの場合
     174                $abort = true;
     175                $submission->set_response( $contact_form->filter_message( __( 'Card payment failed. Please check your card information.', 'payjp-for-kintone' ) ) );
     176                ht_payjp_for_kintone_send_error_mail( $contact_form, $e->getMessage() );
     177
    172178            } catch ( \Payjp\Error\InvalidRequest $e ) {
    173 
     179                // その他のPAY.JPエラーの場合
    174180                $abort = true;
    175181                $submission->set_response( $contact_form->filter_message( $e->getMessage() ) );
  • ht-pay-jp-for-kintone/trunk/readme.txt

    r2989122 r3190331  
    33Donate link:
    44Tags: Contact Form 7, kintone, PAY.JP, form data to kintone
    5 Requires at least: 4.5
    6 Tested up to: 6.3.2
    7 Stable tag: 1.4.1
     5Requires at least: 6.6
     6Tested up to: 6.7
     7Requires PHP: 7.4
     8Stable tag: 1.5.0
    89License: GPLv2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5354
    5455== Changelog ==
     56
     57= 1.5.0( 2024-11-17 ) =
     58
     59* Updated payjp/payjp-php version from 1.0.5 to 1.7.0
     60* Added error handling for \Payjp\Error\Card
    5561
    5662= 1.4.1( 2023-11-05 ) =
  • ht-pay-jp-for-kintone/trunk/vendor/autoload.php

    r2149911 r3190331  
    33// autoload.php @generated by Composer
    44
     5if (PHP_VERSION_ID < 50600) {
     6    if (!headers_sent()) {
     7        header('HTTP/1.1 500 Internal Server Error');
     8    }
     9    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
     10    if (!ini_get('display_errors')) {
     11        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
     12            fwrite(STDERR, $err);
     13        } elseif (!headers_sent()) {
     14            echo $err;
     15        }
     16    }
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
     21}
     22
    523require_once __DIR__ . '/composer/autoload_real.php';
    624
  • ht-pay-jp-for-kintone/trunk/vendor/composer/ClassLoader.php

    r2149911 r3190331  
    3838 * @author Fabien Potencier <fabien@symfony.com>
    3939 * @author Jordi Boggiano <j.boggiano@seld.be>
    40  * @see    http://www.php-fig.org/psr/psr-0/
    41  * @see    http://www.php-fig.org/psr/psr-4/
     40 * @see    https://www.php-fig.org/psr/psr-0/
     41 * @see    https://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
    4444{
     45    /** @var \Closure(string):void */
     46    private static $includeFile;
     47
     48    /** @var string|null */
     49    private $vendorDir;
     50
    4551    // PSR-4
     52    /**
     53     * @var array<string, array<string, int>>
     54     */
    4655    private $prefixLengthsPsr4 = array();
     56    /**
     57     * @var array<string, list<string>>
     58     */
    4759    private $prefixDirsPsr4 = array();
     60    /**
     61     * @var list<string>
     62     */
    4863    private $fallbackDirsPsr4 = array();
    4964
    5065    // PSR-0
     66    /**
     67     * List of PSR-0 prefixes
     68     *
     69     * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
     70     *
     71     * @var array<string, array<string, list<string>>>
     72     */
    5173    private $prefixesPsr0 = array();
     74    /**
     75     * @var list<string>
     76     */
    5277    private $fallbackDirsPsr0 = array();
    5378
     79    /** @var bool */
    5480    private $useIncludePath = false;
     81
     82    /**
     83     * @var array<string, string>
     84     */
    5585    private $classMap = array();
     86
     87    /** @var bool */
    5688    private $classMapAuthoritative = false;
     89
     90    /**
     91     * @var array<string, bool>
     92     */
    5793    private $missingClasses = array();
     94
     95    /** @var string|null */
    5896    private $apcuPrefix;
    5997
     98    /**
     99     * @var array<string, self>
     100     */
     101    private static $registeredLoaders = array();
     102
     103    /**
     104     * @param string|null $vendorDir
     105     */
     106    public function __construct($vendorDir = null)
     107    {
     108        $this->vendorDir = $vendorDir;
     109        self::initializeIncludeClosure();
     110    }
     111
     112    /**
     113     * @return array<string, list<string>>
     114     */
    60115    public function getPrefixes()
    61116    {
    62117        if (!empty($this->prefixesPsr0)) {
    63             return call_user_func_array('array_merge', $this->prefixesPsr0);
     118            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
    64119        }
    65120
     
    67122    }
    68123
     124    /**
     125     * @return array<string, list<string>>
     126     */
    69127    public function getPrefixesPsr4()
    70128    {
     
    72130    }
    73131
     132    /**
     133     * @return list<string>
     134     */
    74135    public function getFallbackDirs()
    75136    {
     
    77138    }
    78139
     140    /**
     141     * @return list<string>
     142     */
    79143    public function getFallbackDirsPsr4()
    80144    {
     
    82146    }
    83147
     148    /**
     149     * @return array<string, string> Array of classname => path
     150     */
    84151    public function getClassMap()
    85152    {
     
    88155
    89156    /**
    90      * @param array $classMap Class to filename map
     157     * @param array<string, string> $classMap Class to filename map
     158     *
     159     * @return void
    91160     */
    92161    public function addClassMap(array $classMap)
     
    103172     * appending or prepending to the ones previously set for this prefix.
    104173     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     174     * @param string              $prefix  The prefix
     175     * @param list<string>|string $paths   The PSR-0 root directories
     176     * @param bool                $prepend Whether to prepend the directories
     177     *
     178     * @return void
    108179     */
    109180    public function add($prefix, $paths, $prepend = false)
    110181    {
     182        $paths = (array) $paths;
    111183        if (!$prefix) {
    112184            if ($prepend) {
    113185                $this->fallbackDirsPsr0 = array_merge(
    114                     (array) $paths,
     186                    $paths,
    115187                    $this->fallbackDirsPsr0
    116188                );
     
    118190                $this->fallbackDirsPsr0 = array_merge(
    119191                    $this->fallbackDirsPsr0,
    120                     (array) $paths
     192                    $paths
    121193                );
    122194            }
     
    127199        $first = $prefix[0];
    128200        if (!isset($this->prefixesPsr0[$first][$prefix])) {
    129             $this->prefixesPsr0[$first][$prefix] = (array) $paths;
     201            $this->prefixesPsr0[$first][$prefix] = $paths;
    130202
    131203            return;
     
    133205        if ($prepend) {
    134206            $this->prefixesPsr0[$first][$prefix] = array_merge(
    135                 (array) $paths,
     207                $paths,
    136208                $this->prefixesPsr0[$first][$prefix]
    137209            );
     
    139211            $this->prefixesPsr0[$first][$prefix] = array_merge(
    140212                $this->prefixesPsr0[$first][$prefix],
    141                 (array) $paths
     213                $paths
    142214            );
    143215        }
     
    148220     * appending or prepending to the ones previously set for this namespace.
    149221     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     222     * @param string              $prefix  The prefix/namespace, with trailing '\\'
     223     * @param list<string>|string $paths   The PSR-4 base directories
     224     * @param bool                $prepend Whether to prepend the directories
    153225     *
    154226     * @throws \InvalidArgumentException
     227     *
     228     * @return void
    155229     */
    156230    public function addPsr4($prefix, $paths, $prepend = false)
    157231    {
     232        $paths = (array) $paths;
    158233        if (!$prefix) {
    159234            // Register directories for the root namespace.
    160235            if ($prepend) {
    161236                $this->fallbackDirsPsr4 = array_merge(
    162                     (array) $paths,
     237                    $paths,
    163238                    $this->fallbackDirsPsr4
    164239                );
     
    166241                $this->fallbackDirsPsr4 = array_merge(
    167242                    $this->fallbackDirsPsr4,
    168                     (array) $paths
     243                    $paths
    169244                );
    170245            }
     
    176251            }
    177252            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    178             $this->prefixDirsPsr4[$prefix] = (array) $paths;
     253            $this->prefixDirsPsr4[$prefix] = $paths;
    179254        } elseif ($prepend) {
    180255            // Prepend directories for an already registered namespace.
    181256            $this->prefixDirsPsr4[$prefix] = array_merge(
    182                 (array) $paths,
     257                $paths,
    183258                $this->prefixDirsPsr4[$prefix]
    184259            );
     
    187262            $this->prefixDirsPsr4[$prefix] = array_merge(
    188263                $this->prefixDirsPsr4[$prefix],
    189                 (array) $paths
     264                $paths
    190265            );
    191266        }
     
    196271     * replacing any others previously set for this prefix.
    197272     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     273     * @param string              $prefix The prefix
     274     * @param list<string>|string $paths  The PSR-0 base directories
     275     *
     276     * @return void
    200277     */
    201278    public function set($prefix, $paths)
     
    212289     * replacing any others previously set for this namespace.
    213290     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     291     * @param string              $prefix The prefix/namespace, with trailing '\\'
     292     * @param list<string>|string $paths  The PSR-4 base directories
    216293     *
    217294     * @throws \InvalidArgumentException
     295     *
     296     * @return void
    218297     */
    219298    public function setPsr4($prefix, $paths)
     
    235314     *
    236315     * @param bool $useIncludePath
     316     *
     317     * @return void
    237318     */
    238319    public function setUseIncludePath($useIncludePath)
     
    257338     *
    258339     * @param bool $classMapAuthoritative
     340     *
     341     * @return void
    259342     */
    260343    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277360     *
    278361     * @param string|null $apcuPrefix
     362     *
     363     * @return void
    279364     */
    280365    public function setApcuPrefix($apcuPrefix)
     
    297382     *
    298383     * @param bool $prepend Whether to prepend the autoloader or not
     384     *
     385     * @return void
    299386     */
    300387    public function register($prepend = false)
    301388    {
    302389        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     390
     391        if (null === $this->vendorDir) {
     392            return;
     393        }
     394
     395        if ($prepend) {
     396            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     397        } else {
     398            unset(self::$registeredLoaders[$this->vendorDir]);
     399            self::$registeredLoaders[$this->vendorDir] = $this;
     400        }
    303401    }
    304402
    305403    /**
    306404     * Unregisters this instance as an autoloader.
     405     *
     406     * @return void
    307407     */
    308408    public function unregister()
    309409    {
    310410        spl_autoload_unregister(array($this, 'loadClass'));
     411
     412        if (null !== $this->vendorDir) {
     413            unset(self::$registeredLoaders[$this->vendorDir]);
     414        }
    311415    }
    312416
     
    315419     *
    316420     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     421     * @return true|null True if loaded, null otherwise
    318422     */
    319423    public function loadClass($class)
    320424    {
    321425        if ($file = $this->findFile($class)) {
    322             includeFile($file);
     426            $includeFile = self::$includeFile;
     427            $includeFile($file);
    323428
    324429            return true;
    325430        }
     431
     432        return null;
    326433    }
    327434
     
    368475    }
    369476
     477    /**
     478     * Returns the currently registered loaders keyed by their corresponding vendor directories.
     479     *
     480     * @return array<string, self>
     481     */
     482    public static function getRegisteredLoaders()
     483    {
     484        return self::$registeredLoaders;
     485    }
     486
     487    /**
     488     * @param  string       $class
     489     * @param  string       $ext
     490     * @return string|false
     491     */
    370492    private function findFileWithExtension($class, $ext)
    371493    {
     
    433555        return false;
    434556    }
     557
     558    /**
     559     * @return void
     560     */
     561    private static function initializeIncludeClosure()
     562    {
     563        if (self::$includeFile !== null) {
     564            return;
     565        }
     566
     567        /**
     568         * Scope isolated include.
     569         *
     570         * Prevents access to $this/self from included files.
     571         *
     572         * @param  string $file
     573         * @return void
     574         */
     575        self::$includeFile = \Closure::bind(static function($file) {
     576            include $file;
     577        }, null, null);
     578    }
    435579}
    436 
    437 /**
    438  * Scope isolated include.
    439  *
    440  * Prevents access to $this/self from included files.
    441  */
    442 function includeFile($file)
    443 {
    444     include $file;
    445 }
  • ht-pay-jp-for-kintone/trunk/vendor/composer/autoload_classmap.php

    r2149911 r3190331  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
    88return array(
     9    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    910);
  • ht-pay-jp-for-kintone/trunk/vendor/composer/autoload_namespaces.php

    r2149911 r3190331  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ht-pay-jp-for-kintone/trunk/vendor/composer/autoload_psr4.php

    r2149911 r3190331  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • ht-pay-jp-for-kintone/trunk/vendor/composer/autoload_real.php

    r2149911 r3190331  
    1414    }
    1515
     16    /**
     17     * @return \Composer\Autoload\ClassLoader
     18     */
    1619    public static function getLoader()
    1720    {
     
    2023        }
    2124
     25        require __DIR__ . '/platform_check.php';
     26
    2227        spl_autoload_register(array('ComposerAutoloaderInit9a018c6d859c504697980df115517622', 'loadClassLoader'), true, true);
    23         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    2429        spl_autoload_unregister(array('ComposerAutoloaderInit9a018c6d859c504697980df115517622', 'loadClassLoader'));
    2530
    26         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    27         if ($useStaticLoader) {
    28             require_once __DIR__ . '/autoload_static.php';
    29 
    30             call_user_func(\Composer\Autoload\ComposerStaticInit9a018c6d859c504697980df115517622::getInitializer($loader));
    31         } else {
    32             $map = require __DIR__ . '/autoload_namespaces.php';
    33             foreach ($map as $namespace => $path) {
    34                 $loader->set($namespace, $path);
    35             }
    36 
    37             $map = require __DIR__ . '/autoload_psr4.php';
    38             foreach ($map as $namespace => $path) {
    39                 $loader->setPsr4($namespace, $path);
    40             }
    41 
    42             $classMap = require __DIR__ . '/autoload_classmap.php';
    43             if ($classMap) {
    44                 $loader->addClassMap($classMap);
    45             }
    46         }
     31        require __DIR__ . '/autoload_static.php';
     32        call_user_func(\Composer\Autoload\ComposerStaticInit9a018c6d859c504697980df115517622::getInitializer($loader));
    4733
    4834        $loader->register(true);
  • ht-pay-jp-for-kintone/trunk/vendor/composer/autoload_static.php

    r2149911 r3190331  
    2121    );
    2222
     23    public static $classMap = array (
     24        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
     25    );
     26
    2327    public static function getInitializer(ClassLoader $loader)
    2428    {
     
    2630            $loader->prefixLengthsPsr4 = ComposerStaticInit9a018c6d859c504697980df115517622::$prefixLengthsPsr4;
    2731            $loader->prefixDirsPsr4 = ComposerStaticInit9a018c6d859c504697980df115517622::$prefixDirsPsr4;
     32            $loader->classMap = ComposerStaticInit9a018c6d859c504697980df115517622::$classMap;
    2833
    2934        }, null, ClassLoader::class);
  • ht-pay-jp-for-kintone/trunk/vendor/composer/installed.json

    r2149911 r3190331  
    1 [
    2     {
    3         "name": "payjp/payjp-php",
    4         "version": "1.0.5",
    5         "version_normalized": "1.0.5.0",
    6         "source": {
    7             "type": "git",
    8             "url": "https://github.com/payjp/payjp-php.git",
    9             "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd"
    10         },
    11         "dist": {
    12             "type": "zip",
    13             "url": "https://api.github.com/repos/payjp/payjp-php/zipball/57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    14             "reference": "57151949f8e1cd9de60f2566b0e2bf7b91a3f3bd",
    15             "shasum": ""
    16         },
    17         "require": {
    18             "ext-curl": "*",
    19             "ext-json": "*",
    20             "ext-mbstring": "*",
    21             "php": ">=5.6"
    22         },
    23         "require-dev": {
    24             "phpunit/phpunit": "~4.0",
    25             "satooshi/php-coveralls": "~0.6.1",
    26             "squizlabs/php_codesniffer": "~2.0"
    27         },
    28         "time": "2019-08-09T13:10:15+00:00",
    29         "type": "library",
    30         "extra": {
    31             "branch-alias": {
    32                 "dev-master": "0.1.*-dev"
    33             }
    34         },
    35         "installation-source": "dist",
    36         "autoload": {
    37             "psr-4": {
    38                 "Payjp\\": "lib/"
    39             }
    40         },
    41         "notification-url": "https://packagist.org/downloads/",
    42         "license": [
    43             "MIT"
     1{
     2        "packages": [
     3                {
     4                        "name": "payjp/payjp-php",
     5                        "version": "1.7.0",
     6                        "version_normalized": "1.7.0.0",
     7                        "source": {
     8                                "type": "git",
     9                                "url": "https://github.com/payjp/payjp-php.git",
     10                                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175"
     11                        },
     12                        "dist": {
     13                                "type": "zip",
     14                                "url": "https://api.github.com/repos/payjp/payjp-php/zipball/f8fe3185fc0a481214c35421f051d8cc50f3f175",
     15                                "reference": "f8fe3185fc0a481214c35421f051d8cc50f3f175",
     16                                "shasum": ""
     17                        },
     18                        "require": {
     19                                "ext-curl": "*",
     20                                "ext-json": "*",
     21                                "ext-mbstring": "*",
     22                                "php": ">=5.6"
     23                        },
     24                        "require-dev": {
     25                                "phpunit/phpunit": "~5.7 || ~9.5",
     26                                "squizlabs/php_codesniffer": "~3.6"
     27                        },
     28                        "time": "2024-11-13T05:21:09+00:00",
     29                        "type": "library",
     30                        "extra": {
     31                                "branch-alias": {
     32                                        "dev-master": "0.1.*-dev"
     33                                }
     34                        },
     35                        "installation-source": "dist",
     36                        "autoload": {
     37                                "psr-4": {
     38                                        "Payjp\\": "lib/"
     39                                }
     40                        },
     41                        "notification-url": "https://packagist.org/downloads/",
     42                        "license": [
     43                                "MIT"
     44                        ],
     45                        "authors": [
     46                                {
     47                                        "name": "Payjp and contributors",
     48                                        "homepage": "https://github.com/payjp/payjp-php/graphs/contributors"
     49                                }
     50                        ],
     51                        "description": "Payjp PHP Library",
     52                        "homepage": "https://pay.jp/",
     53                        "keywords": [
     54                                "api",
     55                                "payjp",
     56                                "payment processing"
     57                        ],
     58                        "support": {
     59                                "issues": "https://github.com/payjp/payjp-php/issues",
     60                                "source": "https://github.com/payjp/payjp-php/tree/1.7.0"
     61                        },
     62                        "install-path": "../payjp/payjp-php"
     63                }
    4464        ],
    45         "authors": [
    46             {
    47                 "name": "Payjp and contributors",
    48                 "homepage": "https://github.com/payjp/payjp-php/graphs/contributors"
    49             }
    50         ],
    51         "description": "Payjp PHP Library",
    52         "homepage": "https://pay.jp/",
    53         "keywords": [
    54             "api",
    55             "payjp",
    56             "payment processing"
    57         ]
    58     }
    59 ]
     65        "dev": true,
     66        "dev-package-names": []
     67}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/.gitignore

    r2685245 r3190331  
    2121# Ignore PHPUnit coverage file
    2222clover.xml
     23
     24# Ignore PHPUnit cache file
     25.phpunit.result.cache
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/README.md

    r2149911 r3190331  
    11# PAY.JP for PHP
    22
    3 [![Build Status](https://travis-ci.org/payjp/payjp-php.svg?branch=master)](https://travis-ci.org/payjp/payjp-php)
     3[![Build Status](https://github.com/payjp/payjp-php/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/payjp/payjp-php/actions)
    44
    55## Requirements
     
    5353- Please see our official [documentation](https://pay.jp/docs/started).
    5454
     55## Retry on HTTP Status Code 429
     56
     57- See [Rate Limit Guideline](https://pay.jp/docs/guideline-rate-limit#2-%E3%83%AA%E3%83%88%E3%83%A9%E3%82%A4)
     58- When you exceeded rate-limit, you can retry request by setting `$maxRetry` 
     59  like `\Payjp\Payjp::setMaxRetry(3);` .
     60- The retry interval base value is `$retryInitialDelay` 
     61  Adjust the value like `\Payjp\Payjp::setRetryInitialDelay(4);` 
     62  The smaller is shorter.
     63- The retry interval calcurating is based on "Exponential backoff with equal jitter" algorithm. 
     64  See https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     65
     66## Logging
     67
     68- This library provides simple log output using `error_log` . You can set any logger that is compatible [PSR-3](https://www.php-fig.org/psr/psr-3/) logger interface. Like below
     69- `\Payjp\Payjp::setLogger($logger);`
     70- As the default behavior, this library output only error level information to stderr.
     71
     72### Logging Case
     73#### info
     74
     75- Every retry on HTTP Status Code 429
     76
     77#### error
     78
     79- When you access inaccessible or non-existing property
     80
    5581## Tests
    5682
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/VERSION

    r2149911 r3190331  
    1 1.0.5
     11.7.0
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/build.php

    r2149911 r3190331  
    3131
    3232$config = $autoload ? 'phpunit.xml' : 'phpunit.no_autoload.xml';
    33 passthru("./vendor/bin/phpunit -c $config", $returnStatus);
     33passthru("./vendor/bin/phpunit -c $config -d error_reporting=-1", $returnStatus);
    3434if ($returnStatus !== 0) {
    3535    exit(1);
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/composer.json

    r2149911 r3190331  
    2222  },
    2323  "require-dev": {
    24     "phpunit/phpunit": "~4.0",
    25     "satooshi/php-coveralls": "~0.6.1",
    26     "squizlabs/php_codesniffer": "~2.0"
     24    "phpunit/phpunit": "~5.7 || ~9.5",
     25    "squizlabs/php_codesniffer": "~3.6"
    2726  },
    2827  "autoload": {
     
    3332      "dev-master": "0.1.*-dev"
    3433    }
     34  },
     35  "scripts": {
     36     "test": [
     37       "phpcs --standard=PSR2 -n lib tests *.php",
     38       "phpunit"
     39     ]
    3540  }
    3641}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/init.php

    r2149911 r3190331  
    44require(dirname(__FILE__) . '/lib/Payjp.php');
    55
    6 // Utilities
     6// Logger
     7require(dirname(__FILE__) . '/lib/Logger/LoggerInterface.php');
     8require(dirname(__FILE__) . '/lib/Logger/DefaultLogger.php');
     9
     10// UtilitiesL
    711require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
    812require(dirname(__FILE__) . '/lib/Util/Set.php');
     
    3135// Payjp API Resources
    3236require(dirname(__FILE__) . '/lib/Account.php');
     37require(dirname(__FILE__) . '/lib/ApplicationUrl.php');
     38require(dirname(__FILE__) . '/lib/Balance.php');
    3339require(dirname(__FILE__) . '/lib/Card.php');
    3440require(dirname(__FILE__) . '/lib/Charge.php');
     
    3743require(dirname(__FILE__) . '/lib/Event.php');
    3844require(dirname(__FILE__) . '/lib/Plan.php');
     45require(dirname(__FILE__) . '/lib/Statement.php');
     46require(dirname(__FILE__) . '/lib/StatementUrl.php');
    3947require(dirname(__FILE__) . '/lib/Subscription.php');
     48require(dirname(__FILE__) . '/lib/Tenant.php');
     49require(dirname(__FILE__) . '/lib/TenantTransfer.php');
     50require(dirname(__FILE__) . '/lib/Term.php');
     51require(dirname(__FILE__) . '/lib/ThreeDSecureRequest.php');
    4052require(dirname(__FILE__) . '/lib/Token.php');
    4153require(dirname(__FILE__) . '/lib/Transfer.php');
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/ApiRequestor.php

    r2149911 r3190331  
    3939    }
    4040
     41    // @var int Number of digit for randomized sleep time seconds
     42    private $digit_num_for_rand = 2;
     43
     44    /**
     45     * Based on "Exponential backoff with equal jitter" algorithm.
     46     * https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     47     *
     48     * @param int $retryCount
     49     *
     50     * @return int retry delay seconds.
     51     */
     52    private function getRetryDelay($retryCount)
     53    {
     54        $wait_half = min(Payjp::getRetryMaxDelay(), Payjp::getRetryInitialDelay() * pow(2, $retryCount)) / 2;
     55        $scale = pow(10, $this->digit_num_for_rand);
     56        return $wait_half + mt_rand(0, $wait_half * $scale) / $scale;
     57    }
     58
    4159    /**
    4260     * @param string $method
     
    5674            $headers = array();
    5775        }
    58         list($rbody, $rcode, $myApiKey) =
    59         $this->_requestRaw($method, $url, $params, $headers);
     76
     77        for ($i = 0; $i <= Payjp::getMaxRetry(); $i++) {
     78            list($rbody, $rcode, $myApiKey) = $this->_requestRaw($method, $url, $params, $headers);
     79            if ($rcode == 429 && $i != Payjp::getMaxRetry()) {
     80                $wait = $this->getRetryDelay($i);
     81                Payjp::getLogger()->info("Retry after {$wait} seconds.");
     82                usleep((int) $wait * 1000000);
     83            } else {
     84                break;
     85            }
     86        }
    6087        $resp = $this->_interpretResponse($rbody, $rcode);
    6188        return array($resp, $myApiKey);
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/ApiResource.php

    r2149911 r3190331  
    77    private static $HEADERS_TO_PERSIST = array('Payjp-Account' => true, 'Payjp-Version' => true);
    88
    9     public static function baseUrl()
    10     {
    11         return Payjp::$apiBase;
    12     }
    13 
    149    /**
    1510     * @return ApiResource The refreshed resource.
     
    1712    public function refresh()
    1813    {
    19         $requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl());
     14        $requestor = new ApiRequestor($this->_opts->apiKey);
    2015        $url = $this->instanceUrl();
    2116
     
    6055    {
    6156        $base = static::className();
    62         return "/v1/${base}s";
     57        return "/v1/{$base}s";
    6358    }
    6459
     
    9388    }
    9489
     90    /**
     91     * @param string $method
     92     * @param string $url
     93     * @param array|null $params
     94     * @param RequestOptions|array|string|null $options
     95     *
     96     * @return list(array, RequestOptions)
     97     */
    9598    protected function _request($method, $url, $params = array(), $options = null)
    9699    {
     
    102105    {
    103106        $opts = Util\RequestOptions::parse($options);
    104         $requestor = new ApiRequestor($opts->apiKey, static::baseUrl());
     107        $requestor = new ApiRequestor($opts->apiKey);
    105108        list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
    106109        foreach ($opts->headers as $k => $v) {
     
    132135    {
    133136        self::_validateParams($params);
    134         $base = static::baseUrl();
    135137        $url = static::classUrl();
    136138
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Charge.php

    r2149911 r3190331  
    7575        return $this;
    7676    }
     77
     78    /**
     79     * @param array|null $params
     80     * @param array|string|null $options
     81     *
     82     * @return Charge The paid charge.
     83     */
     84    public function tdsFinish($params = null, $options = null)
     85    {
     86        $url = $this->instanceUrl() . '/tds_finish';
     87        list($response, $opts) = $this->_request('post', $url, $params, $options);
     88        $this->refreshFrom($response, $opts);
     89        return $this;
     90    }
    7791}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Customer.php

    r2149911 r3190331  
    1212                . "would be: \"Payjp\\Charge::create(array('amount' => 100, "
    1313                . "'currency' => 'usd', 'card' => array('number' => "
    14                                                                                         . "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
     14                . "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
    1515                    throw new Error\Api($message);
    1616        }
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Error/Base.php

    r2149911 r3190331  
    77abstract class Base extends Exception
    88{
     9    public $httpStatus;
     10    public $httpBody;
     11    public $jsonBody;
     12
    913    public function __construct(
    1014        $message,
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Error/Card.php

    r2149911 r3190331  
    55class Card extends Base
    66{
     7    public $param;
     8
    79    public function __construct(
    810        $message,
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Error/InvalidRequest.php

    r2149911 r3190331  
    55class InvalidRequest extends Base
    66{
     7    public $param;
     8
    79    public function __construct(
    810        $message,
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Payjp.php

    r2149911 r3190331  
    1616    // @var boolean Defaults to true.
    1717    public static $verifySslCerts = true;
     18
     19    // @var \Payjp\Logger\LoggerInterface Default logger will output to error_log().
     20    public static $logger = null;
     21
     22    // @var int Max retry count for over_capacity 429 response.
     23    public static $maxRetry = 0;
     24
     25    /**
     26     * The retry interval base value for over_capacity 429 response.
     27     * Based on "Exponential backoff with equal jitter" algorithm.
     28     * See https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
     29     *
     30     * @var int
     31     */
     32    public static $retryInitialDelay = 2;
     33
     34    // @var int Max retry delay seconds for over_capacity 429 response.
     35    public static $retryMaxDelay = 32;
    1836
    1937    const VERSION = '1.0.0';
     
    6987        self::$verifySslCerts = $verify;
    7088    }
     89
     90    /**
     91     * @return \Payjp\Logger\LoggerInterface
     92     */
     93    public static function getLogger()
     94    {
     95        if (self::$logger == null) {
     96            return new \Payjp\Logger\DefaultLogger();
     97        }
     98        return self::$logger;
     99    }
     100
     101    /**
     102     * @param \Payjp\Logger\LoggerInterface $logger
     103     */
     104    public static function setLogger($logger)
     105    {
     106        self::$logger = $logger;
     107    }
     108    /**
     109     * @return int
     110     */
     111    public static function getMaxRetry()
     112    {
     113        return self::$maxRetry;
     114    }
     115
     116    /**
     117     * @param int $value
     118     */
     119    public static function setMaxRetry($value)
     120    {
     121        self::$maxRetry = $value;
     122    }
     123
     124    /**
     125     * @return int
     126     */
     127    public static function getRetryInitialDelay()
     128    {
     129        return self::$retryInitialDelay;
     130    }
     131
     132    /**
     133     * @param int $value
     134     */
     135    public static function setRetryInitialDelay($value)
     136    {
     137        self::$retryInitialDelay = $value;
     138    }
     139
     140    /**
     141     * @return int
     142     */
     143    public static function getRetryMaxDelay()
     144    {
     145        return self::$retryMaxDelay;
     146    }
     147
     148    /**
     149     * @param int $value
     150     */
     151    public static function setRetryMaxDelay($value)
     152    {
     153        self::$retryMaxDelay = $value;
     154    }
    71155}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/PayjpObject.php

    r2149911 r3190331  
    102102                    . "probably as a result of a save(). The attributes currently "
    103103                    . "available on this object are: $attrs";
    104             error_log($message);
     104            Payjp::getLogger()->error($message);
    105105            return null;
    106106        } else {
    107107            $class = get_class($this);
    108             error_log("Payjp Notice: Undefined property of $class instance: $k");
     108            Payjp::getLogger()->error("Payjp Notice: Undefined property of $class instance: $k");
    109109            return null;
    110110        }
     
    112112
    113113    // ArrayAccess methods
     114    #[\ReturnTypeWillChange]
    114115    public function offsetSet($k, $v)
    115116    {
     
    117118    }
    118119
     120    #[\ReturnTypeWillChange]
    119121    public function offsetExists($k)
    120122    {
     
    122124    }
    123125
     126    #[\ReturnTypeWillChange]
    124127    public function offsetUnset($k)
    125128    {
    126129        unset($this->$k);
    127130    }
     131
     132    #[\ReturnTypeWillChange]
    128133    public function offsetGet($k)
    129134    {
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Token.php

    r2149911 r3190331  
    2626        return self::_create($params, $opts);
    2727    }
     28
     29    /**
     30     * @param array|null $params
     31     * @param array|string|null $options
     32     *
     33     * @return Token The paid token.
     34     */
     35    public function tdsFinish($params = null, $options = null)
     36    {
     37        $url = $this->instanceUrl() . '/tds_finish';
     38        list($response, $opts) = $this->_request('post', $url, $params, $options);
     39        $this->refreshFrom($response, $opts);
     40        return $this;
     41    }
    2842}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Transfer.php

    r2149911 r3190331  
    77    /**
    88     * @param string $id The ID of the transfer to retrieve.
    9      * @param array|string|null $opts
     9     * @param RequestOptions|array|string|null $opts
    1010     *
    1111     * @return Transfer
     
    1818    /**
    1919     * @param array|null $params
    20      * @param array|string|null $opts
     20     * @param RequestOptions|array|string|null $opts
    2121     *
    2222     * @return Transfer[]
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Util/Set.php

    r2149911 r3190331  
    3838    }
    3939
     40    #[\ReturnTypeWillChange]
    4041    public function getIterator()
    4142    {
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/lib/Util/Util.php

    r2149911 r3190331  
    77abstract class Util
    88{
     9    // todo wanna use 'private const' (only PHP >= v7.1.0)
     10    private static $types = array(
     11        'application_url' => \Payjp\ApplicationUrl::class,
     12        'balance' => \Payjp\Balance::class,
     13        'card' => \Payjp\Card::class,
     14        'charge' => \Payjp\Charge::class,
     15        'customer' => \Payjp\Customer::class,
     16        'event' => \Payjp\Event::class,
     17        'list' => \Payjp\Collection::class,
     18        'plan' => \Payjp\Plan::class,
     19        'statement' => \Payjp\Statement::class,
     20        'statement_url' => \Payjp\StatementUrl::class,
     21        'subscription' => \Payjp\Subscription::class,
     22        'tenant' => \Payjp\Tenant::class,
     23        'token' => \Payjp\Token::class,
     24        'tenant_transfer' => \Payjp\TenantTransfer::class,
     25        'term' => \Payjp\Term::class,
     26        'transfer' => \Payjp\Transfer::class,
     27        'three_d_secure_request' => \Payjp\ThreeDSecureRequest::class,
     28    );
     29
    930    /**
    1031     * Whether the provided array (or other) is a list rather than a dictionary.
     
    3960        foreach ($values as $k => $v) {
    4061            // FIXME: this is an encapsulation violation
    41             if ($k[0] == '_') {
     62            if (is_string($k) && $k[0] == '_') {
    4263                continue;
    4364            }
     
    6283    public static function convertToPayjpObject($resp, $opts)
    6384    {
    64         $types = array(
    65             'account' => 'Payjp\\Account',
    66             'card' => 'Payjp\\Card',
    67             'charge' => 'Payjp\\Charge',
    68             'customer' => 'Payjp\\Customer',
    69             'list' => 'Payjp\\Collection',
    70             'event' => 'Payjp\\Event',
    71             'token' => 'Payjp\\Token',
    72             'transfer' => 'Payjp\\Transfer',
    73             'plan' => 'Payjp\\Plan',
    74             'subscription' => 'Payjp\\Subscription',
    75         );
    7685        if (self::isList($resp)) {
    7786            $mapped = array();
     
    8190            return $mapped;
    8291        } elseif (is_array($resp)) {
    83             if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
    84                 $class = $types[$resp['object']];
     92            if (isset($resp['object']) && is_string($resp['object']) && isset(self::$types[$resp['object']])) {
     93                $class = self::$types[$resp['object']];
    8594            } else {
    8695                $class = 'Payjp\\PayjpObject';
     
    101110    {
    102111        if (is_string($value) && mb_detect_encoding($value, "UTF-8", true) != "UTF-8") {
    103             return utf8_encode($value);
     112            if (\PHP_VERSION_ID >= 80200) {
     113                return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
     114            } else {
     115                return utf8_encode($value);
     116            }
    104117        } else {
    105118            return $value;
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/AccountTest.php

    r2149911 r3190331  
    77    private function managedAccountResponse($id)
    88    {
    9         return array(
    10             'accounts_enabled' => array('merchant', 'customer'),
     9        return [
     10            'accounts_enabled' => [
     11                'merchant',
     12                'customer',
     13            ],
    1114            'created' => 1432965397,
    12                 'customer' => array(
    13                         'cards' => array(
    14                                 'count' => 1,
    15                                 'data' => array(
    16                                         array(
    17                                                 'address_city' => '\u8d64\u5742',
    18                                                 'address_line1' => '7-4',
    19                                                 'address_line2' => '203',
    20                                                 'address_state' => '\u6e2f\u533a',
    21                                                 'address_zip' => '1070050',
    22                                                 'address_zip_check' => 'passed',
    23                                                 'brand' => 'Visa',
    24                                                 'country' => self::COUNTRY,
    25                                                 'created' => 1432965397,
    26                                                 'cvc_check' => 'passed',
    27                                                 'exp_month' => 12,
    28                                                 'exp_year' => 2016,
    29                                                 'fingerprint' => 'e1d8225886e3a7211127df751c86787f',
    30                                                 'id' => 'car_99abf74cb5527ff68233a8b836dd',
    31                                                 'last4' => '4242',
    32                                                 'livemode' => true,
    33                                                 'name' => 'Test Hodler',
    34                                                 'object' => 'card'
    35                                         )
    36                                 ),
    37                                 'object' => 'list',
    38                                 'url' => '/v1/accounts/cards'
    39                         ),
    40                         'created' => 1432965397,
    41                         'default_card' => null,
    42                         'description' => 'user customer',
    43                         'email' => null,
    44                         'id' => 'acct_cus_38153121efdb7964dd1e147',
    45                         'object' => 'customer'
    46                 ),
    47                 'email' => 'firstuser@mail.com',
    48                 'id' => $id,
    49                 'merchant' => array(
    50                         'bank_enabled' => false,
    51                         'brands_accepted' => array(
    52                                         'Visa',
    53                                         'American Express',
    54                                         'MasterCard',
    55                                         'JCB',
    56                                         'Diners Club'
    57                         ),
    58                         'business_type' => 'personal',
    59                         'charge_type' => null,
    60                         'contact_phone' => null,
    61                         'country' => 'JP',
    62                         'created' => 1432965397,
    63                         'currencies_supported' => array(
    64                                         self::CURRENCY
    65                         ),
    66                         'default_currency' => self::CURRENCY,
    67                         'details_submitted' => false,
    68                         'id' => 'acct_mch_002418151ef82e49f6edee1',
    69                         'livemode_activated_at' => 1432965401,
    70                         'livemode_enabled' => true,
    71                         'object' => 'merchant',
    72                         'product_detail' => null,
    73                         'product_name' => null,
    74                         'product_type' => null,
    75                         'site_published' => false,
    76                         'url' => null
    77                 ),
    78                 'object' => 'account'
    79                        
    80         );
     15            'customer' => [
     16                'cards' => [
     17                    'count' => 1,
     18                    'data' => [
     19                        [
     20                            'address_city' => '\u8d64\u5742',
     21                            'address_line1' => '7-4',
     22                            'address_line2' => '203',
     23                            'address_state' => '\u6e2f\u533a',
     24                            'address_zip' => '1070050',
     25                            'address_zip_check' => 'passed',
     26                            'brand' => 'Visa',
     27                            'country' => self::COUNTRY,
     28                            'created' => 1432965397,
     29                            'cvc_check' => 'passed',
     30                            'exp_month' => 12,
     31                            'exp_year' => 2016,
     32                            'fingerprint' => 'e1d8225886e3a7211127df751c86787f',
     33                            'id' => 'car_99abf74cb5527ff68233a8b836dd',
     34                            'last4' => '4242',
     35                            'livemode' => true,
     36                            'name' => 'Test Hodler',
     37                            'object' => 'card'
     38                        ]
     39                    ],
     40                    'object' => 'list',
     41                    'url' => '/v1/accounts/cards'
     42                ],
     43                'created' => 1432965397,
     44                'default_card' => null,
     45                'description' => 'user customer',
     46                'email' => null,
     47                'id' => 'acct_cus_38153121efdb7964dd1e147',
     48                'object' => 'customer'
     49            ],
     50            'email' => 'firstuser@mail.com',
     51            'id' => $id,
     52            'merchant' => [
     53                'bank_enabled' => false,
     54                'brands_accepted' => [
     55                    'Visa',
     56                    'American Express',
     57                    'MasterCard',
     58                    'JCB',
     59                    'Diners Club'
     60                ],
     61                'business_type' => 'personal',
     62                'charge_type' => null,
     63                'contact_phone' => null,
     64                'country' => 'JP',
     65                'created' => 1432965397,
     66                'currencies_supported' => [
     67                    self::CURRENCY
     68                ],
     69                'default_currency' => self::CURRENCY,
     70                'details_submitted' => false,
     71                'id' => 'acct_mch_002418151ef82e49f6edee1',
     72                'livemode_activated_at' => 1432965401,
     73                'livemode_enabled' => true,
     74                'object' => 'merchant',
     75                'product_detail' => null,
     76                'product_name' => null,
     77                'product_type' => null,
     78                'site_published' => false,
     79                'url' => null
     80            ],
     81            'object' => 'account'
     82        ];
    8183    }
    8284
    8385    public function testBasicRetrieve()
    8486    {
    85         $this->mockRequest('GET', '/v1/accounts', array(), $this->managedAccountResponse('acct_ABC'));
     87        $this->mockRequest('GET', '/v1/accounts', [], $this->managedAccountResponse('acct_ABC'));
    8688        $account = Account::retrieve();
    87        
     89
    8890        $this->assertSame('acct_ABC', $account->id);
    8991        $this->assertSame('acct_cus_38153121efdb7964dd1e147', $account->customer->id);
    9092        $this->assertSame('acct_mch_002418151ef82e49f6edee1', $account->merchant->id);
    9193    }
    92    
    93     public function testRetrieve()
    94     {
    95         $account = Account::retrieve();
    96     }
    9794}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/ApiRequestorTest.php

    r2149911 r3190331  
    55class ApiRequestorTest extends TestCase
    66{
     7    /**
     8     * @before
     9     */
     10    protected function setUpTestCase()
     11    {
     12        parent::setUpTestCase();
     13        # MaxRetryを戻してinitialDelayを短くする
     14        Payjp::setMaxRetry(0);
     15        Payjp::setRetryInitialDelay(0.1);
     16        Payjp::setRetryMaxDelay(32);
     17    }
     18
     19    /**
     20     * @after
     21     */
     22    protected function tearDownTestCase()
     23    {
     24        parent::tearDown();
     25        Payjp::setMaxRetry(0);
     26        $this->setMaxRetryForCi();
     27        Payjp::setRetryInitialDelay(2);
     28        Payjp::setRetryMaxDelay(32);
     29    }
     30
     31    private $errorResponse = array('rcode'=>500, 'rbody'=>array('error' => array(
     32        "code" => "payjp_wrong",
     33        "message" => "An unexpected error occurred.",
     34        "status" => 500,
     35        "type" => "server_error",
     36    )));
     37    private $rateLimitResponse = array('rcode'=>429, 'rbody'=>array('error' => array(
     38        "code" => "over_capacity",
     39        "message" => "The service is over capacity. Please try again later.",
     40        "status" => 429,
     41        "type" => "client_error",
     42    )));
     43    private $successResponse = array('rcode'=>200, 'rbody'=>array('data'=>array()));
     44
     45    private function setUpResponses($responses)
     46    {
     47        $userCallCount = 0;
     48        $mock = $this->setUpMockRequest();
     49        $mock->expects($this->exactly(count($responses)))
     50            ->method('request')
     51            // $userCallCount を使って、responses の中から適切なものを選択するために、参照渡しで渡す。
     52            ->willReturnCallback(static function () use ($responses, &$userCallCount) {
     53                $userCallCount++;
     54                $response = $responses[$userCallCount - 1];
     55                return array(json_encode($response['rbody']), $response['rcode']);
     56            });
     57    }
     58
     59    // _encodeObjects
     60
    761    public function testEncodeObjects()
    862    {
     
    2579        $this->assertSame($enc, array('customer' => "\xc3\xa9"));
    2680    }
     81
     82    // request retry
     83
     84    public function testRetryDisabled()
     85    {
     86        $this->setUpResponses(array($this->rateLimitResponse));
     87        $requestor = new ApiRequestor(self::API_KEY);
     88
     89        try {
     90            $response = $requestor->request('GET', '/v1/accounts');
     91        } catch (Error\Api $e) {
     92            $this->assertSame($e->getMessage(), $this->rateLimitResponse['rbody']['error']['message']);
     93            $this->assertSame($e->getHttpStatus(), $this->rateLimitResponse['rcode']);
     94        }
     95    }
     96
     97    public function testNoRetry()
     98    {
     99        $this->setUpResponses(array($this->errorResponse));
     100        $requestor = new ApiRequestor(self::API_KEY);
     101
     102        try {
     103            $response = $requestor->request('GET', '/v1/accounts');
     104        } catch (Error\Api $e) {
     105            $this->assertSame($e->getMessage(), $this->errorResponse['rbody']['error']['message']);
     106            $this->assertSame($e->getHttpStatus(), $this->errorResponse['rcode']);
     107        }
     108    }
     109
     110    public function testFullRetryAndSuccess()
     111    {
     112        Payjp::setMaxRetry(2);
     113        $this->setUpResponses(array($this->rateLimitResponse, $this->rateLimitResponse, $this->successResponse));
     114        $requestor = new ApiRequestor(self::API_KEY);
     115
     116        $response = $requestor->request('GET', '/v1/accounts');
     117
     118        $this->assertSame($response[0], $this->successResponse['rbody']);
     119    }
     120
     121    public function testFullRetryAndFailed()
     122    {
     123        Payjp::setMaxRetry(2);
     124        $this->setUpResponses(array($this->rateLimitResponse, $this->rateLimitResponse, $this->rateLimitResponse));
     125        $requestor = new ApiRequestor(self::API_KEY);
     126
     127        try {
     128            $response = $requestor->request('GET', '/v1/accounts');
     129        } catch (Error\Api $e) {
     130            $this->assertSame($e->getMessage(), $this->rateLimitResponse['rbody']['error']['message']);
     131            $this->assertSame($e->getHttpStatus(), $this->rateLimitResponse['rcode']);
     132        }
     133    }
     134
     135    public function testGetRetryDelay()
     136    {
     137        Payjp::setRetryInitialDelay(2);
     138        $reflector = new \ReflectionClass('Payjp\\ApiRequestor');
     139        $method = $reflector->getMethod('getRetryDelay');
     140        $method->setAccessible(true);
     141        $r = new ApiRequestor(self::API_KEY);
     142
     143        $this->assertTrue(1 <= $method->invoke($r, 0) && $method->invoke($r, 0) <= 2);
     144        $this->assertTrue(2 <= $method->invoke($r, 1) && $method->invoke($r, 1) <= 4);
     145        $this->assertTrue(4 <= $method->invoke($r, 2) && $method->invoke($r, 2) <= 8);
     146        # not over retryMaxDelay
     147        $this->assertTrue(16 <= $method->invoke($r, 4) && $method->invoke($r, 4) <= 32);
     148        $this->assertTrue(16 <= $method->invoke($r, 10) && $method->invoke($r, 10) <= 32);
     149    }
    27150}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/CardErrorTest.php

    r2149911 r3190331  
    1111        $params =  [
    1212            'card' => [
    13             "number" => "4242424242424242",
    14             "exp_month" => 6,
    15             "exp_year" => date('Y') + 3,
    16             "cvc" => "314"
     13                'number' => '4242424242424242',
     14                'exp_month' => 6,
     15                'exp_year' => date('Y') - 1,
     16                'cvc' => '314'
    1717            ]
    1818        ];
    1919
    20         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    21 
    22         $charge = array(
    23             'amount' => 100,
    24             'currency' => self::CURRENCY,
    25             'card' => $card->id
    26         );
    27 
    2820        try {
    29             Charge::create($charge);
     21            Token::create($params, ['payjp_direct_token_generate' => 'true']);
    3022        } catch (Error\Card $e) {
    3123            $this->assertSame(402, $e->getHttpStatus());
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/ChargeTest.php

    r2149911 r3190331  
    1919        $params =  [
    2020            'card' => [
    21             "number" => "4242424242424242",
    22             "exp_month" => "05",
    23             'exp_year' => date('Y') + 1
    24             ]
    25         ];
    26 
    27         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    28 
    29         $c = Charge::create(
    30             array(
    31                 'amount' => 100,
    32                 'currency' => self::CURRENCY,
    33                 'card' => $card->id
    34             )
    35         );
     21                'number' => '4242424242424242',
     22                'exp_month' => '05',
     23                'exp_year' => date('Y') + 1,
     24                'cvc' => '123',
     25            ]
     26        ];
     27
     28        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     29
     30        $c = Charge::create([
     31            'amount' => 100,
     32            'currency' => self::CURRENCY,
     33            'card' => $card->id,
     34        ]);
    3635        $this->assertTrue($c->paid);
    3736        $this->assertFalse($c->refunded);
     
    4544        $params =  [
    4645            'card' => [
    47             "number" => "4242424242424242",
    48             "exp_month" => 5,
    49             'exp_year' => date('Y') + 1
    50             ]
    51         ];
    52 
    53         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    54 
    55         $c = Charge::create(
    56             array(
    57                 'amount' => 100,
    58                 'currency' => self::CURRENCY,
    59                 'card' => $card->id
    60             ),
    61             array(
    62                 'idempotency_key' => self::generateRandomString(),
    63             )
    64         );
     46                'number' => '4242424242424242',
     47                'exp_month' => 5,
     48                'exp_year' => date('Y') + 1,
     49                'cvc' => '123',
     50            ]
     51        ];
     52
     53        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     54
     55        $c = Charge::create([
     56            'amount' => 100,
     57            'currency' => self::CURRENCY,
     58            'card' => $card->id
     59        ], [
     60            'idempotency_key' => self::generateRandomString(),
     61        ]);
    6562
    6663        $this->assertTrue($c->paid);
     
    7572        $params =  [
    7673            'card' => [
    77             "number" => "4242424242424242",
    78             "exp_month" => 5,
    79             "exp_year" => date('Y') + 1
    80             ]
    81         ];
    82 
    83         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    84 
    85         $c = Charge::create(
    86             array(
    87                 'amount' => 100,
    88                 'currency' => self::CURRENCY,
    89                 'card' => $card->id
    90             )
    91         );
     74                'number' => '4242424242424242',
     75                'exp_month' => 5,
     76                'exp_year' => date('Y') + 1,
     77                'cvc' => '123',
     78            ]
     79        ];
     80
     81        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     82
     83        $c = Charge::create([
     84            'amount' => 100,
     85            'currency' => self::CURRENCY,
     86            'card' => $card->id
     87        ]);
    9288        $d = Charge::retrieve($c->id);
    9389        $this->assertSame($d->id, $c->id);
     
    9995        self::authorizeFromEnv();
    10096
    101         $charges = Charge::all(
    102             array(
    103                     'limit' => 3,
    104                     'offset' => 10
    105             )
    106         );
     97        $charges = Charge::all([
     98            'limit' => 3,
     99            'offset' => 10
     100        ]);
    107101
    108102        $planID = 'gold-' . self::randomString();
     
    111105        $customer = self::createTestCustomer();
    112106
    113         $charge = Charge::create(
    114             array(
    115                     'amount' => 1000,
    116                     'currency' => self::CURRENCY,
    117                     'customer' => $customer->id
    118             )
    119         );
    120 
    121         $charges_2 = Charge::all(
    122             array(
    123                     'customer' => $customer->id
    124             )
    125         );
     107        $charge = Charge::create([
     108            'amount' => 1000,
     109            'currency' => self::CURRENCY,
     110            'customer' => $customer->id
     111        ]);
     112
     113        $charges_2 = Charge::all([
     114            'customer' => $customer->id
     115        ]);
    126116
    127117        $this->assertSame(1, count($charges_2['data']));
    128118        $this->assertSame($charge->id, $charges_2['data'][0]->id);
    129119
    130         $charge_2 = Charge::create(
    131             array(
    132                     'amount' => 1500,
    133                     'currency' => self::CURRENCY,
    134                     'customer' => $customer->id
    135             )
    136         );
    137 
    138         $charges_3 = Charge::all(
    139             array(
    140                     'limit' => 2,
    141                     'offset' => 0,
    142                     'customer' => $customer->id
    143             )
    144         );
     120        $charge_2 = Charge::create([
     121            'amount' => 1500,
     122            'currency' => self::CURRENCY,
     123            'customer' => $customer->id
     124        ]);
     125
     126        $charges_3 = Charge::all([
     127            'limit' => 2,
     128            'offset' => 0,
     129            'customer' => $customer->id
     130        ]);
    145131
    146132        $this->assertSame(2, count($charges_3['data']));
     
    154140        $params =  [
    155141            'card' => [
    156             "number" => "4242424242424242",
    157             "exp_month" => 5,
    158             "exp_year" => date('Y') + 1
    159             ]
    160         ];
    161 
    162         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    163 
    164         $charge = Charge::create(
    165             array(
    166                     'amount' => 100,
    167                     'currency' => self::CURRENCY,
    168                     'card' => $card->id
    169             )
    170         );
     142                'number' => '4242424242424242',
     143                'exp_month' => 5,
     144                'exp_year' => date('Y') + 1,
     145                'cvc' => '123',
     146            ]
     147        ];
     148
     149        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     150
     151        $charge = Charge::create([
     152            'amount' => 100,
     153            'currency' => self::CURRENCY,
     154            'card' => $card->id
     155        ]);
    171156
    172157        $charge->description = 'foo bar';
     
    185170        $params =  [
    186171            'card' => [
    187             "number" => "4242424242424242",
    188             "exp_month" => 5,
    189             "exp_year" => date('Y') + 1
    190             ]
    191         ];
    192 
    193         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    194 
    195         $charge = Charge::create(
    196             array(
    197                     'amount' => 100,
    198                     'currency' => self::CURRENCY,
    199                     'card' => $card->id,
    200                     'capture' => false
    201             )
    202         );
     172                'number' => '4242424242424242',
     173                'exp_month' => 5,
     174                'exp_year' => date('Y') + 1,
     175                'cvc' => '123',
     176            ]
     177        ];
     178
     179        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     180
     181        $charge = Charge::create([
     182            'amount' => 100,
     183            'currency' => self::CURRENCY,
     184            'card' => $card->id,
     185            'capture' => false
     186        ]);
    203187
    204188        $this->assertFalse($charge->captured);
     
    216200        $params =  [
    217201            'card' => [
    218             "number" => "4242424242424242",
    219             "exp_month" => 5,
    220             "exp_year" => date('Y') + 1
    221             ]
    222         ];
    223 
    224         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    225 
    226         $charge = Charge::create(
    227             array(
    228                     'amount' => 100,
    229                     'currency' => self::CURRENCY,
    230                     'card' => $card->id,
    231                     'capture' => false
    232             )
    233         );
     202                'number' => '4242424242424242',
     203                'exp_month' => 5,
     204                'exp_year' => date('Y') + 1,
     205                'cvc' => '123',
     206            ]
     207        ];
     208
     209        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     210
     211        $charge = Charge::create([
     212            'amount' => 100,
     213            'currency' => self::CURRENCY,
     214            'card' => $card->id,
     215            'capture' => false
     216        ]);
    234217
    235218        $this->assertFalse($charge->captured);
     
    247230        $params =  [
    248231            'card' => [
    249             "number" => "4242424242424242",
    250             "exp_month" => 5,
    251             "exp_year" => date('Y') + 1
    252             ]
    253         ];
    254 
    255         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    256 
    257         $charge = Charge::create(
    258             array(
    259                     'amount' => 100,
    260                     'currency' => self::CURRENCY,
    261                     'card' => $card->id,
    262             )
    263         );
     232                'number' => '4242424242424242',
     233                'exp_month' => 5,
     234                'exp_year' => date('Y') + 1,
     235                'cvc' => '123',
     236            ]
     237        ];
     238
     239        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     240
     241        $charge = Charge::create([
     242            'amount' => 100,
     243            'currency' => self::CURRENCY,
     244            'card' => $card->id,
     245        ]);
    264246
    265247        $this->assertTrue($charge->captured);
    266248
    267         $redundChargePart = $charge->refund(
    268             array(
    269                     'amount' => 50,
    270                     'refund_reason' => 'foo bar 1'
    271             )
    272         );
     249        $redundChargePart = $charge->refund([
     250            'amount' => 50,
     251            'refund_reason' => 'foo bar 1'
     252        ]);
    273253
    274254        $this->assertTrue($redundChargePart->refunded);
     
    279259        $this->assertSame(50, $charge->amount_refunded);
    280260
    281         $refundChargeAll = $charge->refund(
    282             array(
    283                     'refund_reason' => 'foo bar 2'
    284             )
    285         );
     261        $refundChargeAll = $charge->refund([
     262            'refund_reason' => 'foo bar 2'
     263        ]);
    286264
    287265        $this->assertTrue($refundChargeAll->refunded);
     
    293271    }
    294272
    295     /**
    296      * @expectedException Payjp\Error\Card
    297      */
    298273    public function testInvalidCard()
    299274    {
    300         self::authorizeFromEnv();
    301 
    302         $params =  [
    303             'card' => [
    304             "number" => "4242424242424241",
    305             "exp_month" => 5,
    306             "exp_year" => date('Y') + 1
    307             ]
    308         ];
    309 
    310         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    311 
    312         Charge::create(
    313             array(
    314                     'amount' => 100,
    315                     'currency' => self::CURRENCY,
    316                     'card' => $card->id
    317             )
    318         );
     275        $this->expectException('\Payjp\Error\Card');
     276
     277        self::authorizeFromEnv();
     278
     279        $params =  [
     280            'card' => [
     281                'number' => '4242424242424241',
     282                'exp_month' => 5,
     283                'exp_year' => date('Y') + 1,
     284                'cvc' => '123',
     285            ]
     286        ];
     287
     288        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     289
     290        Charge::create([
     291            'amount' => 100,
     292            'currency' => self::CURRENCY,
     293            'card' => $card->id
     294        ]);
    319295    }
    320296
     
    326302        $params =  [
    327303            'card' => [
    328             "number" => "4000000000000070",
    329             "exp_month" => '05',
    330             'exp_year' => (date('Y') + 1)
    331             ]
    332         ];
    333 
    334         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    335 
    336         $ch = Charge::create(
    337             array(
    338                     'amount' => 100,
    339                     'currency' => self::CURRENCY,
    340                     'card' => $card->id
    341             )
    342         );
    343 
    344         $this->assertSame("failed", $ch->card->address_zip_check);
     304                'number' => '4000000000000070',
     305                'exp_month' => '05',
     306                'exp_year' => (date('Y') + 1),
     307                'cvc' => '123',
     308            ]
     309        ];
     310
     311        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     312
     313        $ch = Charge::create([
     314            'amount' => 100,
     315            'currency' => self::CURRENCY,
     316            'card' => $card->id
     317        ]);
     318
     319        $this->assertSame('failed', $ch->card->address_zip_check);
    345320    }
    346321
     
    351326        $params =  [
    352327            'card' => [
    353             "number" => "4000000000000100",
    354             "exp_month" => '05',
    355             'exp_year' => (date('Y') + 1)
    356             ]
    357         ];
    358 
    359         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    360 
    361         $ch = Charge::create(
    362             array(
    363                     'amount' => 100,
    364                     'currency' => self::CURRENCY,
    365                     'card' => $card->id
    366             )
    367         );
    368 
    369         $this->assertSame("failed", $ch->card->cvc_check);
     328                'number' => '4000000000000100',
     329                'exp_month' => '05',
     330                'exp_year' => (date('Y') + 1),
     331                'cvc' => '123',
     332            ]
     333        ];
     334
     335        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     336
     337        $ch = Charge::create([
     338            'amount' => 100,
     339            'currency' => self::CURRENCY,
     340            'card' => $card->id
     341        ]);
     342
     343        $this->assertSame('failed', $ch->card->cvc_check);
    370344    }
    371345
     
    376350        $params =  [
    377351            'card' => [
    378             "number" => "4000000000000150",
    379             "exp_month" => '05',
    380             'exp_year' => (date('Y') + 1)
    381             ]
    382         ];
    383 
    384         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    385 
    386         $ch = Charge::create(
    387             array(
    388                     'amount' => 100,
    389                     'currency' => self::CURRENCY,
    390                     'card' => $card->id
    391             )
    392         );
    393 
    394         $this->assertSame("unavailable", $ch->card->cvc_check);
     352                'number' => '4000000000000150',
     353                'exp_month' => '05',
     354                'exp_year' => (date('Y') + 1),
     355                'cvc' => '123',
     356            ]
     357        ];
     358
     359        $card = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     360
     361        $ch = Charge::create([
     362            'amount' => 100,
     363            'currency' => self::CURRENCY,
     364            'card' => $card->id
     365        ]);
     366
     367        $this->assertSame('unavailable', $ch->card->cvc_check);
    395368    }
    396369}
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/CustomerTest.php

    r2149911 r3190331  
    88    public function testCreate()
    99    {
    10         $attribute = array(
    11                         'email' => 'gdb@pay.jp',
    12                         'description' => 'foo bar'
    13         );
    14        
     10        $attribute = [
     11            'email' => 'gdb@pay.jp',
     12            'description' => 'foo bar'
     13        ];
     14
    1515        $customer = self::createTestCustomer($attribute);
    1616        $this->assertSame($attribute['email'], $customer->email);
    1717        $this->assertSame($attribute['description'], $customer->description);
    1818    }
    19        
     19
    2020    // GET/customers/:id
    2121    public function testRetrieve()
     
    2323        $customer = self::createTestCustomer();
    2424        $retrieve_customer = Customer::retrieve($customer->id);
    25        
    2625        $this->assertSame($customer->id, $retrieve_customer->id);
    2726    }
    28    
     27
    2928    // GET/customers/
    3029    public function testAll()
    3130    {
    32         $customers = Customer::all(
    33             array(
    34                 'limit' => 3,
    35                 'offset' => 10
    36             )
    37         );
    38     }
    39    
     31        $customers = Customer::all([
     32            'limit' => 3,
     33            'offset' => 10
     34        ]);
     35        $this->assertCount(3, $customers['data']);
     36    }
     37
    4038    // DELETE/customers/:id
    4139    public function testDeletion()
     
    4341        $customer = self::createTestCustomer();
    4442        $id = $customer->id;
    45        
     43
    4644        $delete_customer = $customer->delete();
    4745
     
    4947        $this->assertFalse($customer->livemode);
    5048        $this->assertTrue($customer->deleted);
    51        
     49
    5250        $this->assertNull($customer['active_card']);
    53        
     51
    5452        $this->assertSame($id, $delete_customer->id);
    5553        $this->assertFalse($delete_customer->livemode);
    5654        $this->assertTrue($delete_customer->deleted);
    57        
     55
    5856        $this->assertNull($delete_customer['active_card']);
    5957    }
    60        
     58
    6159    //POST /customers/:id
    6260    public function testSave()
     
    8381    }
    8482
    85     /**
    86      * @expectedException Payjp\Error\InvalidRequest
    87      */
    8883    public function testBogusAttribute()
    8984    {
     85        $this->expectException('\Payjp\Error\InvalidRequest');
    9086        $customer = self::createTestCustomer();
    9187        $customer->bogus = 'bogus';
     
    9389    }
    9490
    95     /**
    96      * @expectedException InvalidArgumentException
    97      */
    9891    public function testUpdateDescriptionEmpty()
    9992    {
     93        $this->expectException('\InvalidArgumentException');
    10094        $customer = self::createTestCustomer();
    10195        $customer->description = '';
    102        
    103         $customer->save();
    104        
     96
     97        $customer->save();
     98
    10599        $updatedCustomer = Customer::retrieve($customer->id);
    106100        $this->assertSame('123', $updatedCustomer->description);
    107101    }
    108        
     102
    109103    public function testUpdateDescriptionNull()
    110104    {
    111         $customer = self::createTestCustomer(array('description' => 'foo bar'));
     105        $customer = self::createTestCustomer(['description' => 'foo bar']);
    112106        $customer->description = null;
    113    
    114         $customer->save();
    115    
     107
     108        $customer->save();
     109
    116110        $updatedCustomer = Customer::retrieve($customer->id);
    117111        $this->assertSame('', $updatedCustomer->description);
    118112        $this->assertSame('', $customer->description);
    119113    }
    120    
     114
    121115    //POST /customers/:id/cards
    122116    //GET /customers/:id/cards
     
    124118    {
    125119        $customer = $this->createTestCustomer();
    126        
     120
    127121        $defaultCard = $customer->cards->data[0];
    128122
    129123        $params =  [
    130124            'card' => [
    131             "number" => "4242424242424242",
    132             "exp_month" => 12,
    133             "exp_year" => date('Y') + 3,
    134             "cvc" => "314"
     125                'number' => '4242424242424242',
     126                'exp_month' => 12,
     127                'exp_year' => date('Y') + 3,
     128                'cvc' => '314'
    135129            ]
    136130        ];
    137131
    138         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    139          
     132        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     133
    140134        $params2 =  [
    141135            'card' => [
    142             "number" => "4242424242424242",
    143             "exp_month" => 7,
    144             "exp_year" => date('Y') + 3,
    145             "cvc" => "314"
     136                'number' => '4242424242424242',
     137                'exp_month' => 7,
     138                'exp_year' => date('Y') + 3,
     139                'cvc' => '314'
    146140            ]
    147141        ];
    148142
    149         $card = Token::create($params2, $options = ['payjp_direct_token_generate' => 'true']);
    150        
    151         $createdCard = $customer->cards->create(array("card" => $token->id));
    152         $createdCard_2 = $customer->cards->create(array("card" => $card->id));
    153        
    154         $updatedCustomer = Customer::retrieve($customer->id);
    155         $cardList = $updatedCustomer->cards->all();
    156         $this->assertSame(count($cardList["data"]), 3);
    157 
    158         $this->assertSame($createdCard_2->id, $cardList["data"][0]->id);
    159         $this->assertSame($createdCard->id, $cardList["data"][1]->id);
    160         $this->assertSame($defaultCard->id, $cardList["data"][2]->id);
    161          
    162         $card = $customer->cards->retrieve($cardList["data"][1]->id);
    163         $this->assertSame($card->id, $cardList["data"][1]->id);
    164        
    165         $updatedCustomer = Customer::retrieve($customer->id);
    166         $cardList = $updatedCustomer->cards->all(
    167             array(
    168                 'limit' => 1,
    169                 'offset' => 1
    170             )
    171         );
    172         $this->assertSame(count($cardList["data"]), 1);
    173     }
    174    
     143        $card = Token::create($params2, ['payjp_direct_token_generate' => 'true']);
     144
     145        $createdCard = $customer->cards->create(['card' => $token->id]);
     146        $createdCard_2 = $customer->cards->create(['card' => $card->id]);
     147
     148        $updatedCustomer = Customer::retrieve($customer->id);
     149        $cardList = $updatedCustomer->cards->all();
     150        $this->assertSame(count($cardList['data']), 3);
     151
     152        $this->assertSame($createdCard_2->id, $cardList['data'][0]->id);
     153        $this->assertSame($createdCard->id, $cardList['data'][1]->id);
     154        $this->assertSame($defaultCard->id, $cardList['data'][2]->id);
     155
     156        $card = $customer->cards->retrieve($cardList['data'][1]->id);
     157        $this->assertSame($card->id, $cardList['data'][1]->id);
     158
     159        $updatedCustomer = Customer::retrieve($customer->id);
     160        $cardList = $updatedCustomer->cards->all([
     161            'limit' => 1,
     162            'offset' => 1
     163        ]);
     164        $this->assertSame(count($cardList['data']), 1);
     165    }
     166
    175167    //POST /customers/:id/cards/:card_id
    176168    public function testCustomerUpdateCard()
    177169    {
    178170        $customer = $this->createTestCustomer();
    179    
     171
    180172        $cards = $customer->cards->all();
    181         $this->assertSame(count($cards["data"]), 1);
    182    
     173        $this->assertSame(count($cards['data']), 1);
     174
    183175        $card = $cards['data'][0];
    184         $card->name = "Littleorc";
     176        $card->name = 'Littleorc';
    185177        $card->save();
    186    
    187         $updatedCustomer = Customer::retrieve($customer->id);
    188         $cardList = $updatedCustomer->cards->all();
    189         $this->assertSame($cardList["data"][0]->name, "Littleorc");
    190     }
    191    
     178
     179        $updatedCustomer = Customer::retrieve($customer->id);
     180        $cardList = $updatedCustomer->cards->all();
     181        $this->assertSame($cardList['data'][0]->name, 'Littleorc');
     182    }
     183
    192184    public function testCustomerDeleteCard()
    193185    {
    194186        $params =  [
    195187            'card' => [
    196             "number" => "4242424242424242",
    197             "exp_month" => 7,
    198             "exp_year" => date('Y') + 3,
    199             "cvc" => "314"
     188                'number' => '4242424242424242',
     189                'exp_month' => 7,
     190                'exp_year' => date('Y') + 3,
     191                'cvc' => '314'
    200192            ]
    201193        ];
    202194
    203195        $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    204    
     196
    205197        $customer = $this->createTestCustomer();
    206         $createdCard = $customer->cards->create(array("card" => $token->id));
    207    
    208         $updatedCustomer = Customer::retrieve($customer->id);
    209         $cardList = $updatedCustomer->cards->all();
    210         $this->assertSame(count($cardList["data"]), 2);
    211    
     198        $createdCard = $customer->cards->create(['card' => $token->id]);
     199
     200        $updatedCustomer = Customer::retrieve($customer->id);
     201        $cardList = $updatedCustomer->cards->all();
     202        $this->assertSame(count($cardList['data']), 2);
     203
    212204        $deleteStatus = $updatedCustomer->cards->retrieve($createdCard->id)->delete();
    213205        $this->assertTrue($deleteStatus->deleted);
    214    
     206
    215207        $postDeleteCustomer = Customer::retrieve($customer->id);
    216208        $postDeleteCards = $postDeleteCustomer->cards->all();
    217         $this->assertSame(count($postDeleteCards["data"]), 1);
    218        
    219         $cardList = $updatedCustomer->cards->all();
    220         $this->assertSame(count($cardList["data"]), 1);
    221     }
    222    
     209        $this->assertSame(count($postDeleteCards['data']), 1);
     210
     211        $cardList = $updatedCustomer->cards->all();
     212        $this->assertSame(count($cardList['data']), 1);
     213    }
     214
    223215    public function testCustomerSubscriptionAllRetrieve()
    224216    {
    225217        $planID = 'gold-' . self::randomString();
    226218        self::retrieveOrCreatePlan($planID);
    227        
    228         $customer = self::createTestCustomer();
    229        
    230         $subscription = Subscription::create(
    231             array(
    232                 'customer' => $customer->id,
    233                 'plan' => $planID
    234             )
    235         );
    236        
     219
     220        $customer = self::createTestCustomer();
     221
     222        $subscription = Subscription::create([
     223            'customer' => $customer->id,
     224            'plan' => $planID
     225        ]);
     226
    237227        $planID_2 = 'gold-2-' . self::randomString();
    238228        self::retrieveOrCreatePlan($planID_2);
    239229
    240         $subscription_2 = Subscription::create(
    241             array(
    242                 'customer' => $customer->id,
    243                 'plan' => $planID_2
    244             )
    245         );
    246        
     230        $subscription_2 = Subscription::create([
     231            'customer' => $customer->id,
     232            'plan' => $planID_2
     233        ]);
     234
    247235        $customerRetrive = Customer::retrieve($customer->id);
    248236        $subscriptions = $customerRetrive->subscriptions->all();
     
    250238        $this->assertSame($subscription_2->id, $subscriptions['data'][0]->id);
    251239        $this->assertSame($subscription->id, $subscriptions['data'][1]->id);
    252          
     240
    253241        $this->assertSame(2, count($subscriptions['data']));
    254242        $this->assertSame($customer->id, $subscriptions['data'][0]->customer);
    255243        $this->assertSame($planID_2, $subscriptions['data'][0]->plan->id);
    256        
     244
    257245        $subscriptionRetrieve = $customerRetrive->subscriptions->retrieve($subscription->id);
    258246        $this->assertSame($subscription->id, $subscriptionRetrieve->id);
    259247        $this->assertSame($planID, $subscriptionRetrieve->plan->id);
    260248    }
    261    
     249
    262250    public function testCustomerChargeAll()
    263251    {
    264252        $planID = 'gold-' . self::randomString();
    265253        self::retrieveOrCreatePlan($planID);
    266      
    267         $customer = self::createTestCustomer();
    268              
    269         $charge = Charge::create(
    270             array(
    271                 'amount' => 1000,
    272                 'currency' => self::CURRENCY,
    273                 'customer' => $customer->id
    274             )
    275         );
    276            
     254
     255        $customer = self::createTestCustomer();
     256
     257        $charge = Charge::create([
     258            'amount' => 1000,
     259            'currency' => self::CURRENCY,
     260            'customer' => $customer->id
     261        ]);
     262
    277263        $charges = $customer->charges();
    278            
     264
    279265        $this->assertSame(1, count($charges['data']));
    280266        $this->assertSame($charge->id, $charges['data'][0]->id);
    281267
    282         $charge_2 = Charge::create(
    283             array(
    284                 'amount' => 1500,
    285                 'currency' => self::CURRENCY,
    286                  'customer' => $customer->id
    287             )
    288         );
    289    
     268        $charge_2 = Charge::create([
     269            'amount' => 1500,
     270            'currency' => self::CURRENCY,
     271            'customer' => $customer->id
     272        ]);
     273
    290274        $charges_2 = $customer->charges();
    291                
     275
    292276        $this->assertSame(2, count($charges_2['data']));
    293277        $this->assertSame($charge_2->id, $charges_2['data'][0]->id);
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/PayjpObjectTest.php

    r2149911 r3190331  
    4949        $converted = $s->__toArray();
    5050
    51         $this->assertInternalType('array', $converted);
     51        $this->assertSame('array', gettype($converted));
    5252        $this->assertArrayHasKey('foo', $converted);
    5353        $this->assertEquals('a', $converted['foo']);
     
    6464        $converted = $s->__toArray(true);
    6565
    66         $this->assertInternalType('array', $converted);
     66        $this->assertSame('array', gettype($converted));
    6767        $this->assertArrayHasKey('child', $converted);
    68         $this->assertInternalType('array', $converted['child']);
     68        $this->assertSame('array', gettype($converted['child']));
    6969        $this->assertArrayHasKey('foo', $converted['child']);
    7070        $this->assertEquals('a', $converted['child']['foo']);
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/PlanTest.php

    r2149911 r3190331  
    88    {
    99        self::authorizeFromEnv();
    10         $planID = 'gold-' . self::randomString();
    11         $p = Plan::create(array(
     10        $planId = 'gold-' . self::randomString();
     11        $p = Plan::create([
    1212            'amount'   => 2000,
    1313            'interval' => 'month',
    1414            'currency' => self::CURRENCY,
    1515            'name'     => 'Plan',
    16             'id'       => $planID
    17         ));
    18        
    19         $plan_retrieve = Plan::retrieve($planID);
    20         $this->assertSame($planID, $plan_retrieve->id);
    21                
    22         $planID_2 = 'foobar-2-' . self::randomString();
    23         $p_2 = Plan::create(
    24             array(
    25                 'amount'   => 3000,
    26                 'interval' => 'month',
    27                 'currency' => self::CURRENCY,
    28                 'name'     => 'Plan_2',
    29                 'id'       => $planID_2
    30             )
    31         );
     16            'id'       => $planId
     17        ]);
    3218
    33         $plans = Plan::all(
    34             array(
    35                 'limit' => 2,
    36                 'offset' => 0
    37             )
    38         );
     19        $plan_retrieve = Plan::retrieve($planId);
     20        $this->assertSame($planId, $plan_retrieve->id);
     21
     22        $planId_2 = 'foobar-2-' . self::randomString();
     23        $p_2 = Plan::create([
     24            'amount'   => 3000,
     25            'interval' => 'month',
     26            'currency' => self::CURRENCY,
     27            'name'     => 'Plan_2',
     28            'id'       => $planId_2
     29        ]);
     30
     31        $plans = Plan::all([
     32            'limit' => 2,
     33            'offset' => 0
     34        ]);
    3935        $this->assertSame(2, count($plans['data']));
    4036    }
     
    4339    {
    4440        self::authorizeFromEnv();
    45         $plan_ID = 'gold-' . self::randomString();
    46         $p = Plan::create(array(
     41        $planId = 'gold-' . self::randomString();
     42        $p = Plan::create([
    4743            'amount' => 2000,
    4844            'interval' => 'month',
    4945            'currency' => self::CURRENCY,
    5046            'name' => 'Plan',
    51             'id' => $plan_ID
    52         ));
     47            'id' => $planId
     48        ]);
    5349        $p->delete();
    5450        $this->assertTrue($p->deleted);
    55         $this->assertSame($plan_ID, $p->id);
     51        $this->assertSame($planId, $p->id);
    5652    }
    5753
     
    5955    {
    6056        try {
    61             $retrievedPlan = Plan::retrieve('0');
     57            Plan::retrieve('0');
    6258        } catch (Error\InvalidRequest $e) {
    63             // Can either succeed or 404, all other errors are bad
    64             if ($e->httpStatus !== 404) {
    65                 $this->fail();
    66             }
     59            $this->assertSame(404, $e->httpStatus);
    6760        }
    6861    }
     
    7164    {
    7265        self::authorizeFromEnv();
    73         $planID = 'gold-' . self::randomString();
    74         $p = Plan::create(array(
     66        $planId = 'gold-' . self::randomString();
     67        $p = Plan::create([
    7568            'amount'   => 2000,
    7669            'interval' => 'month',
    7770            'currency' => self::CURRENCY,
    7871            'name'     => 'Plan',
    79             'id'       => $planID
    80         ));
     72            'id'       => $planId
     73        ]);
    8174        $p->name = 'A new plan name';
    8275        $p->save();
    8376        $this->assertSame($p->name, 'A new plan name');
    8477
    85         $payjpPlan = Plan::retrieve($planID);
     78        $payjpPlan = Plan::retrieve($planId);
    8679        $this->assertSame($p->name, $payjpPlan->name);
    8780    }
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/RequestOptionsTest.php

    r2149911 r3190331  
    7171    }
    7272
    73     /**
    74      * @expectedException Payjp\Error\Api
    75      */
    7673    public function testWrongType()
    7774    {
     75        $this->expectException("\Payjp\Error\Api");
    7876        $opts = Util\RequestOptions::parse(5);
    7977    }
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/TestCase.php

    r2149911 r3190331  
    77 * objects.
    88 */
    9 class TestCase extends \PHPUnit_Framework_TestCase
     9class TestCase extends \PHPUnit\Framework\TestCase
    1010{
    1111    const API_KEY = 'sk_test_c62fade9d045b54cd76d7036';// public api key for test
     
    1313    const COUNTRY = 'JP';
    1414
    15     private $mock;
     15    protected $mock;
    1616
    1717    protected static function authorizeFromEnv()
     
    2525    }
    2626
    27     protected function setUp()
     27    protected static function setMaxRetryForCi()
    2828    {
     29        $maxRetry = getenv('MAX_RETRY');
     30        if ($maxRetry) {
     31            Payjp::setMaxRetry($maxRetry);
     32        }
     33    }
     34
     35    /**
     36     * @before
     37     */
     38    protected function setUpTestCase()
     39    {
     40        $this->setMaxRetryForCi();
    2941        ApiRequestor::setHttpClient(HttpClient\CurlClient::instance());
    3042        $this->mock = null;
    31         $this->call = 0;
    3243    }
    3344
     
    3546    {
    3647        $mock = $this->setUpMockRequest();
    37         $mock->expects($this->at($this->call++))
    38              ->method('request')
    39                  ->with(strtolower($method), 'https://api.pay.jp' . $path, $this->anything(), $params, false)
    40                  ->willReturn(array(json_encode($return), 200));
     48        $mock->expects($this->once())
     49            ->method('request')
     50            ->with(
     51                strtolower($method),
     52                'https://api.pay.jp' . $path,
     53                $this->anything(),
     54                $params,
     55                false
     56            )
     57            ->willReturn(array(json_encode($return), 200));
    4158    }
    4259
    43     private function setUpMockRequest()
    44     {
    45         if (!$this->mock) {
    46             self::authorizeFromEnv();
    47             $this->mock = $this->getMock('\Payjp\HttpClient\ClientInterface');
    48             ApiRequestor::setHttpClient($this->mock);
    49         }
    50         return $this->mock;
    51     }
    52 
    53     /**
    54      * Create a valid test charge.
    55      */
    56     protected static function createTestCharge(array $attributes = array())
     60    protected function setUpMockRequest()
    5761    {
    5862        self::authorizeFromEnv();
    59 
    60         $params =  [
    61             'card' => [
    62             "number" => "4242424242424242",
    63             "exp_month" => 6,
    64             "exp_year" => date('Y') + 3,
    65             "cvc" => "314"
    66             ]
    67         ];
    68 
    69         $card = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    70 
    71         return Charge::create(
    72             $attributes + array(
    73                 'amount' => 2000,
    74                 'currency' => self::CURRENCY,
    75                 'description' => 'Charge for test@example.com',
    76                 'card' => $card
    77             )
    78         );
    79     }
    80 
    81     /**
    82      * Create a valid test charge.
    83      */
    84     protected static function createTestTransfer(array $attributes = array())
    85     {
    86         self::authorizeFromEnv();
    87 
    88         $recipient = self::createTestRecipient();
    89 
    90         return Transfer::create(
    91             $attributes + array(
    92                 'amount' => 2000,
    93                 'currency' => self::CURRENCY,
    94                 'description' => 'Transfer to test@example.com',
    95                 'recipient' => $recipient->id
    96             )
    97         );
     63        $this->mock = $this->createMock('\Payjp\HttpClient\ClientInterface');
     64        ApiRequestor::setHttpClient($this->mock);
     65        return $this->mock;
    9866    }
    9967
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/TokenTest.php

    r2149911 r3190331  
    1111        $this->assertSame($token->instanceUrl(), '/v1/tokens/abcd%2Fefgh');
    1212    }
    13    
     13
    1414    public function testCreate()
    1515    {
    1616        self::authorizeFromEnv();
    17    
     17
    1818        $params =  [
    1919            'card' => [
    20             "number" => "4242424242424242",
    21             "exp_month" => 6,
    22             "exp_year" => date('Y') + 3,
    23             "cvc" => "314"
     20                'number' => '4242424242424242',
     21                'exp_month' => 6,
     22                'exp_year' => date('Y') + 3,
     23                'cvc' => '314'
    2424            ]
    2525        ];
    26        
    27         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
     26
     27        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     28        $this->assertNotNull($token);
    2829    }
    29    
     30
    3031    public function testRetrieve()
    3132    {
     
    3435        $params =  [
    3536            'card' => [
    36             "number" => "4242424242424242",
    37             "exp_month" => 6,
    38             "exp_year" => date('Y') + 3,
    39             "cvc" => "314"
     37                'number' => '4242424242424242',
     38                'exp_month' => 6,
     39                'exp_year' => date('Y') + 3,
     40                'cvc' => '314'
    4041            ]
    4142        ];
    42        
    43         $token = Token::create($params, $options = ['payjp_direct_token_generate' => 'true']);
    44          
     43
     44        $token = Token::create($params, ['payjp_direct_token_generate' => 'true']);
     45
    4546        $token_retrieve = Token::retrieve($token->id);
    46        
     47
    4748        $this->assertSame($token->id, $token_retrieve->id);
    4849    }
  • ht-pay-jp-for-kintone/trunk/vendor/payjp/payjp-php/tests/TransferTest.php

    r2149911 r3190331  
    88    {
    99        self::authorizeFromEnv();
    10        
    11         $transfers = Transfer::all(
    12             array(
    13                 'limit' => 3,
    14                 'offset' => 0
    15             )
    16         );
     10
     11        $transfers = Transfer::all([
     12            'limit' => 3,
     13            'offset' => 0
     14        ]);
    1715
    1816        if (count($transfers['data'])) {
     
    2119        }
    2220    }
    23    
     21
    2422    public function testAllCharge()
    2523    {
    2624        self::authorizeFromEnv();
    27    
    28         $transfers = Transfer::all(
    29             array(
     25
     26        $transfers = Transfer::all([
     27            'limit' => 3,
     28            'offset' => 0
     29        ]);
     30
     31        if (count($transfers['data'])) {
     32            $transfer = Transfer::retrieve($transfers['data'][0]->id);
     33            $charges = $transfer->charges->all([
    3034                'limit' => 3,
    3135                'offset' => 0
    32             )
    33         );
    34    
    35         if (count($transfers['data'])) {
    36             $transfer = Transfer::retrieve($transfers['data'][0]->id);
    37             $charges = $transfer->charges->all(
    38                 array(
    39                     'limit' => 3,
    40                     'offset' => 0
    41                 )
    42             );
     36            ]);
     37            $this->markTestSkipped('Should be changed to mock.');
     38            // $this->assertTrue(count($charges['data']) > 0);
    4339        }
    4440    }
Note: See TracChangeset for help on using the changeset viewer.