2017 © Pedro Peláez
 

library sweetpay-php

sweetpay-php PHP Library

image

sweetpay/sweetpay-php

sweetpay-php PHP Library

  • Friday, August 5, 2016
  • by Akino76
  • Repository
  • 2 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SweetPay PHP bindings

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Composer

You can install the bindings via Composer. Run the following command:, (*2)

composer require sweetpay/sweetpay-php dev-master

go to to the sweetpay-php directory and run:, (*3)

composer install

this will create a vendor directory inside the src directory., (*4)

To use the bindings, use Composer's autoload:, (*5)

require_once('pathto/vendor/autoload.php');

Also recommended it to use the spl autoloader., (*6)

   /*Needed for loading the classes inside src*/
    function autoload($className)
    {
        $className = ltrim($className, '\\');
        $fileName  = '';
        $namespace = '';
        if ($lastNsPos = strrpos($className, '\\')) {
            $namespace = substr($className, 0, $lastNsPos);
            $className = substr($className, $lastNsPos + 1);
            $fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
        }
        $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

        require $fileName;
    }
    spl_autoload_register('autoload');

Requirements

PHP 5.4 and later., (*7)

Getting started

Set permission for src/logs directory as 777, using the terminal:, (*8)

    sudo chmod 777 logs

in this file all the debug information will be added using monolog/monolog., (*9)

Set up conditions


// The intital setup, some curl setup can be changed in this array $setup = array( "apiKey" => (string) "NNq7Rcnb8y8jGTsU", "stage" => (boolean) true, "DEFAULT_TIMEOUT" => (int ) 30 ); try { // run the setup \Sweetpay\CheckoutCond::setCondition($setup); } catch (Exception $e) { $input = array('line' => __LINE__, 'path' => __FILE__, 'input' => $setup); \Sweetpay\Helper::errorMessage($e, $input); // if any error, check stdout for any error message and logs/* var_dump(\Sweetpay\CheckoutCond::getApiKey()); } // end of try

Run a transaction

    $transactionData = array(
                'transactons' => array(
                    array('amount' => '100', 'currency' => 'SEK')  ,
                    array('amount' => '200', 'currency' => 'SEK')
                ),
                'country' => 'SE',
                'merchantId' => 'paylevo');

        try {
            $Check  = new \Sweetpay\CheckOut($transactionData);
            $vars   = $Check->getOutput()                ;

            // check the respons,
            var_dump($vars);

        } catch (Exception $e) {
            $input  = array('line'  => __LINE__,
                            'path'  => __FILE__,
                            'input' => $transactionData);
            \Sweetpay\Helper::errorMessage($e, $input);

        }

For a concreate and working exempel for both transactions and subscription see Test/* directory, (*10)

The Versions

05/08 2016

dev-master

9999999-dev https://github.com/sweetpay/

sweetpay-php PHP Library

  Sources   Download

MIT

The Requires

 

The Development Requires

by SweetPay

api payment processing sweetpay