Removed mollie API from vendor and added it to gitmodules

This commit is contained in:
Wouter van Os
2015-10-17 17:24:17 +02:00
parent 0098ad831e
commit a3855a3ee6
19 changed files with 5 additions and 5699 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "src/mollie/vendor/Mollie"]
path = src/mollie/vendor/Mollie
url = git@github.com:mollie/mollie-api-php.git

View File

@@ -5,7 +5,7 @@
* *
*/ */
require_once '../../../init.php'; require_once '../../../init.php';
require_once 'vendor/Mollie/API/Autoloader.php'; require_once 'vendor/Mollie/src/Mollie/API/Autoloader.php';
$whmcs->load_function('gateway'); $whmcs->load_function('gateway');
$whmcs->load_function('invoice'); $whmcs->load_function('invoice');

View File

@@ -1,6 +1,6 @@
<?php <?php
require_once 'vendor/Mollie/API/Autoloader.php'; require_once 'vendor/Mollie/src/Mollie/API/Autoloader.php';
function mollie_config() { function mollie_config() {
return array( return array(

View File

@@ -1,68 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Autoloader
{
/**
* @param string $class_name
*/
public static function autoload ($class_name)
{
if (strpos($class_name, "Mollie_") === 0)
{
$file_name = str_replace("_", "/", $class_name);
$file_name = realpath(dirname(__FILE__) . "/../../{$file_name}.php");
if ($file_name !== false)
{
require $file_name;
}
}
}
/**
* @return bool
*/
public static function register ()
{
return spl_autoload_register(array(__CLASS__, "autoload"));
}
/**
* @return bool
*/
public static function unregister ()
{
return spl_autoload_unregister(array(__CLASS__, "autoload"));
}
}
Mollie_API_Autoloader::register();

View File

@@ -1,306 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Client
{
/**
* Version of our client.
*/
const CLIENT_VERSION = "1.2.10";
/**
* Endpoint of the remote API.
*/
const API_ENDPOINT = "https://api.mollie.nl";
/**
* Version of the remote API.
*/
const API_VERSION = "v1";
const HTTP_GET = "GET";
const HTTP_POST = "POST";
const HTTP_DELETE = "DELETE";
/**
* @var string
*/
protected $api_endpoint = self::API_ENDPOINT;
/**
* RESTful Payments resource.
*
* @var Mollie_API_Resource_Payments
*/
public $payments;
/**
* RESTful Payments Refunds resource.
*
* @var Mollie_API_Resource_Payments_Refunds
*/
public $payments_refunds;
/**
* RESTful Issuers resource.
*
* @var Mollie_API_Resource_Issuers
*/
public $issuers;
/**
* RESTful Methods resource.
*
* @var Mollie_API_Resource_Methods
*/
public $methods;
/**
* @var string
*/
protected $api_key;
/**
* @var array
*/
protected $version_strings = array();
/**
* @var resource
*/
protected $ch;
/**
* @throws Mollie_API_Exception_IncompatiblePlatform
*/
public function __construct ()
{
$this->getCompatibilityChecker()
->checkCompatibility();
$this->payments = new Mollie_API_Resource_Payments($this);
$this->payments_refunds = new Mollie_API_Resource_Payments_Refunds($this);
$this->issuers = new Mollie_API_Resource_Issuers($this);
$this->methods = new Mollie_API_Resource_Methods($this);
$curl_version = curl_version();
$this->addVersionString("Mollie/" . self::CLIENT_VERSION);
$this->addVersionString("PHP/" . phpversion());
$this->addVersionString("cURL/" . $curl_version["version"]);
$this->addVersionString($curl_version["ssl_version"]);
}
/**
* @param string $url
*/
public function setApiEndpoint ($url)
{
$this->api_endpoint = rtrim(trim($url), '/');
}
/**
* @return string
*/
public function getApiEndpoint ()
{
return $this->api_endpoint;
}
/**
* @param string $api_key The Mollie API key, starting with 'test_' or 'live_'
* @throws Mollie_API_Exception
*/
public function setApiKey ($api_key)
{
$api_key = trim($api_key);
if (!preg_match('/^(live|test)_\w+$/', $api_key))
{
throw new Mollie_API_Exception("Invalid API key: '{$api_key}'. An API key must start with 'test_' or 'live_'.");
}
$this->api_key = $api_key;
}
/**
* @param string $version_string
*/
public function addVersionString ($version_string)
{
$this->version_strings[] = str_replace(array(" ", "\t", "\n", "\r"), '-', $version_string);
}
/**
* Perform an http call. This method is used by the resource specific classes. Please use the $payments property to
* perform operations on payments.
*
* @see $payments
* @see $isuers
*
* @param $http_method
* @param $api_method
* @param $http_body
*
* @return string
* @throws Mollie_API_Exception
*
* @codeCoverageIgnore
*/
public function performHttpCall ($http_method, $api_method, $http_body = NULL)
{
if (empty($this->api_key))
{
throw new Mollie_API_Exception("You have not set an API key. Please use setApiKey() to set the API key.");
}
if (empty($this->ch) || !function_exists("curl_reset"))
{
/*
* Initialize a cURL handle.
*/
$this->ch = curl_init();
}
else
{
/*
* Reset the earlier used cURL handle.
*/
curl_reset($this->ch);
}
$url = $this->api_endpoint . "/" . self::API_VERSION . "/" . $api_method;
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 10);
$user_agent = join(' ', $this->version_strings);
$request_headers = array(
"Accept: application/json",
"Authorization: Bearer {$this->api_key}",
"User-Agent: {$user_agent}",
"X-Mollie-Client-Info: " . php_uname(),
);
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $http_method);
if ($http_body !== NULL)
{
$request_headers[] = "Content-Type: application/json";
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $http_body);
}
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, TRUE);
/*
* On some servers, the list of installed certificates is outdated or not present at all (the ca-bundle.crt
* is not installed). So we tell cURL which certificates we trust.
*/
curl_setopt($this->ch, CURLOPT_CAINFO, realpath(dirname(__FILE__) . "/cacert.pem"));
$body = curl_exec($this->ch);
if (curl_errno($this->ch) == CURLE_SSL_CACERT || curl_errno($this->ch) == CURLE_SSL_PEER_CERTIFICATE || curl_errno($this->ch) == 77 /* CURLE_SSL_CACERT_BADFILE (constant not defined in PHP though) */)
{
if (strpos(curl_error($this->ch), "error setting certificate verify locations") !== FALSE)
{
/*
* Error setting CA-file. Could be missing, or there is a bug in OpenSSL with too long paths.
* We give up. Don't do any peer validations.
*
* @internal #MOL017891004
*/
array_shift($request_headers);
$request_headers[] = "X-Mollie-Debug: unable to use shipped root certificaties, no peer validation.";
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$body = curl_exec($this->ch);
}
}
if (strpos(curl_error($this->ch), "certificate subject name 'mollie.nl' does not match target host") !== FALSE)
{
/*
* On some servers, the wildcard SSL certificate is not processed correctly. This happens with OpenSSL 0.9.7
* from 2003.
*/
$request_headers[] = "X-Mollie-Debug: old OpenSSL found";
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
$body = curl_exec($this->ch);
}
if (curl_errno($this->ch))
{
$message = "Unable to communicate with Mollie (".curl_errno($this->ch)."): " . curl_error($this->ch) . ".";
curl_close($this->ch);
$this->ch = NULL;
throw new Mollie_API_Exception($message);
}
if (!function_exists("curl_reset"))
{
/*
* Keep it open if supported by PHP, else close the handle.
*/
curl_close($this->ch);
$this->ch = NULL;
}
return $body;
}
/**
* Close any cURL handles, if we have them.
*/
public function __destruct ()
{
if (is_resource($this->ch))
{
curl_close($this->ch);
}
}
/**
* @return Mollie_API_CompatibilityChecker
* @codeCoverageIgnore
*/
protected function getCompatibilityChecker ()
{
return new Mollie_API_CompatibilityChecker();
}
}

