2017 © Pedro Peláez
 

library spreedly

Spreedly API

image

tuurbo/spreedly

Spreedly API

  • Tuesday, September 19, 2017
  • by tuurbo
  • Repository
  • 6 Watchers
  • 13 Stars
  • 31,094 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 0 Open issues
  • 23 Versions
  • 10 % Grown

The README.md

changelog !! As of the 2.0 release the amount must be an integer as required by Spreedly. E.g., 1098 for \$10.98 !!, (*1)

Getting Started

Setup/Install

Install through Composer., (*2)

composer require tuurbo/spreedly

Laravel 4 or 5 Setup

Next, update app/config/app.php to include a reference to this package's service provider in the providers array and the facade in the aliases array., (*3)

'providers' => [
    ...
   'Tuurbo\Spreedly\SpreedlyServiceProvider'
]

'aliases' => [
    ...
    'Spreedly' => 'Tuurbo\Spreedly\SpreedlyFacade'
]

Login to your Spreedly account to retrieve your api credentials. You can set your default gateway once you've created your first gateway., (*4)

Add to app/config/services.php config file., (*5)

return [

    ...

    'spreedly' => [
        'key' => '', // (required) Environment key
        'secret' => '', // (required) Signing Secret
        'gateway' => '', // (required) Default gateway
        'timeout' => '', // (optional) Default 64 seconds (recommended by Spreedly)
        'connect_timeout' => '', // (optional) Default 10 seconds
    ]

];

Default Setup (Non Laravel)

$config = [
    'key' => '', // (required) Environment key
    'secret' => '', // (required) Signing Secret
    'gateway' => '', // (required) Default gateway
    'timeout' => '', // (optional) Default 64 seconds (recommended by Spreedly)
    'connect_timeout' => '', // (optional) Default 10 seconds
];

$spreedly = new Tuurbo\Spreedly\Spreedly($config);

// The amount must be an integer as per required by Spreedly. E.g., 1098 for $10.98.
$resp = $spreedly->payment($paymentToken)->purchase(1098);

Example response handling

// If the call to Spreedly is successful
if ($resp->success()) {
    return $resp->response();
    // $resp->transactionToken();
    // $resp->paymentToken();
    // $resp->message();
}

// If the call to Spreedly fails or payment declines
if ($resp->fails()) {

    // returns array
    return $resp->errors();

    // returns list of errors as a string
    return $resp->errors(true);
}

More Docs

Gateways

Payment Methods

Transactions

Quick list of all methods

NOTE: Many of the methods below return multiple tokens. Be sure when storing tokens, you store the correct ones for later use., (*6)

// Gateway calls.
Spreedly::gateway()->setup();
Spreedly::gateway()->all();
Spreedly::gateway()->show();
Spreedly::gateway()->create();
Spreedly::gateway()->disable();
Spreedly::gateway()->update();
Spreedly::gateway()->transactions();

// If using multiple gateways, you can set the gateway token before the payment call.
Spreedly::gateway()->payment()->purchase();
Spreedly::gateway()->payment()->authorize();

// Uses default gateway.
Spreedly::payment()->all();
Spreedly::payment()->create();
Spreedly::payment()->update();
Spreedly::payment()->disable();
Spreedly::payment()->retain();
Spreedly::payment()->recache();
Spreedly::payment()->store();
Spreedly::payment()->get();
Spreedly::payment()->transactions();
Spreedly::payment()->purchase();
Spreedly::payment()->authorize();
Spreedly::payment()->verify();
Spreedly::payment()->generalCredit();

// Transaction calls
Spreedly::transaction()->all();
Spreedly::transaction()->get();
Spreedly::transaction()->referencing();
Spreedly::transaction()->transcript();
Spreedly::transaction()->purchase();
Spreedly::transaction()->void();
Spreedly::transaction()->credit();
Spreedly::transaction()->capture();
Spreedly::transaction()->complete();

Development

Clone the repo and run npm install. This will composer install., (*7)

Testing, (*8)

Tests are in the spec directory. They are written with phpspec., (*9)

To run your tests, simply do npm test. If you don't want to use npm, that's fine, simply run vendor/bin/phpspec run, (*10)

Please ensure you have added proper test coverage for each Pull Request., (*11)

Changelog

2.4+

See releases page https://github.com/tuurbo/spreedly/releases, (*12)

2.3

  • added support for laravel 5.4

2.2

  • added ability to merge configs.

2.1

  • changed default timeout from 15 seconds to 64 seconds as recommended by Spreedly.
  • added timeout method to change timeout per api call. E.g., Spreedly::timeout(25)->payment()->purchase().
  • added new Tuurbo\Spreedly\Exceptions\TimeoutException for catching timeouts.

2.0

  • amount is no longer converted to cents.
    • the amount must be an integer as required by Spreedly. E.g., 1098 for \$10.98
  • switched from Spreedly xml api to json api.
  • renamed ->declined() method to ->message().

The Versions

19/09 2017

dev-master

9999999-dev

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

19/09 2017

2.3.1

2.3.1.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

04/02 2017

2.3.0

2.3.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

02/12 2016

2.2.0

2.2.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

26/04 2016

dev-receivers

dev-receivers

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

02/03 2016

2.1.1

2.1.1.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

18/02 2016

2.1.0

2.1.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

18/02 2016

2.0.0

2.0.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

29/01 2016

1.8.0

1.8.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

28/01 2016

1.7.0

1.7.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

28/01 2016

1.6.0

1.6.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

20/10 2015

1.5.0

1.5.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

16/10 2015

1.4.0

1.4.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

28/08 2015

1.3.2

1.3.2.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

03/08 2015

1.3.1

1.3.1.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

31/07 2015

1.3.0

1.3.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

28/07 2015

1.2.0

1.2.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

24/07 2015

1.1.0

1.1.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

10/07 2015

1.0.1

1.0.1.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

03/06 2015

1.0.0

1.0.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

17/03 2015

0.9.2

0.9.2.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

14/01 2015

0.9.1

0.9.1.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly

15/09 2014

0.9.0

0.9.0.0

Spreedly API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fraser

laravel payment credit card spreedly