Ejemplo n.º 1
0
    <head>
        <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'];
    // キャンセル
    $charge = $spike->refund($id);
    var_dump($charge);
} catch (Exception $e) {
    // エラー
    var_dump($e);
}
?>

</pre>
    </body>
    </html>
Ejemplo n.º 2
0
<?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));
Ejemplo n.º 3
0
    $year = $_POST['year'];
    $cvc = $_POST['cvc'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $request = new \Issei\Spike\TokenRequest();
    $request->setCardNumber($card_number)->setExpirationMonth($month)->setExpirationYear($year)->setHolderName($name)->setSecurityCode($cvc)->setCurrency('JPY')->setEmail($email);
    $token = $spike->requestToken($request);
    // 課金を作成
    $request = new \Issei\Spike\ChargeRequest();
    $request->setToken($token)->setAmount(666, 'JPY')->setCapture(false);
    $product = new \Issei\Spike\Model\Product('my-product-00001');
    $product->setTitle('Product Name')->setDescription('Description of Product.')->setPrice(333, 'JPY')->setLanguage('JA')->setCount(2)->setStock(97);
    $request->addProduct($product);
    $charge = $spike->charge($request);
    var_dump($charge);
    // 課金を確定
    $charge = $spike->capture($charge);
    var_dump($charge);
    // 課金を取り消し
    $response = $spike->refund($charge);
    var_dump($response);
} catch (Exception $e) {
    // エラー
    var_dump($e);
}
?>

</pre>
    </body>
    </html>