View File

@@ -1,158 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_CompatibilityChecker
{
/**
* @var string
*/
public static $MIN_PHP_VERSION = '5.2.0';
/**
* Used cURL functions
*
* @var array
*/
public static $REQUIRED_CURL_FUNCTIONS = array(
'curl_init',
'curl_setopt',
'curl_exec',
'curl_error',
'curl_errno',
'curl_close',
'curl_version',
);
/**
* @throws Mollie_API_Exception_IncompatiblePlatform
* @return void
*/
public function checkCompatibility ()
{
if (!$this->satisfiesPhpVersion())
{
throw new Mollie_API_Exception_IncompatiblePlatform(
"The client requires PHP version >= " . self::$MIN_PHP_VERSION . ", you have " . PHP_VERSION . ".",
Mollie_API_Exception_IncompatiblePlatform::INCOMPATIBLE_PHP_VERSION
);
}
if (!$this->satisfiesJsonExtension())
{
throw new Mollie_API_Exception_IncompatiblePlatform(
"PHP extension json is not enabled. Please make sure to enable 'json' in your PHP configuration.",
Mollie_API_Exception_IncompatiblePlatform::INCOMPATIBLE_JSON_EXTENSION
);
}
if (!$this->satisfiesCurlExtension())
{
throw new Mollie_API_Exception_IncompatiblePlatform(
"PHP extension cURL is not enabled. Please make sure to enable 'curl' in your PHP configuration.",
Mollie_API_Exception_IncompatiblePlatform::INCOMPATIBLE_CURL_EXTENSION
);
}
if (!$this->satisfiesCurlFunctions())
{
throw new Mollie_API_Exception_IncompatiblePlatform(
"This client requires the following cURL functions to be available: " . implode(', ', self::$REQUIRED_CURL_FUNCTIONS) . ". " .
"Please check that none of these functions are disabled in your PHP configuration.",
Mollie_API_Exception_IncompatiblePlatform::INCOMPATIBLE_CURL_FUNCTION
);
}
}
/**
* @return bool
* @codeCoverageIgnore
*/
public function satisfiesPhpVersion ()
{
return (bool) version_compare(PHP_VERSION, self::$MIN_PHP_VERSION, ">=");
}
/**
* @return bool
* @codeCoverageIgnore
*/
public function satisfiesJsonExtension ()
{
// Check by extension_loaded
if (function_exists('extension_loaded') && extension_loaded('json'))
{
return TRUE;
}
elseif (function_exists('json_encode'))
{
return TRUE;
}
return FALSE;
}
/**
* @return bool
* @codeCoverageIgnore
*/
public function satisfiesCurlExtension ()
{
// Check by extension_loaded
if (function_exists('extension_loaded') && extension_loaded('curl'))
{
return TRUE;
}
// Check by calling curl_version()
elseif (function_exists('curl_version') && curl_version())
{
return TRUE;
}
return FALSE;
}
/**
* @return bool
* @codeCoverageIgnore
*/
public function satisfiesCurlFunctions ()
{
foreach (self::$REQUIRED_CURL_FUNCTIONS as $curl_function)
{
if (!function_exists($curl_function))
{
return FALSE;
}
}
return TRUE;
}
}

