Add Mollie API integration and webhook for software upgrade payments
- Introduced the `CaBundle.php` class for managing CA certificates. - Updated `installed.json` and `installed.php` to include the new `composer/ca-bundle` dependency. - Added `platform_check.php` to enforce PHP version requirements. - Created `initialize.php` for initializing the Mollie API client with the API key. - Implemented `webhook_mollie.php` to handle webhook callbacks for software upgrade payments, including transaction status updates and invoice generation. - Integrated DomPDF for generating invoices and sending them via email.
This commit is contained in:
74
assets/mollie/src/Endpoints/BalanceEndpoint.php
Normal file
74
assets/mollie/src/Endpoints/BalanceEndpoint.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Balance;
|
||||
use Mollie\Api\Resources\BalanceCollection;
|
||||
use Mollie\Api\Resources\BaseCollection;
|
||||
class BalanceEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const RESOURCE_ID_PREFIX = 'bal_';
|
||||
protected $resourcePath = "balances";
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\BalanceCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Balance($this->client);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single balance from Mollie.
|
||||
*
|
||||
* Will throw an ApiException if the balance id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $balanceId
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\Balance|\Mollie\Api\Resources\BaseResource
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get(string $balanceId, array $parameters = [])
|
||||
{
|
||||
if (empty($balanceId) || \strpos($balanceId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid balance ID: '{$balanceId}'. A balance ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_read($balanceId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve the primary balance from Mollie.
|
||||
*
|
||||
* Will throw an ApiException if the balance id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\Balance|\Mollie\Api\Resources\BaseResource
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function primary(array $parameters = [])
|
||||
{
|
||||
return parent::rest_read("primary", $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Balances from Mollie.
|
||||
*
|
||||
* @param string|null $from The first Balance ID you want to include in your list.
|
||||
* @param int|null $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return BaseCollection|BalanceCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function page(?string $from = null, ?int $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
57
assets/mollie/src/Endpoints/BalanceReportEndpoint.php
Normal file
57
assets/mollie/src/Endpoints/BalanceReportEndpoint.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Balance;
|
||||
use Mollie\Api\Resources\BalanceReport;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class BalanceReportEndpoint extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "balances_report";
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\BalanceReport($this->client);
|
||||
}
|
||||
/**
|
||||
* Retrieve a balance report for the provided balance id and parameters.
|
||||
*
|
||||
* @param string $balanceId
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId(string $balanceId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $balanceId;
|
||||
$result = $this->client->performHttpCall(self::REST_READ, $this->getResourcePath() . $this->buildQueryString($parameters));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* Retrieve the primary balance.
|
||||
* This is the balance of your account’s primary currency, where all payments are settled to by default.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForPrimary(array $parameters = [])
|
||||
{
|
||||
return $this->getForId("primary", $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve a balance report for the provided balance resource and parameters.
|
||||
*
|
||||
* @param \Mollie\Api\Resources\Balance $balance
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Balance $balance, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($balance->id, $parameters);
|
||||
}
|
||||
}
|
||||
73
assets/mollie/src/Endpoints/BalanceTransactionEndpoint.php
Normal file
73
assets/mollie/src/Endpoints/BalanceTransactionEndpoint.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Balance;
|
||||
use Mollie\Api\Resources\BalanceTransaction;
|
||||
use Mollie\Api\Resources\BalanceTransactionCollection;
|
||||
class BalanceTransactionEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const RESOURCE_ID_PREFIX = 'baltr_';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resourcePath = "balances_transactions";
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\BalanceTransactionCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\BalanceTransaction($this->client);
|
||||
}
|
||||
/**
|
||||
* List the transactions for a specific Balance.
|
||||
*
|
||||
* @param Balance $balance
|
||||
* @param array $parameters
|
||||
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
|
||||
*
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Balance $balance, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($balance->id, $parameters);
|
||||
}
|
||||
/**
|
||||
* List the transactions for a specific Balance ID.
|
||||
*
|
||||
* @param string $balanceId
|
||||
* @param array $parameters
|
||||
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
|
||||
*
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId(string $balanceId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $balanceId;
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
/**
|
||||
* List the transactions for the primary Balance.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
|
||||
*
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForPrimary(array $parameters = [])
|
||||
{
|
||||
$this->parentId = "primary";
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
46
assets/mollie/src/Endpoints/ChargebackEndpoint.php
Normal file
46
assets/mollie/src/Endpoints/ChargebackEndpoint.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Chargeback;
|
||||
use Mollie\Api\Resources\ChargebackCollection;
|
||||
class ChargebackEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "chargebacks";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Chargeback
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Chargeback($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return ChargebackCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\ChargebackCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Chargebacks from Mollie.
|
||||
*
|
||||
* @param string $from The first chargeback ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return ChargebackCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
63
assets/mollie/src/Endpoints/ClientEndpoint.php
Normal file
63
assets/mollie/src/Endpoints/ClientEndpoint.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Client;
|
||||
use Mollie\Api\Resources\ClientCollection;
|
||||
class ClientEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "clients";
|
||||
/**
|
||||
* @return Client
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Client($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return ClientCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\ClientCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve a client from Mollie.
|
||||
*
|
||||
* Will throw an ApiException if the client id is invalid or the resource cannot be found.
|
||||
* The client id corresponds to the organization id, for example "org_1337".
|
||||
*
|
||||
* @param string $clientId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Client
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($clientId, array $parameters = [])
|
||||
{
|
||||
if (empty($clientId)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Client ID is empty.");
|
||||
}
|
||||
return parent::rest_read($clientId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a page of clients from Mollie.
|
||||
*
|
||||
* @param string $from The first client ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return ClientCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
36
assets/mollie/src/Endpoints/ClientLinkEndpoint.php
Normal file
36
assets/mollie/src/Endpoints/ClientLinkEndpoint.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\ClientLink;
|
||||
class ClientLinkEndpoint extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "client-links";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'cl_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one
|
||||
* type of object.
|
||||
*
|
||||
* @return ClientLink
|
||||
*/
|
||||
protected function getResourceObject() : \Mollie\Api\Resources\ClientLink
|
||||
{
|
||||
return new \Mollie\Api\Resources\ClientLink($this->client);
|
||||
}
|
||||
/**
|
||||
* Creates a client link in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the client link.
|
||||
*
|
||||
* @return ClientLink
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = []) : \Mollie\Api\Resources\ClientLink
|
||||
{
|
||||
return $this->rest_create($data, []);
|
||||
}
|
||||
}
|
||||
41
assets/mollie/src/Endpoints/CollectionEndpointAbstract.php
Normal file
41
assets/mollie/src/Endpoints/CollectionEndpointAbstract.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\BaseCollection;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
abstract class CollectionEndpointAbstract extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
/**
|
||||
* Get a collection of objects from the REST API.
|
||||
*
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $filters
|
||||
*
|
||||
* @return mixed
|
||||
* @throws ApiException
|
||||
*/
|
||||
protected function rest_list($from = null, $limit = null, array $filters = [])
|
||||
{
|
||||
$filters = \array_merge(["from" => $from, "limit" => $limit], $filters);
|
||||
$apiPath = $this->getResourcePath() . $this->buildQueryString($filters);
|
||||
$result = $this->client->performHttpCall(self::REST_LIST, $apiPath);
|
||||
/** @var BaseCollection $collection */
|
||||
$collection = $this->getResourceCollectionObject($result->count, $result->_links);
|
||||
foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) {
|
||||
$collection[] = \Mollie\Api\Resources\ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject());
|
||||
}
|
||||
return $collection;
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return BaseCollection
|
||||
*/
|
||||
protected abstract function getResourceCollectionObject($count, $_links);
|
||||
}
|
||||
111
assets/mollie/src/Endpoints/CustomerEndpoint.php
Normal file
111
assets/mollie/src/Endpoints/CustomerEndpoint.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Customer;
|
||||
use Mollie\Api\Resources\CustomerCollection;
|
||||
class CustomerEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "customers";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'cst_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Customer
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Customer($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return CustomerCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\CustomerCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a customer in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the customer.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Customer
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single customer from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the customer id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $customerId
|
||||
* @param array $parameters
|
||||
* @return Customer
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($customerId, array $parameters = [])
|
||||
{
|
||||
return $this->rest_read($customerId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Update a specific Customer resource.
|
||||
*
|
||||
* Will throw an ApiException if the customer id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $customerId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Customer
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($customerId, array $data = [])
|
||||
{
|
||||
if (empty($customerId) || \strpos($customerId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid order ID: '{$customerId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_update($customerId, $data);
|
||||
}
|
||||
/**
|
||||
* Deletes the given Customer.
|
||||
*
|
||||
* Will throw a ApiException if the customer id is invalid or the resource cannot be found.
|
||||
* Returns with HTTP status No Content (204) if successful.
|
||||
*
|
||||
* @param string $customerId
|
||||
*
|
||||
* @param array $data
|
||||
* @return null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function delete($customerId, array $data = [])
|
||||
{
|
||||
return $this->rest_delete($customerId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Customers from Mollie.
|
||||
*
|
||||
* @param string $from The first customer ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return CustomerCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
88
assets/mollie/src/Endpoints/CustomerPaymentsEndpoint.php
Normal file
88
assets/mollie/src/Endpoints/CustomerPaymentsEndpoint.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Customer;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\PaymentCollection;
|
||||
class CustomerPaymentsEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "customers_payments";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Payment
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Payment($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return PaymentCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Create a subscription for a Customer
|
||||
*
|
||||
* @param Customer $customer
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Payment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Customer $customer, array $options = [], array $filters = [])
|
||||
{
|
||||
return $this->createForId($customer->id, $options, $filters);
|
||||
}
|
||||
/**
|
||||
* Create a subscription for a Customer ID
|
||||
*
|
||||
* @param string $customerId
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Payment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($customerId, array $options = [], array $filters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_create($options, $filters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return PaymentCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Customer $customer, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($customer->id, $from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\PaymentCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($customerId, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
163
assets/mollie/src/Endpoints/EndpointAbstract.php
Normal file
163
assets/mollie/src/Endpoints/EndpointAbstract.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\MollieApiClient;
|
||||
use Mollie\Api\Resources\BaseResource;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
abstract class EndpointAbstract
|
||||
{
|
||||
public const REST_CREATE = \Mollie\Api\MollieApiClient::HTTP_POST;
|
||||
public const REST_UPDATE = \Mollie\Api\MollieApiClient::HTTP_PATCH;
|
||||
public const REST_READ = \Mollie\Api\MollieApiClient::HTTP_GET;
|
||||
public const REST_LIST = \Mollie\Api\MollieApiClient::HTTP_GET;
|
||||
public const REST_DELETE = \Mollie\Api\MollieApiClient::HTTP_DELETE;
|
||||
/**
|
||||
* @var MollieApiClient
|
||||
*/
|
||||
protected $client;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resourcePath;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $parentId;
|
||||
/**
|
||||
* @param MollieApiClient $api
|
||||
*/
|
||||
public function __construct(\Mollie\Api\MollieApiClient $api)
|
||||
{
|
||||
$this->client = $api;
|
||||
}
|
||||
/**
|
||||
* @param array $filters
|
||||
* @return string
|
||||
*/
|
||||
protected function buildQueryString(array $filters)
|
||||
{
|
||||
if (empty($filters)) {
|
||||
return "";
|
||||
}
|
||||
foreach ($filters as $key => $value) {
|
||||
if ($value === \true) {
|
||||
$filters[$key] = "true";
|
||||
}
|
||||
if ($value === \false) {
|
||||
$filters[$key] = "false";
|
||||
}
|
||||
}
|
||||
return "?" . \http_build_query($filters, "", "&");
|
||||
}
|
||||
/**
|
||||
* @param array $body
|
||||
* @param array $filters
|
||||
* @return mixed
|
||||
* @throws ApiException
|
||||
*/
|
||||
protected function rest_create(array $body, array $filters)
|
||||
{
|
||||
$result = $this->client->performHttpCall(self::REST_CREATE, $this->getResourcePath() . $this->buildQueryString($filters), $this->parseRequestBody($body));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* Sends a PATCH request to a single Mollie API object.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
* @throws ApiException
|
||||
*/
|
||||
protected function rest_update($id, array $body = [])
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid resource id.");
|
||||
}
|
||||
$id = \urlencode($id);
|
||||
$result = $this->client->performHttpCall(self::REST_UPDATE, "{$this->getResourcePath()}/{$id}", $this->parseRequestBody($body));
|
||||
if ($result == null) {
|
||||
return null;
|
||||
}
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* Retrieves a single object from the REST API.
|
||||
*
|
||||
* @param string $id Id of the object to retrieve.
|
||||
* @param array $filters
|
||||
* @return mixed
|
||||
* @throws ApiException
|
||||
*/
|
||||
protected function rest_read($id, array $filters)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid resource id.");
|
||||
}
|
||||
$id = \urlencode($id);
|
||||
$result = $this->client->performHttpCall(self::REST_READ, "{$this->getResourcePath()}/{$id}" . $this->buildQueryString($filters));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* Sends a DELETE request to a single Molle API object.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
* @throws ApiException
|
||||
*/
|
||||
protected function rest_delete($id, array $body = [])
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid resource id.");
|
||||
}
|
||||
$id = \urlencode($id);
|
||||
$result = $this->client->performHttpCall(self::REST_DELETE, "{$this->getResourcePath()}/{$id}", $this->parseRequestBody($body));
|
||||
if ($result == null) {
|
||||
return null;
|
||||
}
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return BaseResource
|
||||
*/
|
||||
protected abstract function getResourceObject();
|
||||
/**
|
||||
* @param string $resourcePath
|
||||
*/
|
||||
public function setResourcePath($resourcePath)
|
||||
{
|
||||
$this->resourcePath = \strtolower($resourcePath);
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getResourcePath()
|
||||
{
|
||||
if (\strpos($this->resourcePath, "_") !== \false) {
|
||||
[$parentResource, $childResource] = \explode("_", $this->resourcePath, 2);
|
||||
if (empty($this->parentId)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Subresource '{$this->resourcePath}' used without parent '{$parentResource}' ID.");
|
||||
}
|
||||
return "{$parentResource}/{$this->parentId}/{$childResource}";
|
||||
}
|
||||
return $this->resourcePath;
|
||||
}
|
||||
/**
|
||||
* @param array $body
|
||||
* @return null|string
|
||||
*/
|
||||
protected function parseRequestBody(array $body)
|
||||
{
|
||||
if (empty($body)) {
|
||||
return null;
|
||||
}
|
||||
return @\json_encode($body);
|
||||
}
|
||||
}
|
||||
73
assets/mollie/src/Endpoints/InvoiceEndpoint.php
Normal file
73
assets/mollie/src/Endpoints/InvoiceEndpoint.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Invoice;
|
||||
use Mollie\Api\Resources\InvoiceCollection;
|
||||
class InvoiceEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "invoices";
|
||||
/**
|
||||
* Get the object that is used by this API. Every API uses one type of object.
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseResource
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Invoice($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API. Every API uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\InvoiceCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve an Invoice from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the invoice id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $invoiceId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Invoice
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($invoiceId, array $parameters = [])
|
||||
{
|
||||
return $this->rest_read($invoiceId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Invoices from Mollie.
|
||||
*
|
||||
* @param string $from The first invoice ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return InvoiceCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* This is a wrapper method for page
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function all(array $parameters = [])
|
||||
{
|
||||
return $this->page(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
134
assets/mollie/src/Endpoints/MandateEndpoint.php
Normal file
134
assets/mollie/src/Endpoints/MandateEndpoint.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Customer;
|
||||
use Mollie\Api\Resources\Mandate;
|
||||
use Mollie\Api\Resources\MandateCollection;
|
||||
class MandateEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "customers_mandates";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Mandate
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Mandate($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return MandateCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\MandateCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Mandate
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Customer $customer, array $options = [], array $filters = [])
|
||||
{
|
||||
return $this->createForId($customer->id, $options, $filters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Mandate
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($customerId, array $options = [], array $filters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_create($options, $filters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $mandateId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Mandate
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Customer $customer, $mandateId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($customer->id, $mandateId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $mandateId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Mandate
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId($customerId, $mandateId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_read($mandateId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\MandateCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Customer $customer, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($customer->id, $from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param null $from
|
||||
* @param null $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\MandateCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($customerId, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_list($from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $mandateId
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function revokeFor(\Mollie\Api\Resources\Customer $customer, $mandateId, $data = [])
|
||||
{
|
||||
return $this->revokeForId($customer->id, $mandateId, $data);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $mandateId
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function revokeForId($customerId, $mandateId, $data = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_delete($mandateId, $data);
|
||||
}
|
||||
}
|
||||
88
assets/mollie/src/Endpoints/MethodEndpoint.php
Normal file
88
assets/mollie/src/Endpoints/MethodEndpoint.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Method;
|
||||
use Mollie\Api\Resources\MethodCollection;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class MethodEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "methods";
|
||||
/**
|
||||
* @return Method
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Method($this->client);
|
||||
}
|
||||
/**
|
||||
* Retrieve all active methods. In test mode, this includes pending methods. The results are not paginated.
|
||||
*
|
||||
* @deprecated Use allActive() instead
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function all(array $parameters = [])
|
||||
{
|
||||
return $this->allActive($parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve all active methods for the organization. In test mode, this includes pending methods.
|
||||
* The results are not paginated.
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function allActive(array $parameters = [])
|
||||
{
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve all available methods for the organization, including activated and not yet activated methods. The
|
||||
* results are not paginated. Make sure to include the profileId parameter if using an OAuth Access Token.
|
||||
*
|
||||
* @param array $parameters Query string parameters.
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function allAvailable(array $parameters = [])
|
||||
{
|
||||
$url = 'methods/all' . $this->buildQueryString($parameters);
|
||||
$result = $this->client->performHttpCall('GET', $url);
|
||||
return \Mollie\Api\Resources\ResourceFactory::createBaseResourceCollection($this->client, \Mollie\Api\Resources\Method::class, $result->_embedded->methods, $result->_links);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return MethodCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\MethodCollection($count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve a payment method from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the method id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $methodId
|
||||
* @param array $parameters
|
||||
* @return \Mollie\Api\Resources\Method
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($methodId, array $parameters = [])
|
||||
{
|
||||
if (empty($methodId)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Method ID is empty.");
|
||||
}
|
||||
return parent::rest_read($methodId, $parameters);
|
||||
}
|
||||
}
|
||||
74
assets/mollie/src/Endpoints/OnboardingEndpoint.php
Normal file
74
assets/mollie/src/Endpoints/OnboardingEndpoint.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\BaseResource;
|
||||
use Mollie\Api\Resources\Onboarding;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class OnboardingEndpoint extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "onboarding/me";
|
||||
protected function getResourceCollectionObject($count, $links)
|
||||
{
|
||||
throw new \BadMethodCallException('not implemented');
|
||||
}
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return BaseResource
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Onboarding($this->client);
|
||||
}
|
||||
/**
|
||||
* Retrieve the organization's onboarding status from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the resource cannot be found.
|
||||
*
|
||||
* @return Onboarding
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->rest_read('', []);
|
||||
}
|
||||
/**
|
||||
* Submit data that will be prefilled in the merchant’s onboarding.
|
||||
* Please note that the data you submit will only be processed when the onboarding status is needs-data.
|
||||
*
|
||||
* Information that the merchant has entered in their dashboard will not be overwritten.
|
||||
*
|
||||
* Will throw a ApiException if the resource cannot be found.
|
||||
*
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function submit(array $parameters = [])
|
||||
{
|
||||
return $this->rest_create($parameters, []);
|
||||
}
|
||||
/**
|
||||
* @param string $id
|
||||
* @param array $filters
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
protected function rest_read($id, array $filters)
|
||||
{
|
||||
$result = $this->client->performHttpCall(self::REST_READ, $this->getResourcePath() . $this->buildQueryString($filters));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
/**
|
||||
* @param array $body
|
||||
* @param array $filters
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
protected function rest_create(array $body, array $filters)
|
||||
{
|
||||
$this->client->performHttpCall(self::REST_CREATE, $this->getResourcePath() . $this->buildQueryString($filters), $this->parseRequestBody($body));
|
||||
}
|
||||
}
|
||||
119
assets/mollie/src/Endpoints/OrderEndpoint.php
Normal file
119
assets/mollie/src/Endpoints/OrderEndpoint.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Order;
|
||||
use Mollie\Api\Resources\OrderCollection;
|
||||
class OrderEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "orders";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'ord_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one
|
||||
* type of object.
|
||||
*
|
||||
* @return Order
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Order($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API
|
||||
* endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return OrderCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\OrderCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a order in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the order.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Order
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* Update a specific Order resource
|
||||
*
|
||||
* Will throw a ApiException if the order id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $orderId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Order
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($orderId, array $data = [])
|
||||
{
|
||||
if (empty($orderId) || \strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_update($orderId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single order from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the order id is invalid or the resource cannot
|
||||
* be found.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Order
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($orderId, array $parameters = [])
|
||||
{
|
||||
if (empty($orderId) || \strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_read($orderId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Cancel the given Order.
|
||||
*
|
||||
* If the order was partially shipped, the status will be "completed" instead of
|
||||
* "canceled".
|
||||
* Will throw a ApiException if the order id is invalid or the resource cannot
|
||||
* be found.
|
||||
* Returns the canceled order with HTTP status 200.
|
||||
*
|
||||
* @param string $orderId
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Order
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function cancel($orderId, $parameters = [])
|
||||
{
|
||||
return $this->rest_delete($orderId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Orders from Mollie.
|
||||
*
|
||||
* @param string $from The first order ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return OrderCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
115
assets/mollie/src/Endpoints/OrderLineEndpoint.php
Normal file
115
assets/mollie/src/Endpoints/OrderLineEndpoint.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Order;
|
||||
use Mollie\Api\Resources\OrderLine;
|
||||
use Mollie\Api\Resources\OrderLineCollection;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class OrderLineEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "orders_lines";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'odl_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one
|
||||
* type of object.
|
||||
*
|
||||
* @return OrderLine
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\OrderLine($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API
|
||||
* endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return OrderLineCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\OrderLineCollection($count, $_links);
|
||||
}
|
||||
/**
|
||||
* Update a specific OrderLine resource.
|
||||
*
|
||||
* Will throw an ApiException if the order line id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string|null $orderId
|
||||
* @param string $orderlineId
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseResource|null
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function update($orderId, $orderlineId, array $data = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
if (empty($orderlineId) || \strpos($orderlineId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid order line ID: '{$orderlineId}'. An order line ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_update($orderlineId, $data);
|
||||
}
|
||||
/**
|
||||
* @param string $orderId
|
||||
* @param array $operations
|
||||
* @param array $parameters
|
||||
* @return Order|\Mollie\Api\Resources\BaseResource
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function updateMultiple(string $orderId, array $operations, array $parameters = [])
|
||||
{
|
||||
if (empty($orderId)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid resource id.");
|
||||
}
|
||||
$this->parentId = $orderId;
|
||||
$parameters['operations'] = $operations;
|
||||
$result = $this->client->performHttpCall(self::REST_UPDATE, "{$this->getResourcePath()}", $this->parseRequestBody($parameters));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, new \Mollie\Api\Resources\Order($this->client));
|
||||
}
|
||||
/**
|
||||
* Cancel lines for the provided order.
|
||||
* The data array must contain a lines array.
|
||||
* You can pass an empty lines array if you want to cancel all eligible lines.
|
||||
* Returns null if successful.
|
||||
*
|
||||
* @param Order $order
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function cancelFor(\Mollie\Api\Resources\Order $order, array $data)
|
||||
{
|
||||
return $this->cancelForId($order->id, $data);
|
||||
}
|
||||
/**
|
||||
* Cancel lines for the provided order id.
|
||||
* The data array must contain a lines array.
|
||||
* You can pass an empty lines array if you want to cancel all eligible lines.
|
||||
* Returns null if successful.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function cancelForId($orderId, array $data)
|
||||
{
|
||||
if (!isset($data['lines']) || !\is_array($data['lines'])) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("A lines array is required.");
|
||||
}
|
||||
$this->parentId = $orderId;
|
||||
$this->client->performHttpCall(self::REST_DELETE, "{$this->getResourcePath()}", $this->parseRequestBody($data));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
67
assets/mollie/src/Endpoints/OrderPaymentEndpoint.php
Normal file
67
assets/mollie/src/Endpoints/OrderPaymentEndpoint.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Order;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\PaymentCollection;
|
||||
class OrderPaymentEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "orders_payments";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'tr_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one
|
||||
* type of object.
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Payment
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Payment($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API
|
||||
* endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return \Mollie\Api\Resources\PaymentCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a payment in Mollie for a specific order.
|
||||
*
|
||||
* @param \Mollie\Api\Resources\Order $order
|
||||
* @param array $data An array containing details on the order payment.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Payment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Order $order, array $data, array $filters = [])
|
||||
{
|
||||
return $this->createForId($order->id, $data, $filters);
|
||||
}
|
||||
/**
|
||||
* Creates a payment in Mollie for a specific order ID.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param array $data An array containing details on the order payment.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Payment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($orderId, array $data, array $filters = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
}
|
||||
63
assets/mollie/src/Endpoints/OrderRefundEndpoint.php
Normal file
63
assets/mollie/src/Endpoints/OrderRefundEndpoint.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Order;
|
||||
use Mollie\Api\Resources\Refund;
|
||||
use Mollie\Api\Resources\RefundCollection;
|
||||
class OrderRefundEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "orders_refunds";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Refund
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Refund($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return RefundCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\RefundCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Refund some order lines. You can provide an empty array for the
|
||||
* "lines" data to refund all eligible lines for this order.
|
||||
*
|
||||
* @param Order $order
|
||||
* @param array $data
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Order $order, array $data, array $filters = [])
|
||||
{
|
||||
return $this->createForId($order->id, $data, $filters);
|
||||
}
|
||||
/**
|
||||
* Refund some order lines. You can provide an empty array for the
|
||||
* "lines" data to refund all eligible lines for this order.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param array $data
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($orderId, array $data, array $filters = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
return parent::rest_create($data, $filters);
|
||||
}
|
||||
}
|
||||
58
assets/mollie/src/Endpoints/OrganizationEndpoint.php
Normal file
58
assets/mollie/src/Endpoints/OrganizationEndpoint.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Organization;
|
||||
use Mollie\Api\Resources\OrganizationCollection;
|
||||
class OrganizationEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "organizations";
|
||||
/**
|
||||
* @return Organization
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Organization($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return OrganizationCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\OrganizationCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve an organization from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the organization id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $organizationId
|
||||
* @param array $parameters
|
||||
* @return Organization
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($organizationId, array $parameters = [])
|
||||
{
|
||||
if (empty($organizationId)) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Organization ID is empty.");
|
||||
}
|
||||
return parent::rest_read($organizationId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve the current organization from Mollie.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Organization
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function current(array $parameters = [])
|
||||
{
|
||||
return parent::rest_read('me', $parameters);
|
||||
}
|
||||
}
|
||||
49
assets/mollie/src/Endpoints/OrganizationPartnerEndpoint.php
Normal file
49
assets/mollie/src/Endpoints/OrganizationPartnerEndpoint.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\BaseResource;
|
||||
use Mollie\Api\Resources\Partner;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class OrganizationPartnerEndpoint extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "organizations/me/partner";
|
||||
protected function getResourceCollectionObject($count, $links)
|
||||
{
|
||||
throw new \BadMethodCallException('not implemented');
|
||||
}
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return BaseResource
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Partner($this->client);
|
||||
}
|
||||
/**
|
||||
* Retrieve details about the partner status of the currently authenticated organization.
|
||||
*
|
||||
* Will throw an ApiException if the resource cannot be found.
|
||||
*
|
||||
* @return Partner
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->rest_read('', []);
|
||||
}
|
||||
/**
|
||||
* @param string $id
|
||||
* @param array $filters
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
protected function rest_read($id, array $filters)
|
||||
{
|
||||
$result = $this->client->performHttpCall(self::REST_READ, $this->getResourcePath() . $this->buildQueryString($filters));
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, $this->getResourceObject());
|
||||
}
|
||||
}
|
||||
109
assets/mollie/src/Endpoints/PaymentCaptureEndpoint.php
Normal file
109
assets/mollie/src/Endpoints/PaymentCaptureEndpoint.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Capture;
|
||||
use Mollie\Api\Resources\CaptureCollection;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
class PaymentCaptureEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payments_captures";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Capture
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Capture($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return \Mollie\Api\Resources\CaptureCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\CaptureCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a payment capture in Mollie.
|
||||
*
|
||||
* @param Payment $payment.
|
||||
* @param array $data An array containing details on the capture.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Payment $payment, array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->createForId($payment->id, $data, $filters);
|
||||
}
|
||||
/**
|
||||
* Creates a payment capture in Mollie.
|
||||
*
|
||||
* @param string $paymentId The payment's ID.
|
||||
* @param array $data An array containing details on the capture.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($paymentId, array $data = [], array $filters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param string $captureId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Payment $payment, $captureId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($payment->id, $captureId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param string $captureId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId($paymentId, $captureId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_read($captureId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Payment $payment, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($payment->id, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Capture
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($paymentId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
80
assets/mollie/src/Endpoints/PaymentChargebackEndpoint.php
Normal file
80
assets/mollie/src/Endpoints/PaymentChargebackEndpoint.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Chargeback;
|
||||
use Mollie\Api\Resources\ChargebackCollection;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
class PaymentChargebackEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payments_chargebacks";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Chargeback
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Chargeback($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return ChargebackCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\ChargebackCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param string $chargebackId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Chargeback
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Payment $payment, $chargebackId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($payment->id, $chargebackId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param string $chargebackId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Chargeback
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId($paymentId, $chargebackId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_read($chargebackId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Chargeback
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Payment $payment, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($payment->id, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Chargeback
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($paymentId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
152
assets/mollie/src/Endpoints/PaymentEndpoint.php
Normal file
152
assets/mollie/src/Endpoints/PaymentEndpoint.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\PaymentCollection;
|
||||
use Mollie\Api\Resources\Refund;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class PaymentEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payments";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'tr_';
|
||||
/**
|
||||
* @return Payment
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Payment($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return PaymentCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a payment in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the payment.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Payment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* Update the given Payment.
|
||||
*
|
||||
* Will throw a ApiException if the payment id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $paymentId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Payment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($paymentId, array $data = [])
|
||||
{
|
||||
if (empty($paymentId) || \strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_update($paymentId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single payment from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the payment id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $paymentId
|
||||
* @param array $parameters
|
||||
* @return Payment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($paymentId, array $parameters = [])
|
||||
{
|
||||
if (empty($paymentId) || \strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_read($paymentId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Deletes the given Payment.
|
||||
*
|
||||
* Will throw a ApiException if the payment id is invalid or the resource cannot be found.
|
||||
* Returns with HTTP status No Content (204) if successful.
|
||||
*
|
||||
* @param string $paymentId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Payment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function delete($paymentId, array $data = [])
|
||||
{
|
||||
return $this->rest_delete($paymentId, $data);
|
||||
}
|
||||
/**
|
||||
* Cancel the given Payment. This is just an alias of the 'delete' method.
|
||||
*
|
||||
* Will throw a ApiException if the payment id is invalid or the resource cannot be found.
|
||||
* Returns with HTTP status No Content (204) if successful.
|
||||
*
|
||||
* @param string $paymentId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Payment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function cancel($paymentId, array $data = [])
|
||||
{
|
||||
return $this->rest_delete($paymentId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Payments from Mollie.
|
||||
*
|
||||
* @param string $from The first payment ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return PaymentCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* Issue a refund for the given payment.
|
||||
*
|
||||
* The $data parameter may either be an array of endpoint parameters, a float value to
|
||||
* initiate a partial refund, or empty to do a full refund.
|
||||
*
|
||||
* @param Payment $payment
|
||||
* @param array|float|null $data
|
||||
*
|
||||
* @return Refund
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function refund(\Mollie\Api\Resources\Payment $payment, $data = [])
|
||||
{
|
||||
$resource = "{$this->getResourcePath()}/" . \urlencode($payment->id) . "/refunds";
|
||||
$body = null;
|
||||
if (($data === null ? 0 : \count($data)) > 0) {
|
||||
$body = \json_encode($data);
|
||||
}
|
||||
$result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body);
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, new \Mollie\Api\Resources\Refund($this->client));
|
||||
}
|
||||
}
|
||||
79
assets/mollie/src/Endpoints/PaymentLinkEndpoint.php
Normal file
79
assets/mollie/src/Endpoints/PaymentLinkEndpoint.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\PaymentLink;
|
||||
use Mollie\Api\Resources\PaymentLinkCollection;
|
||||
class PaymentLinkEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payment-links";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'pl_';
|
||||
/**
|
||||
* @return PaymentLink
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentLink($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return PaymentLinkCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentLinkCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a payment link in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the payment link.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return PaymentLink
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* Retrieve payment link from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the payment link id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $paymentLinkId
|
||||
* @param array $parameters
|
||||
* @return PaymentLink
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($paymentLinkId, array $parameters = [])
|
||||
{
|
||||
if (empty($paymentLinkId) || \strpos($paymentLinkId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid payment link ID: '{$paymentLinkId}'. A payment link ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_read($paymentLinkId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Payment Links from Mollie.
|
||||
*
|
||||
* @param string $from The first payment link ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return PaymentLinkCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
109
assets/mollie/src/Endpoints/PaymentRefundEndpoint.php
Normal file
109
assets/mollie/src/Endpoints/PaymentRefundEndpoint.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\Refund;
|
||||
use Mollie\Api\Resources\RefundCollection;
|
||||
class PaymentRefundEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payments_refunds";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Refund
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Refund($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return RefundCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\RefundCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param string $refundId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Payment $payment, $refundId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($payment->id, $refundId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param string $refundId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId($paymentId, $refundId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_read($refundId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Payment $payment, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($payment->id, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($paymentId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
/**
|
||||
* Creates a refund for a specific payment.
|
||||
*
|
||||
* @param Payment $payment
|
||||
* @param array $data
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Payment $payment, array $data, array $filters = [])
|
||||
{
|
||||
return $this->createForId($payment->id, $data, $filters);
|
||||
}
|
||||
/**
|
||||
* Creates a refund for a specific payment.
|
||||
*
|
||||
* @param string $paymentId
|
||||
* @param array $data
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Refund
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId(string $paymentId, array $data, array $filters = [])
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
return parent::rest_create($data, $filters);
|
||||
}
|
||||
}
|
||||
60
assets/mollie/src/Endpoints/PaymentRouteEndpoint.php
Normal file
60
assets/mollie/src/Endpoints/PaymentRouteEndpoint.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\Route;
|
||||
use Mollie\Api\Resources\RouteCollection;
|
||||
class PaymentRouteEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "payments_routes";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Route
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Route($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return \Mollie\Api\Resources\RouteCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\RouteCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param string $routeId
|
||||
* @param string $releaseDate - UTC datetime in ISO-8601 format when the funds for the following payment will become available on
|
||||
* the balance of the connected account
|
||||
*
|
||||
* @return Route
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function updateReleaseDateFor(\Mollie\Api\Resources\Payment $payment, $routeId, $releaseDate)
|
||||
{
|
||||
return $this->updateReleaseDateForPaymentId($payment->id, $routeId, $releaseDate);
|
||||
}
|
||||
/**
|
||||
* @param string $paymentId
|
||||
* @param string $routeId
|
||||
* @param string $releaseDate - UTC datetime in ISO-8601 format when the funds for the following payment will become available on
|
||||
* the balance of the connected account
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Route
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function updateReleaseDateForPaymentId($paymentId, $routeId, $releaseDate, $testmode = \false)
|
||||
{
|
||||
$this->parentId = $paymentId;
|
||||
$params = ['releaseDate' => $releaseDate, 'testmode' => $testmode];
|
||||
return parent::rest_update($routeId, $params);
|
||||
}
|
||||
}
|
||||
60
assets/mollie/src/Endpoints/PermissionEndpoint.php
Normal file
60
assets/mollie/src/Endpoints/PermissionEndpoint.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Permission;
|
||||
use Mollie\Api\Resources\PermissionCollection;
|
||||
class PermissionEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "permissions";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one
|
||||
* type of object.
|
||||
*
|
||||
* @return Permission
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Permission($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API
|
||||
* endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return PermissionCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PermissionCollection($count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single Permission from Mollie.
|
||||
*
|
||||
* Will throw an ApiException if the permission id is invalid.
|
||||
*
|
||||
* @param string $permissionId
|
||||
* @param array $parameters
|
||||
* @return Permission
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($permissionId, array $parameters = [])
|
||||
{
|
||||
return $this->rest_read($permissionId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve all permissions.
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return PermissionCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function all(array $parameters = [])
|
||||
{
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
130
assets/mollie/src/Endpoints/ProfileEndpoint.php
Normal file
130
assets/mollie/src/Endpoints/ProfileEndpoint.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\CurrentProfile;
|
||||
use Mollie\Api\Resources\Profile;
|
||||
use Mollie\Api\Resources\ProfileCollection;
|
||||
class ProfileEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "profiles";
|
||||
protected $resourceClass = \Mollie\Api\Resources\Profile::class;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'pfl_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Profile
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new $this->resourceClass($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return ProfileCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\ProfileCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Creates a Profile in Mollie.
|
||||
*
|
||||
* @param array $data An array containing details on the profile.
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Profile
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function create(array $data = [], array $filters = [])
|
||||
{
|
||||
return $this->rest_create($data, $filters);
|
||||
}
|
||||
/**
|
||||
* Retrieve a Profile from Mollie.
|
||||
*
|
||||
* Will throw an ApiException if the profile id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $profileId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Profile
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($profileId, array $parameters = [])
|
||||
{
|
||||
if ($profileId === 'me') {
|
||||
return $this->getCurrent($parameters);
|
||||
}
|
||||
return $this->rest_read($profileId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Update a specific Profile resource.
|
||||
*
|
||||
* Will throw an ApiException if the profile id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $profileId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Profile
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($profileId, array $data = [])
|
||||
{
|
||||
if (empty($profileId) || \strpos($profileId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid profile id: '{$profileId}'. An profile id should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_update($profileId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieve the current Profile from Mollie.
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return CurrentProfile
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getCurrent(array $parameters = [])
|
||||
{
|
||||
$this->resourceClass = \Mollie\Api\Resources\CurrentProfile::class;
|
||||
return $this->rest_read('me', $parameters);
|
||||
}
|
||||
/**
|
||||
* Delete a Profile from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the profile id is invalid or the resource cannot be found.
|
||||
* Returns with HTTP status No Content (204) if successful.
|
||||
*
|
||||
* @param string $profileId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Profile
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function delete($profileId, array $data = [])
|
||||
{
|
||||
return $this->rest_delete($profileId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Profiles from Mollie.
|
||||
*
|
||||
* @param string $from The first profile ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return ProfileCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
116
assets/mollie/src/Endpoints/ProfileMethodEndpoint.php
Normal file
116
assets/mollie/src/Endpoints/ProfileMethodEndpoint.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Method;
|
||||
use Mollie\Api\Resources\MethodCollection;
|
||||
use Mollie\Api\Resources\Profile;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
class ProfileMethodEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "profiles_methods";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Method
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Method($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return MethodCollection()
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\MethodCollection($count, $_links);
|
||||
}
|
||||
/**
|
||||
* Enable a method for the provided Profile ID.
|
||||
*
|
||||
* @param string $profileId
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @return \Mollie\Api\Resources\Method
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($profileId, $methodId, array $data = [])
|
||||
{
|
||||
$this->parentId = $profileId;
|
||||
$resource = $this->getResourcePath() . '/' . \urlencode($methodId);
|
||||
$body = null;
|
||||
if (\count($data) > 0) {
|
||||
$body = \json_encode($data);
|
||||
}
|
||||
$result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body);
|
||||
return \Mollie\Api\Resources\ResourceFactory::createFromApiResult($result, new \Mollie\Api\Resources\Method($this->client));
|
||||
}
|
||||
/**
|
||||
* Enable a method for the provided Profile object.
|
||||
*
|
||||
* @param Profile $profile
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @return Method
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor($profile, $methodId, array $data = [])
|
||||
{
|
||||
return $this->createForId($profile->id, $methodId, $data);
|
||||
}
|
||||
/**
|
||||
* Enable a method for the current profile.
|
||||
*
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @return \Mollie\Api\Resources\Method
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForCurrentProfile($methodId, array $data = [])
|
||||
{
|
||||
return $this->createForId('me', $methodId, $data);
|
||||
}
|
||||
/**
|
||||
* Disable a method for the provided Profile ID.
|
||||
*
|
||||
* @param string $profileId
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function deleteForId($profileId, $methodId, array $data = [])
|
||||
{
|
||||
$this->parentId = $profileId;
|
||||
return $this->rest_delete($methodId, $data);
|
||||
}
|
||||
/**
|
||||
* Disable a method for the provided Profile object.
|
||||
*
|
||||
* @param Profile $profile
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function deleteFor($profile, $methodId, array $data = [])
|
||||
{
|
||||
return $this->deleteForId($profile->id, $methodId, $data);
|
||||
}
|
||||
/**
|
||||
* Disable a method for the current profile.
|
||||
*
|
||||
* @param string $methodId
|
||||
* @param array $data
|
||||
* @return \Mollie\Api\Resources\Method
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function deleteForCurrentProfile($methodId, array $data)
|
||||
{
|
||||
return $this->deleteForId('me', $methodId, $data);
|
||||
}
|
||||
}
|
||||
46
assets/mollie/src/Endpoints/RefundEndpoint.php
Normal file
46
assets/mollie/src/Endpoints/RefundEndpoint.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Refund;
|
||||
use Mollie\Api\Resources\RefundCollection;
|
||||
class RefundEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "refunds";
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Refund
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Refund($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return RefundCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\RefundCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Refunds from Mollie.
|
||||
*
|
||||
* @param string $from The first refund ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return RefundCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
40
assets/mollie/src/Endpoints/SettlementPaymentEndpoint.php
Normal file
40
assets/mollie/src/Endpoints/SettlementPaymentEndpoint.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\Payment;
|
||||
use Mollie\Api\Resources\PaymentCollection;
|
||||
class SettlementPaymentEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "settlements_payments";
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Payment($this->client);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\PaymentCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Payments from Mollie.
|
||||
*
|
||||
* @param string $settlementId
|
||||
* @param string $from The first payment ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function pageForId($settlementId, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $settlementId;
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
80
assets/mollie/src/Endpoints/SettlementsEndpoint.php
Normal file
80
assets/mollie/src/Endpoints/SettlementsEndpoint.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Settlement;
|
||||
use Mollie\Api\Resources\SettlementCollection;
|
||||
class SettlementsEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "settlements";
|
||||
/**
|
||||
* Get the object that is used by this API. Every API uses one type of object.
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseResource
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Settlement($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API. Every API uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return \Mollie\Api\Resources\BaseCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\SettlementCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single settlement from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the settlement id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $settlementId
|
||||
* @param array $parameters
|
||||
* @return Settlement
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($settlementId, array $parameters = [])
|
||||
{
|
||||
return parent::rest_read($settlementId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve the details of the current settlement that has not yet been paid out.
|
||||
*
|
||||
* @return Settlement
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
return parent::rest_read("next", []);
|
||||
}
|
||||
/**
|
||||
* Retrieve the details of the open balance of the organization.
|
||||
*
|
||||
* @return Settlement
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
return parent::rest_read("open", []);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Settlements from Mollie.
|
||||
*
|
||||
* @param string $from The first settlement ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return SettlementCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
145
assets/mollie/src/Endpoints/ShipmentEndpoint.php
Normal file
145
assets/mollie/src/Endpoints/ShipmentEndpoint.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Order;
|
||||
use Mollie\Api\Resources\Shipment;
|
||||
use Mollie\Api\Resources\ShipmentCollection;
|
||||
class ShipmentEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "orders_shipments";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'shp_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Shipment
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Shipment($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API
|
||||
* endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return ShipmentCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\ShipmentCollection($count, $_links);
|
||||
}
|
||||
/**
|
||||
* Create a shipment for some order lines. You can provide an empty array for the
|
||||
* "lines" option to include all unshipped lines for this order.
|
||||
*
|
||||
* @param Order $order
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Shipment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Order $order, array $options = [], array $filters = [])
|
||||
{
|
||||
return $this->createForId($order->id, $options, $filters);
|
||||
}
|
||||
/**
|
||||
* Create a shipment for some order lines. You can provide an empty array for the
|
||||
* "lines" option to include all unshipped lines for this order.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Shipment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function createForId($orderId, array $options = [], array $filters = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
return parent::rest_create($options, $filters);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single shipment and the order lines shipped by a shipment’s ID.
|
||||
*
|
||||
* @param Order $order
|
||||
* @param string $shipmentId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Shipment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Order $order, $shipmentId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($order->id, $shipmentId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieve a single shipment and the order lines shipped by a shipment’s ID.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param string $shipmentId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\Shipment
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function getForId($orderId, $shipmentId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
return parent::rest_read($shipmentId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Update a specific Order Shipment resource.
|
||||
*
|
||||
* Will throw an ApiException if the shipment id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $shipmentId
|
||||
* @param string $orderId
|
||||
*
|
||||
* @param array $data
|
||||
* @return Shipment
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($orderId, $shipmentId, array $data = [])
|
||||
{
|
||||
if (empty($shipmentId) || \strpos($shipmentId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid subscription ID: '{$shipmentId}'. An subscription ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
$this->parentId = $orderId;
|
||||
return parent::rest_update($shipmentId, $data);
|
||||
}
|
||||
/**
|
||||
* Return all shipments for the Order provided.
|
||||
*
|
||||
* @param Order $order
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return ShipmentCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Order $order, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($order->id, $parameters);
|
||||
}
|
||||
/**
|
||||
* Return all shipments for the provided Order id.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return \Mollie\Api\Resources\ShipmentCollection
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function listForId($orderId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $orderId;
|
||||
return parent::rest_list(null, null, $parameters);
|
||||
}
|
||||
}
|
||||
187
assets/mollie/src/Endpoints/SubscriptionEndpoint.php
Normal file
187
assets/mollie/src/Endpoints/SubscriptionEndpoint.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Customer;
|
||||
use Mollie\Api\Resources\ResourceFactory;
|
||||
use Mollie\Api\Resources\Subscription;
|
||||
use Mollie\Api\Resources\SubscriptionCollection;
|
||||
class SubscriptionEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "customers_subscriptions";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'sub_';
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return Subscription
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Subscription($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return SubscriptionCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\SubscriptionCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Create a subscription for a Customer
|
||||
*
|
||||
* @param Customer $customer
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Subscription
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function createFor(\Mollie\Api\Resources\Customer $customer, array $options = [], array $filters = [])
|
||||
{
|
||||
return $this->createForId($customer->id, $options, $filters);
|
||||
}
|
||||
/**
|
||||
* Create a subscription for a Customer
|
||||
*
|
||||
* @param string $customerId
|
||||
* @param array $options
|
||||
* @param array $filters
|
||||
*
|
||||
* @return Subscription
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function createForId($customerId, array $options = [], array $filters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_create($options, $filters);
|
||||
}
|
||||
/**
|
||||
* Update a specific Subscription resource.
|
||||
*
|
||||
* Will throw an ApiException if the subscription id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $subscriptionId
|
||||
* @param string $customerId
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return Subscription
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function update($customerId, $subscriptionId, array $data = [])
|
||||
{
|
||||
if (empty($subscriptionId) || \strpos($subscriptionId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid subscription ID: '{$subscriptionId}'. An subscription ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_update($subscriptionId, $data);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $subscriptionId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Subscription
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getFor(\Mollie\Api\Resources\Customer $customer, $subscriptionId, array $parameters = [])
|
||||
{
|
||||
return $this->getForId($customer->id, $subscriptionId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $subscriptionId
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Subscription
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getForId($customerId, $subscriptionId, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_read($subscriptionId, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return SubscriptionCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function listFor(\Mollie\Api\Resources\Customer $customer, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->listForId($customer->id, $from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $from The first resource ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return SubscriptionCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function listForId($customerId, $from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_list($from, $limit, $parameters);
|
||||
}
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @param string $subscriptionId
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function cancelFor(\Mollie\Api\Resources\Customer $customer, $subscriptionId, array $data = [])
|
||||
{
|
||||
return $this->cancelForId($customer->id, $subscriptionId, $data);
|
||||
}
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $subscriptionId
|
||||
* @param array $data
|
||||
*
|
||||
* @return null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function cancelForId($customerId, $subscriptionId, array $data = [])
|
||||
{
|
||||
$this->parentId = $customerId;
|
||||
return parent::rest_delete($subscriptionId, $data);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Subscriptions from Mollie.
|
||||
*
|
||||
* @param string $from The first payment ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return SubscriptionCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
$filters = \array_merge(["from" => $from, "limit" => $limit], $parameters);
|
||||
$apiPath = 'subscriptions' . $this->buildQueryString($filters);
|
||||
$result = $this->client->performHttpCall(self::REST_LIST, $apiPath);
|
||||
/** @var SubscriptionCollection $collection */
|
||||
$collection = $this->getResourceCollectionObject($result->count, $result->_links);
|
||||
foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) {
|
||||
$collection[] = \Mollie\Api\Resources\ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject());
|
||||
}
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
65
assets/mollie/src/Endpoints/TerminalEndpoint.php
Normal file
65
assets/mollie/src/Endpoints/TerminalEndpoint.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Exceptions\ApiException;
|
||||
use Mollie\Api\Resources\Terminal;
|
||||
use Mollie\Api\Resources\TerminalCollection;
|
||||
class TerminalEndpoint extends \Mollie\Api\Endpoints\CollectionEndpointAbstract
|
||||
{
|
||||
protected $resourcePath = "terminals";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RESOURCE_ID_PREFIX = 'term_';
|
||||
/**
|
||||
* @return Terminal
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
return new \Mollie\Api\Resources\Terminal($this->client);
|
||||
}
|
||||
/**
|
||||
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
|
||||
*
|
||||
* @param int $count
|
||||
* @param \stdClass $_links
|
||||
*
|
||||
* @return TerminalCollection
|
||||
*/
|
||||
protected function getResourceCollectionObject($count, $_links)
|
||||
{
|
||||
return new \Mollie\Api\Resources\TerminalCollection($this->client, $count, $_links);
|
||||
}
|
||||
/**
|
||||
* Retrieve terminal from Mollie.
|
||||
*
|
||||
* Will throw a ApiException if the terminal id is invalid or the resource cannot be found.
|
||||
*
|
||||
* @param string $terminalId
|
||||
* @param array $parameters
|
||||
* @return Terminal
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function get($terminalId, array $parameters = [])
|
||||
{
|
||||
if (empty($terminalId) || \strpos($terminalId, self::RESOURCE_ID_PREFIX) !== 0) {
|
||||
throw new \Mollie\Api\Exceptions\ApiException("Invalid terminal ID: '{$terminalId}'. A terminal ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
|
||||
}
|
||||
return parent::rest_read($terminalId, $parameters);
|
||||
}
|
||||
/**
|
||||
* Retrieves a collection of Terminals from Mollie for the current organization / profile, ordered from newest to oldest.
|
||||
*
|
||||
* @param string $from The first terminal ID you want to include in your list.
|
||||
* @param int $limit
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return TerminalCollection
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function page($from = null, $limit = null, array $parameters = [])
|
||||
{
|
||||
return $this->rest_list($from, $limit, $parameters);
|
||||
}
|
||||
}
|
||||
33
assets/mollie/src/Endpoints/WalletEndpoint.php
Normal file
33
assets/mollie/src/Endpoints/WalletEndpoint.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Mollie\Api\Endpoints;
|
||||
|
||||
use Mollie\Api\Resources\BaseResource;
|
||||
class WalletEndpoint extends \Mollie\Api\Endpoints\EndpointAbstract
|
||||
{
|
||||
/**
|
||||
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
|
||||
*
|
||||
* @return void|BaseResource
|
||||
*/
|
||||
protected function getResourceObject()
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
/**
|
||||
* Obtain a new ApplePay payment session.
|
||||
*
|
||||
* @param string $domain
|
||||
* @param string $validationUrl
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return false|string
|
||||
* @throws \Mollie\Api\Exceptions\ApiException
|
||||
*/
|
||||
public function requestApplePayPaymentSession($domain, $validationUrl, $parameters = [])
|
||||
{
|
||||
$body = $this->parseRequestBody(\array_merge(['domain' => $domain, 'validationUrl' => $validationUrl], $parameters));
|
||||
$response = $this->client->performHttpCall(self::REST_CREATE, 'wallets/applepay/sessions', $body);
|
||||
return \json_encode($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user