Example #1
0
          <a class="navbar-brand" href="../">SPIKE API demo</a>
        </div>
      </div>
    </div>

    <div class="container">

      <div class="starter-template">
        <h1>SPIKE Charges demo</h1>


<?php 
require '../../vendor/autoload.php';
try {
    $spike = new \Issei\Spike\Spike(trim(file_get_contents('../../secret.key')));
    $charges = $spike->getCharges($pages = 100);
    foreach ($charges as $charge) {
        print sprintf("<h2>%s</h2>", $charge->getId());
        print '<div class="row">';
        print '<div class="col-sm-6">';
        print sprintf('%s %s', $charge->getAmount()->getCurrency(), number_format($charge->getAmount()->getAmount()));
        print '<br>';
        print $charge->getCreated()->format('Y-m-d H:i:s');
        print '</div>';
        print '<div class="col-sm-6">';
        if ($charge->isPaid() && !$charge->isCaptured()) {
            print sprintf('<a href="capture.php?id=%s" class="btn btn-success">Capture</a> ', $charge->getId());
            print sprintf('<a href="refund.php?id=%s" class="btn btn-warning">Auth cancel</a> ', $charge->getId());
        }
        if ($charge->isCaptured()) {
            if (!$charge->isRefunded()) {
Example #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));