View File

@@ -1,54 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Exception extends Exception
{
/**
* @var string
*/
protected $_field;
/**
* @return string
*/
public function getField ()
{
return $this->_field;
}
/**
* @param string $field
*/
public function setField ($field)
{
$this->_field = (string) $field;
}
}

View File

@@ -1,38 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Exception_IncompatiblePlatform extends Mollie_API_Exception
{
const INCOMPATIBLE_PHP_VERSION = 1000;
const INCOMPATIBLE_CURL_EXTENSION = 2000;
const INCOMPATIBLE_CURL_FUNCTION = 2500;
const INCOMPATIBLE_JSON_EXTENSION = 3000;
}

View File

@@ -1,55 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Object_Issuer
{
/**
* Id of the issuer.
*
* @var string
*/
public $id;
/**
* Name of the issuer.
*
* @var string
*/
public $name;
/**
* The payment method this issuer belongs to.
*
* @see Mollie_API_Object_Method
* @var string
*/
public $method;
}

View File

@@ -1,54 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Object_List extends ArrayObject
{
/**
* Total number of available objects on the Mollie platform.
*
* @var int
*/
public $totalCount;
/**
* Numeric offset from which this list of object was created.
*
* @var int
*/
public $offset;
/**
* Total number of retrieved objects.
*
* @var int
*/
public $count;
}

View File

