<meta charset="utf-8"> <title>Sample Page</title> <meta name="author" content="Yuki Matsukura"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <pre> <?php require '../../vendor/autoload.php'; try { $spike = new \Issei\Spike\Spike(trim(file_get_contents('../../secret.key'))); $id = $_GET['id']; // capture $charge = $spike->getCharge($id); $charge = $spike->capture($charge); var_dump($charge); } catch (Exception $e) { // エラー var_dump($e); } ?> </pre> </body> </html>
<?php require __DIR__ . '/../../vendor/autoload.php'; require __DIR__ . '/definition.php'; $spike = new \Issei\Spike\Spike(API_SECRET); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo '<h1>Retrieve the token</h1>'; $req = new \Issei\Spike\TokenRequest(); $req->setCardNumber('4444333322221111')->setExpirationMonth(12)->setExpirationYear(19)->setHolderName('Taro Spike')->setSecurityCode('123')->setCurrency('JPY')->setEmail('*****@*****.**'); dump($token = $spike->requestToken($req)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo '<h1>New charge</h1>'; $req = new \Issei\Spike\ChargeRequest(); $req->setAmount(100, 'JPY')->setToken($token)->addProduct((new \Issei\Spike\Model\Product(uniqid('product-', true)))->setTitle('Title')->setDescription('Description')->setCount(1)->setPrice(100, 'USD')->setLanguage('JA')); dump($spike->charge($req)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo '<h1>Retrieve charges</h1>'; dump($charges = $spike->getCharges(5)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo '<h1>Retrieve a charge</h1>'; dump($charge = $spike->getCharge($charges[0])); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo '<h1>Refund the charge</h1>'; dump($spike->refund($charge));