• Namespace
  • Class

Namespaces

  • Klarna
    • Exceptions
    • Rest
      • Checkout
      • CustomerToken
      • HostedPaymentPage
      • InstantShopping
      • MerchantCardService
      • OrderManagement
      • Payments
      • Settlements
      • Transport
        • Exception

Classes

  • Klarna\Rest\Checkout\Order
  • Klarna\Rest\CustomerToken\Tokens
  • Klarna\Rest\HostedPaymentPage\Sessions
  • Klarna\Rest\InstantShopping\ButtonKeys
  • Klarna\Rest\InstantShopping\Orders
  • Klarna\Rest\MerchantCardService\VCCSettlements
  • Klarna\Rest\OrderManagement\Capture
  • Klarna\Rest\OrderManagement\Order
  • Klarna\Rest\OrderManagement\Refund
  • Klarna\Rest\Payments\Orders
  • Klarna\Rest\Payments\Sessions
  • Klarna\Rest\Resource
  • Klarna\Rest\Settlements\Payouts
  • Klarna\Rest\Settlements\Reports
  • Klarna\Rest\Settlements\Transactions
  • Klarna\Rest\Transport\ApiResponse
  • Klarna\Rest\Transport\Connector
  • Klarna\Rest\Transport\CURLConnector
  • Klarna\Rest\Transport\GuzzleConnector
  • Klarna\Rest\Transport\Method
  • Klarna\Rest\Transport\ResponseValidator
  • Klarna\Rest\Transport\UserAgent

Interfaces

  • Klarna\Rest\Transport\ConnectorInterface
  • Klarna\Rest\Transport\UserAgentInterface

Exceptions

  • Klarna\Exceptions\NotApplicableException
  • Klarna\Rest\Transport\Exception\ConnectorException
 1 <?php
 2 /**
 3  * Copyright 2014 Klarna AB
 4  *
 5  * Licensed under the Apache License, Version 2.0 (the "License");
 6  * you may not use this file except in compliance with the License.
 7  * You may obtain a copy of the License at
 8  *
 9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * File containing the Transactions class.
18  */
19 
20 namespace Klarna\Rest\Settlements;
21 
22 use GuzzleHttp\Exception\RequestException;
23 use Klarna\Exceptions\NotApplicableException;
24 use Klarna\Rest\Resource;
25 use Klarna\Rest\Transport\ConnectorInterface;
26 use Klarna\Rest\Transport\Exception\ConnectorException;
27 
28 /**
29  * Transactions resource.
30  *
31  * @example docs/examples/SettlementsAPI/Transactions/get_transactions.php Returns a collection of transactions
32  */
33 class Transactions extends Resource
34 {
35     /**
36      * {@inheritDoc}
37      */
38     public static $path = '/settlements/v1/transactions';
39 
40     /**
41      * Constructs a Transactions instance.
42      *
43      * @param ConnectorInterface $connector HTTP transport connector
44      */
45     public function __construct(ConnectorInterface $connector)
46     {
47         parent::__construct($connector);
48     }
49 
50     /**
51      * Not applicable.
52      *
53      * @throws NotApplicableException
54      */
55     public function fetch()
56     {
57         throw new NotApplicableException('Not applicable');
58     }
59 
60     /**
61      * Returns a collection of transactions.
62      *
63      * @param array $params Additional query params to filter transactions.
64      *
65      * @see https://developers.klarna.com/api/#settlements-api-get-transactions
66      *
67      * @throws ConnectorException        When the API replies with an error response
68      * @throws RequestException          When an error is encountered
69      * @throws \RuntimeException         On an unexpected API response
70      * @throws \RuntimeException         If the response content type is not JSON
71      * @throws \InvalidArgumentException If the JSON cannot be parsed
72      * @throws \LogicException           When Guzzle cannot populate the response
73      *
74      * @return array Transactions data
75      */
76     public function getTransactions(array $params = [])
77     {
78         return $this->get(self::$path . '?' . http_build_query($params))
79             ->expectSuccessfull()
80             ->status('200')
81             ->contentType('application/json')
82             ->getJson();
83     }
84 }
85 
API documentation generated by ApiGen