@@ -1,137 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Object_Method
{
/**
* @link https://mollie.com/ideal
*/
const IDEAL = "ideal";
/**
* @link https://mollie.com/paysafecard
*/
const PAYSAFECARD = "paysafecard";
/**
* @link https://mollie.com/creditcard
*/
const CREDITCARD = "creditcard";
/**
* @link https://mollie.com/mistercash
*/
const MISTERCASH = "mistercash";
/**
* @link https://mollie.com/sofort
*/
const SOFORT = "sofort";
/**
* @link https://mollie.com/banktransfer
*/
const BANKTRANSFER = "banktransfer";
/**
* @link https://mollie.com/directdebit
*/
const DIRECTDEBIT = "directdebit";
/**
* @link https://mollie.com/paypal
*/
const PAYPAL = "paypal";
/**
* @link https://mollie.com/bitcoin
*/
const BITCOIN = "bitcoin";
/**
* @link https://mollie.com/belfiusdirectnet
*/
const BELFIUS = "belfius";
/**
* Id of the payment method.
*
* @var string
*/
public $id;
/**
* More legible description of the payment method.
*
* @var string
*/
public $description;
/**
* The $amount->minimum and $amount->maximum supported by this method and the used API key.
*
* @var object
*/
public $amount;
/**
* The $image->normal and $image->bigger to display the payment method logo.
*
* @var object
*/
public $image;
/**
* @return float|null
*/
public function getMinimumAmount ()
{
if (empty($this->amount))
{
return NULL;
}
return (float) $this->amount->minimum;
}
/**
* @return float|null
*/
public function getMaximumAmount ()
{
if (empty($this->amount))
{
return NULL;
}
return (float) $this->amount->maximum;
}
}

View File

@@ -1,345 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Object_Payment
{
/**
* The payment has just been created, no action has happened on it yet.
*/
const STATUS_OPEN = "open";
/**
* The payment has just been started, no final confirmation yet.
*/
const STATUS_PENDING = "pending";
/**
* The customer has cancelled the payment.
*/
const STATUS_CANCELLED = "cancelled";
/**
* The payment has expired due to inaction of the customer.
*/
const STATUS_EXPIRED = "expired";
/**
* The payment has been paid.
*/
const STATUS_PAID = "paid";
/**
* The payment has been paidout and the money has been transferred to the bank account of the merchant.
*/
const STATUS_PAIDOUT = "paidout";
/**
* The payment has been refunded, either through Mollie or through the payment provider (in the case of PayPal).
*/
const STATUS_REFUNDED = "refunded";
/**
* Some payment methods provide your customers with the ability to dispute payments which could
* ultimately lead to a chargeback.
*/
const STATUS_CHARGED_BACK = "charged_back";
/**
* Id of the payment (on the Mollie platform).
*
* @var string
*/
public $id;
/**
* Mode of the payment, either "live" or "test" depending on the API Key that was used.
*
* @var string
*/
public $mode;
/**
* The amount of the payment in EURO with 2 decimals.
*
* @var float
*/
public $amount;
/**
* The amount of the payment that has been refunded to the consumer, in EURO with 2 decimals. This field will be
* NULL if the payment can not be refunded.
*
* @var float|null
*/
public $amountRefunded;
/**
* The amount of a refunded payment that can still be refunded, in EURO with 2 decimals. This field will be
* NULL if the payment can not be refunded.
*
* For some payment methods this amount can be higher than the payment amount. This is possible to reimburse
* the costs for a return shipment to your customer for example.
*
* @var float|null
*/
public $amountRemaining;
/**
* Description of the payment that is shown to the customer during the payment, and
* possibly on the bank or credit card statement.
*
* @var string
*/
public $description;
/**
* If method is empty/null, the customer can pick his/her preferred payment method.
*
* @see Mollie_API_Object_Method
* @var string|null
*/
public $method;
/**
* The status of the payment.
*
* @var string
*/
public $status = self::STATUS_OPEN;
/**
* The period after which the payment will expire in ISO-8601 format.
*
* @example P12DT11H30M45S (12 days, 11 hours, 30 minutes and 45 seconds)
* @var string|null
*/
public $expiryPeriod;
/**
* Date and time the payment was created in ISO-8601 format.
*
* @example "2013-12-25T10:30:54.0Z"
* @var string|null
*/
public $createdDatetime;
/**
* Date and time the payment was paid in ISO-8601 format.
*
* @var string|null
*/
public $paidDatetime;
/**
* Date and time the payment was cancelled in ISO-8601 format.
*
* @var string|null
*/
public $cancelledDatetime;
/**
* Date and time the payment was cancelled in ISO-8601 format.
*
* @var string|null
*/
public $expiredDatetime;
/**
* The profile ID this payment belongs to.
*
* @example pfl_xH2kP6Nc6X
* @var string
*/
public $profileId;
/**
* The locale used for this payment.
*
* @var string|null
*/
public $locale;
/**
* During creation of the payment you can set custom metadata that is stored with
* the payment, and given back whenever you retrieve that payment.
*
* @var object|mixed|null
*/
public $metadata;
/**
* Details of a successfully paid payment are set here. For example, the iDEAL
* payment method will set $details->consumerName and $details->consumerAccount.
*
* @var object
*/
public $details;
/**
* @var object
*/
public $links;
/**
* Is this payment cancelled?
*
* @return bool
*/
public function isCancelled ()
{
return $this->status == self::STATUS_CANCELLED;
}
/**
* Is this payment expired?
*
* @return bool
*/
public function isExpired ()
{
return $this->status == self::STATUS_EXPIRED;
}
/**
* Is this payment still open / ongoing?
*
* @return bool
*/
public function isOpen ()
{
return $this->status == self::STATUS_OPEN;
}
/**
* Is this payment pending?
*
* @return bool
*/
public function isPending ()
{
return $this->status == self::STATUS_PENDING;
}
/**
* Is this payment paid for?
*
* @return bool
*/
public function isPaid ()
{
return !empty($this->paidDatetime);
}
/**
* Is this payment (partially) refunded?
*
* @return bool
*/
public function isRefunded ()
{
return $this->status == self::STATUS_REFUNDED;
}
/**
* Is this payment charged back?
*
* @return bool
*/
public function isChargedBack ()
{
return $this->status == self::STATUS_CHARGED_BACK;
}
/**
* Get the payment URL where the customer can complete the payment.
*
* @return string|null
*/
public function getPaymentUrl ()
{
if (empty($this->links->paymentUrl))
{
return NULL;
}
return $this->links->paymentUrl;
}
/**
* @return bool
*/
public function canBeRefunded ()
{
return $this->amountRemaining !== NULL;
}
/**
* @return bool
*/
public function canBePartiallyRefunded ()
{
return $this->canBeRefunded() && $this->method !== Mollie_API_Object_Method::CREDITCARD;
}
/**
* Get the amount that is already refunded
*
* @return float
*/
public function getAmountRefunded ()
{
if ($this->amountRefunded)
{
return floatval($this->amountRefunded);
}
return 0;
}
/**
* Get the remaining amount that can be refunded. For some payment methods this amount can be higher than
* the payment amount. This is possible to reimburse the costs for a return shipment to your customer for example.
*
* @return float
*/
public function getAmountRemaining ()
{
if ($this->amountRemaining)
{
return floatval($this->amountRemaining);
}
return 0;
}
}

