Skip to content

BackupTek/sparrow-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SparrowOne SDK [PHP]

This repository contains a full PHP client implementation for the following APIs:

  • SPARROW Merchant Public API (as SparrowMerchantClient)
  • SPARROW Merchant Transaction Query API (as SparrowMerchantClient)
  • SPARROW Merchant Settlement API (as SparrowMerchantClient)
  • SPARROW Services API (as SparrowServiceClient)

Pre-requisites

1. Library requirements

  • PHP >= 7.0
  • Composer
  • Laravel >= 5.3 (optional)

2. Obtain a Sparrow merchant key

⚠ Warning ⚠

In order to avoid the risk of running live transactions and payments while testing, it is vital to obtain and use a merchant key associated with a merchant account that has its integration mode set to either Test or Development.

3. Installation

The library is installed via Composer.

First, add the library as a dependency to your composer.json file:

{
    "repositories": [
        {
            "type": "git",
            "url" : "https://bitbucket.org/digitalequationteam/sparrow-sdk-php.git"
        }
    ],
    "require": {
        "digitalequation/sparrow-sdk": "~1.0"
    }
}

Afterwards, update your project dependencies:

$ composer update

4. Laravel integration

Once Composer has installed the package, add this line of code to the providers array located in your config/app.php file:

SparrowSDK\Laravel\SDKServiceProvider::class,

Then add these lines to the aliases array:

'SparrowMerchant' => SparrowSDK\Laravel\Facades\SparrowMerchant::class,
'SparrowService'  => SparrowSDK\Laravel\Facades\SparrowService::class,

5. Laravel configuration publishing

Run php artisan vendor:publish to publish this package's configuration. Afterwards you can edit config/sparrow-sdk.php to suit your needs.

By default, the configuration file makes use of the SPARROW_MKEY env variable. If this variable is not set, then the Facade instance will be created with no attached merchant key.

[SparrowMerchantClient]

Creating a new instance

// 1. Import the merchant client class
use SparrowSDK\SparrowMerchantClient;

// 2A. Blank instancing, add merchant key later
$sparrowMC = new SparrowMerchantClient;
$sparrowMC->setMerchantKey('mmmmmmmmmmmmmmmmmmmmmmmm');

// 2B. Instancing with a merchant key
$sparrowMC = new SparrowMerchantClient('mmmmmmmmmmmmmmmmmmmmmmmm');

// 3. Get currently attached merchant key
$mkey = $sparrowMC->getMerchantKey();

// 4. Set user authentication token
$sparrowMC->setAuthToken('aaaaaaaaaaaaaaaaaaaaaaaa');

// 5. Get currently attached auth token
$authToken = $sparrowMC->getAuthToken();

Methods

  • ->auth
    • ->getToken($username, $password) - This action is used to obtain an authentication token for the specified user
  • ->terminal
    • ->settle() - This action is used to settle all transactions for the specified account which require settlement. [requires an attached merchant key] [requires an attached auth token]
  • ->transaction
    • ->getAll($fields = []) - This action is used to retrieve a list of transactions. [requires an attached auth token]
    • ->getDetails($transactionId) - This action is used to retrieve details about a particular transaction. [requires an attached auth token]

[SparrowServiceClient]

Creating a new instance

// 1. Import the service client class
use SparrowSDK\SparrowServiceClient;

// 2A. Blank instancing, add merchant key later
$sparrowSC = new SparrowServiceClient;
$sparrowSC->setMerchantKey('mmmmmmmmmmmmmmmmmmmmmmmm');

// 2B. Instancing with a merchant key
$sparrowSC = new SparrowServiceClient('mmmmmmmmmmmmmmmmmmmmmmmm');

// 3. Get currently attached merchant key
$mkey = $sparrowSC->getMerchantKey();

Methods

  • ->airline
    • ->passengerSale($fields) - Not implemented !
  • ->authorization
    • ->simple($fields)
    • ->verifyAccount($fields)
  • ->balance
    • ->inquire($fields)
  • ->capture
    • ->simple($fields)
    • ->simpleOffline($fields)
    • ->advanced($fields, $optAmounts = [])
  • ->chargeback
    • ->markTransaction($fields)
  • ->credit
    • ->simpleAch($fields)
    • ->advancedAch($fields, $optAmounts = [])
    • ->simpleEcheck($fields)
    • ->advancedEcheck($fields, $optAmounts = [])
    • ->simpleEwallet($fields)
  • ->customField
    • ->decrypt($fields)
  • ->invoice
    • ->create($fields, $invoiceItems = [])
    • ->update($fields, $invoiceItems = [])
    • ->get($fields)
    • ->cancel($fields)
    • ->cancelByCustomer($fields)
    • ->payWithCreditCard($fields)
    • ->payWithBankAccount($fields)
  • ->paymentPlan
    • ->add($fields, $sequences = [])
    • ->update($fields)
    • ->addSequence($fields, $sequences = [])
    • ->updateSequence($fields, $sequences = [])
    • ->deleteSequence($fields, $sequences = [])
    • ->delete($fields)
    • ->assignToCustomer($fields)
    • ->updateAssignment($fields)
    • ->cancelAssignment($fields)
  • ->refund
    • ->simpleCard($fields)
    • ->advancedCard($fields, $optAmounts = [])
    • ->simpleAch($fields)
    • ->advancedAch($fields, $optAmounts = [])
    • ->simpleEcheck($fields)
    • ->advancedEcheck($fields, $optAmounts = [])
  • ->sale
    • ->simpleCard($fields)
    • ->advancedCard($fields, $skus = [], $optAmounts = [])
    • ->simpleStarCard($fields)
    • ->advancedStarCard($fields, $skus = [])
    • ->simpleAch($fields)
    • ->advancedAch($fields, $optAmounts = [])
    • ->simpleEcheck($fields)
    • ->advancedEcheck($fields, $optAmounts = [])
    • ->simpleFiserv($fields) - Alias for ->simpleCard($fields)
    • ->advancedFiserv($fields, $optAmounts = []) - Alias for ->advancedCard($fields, [], $optAmounts)
    • ->simpleToken($fields)
  • ->vault
    • ->addCustomer($fields, $payTypes = [])
    • ->updateCustomer($fields)
    • ->addPaymentType($fields, $payTypes = [])
    • ->updatePaymentType($fields, $payTypes = [])
    • ->deletePaymentType($fields, $payTypes = [])
    • ->deleteCustomer($fields)
    • ->getCustomer($fields)
    • ->getPaymentType($fields)
    • ->decryptPaymentType($fields)
  • ->void
    • ->simple($fields)
    • ->advanced($fields)

Useful resources

Following is a list of reference API documentation:

Miscellaneous API documentation (possible future use):

Licensing

© Digital Equation 2017-2018

Any unauthorized use or distribution of this software is strictly prohibited!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages