2017 © Pedro Peláez
 

library spike-php

The client of https://spike.cc REST api for PHP.

image

issei-m/spike-php

The client of https://spike.cc REST api for PHP.

  • Sunday, November 26, 2017
  • by issei-m
  • Repository
  • 1 Watchers
  • 6 Stars
  • 1,191 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

Spike for PHP

[ABANDONED]

This project is already abandoned due to SPIKE payment service close, and you can no longer access to their api endpoint anymore., (*1)


Latest release: v1.0-BETA5, (*2)

The client of https://spike.cc REST api for PHP (5.4+, 7+, HHVM)., (*3)

Basic Usage

First, initialize the Spike object with your api secret key. It's the entry point for accessing the all api interfaces:, (*4)

$spike = new \Issei\Spike\Spike('your_api_secret_key');

Create a new charge

To create a new charge, you have to build a ChargeRequest object. It can be specified card token, amount, currency and some related products. Next, call charge() method with it. If charge succeeded this method will return the new Charge object generated by REST api:, (*5)

// The token's id is retrieved by SPIKE Checkout (client side script) usually.
$token = new \Issei\Spike\Model\Token('tok_xxxxxxxxxxxxxxxxxxxxxxxx');

$request = new \Issei\Spike\ChargeRequest();
$request
    ->setToken($token)
    ->setAmount(123.45, 'USD')
    ->setCapture(true) // If you set false, you can delay capturing.
;

$product = new \Issei\Spike\Model\Product('my-product-00001');
$product
    ->setTitle('Product Name')
    ->setDescription('Description of Product.')
    ->setPrice(123.45, 'USD')
    ->setLanguage('EN')
    ->setCount(3)
    ->setStock(97)
;

// The product can be added any times.
$request->addProduct($product);

/** @var $createdCharge \Issei\Spike\Model\Charge */
$createdCharge = $spike->charge($request);

Tips: You can pass the Token's id directly instead of generating the new Token object:, (*6)

$request->setToken('tok_xxxxxxxxxxxxxxxxxxxxxxxx');

NOTE: If you want to know how to get a card token, read Request a token section., (*7)

Find a charge

Call getCharge() method with charge id:, (*8)

/** @var $charge \Issei\Spike\Model\Charge */
$charge = $spike->getCharge('20150101-100000-xxxxxxxxxx');

Capture the charge

If you have a charge which has not been captured, you can use capture() method to capture it:, (*9)

/** @var $charge \Issei\Spike\Model\Charge */
$capturedCharge = $spike->capture($charge);

Refund the charge

Call refund() method with the Charge object that you want to refund:, (*10)

/** @var $charge \Issei\Spike\Model\Charge */
$refundedCharge = $spike->refund($charge);

Tips: You can pass the Charge's id directly instead of generating/retrieving the Charge object:, (*11)

$refundedCharge = $spike->refund('20150101-100000-xxxxxxxxxx');

Retrieve the all charges

Call getCharges() method. it returns an array containing the Charge objects., (*12)

/** @var $charges \Issei\Spike\Model\Charge[] */
$charges = $spike->getCharges();

Paging

You can specify the limit of number of records at 1st argument (10 records by default):, (*13)

$charges = $spike->getCharges(5);

If you pass a Charge object (or ID as a string directly) into 2nd argument, you can retrieve charges that older than (passed charge is NOT included to list):, (*14)

$nextCharges = $spike->getCharges(5, $charges[count($charges) - 1]);

At 3rd argument, you can also specify the charge (or ID as a string directly) object if you want to retrieve charges that newer than (passed charge is NOT included to list):, (*15)

$nextCharges = $spike->getCharges(5, $charges[count($charges) - 1], ...);

Request a token

If you have contracted with https://spike.cc to request a new token, you can get a new token by requestToken() method with TokenRequest:, (*16)

$request = new \Issei\Spike\TokenRequest();
$request
    ->setCardNumber('4444333322221111')
    ->setExpirationMonth(12)
    ->setExpirationYear(19)
    ->setHolderName('Taro Spike')
    ->setSecurityCode('123')
    ->setCurrency('JPY')
    ->setEmail('test@example.jp')
;

/** @var $charge \Issei\Spike\Model\Token */
$token = $spike->requestToken($request);

Of course, you can create a new charge with it:, (*17)

$request = new \Issei\Spike\ChargeRequest();
$request
    ->setToken($token)
    // ...
;

/** @var $charge \Issei\Spike\Model\Charge */
$charge = $spike->charge($request);

Find a token

Call getToken() method with token id:, (*18)

/** @var $token \Issei\Spike\Model\Token */
$token = $spike->getToken('tok_xxxxxxxxxxxxxxxxxxxxxxxx');

Installation

Use Composer to install the package:, (*19)

$ composer require issei-m/spike-php

Contributing

  1. Fork it
  2. Create your feature branch
  3. Commit your change and push it
  4. Create a new pull request

The Versions

26/11 2017

dev-master

9999999-dev

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.5

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc

22/11 2017

v1.0-BETA5

1.0.0.0-beta5

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.5

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc

22/12 2016

v1.0-BETA4

1.0.0.0-beta4

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc

14/05 2015

v1.0-BETA3

1.0.0.0-beta3

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc

29/03 2015

v1.0-BETA2

1.0.0.0-beta2

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc

16/01 2015

v1.0-BETA1

1.0.0.0-beta1

The client of https://spike.cc REST api for PHP.

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

by Issei Murasawa

rest payments spike spike.cc