View File

@@ -1,113 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
class Mollie_API_Object_Payment_Refund
{
/**
* The refund will be send to the bank on the next business day. You can still cancel the refund.
*/
const STATUS_PENDING = 'pending';
/**
* The refund has been sent to the bank. The refund amount will be transferred to the consumer account as soon as possible.
*/
const STATUS_PROCESSING = 'processing';
/**
* The refund amount has been transferred to the consumer.
*/
const STATUS_REFUNDED = 'refunded';
/**
* Id of the payment method.
*
* @var string
*/
public $id;
/**
* The $amount that was refunded.
*
* @var float
*/
public $amount;
/**
* The payment that was refunded.
*
* @var Mollie_API_Object_Payment
*/
public $payment;
/**
* Date and time the payment was cancelled in ISO-8601 format.
*
* @var string|null
*/
public $refundedDatetime;
/**
* The refund status
*
* @var string
*/
public $status;
/**
* Is this refund pending?
*
* @return bool
*/
public function isPending ()
{
return $this->status == self::STATUS_PENDING;
}
/**
* Is this refund processing?
*
* @return bool
*/
public function isProcessing ()
{
return $this->status == self::STATUS_PROCESSING;
}
/**
* Is this refund transferred to consumer?
*
* @return bool
*/
public function isTransferred ()
{
return $this->status == self::STATUS_REFUNDED;
}
}

View File

@@ -1,250 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*/
abstract class Mollie_API_Resource_Base
{
const REST_CREATE = Mollie_API_Client::HTTP_POST;
const REST_UPDATE = Mollie_API_Client::HTTP_POST;
const REST_READ = Mollie_API_Client::HTTP_GET;
const REST_LIST = Mollie_API_Client::HTTP_GET;
const REST_DELETE = Mollie_API_Client::HTTP_DELETE;
/**
* Default number of objects to retrieve when listing all objects.
*/
const DEFAULT_LIMIT = 50;
/**
* @var Mollie_API_Client
*/
protected $api;
/**
* @param Mollie_API_Client $api
*/
public function __construct(Mollie_API_Client $api)
{
$this->api = $api;
}
/**
* @return string
*/
protected function getResourceName ()
{
$class_parts = explode("_", get_class($this));
return strtolower(end($class_parts));
}
/**
* @param $rest_resource
* @param $body
*
* @return object
*/
private function rest_create($rest_resource, $body)
{
$result = $this->performApiCall(self::REST_CREATE, $rest_resource, $body);
return $this->copy($result, $this->getResourceObject($rest_resource));
}
/**
* Retrieves a single object from the REST API.
*
* @param string $rest_resource Resource name.
* @param string $id Id of the object to retrieve.
* @throws Mollie_API_Exception
* @return object
*/
private function rest_read ($rest_resource, $id)
{
if (empty($id))
{
throw new Mollie_API_Exception("Invalid resource id.");
}
$id = urlencode($id);
$result = $this->performApiCall(self::REST_READ, "{$rest_resource}/{$id}");
return $this->copy($result, $this->getResourceObject($rest_resource));
}
/**
* Get a collection of objects from the REST API.
*
* @param $rest_resource
* @param int $offset
* @param int $limit
* @param array $options
*
* @return Mollie_API_Object_List
*/
private function rest_list($rest_resource, $offset = 0, $limit = self::DEFAULT_LIMIT, array $options = array())
{
$options = array_merge(array("offset" => $offset, "count" => $limit), $options);
$api_path = $rest_resource . "?" . http_build_query($options, "", "&"); /* Force & because of some PHP 5.3 defaults */
$result = $this->performApiCall(self::REST_LIST, $api_path);
/** @var Mollie_API_Object_List $collection */
$collection = $this->copy($result, new Mollie_API_Object_List);
foreach ($result->data as $data_result)
{
$collection[] = $this->copy($data_result, $this->getResourceObject());
}
return $collection;
}
/**
* Copy the results received from the API into the PHP objects that we use.
*
* @param object $api_result
* @param object $object
*
* @return object
*/
protected function copy($api_result, $object)
{
foreach ($api_result as $property => $value)
{
if (property_exists(get_class($object), $property))
{
$object->$property = $value;
}
}
return $object;
}
/**
* Get the object that is used by this API. Every API uses one type of object.
*
* @return object
*/
abstract protected function getResourceObject();
/**
* Create a resource with the remote API.
*
* @param array $data An array containing details on the resource. Fields supported depend on the resource created.
*
* @throws Mollie_API_Exception
* @return object
*/
public function create(array $data = array())
{
$encoded = json_encode($data);
if (version_compare(phpversion(), "5.3.0", ">="))
{
if (json_last_error() != JSON_ERROR_NONE)
{
throw new Mollie_API_Exception("Error encoding parameters into JSON: '" . json_last_error() . "'.");
}
}
else
{
if ($encoded === FALSE)
{
throw new Mollie_API_Exception("Error encoding parameters into JSON.");
}
}
return $this->rest_create($this->getResourceName(), $encoded);
}
/**
* Retrieve information on a single resource from Mollie.
*
* Will throw a Mollie_API_Exception if the resource cannot be found.
*
* @param string $resource_id
*
* @throws Mollie_API_Exception
* @return object
*/
public function get($resource_id)
{
return $this->rest_read($this->getResourceName(), $resource_id);
}
/**
* Retrieve all objects of a certain resource.
*
* @param int $offset
* @param int $limit
* @param array $options
*
* @return Mollie_API_Object_List
*/
public function all ($offset = 0, $limit = 0, array $options = array())
{
return $this->rest_list($this->getResourceName(), $offset, $limit, $options);
}
/**
* Perform an API call, and interpret the results and convert them to correct objects.
*
* @param $http_method
* @param $api_method
* @param null $http_body
*
* @return object
* @throws Mollie_API_Exception
*/
protected function performApiCall($http_method, $api_method, $http_body = NULL)
{
$body = $this->api->performHttpCall($http_method, $api_method, $http_body);
if (!($object = @json_decode($body)))
{
throw new Mollie_API_Exception("Unable to decode Mollie response: '{$body}'.");
}
if (!empty($object->error))
{
$exception = new Mollie_API_Exception("Error executing API call ({$object->error->type}): {$object->error->message}.");
if (!empty($object->error->field))
{
$exception->setField($object->error->field);
}
throw $exception;
}
return $object;
}
}

View File

@@ -1,44 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*
* @method Mollie_API_Object_Issuer[]|Mollie_API_Object_List all($offset = 0, $limit = 0)
* @method Mollie_API_Object_Issuer get($id)
*/
class Mollie_API_Resource_Issuers extends Mollie_API_Resource_Base
{
/**
* @return Mollie_API_Object_Issuer
*/
protected function getResourceObject ()
{
return new Mollie_API_Object_Issuer;
}
}

View File

@@ -1,44 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*
* @method Mollie_API_Object_Method[]|Mollie_API_Object_List all($offset = 0, $limit = 0)
* @method Mollie_API_Object_Method get($id)
*/
class Mollie_API_Resource_Methods extends Mollie_API_Resource_Base
{
/**
* @return Mollie_API_Object_Method
*/
protected function getResourceObject ()
{
return new Mollie_API_Object_Method;
}
}

View File

@@ -1,102 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*
* @method Mollie_API_Object_Payment[]|Mollie_API_Object_List all($offset = 0, $limit = 0)
* @method Mollie_API_Object_Payment create(array $data)
*/
class Mollie_API_Resource_Payments extends Mollie_API_Resource_Base
{
/**
* @var string
*/
const RESOURCE_ID_PREFIX = 'tr_';
/**
* @return Mollie_API_Object_Payment
*/
protected function getResourceObject ()
{
return new Mollie_API_Object_Payment;
}
/**
* Retrieve a single payment from Mollie.
*
* Will throw a Mollie_API_Exception if the payment id is invalid or the resource cannot be found.
*
* @param string $payment_id
*
* @throws Mollie_API_Exception
* @return Mollie_API_Object_Payment
*/
public function get($payment_id)
{
if (empty($payment_id) || strpos($payment_id, self::RESOURCE_ID_PREFIX) !== 0)
{
throw new Mollie_API_Exception("Invalid payment ID: '{$payment_id}'. A payment ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
}
return parent::get($payment_id);
}
/**
* @param Mollie_API_Object_Payment $payment
* @param float|NULL $amount Amount to refund, or NULL to refund full amount.
* @return Mollie_API_Object_Payment_Refund
*/
public function refund (Mollie_API_Object_Payment $payment, $amount = NULL)
{
$resource = "{$this->getResourceName()}/" . urlencode($payment->id) . "/refunds";
$body = NULL;
if ($amount)
{
$body = json_encode(
array("amount" => $amount)
);
}
$result = $this->performApiCall(self::REST_CREATE, $resource, $body);
/*
* Update the payment with the new properties that we got from the refund.
*/
if (!empty($result->payment))
{
foreach ($result->payment as $payment_key => $payment_value)
{
$payment->{$payment_key} = $payment_value;
}
}
return $this->copy($result, new Mollie_API_Object_Payment_Refund);
}
}

View File

@@ -1,69 +0,0 @@
<?php
/**
* Copyright (c) 2013, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php
* @author Mollie B.V. <info@mollie.com>
* @copyright Mollie B.V.
* @link https://www.mollie.com
*
* @method Mollie_API_Object_Payment_Refund[]|Mollie_API_Object_List all($offset = 0, $limit = 0)
* @method Mollie_API_Object_Payment_Refund get($resource_id)
*/
class Mollie_API_Resource_Payments_Refunds extends Mollie_API_Resource_Base
{
/**
* @var string
*/
private $payment_id;
/**
* @return Mollie_API_Object_Method
*/
protected function getResourceObject ()
{
return new Mollie_API_Object_Payment_Refund;
}
/**
* @return string
*/
protected function getResourceName ()
{
return "payments/" . urlencode($this->payment_id) . "/refunds";
}
/**
* Set the resource to use a certain payment. Use this method before performing a get() or all() call.
*
* @param Mollie_API_Object_Payment $payment
* @return self
*/
public function with(Mollie_API_Object_Payment $payment)
{
$this->payment_id = $payment->id;
return $this;
}
}

File diff suppressed because it is too large Load Diff