├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── autoload.php
├── build.xml
├── composer.json
├── lib
└── Paymill
│ ├── API
│ ├── CommunicationAbstract.php
│ └── Curl.php
│ ├── Models
│ ├── Internal
│ │ ├── AbstractAddress.php
│ │ ├── BillingAddress.php
│ │ ├── Item.php
│ │ └── ShippingAddress.php
│ ├── Request
│ │ ├── Base.php
│ │ ├── Checksum.php
│ │ ├── ChecksumBase.php
│ │ ├── Client.php
│ │ ├── Fraud.php
│ │ ├── KontosecureChecksum.php
│ │ ├── Offer.php
│ │ ├── Payment.php
│ │ ├── PaypalChecksum.php
│ │ ├── Preauthorization.php
│ │ ├── Refund.php
│ │ ├── SofortChecksum.php
│ │ ├── Subscription.php
│ │ ├── Transaction.php
│ │ └── Webhook.php
│ └── Response
│ │ ├── Base.php
│ │ ├── Checksum.php
│ │ ├── Client.php
│ │ ├── Error.php
│ │ ├── Fraud.php
│ │ ├── Offer.php
│ │ ├── Payment.php
│ │ ├── Preauthorization.php
│ │ ├── Refund.php
│ │ ├── Subscription.php
│ │ ├── Transaction.php
│ │ └── Webhook.php
│ ├── Request.php
│ └── Services
│ ├── PaymillException.php
│ ├── ResponseHandler.php
│ └── Util.php
├── samples
├── authentication
│ └── authentication.php
├── checksums
│ ├── create.php
│ ├── get_by_id.php
│ └── list.php
├── clients
│ ├── create_new_client.php
│ ├── export_clients_list.php
│ ├── get_client_details.php
│ ├── list_clients.php
│ ├── remove_client.php
│ └── update_client.php
├── offers
│ ├── create_new_offer.php
│ ├── export_offers_list.php
│ ├── get_offer_details.php
│ ├── list_offers.php
│ ├── remove_offer.php
│ └── update_offer.php
├── payments
│ ├── create_new_credit_card_payment_with_token.php
│ ├── create_new_credit_card_payment_with_token_and_client.php
│ ├── create_new_debit_payment_with_token.php
│ ├── create_new_debit_payment_with_token_and_client.php
│ ├── export_payments_list.php
│ ├── get_payment_details.php
│ ├── list_payments.php
│ └── remove_payment.php
├── preauthorizations
│ ├── create_new_preauthorization_with_payment.php
│ ├── create_new_preauthorization_with_token.php
│ ├── export_preauthorizations_list.php
│ ├── get_preauthorization_details.php
│ ├── list_preauthorizations.php
│ └── remove_preauthorization.php
├── refunds
│ ├── create_new_refund.php
│ ├── export_refunds_list.php
│ ├── get_refund_details.php
│ └── list_refunds.php
├── subscriptions
│ ├── cancel_subscription.php
│ ├── create_new_subscription_with_an_offer.php
│ ├── create_new_subscription_with_an_offer_and_different_values.php
│ ├── create_new_subscription_without_an_offer.php
│ ├── delete_subscription.php
│ ├── export_subscriptions_list.php
│ ├── get_subscription_details.php
│ ├── list_subscriptions.php
│ ├── pause_subscription.php
│ ├── update_subscription.php
│ ├── update_subscription_amount.php
│ └── update_subscription_offer.php
├── transactions
│ ├── create_new_transaction_with_app_fee.php
│ ├── create_new_transaction_with_client_and_payment.php
│ ├── create_new_transaction_with_payment.php
│ ├── create_new_transaction_with_preauthorization.php
│ ├── create_new_transaction_with_token.php
│ ├── export_transactions_list.php
│ ├── get_transaction_details_by_id.php
│ ├── get_transaction_details_by_slv.php
│ ├── list_transactions.php
│ └── upate_transaction.php
└── webhooks
│ ├── create_new_email_webhook.php
│ ├── create_new_url_webhook.php
│ ├── export_webhooks_list.php
│ ├── get_webhook_details.php
│ ├── list_webhooks.php
│ ├── remove_webhook.php
│ └── update_webhook.php
└── tests
├── Integration
├── ChecksumTest.php
├── ClientTest.php
├── IntegrationBase.php
├── OfferTest.php
├── PaymentTest.php
├── PreauthorizationTest.php
├── RefundTest.php
├── SubscriptionTest.php
├── TransactionTest.php
└── WebhookTest.php
├── Unit
└── Paymill
│ ├── API
│ └── CurlTest.php
│ ├── Models
│ ├── Internal
│ │ ├── BillingAddressTest.php
│ │ ├── ItemTest.php
│ │ └── ShippingAddressTest.php
│ ├── Request
│ │ ├── BaseTest.php
│ │ ├── ChecksumTest.php
│ │ ├── ClientTest.php
│ │ ├── OfferTest.php
│ │ ├── PaymentTest.php
│ │ ├── PreauthorizationTest.php
│ │ ├── RefundTest.php
│ │ ├── SubscriptionTest.php
│ │ ├── TransactionTest.php
│ │ └── WebhookTest.php
│ └── Response
│ │ ├── BaseTest.php
│ │ ├── ChecksumTest.php
│ │ ├── ClientTest.php
│ │ ├── ErrorTest.php
│ │ ├── OfferTest.php
│ │ ├── PaymentTest.php
│ │ ├── PreauthorizationTest.php
│ │ ├── RefundTest.php
│ │ ├── SubscriptionTest.php
│ │ ├── TransactionTest.php
│ │ └── WebhookTest.php
│ └── Services
│ ├── RequestTest.php
│ └── ResponseHandlerTest.php
├── bootstrap.php
└── phpunit.xml.dist
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /build/
3 | /vendor
4 | phpunit.xml
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | script:
4 | - ant test
5 | - ant test-integration
6 |
7 | env:
8 | global:
9 | - secure: "StaRWxgVW55YXMetUfL91rGDHJCBC0e3Nv9qYx5jg2aa9H0BIYhJ8vYtDXbKFEeGXWRnlLdPVclzRiIMdYQTZaBrjHxWVzE9N5stIyIq/Ik5hvkRs3h78ICSsDJB7SAun+aYv4vV/2kR44B0YiOhWZehV3IhAWO1Csd4HDjiQHY="
10 | - PAYMILL_API_TEST_KEY: 0dcb0c6a3dcddace93de405fb98857b7
11 | - PAYMILL_API_PUBLIC_TEST_KEY: 07558773223ff498c4ab0ca581551453
12 |
13 | matrix:
14 | include:
15 | - php: 7.0
16 | env: PAYMILL_WH_1=subscription.failed PAYMILL_WH_2=subscription.expiring
17 | - php: 5.6
18 | env: PAYMILL_WH_1=transaction.succeeded PAYMILL_WH_2=subscription.created
19 | - php: 5.5
20 | env: PAYMILL_WH_1=chargeback.executed PAYMILL_WH_2=transaction.created
21 | - php: 5.4
22 | env: PAYMILL_WH_1=transaction.pending PAYMILL_WH_2=transaction.failed
23 | - php: 5.3
24 | env: PAYMILL_WH_1=client.updated PAYMILL_WH_2=subscription.updated
25 | - php: hhvm
26 | env: PAYMILL_WH_1=subscription.deleted PAYMILL_WH_2=subscription.succeeded
27 |
28 | before_install: composer self-update
29 | install: composer install
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (C) 2012 Paymill GmbH
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
5 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
6 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to
7 | do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
12 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
13 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
14 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PAYMILL-PHP
2 | ===========
3 |
4 | [](https://travis-ci.org/paymill/paymill-php)[](https://packagist.org/packages/paymill/paymill)[](https://packagist.org/packages/paymill/paymill)
5 |
6 | VERSIONING
7 | ----------
8 |
9 | This wrapper is using the api v2.1 launched in June 2014. If you wish to use the old api v2.0 please use the wrapper in branch v2: https://github.com/paymill/paymill-php/tree/v2.
10 |
11 | How to test cards and errors
12 | ----------------------------
13 |
14 | There are different credit card numbers, frontend and backend error codes, which can be used for testing. For more information, please read our testing reference. https://www.paymill.com/en-gb/documentation-3/reference/testing/
15 |
16 | How to run unit and integration tests
17 | -------------------------------------
18 | Just run:
19 |
20 | ```
21 | ant test
22 | ```
23 |
24 |
25 | Getting started with PAYMILL
26 | ----------------------------
27 |
28 | If you don't already use Composer, then you probably should read the installation guide http://getcomposer.org/download/.
29 |
30 | Please include this library via Composer in your composer.json and execute **composer update** to refresh the autoload.php.
31 |
32 | ```json
33 | {
34 | "repositories": [
35 | {
36 | "type": "vcs",
37 | "url": "https://github.com/paymill/paymill-php"
38 | }
39 | ],
40 | "require": {
41 | "paymill/paymill": "dev-master"
42 | }
43 | }
44 | ```
45 |
46 | If you don't want to use composer, paymill-php library provides its own **autoload** script. You have to include the autoload script in all files, in which you are going to use the PAYMILL library.
47 |
48 | Lets say you have two files, which are going to use the PAYMILL lib. First one is located in the project root, the other one is in the app folder. You have downloaded the PAYMILL library in your project root folder under the name **paymill-php**.
49 |
50 | To load the PAYMILL library from the file, which is located in *your project root folder*, you need to **require** PAYMILL's **autoload** script like this:
51 |
52 | ```php
53 | require './paymill-php/autoload.php';
54 | ```
55 |
56 | To load the PAYMILL library from the file, which is located in *the app folder*, you need to **require** PAYMILL's **autoload** script like this:
57 |
58 | ```php
59 | require '../paymill-php/autoload.php';
60 | ```
61 |
62 | 1. Instantiate the request class with the following parameters: $apiKey: First parameter is always your private API (test) Key
63 |
64 | ```php
65 | $request = new Paymill\Request($apiKey);
66 | ```
67 |
68 | 1. Instantiate the model class with the parameters described in the API-reference:
69 |
70 | ```php
71 | $payment = new \Paymill\Models\Request\Payment();
72 | $payment->setToken("098f6bcd4621d373cade4e832627b4f6");
73 | ```
74 |
75 | 1. Use your desired function:
76 |
77 | ```php
78 | $response = $request->create($payment);
79 | $paymentId = $response->getId();
80 | ```
81 |
82 | It recommend to wrap it into a "try/catch" to handle exceptions like this:
83 |
84 | ```php
85 | try {
86 | $response = $request->create($payment);
87 | $paymentId = $response->getId();
88 | } catch(\Paymill\Services\PaymillException $e){
89 | //Do something with the error informations below
90 | $e->getResponseCode();
91 | $e->getStatusCode();
92 | $e->getErrorMessage();
93 | $e->getRawError();
94 | }
95 | ```
96 |
97 | Receiving Response
98 | ------------------
99 |
100 | This section shows diffrent ways how to receive a response. The followings examples show how to get the Id for a transaction.
101 |
102 | 1. The default response is one of the response-models.
103 |
104 | ```php
105 | $response = $request->create($payment);
106 | $response->getId();
107 | ```
108 |
109 | 1. getLastResponse() returns the unconverted response from the API.
110 |
111 | ```php
112 | $request->create($payment);
113 | $response = $request->getLastResponse();
114 | $response['body']['data']['id'];
115 | ```
116 |
117 | 1. getJSONObject returns the response as stdClass-Object.
118 |
119 | ```php
120 | $request->create($payment);
121 | $response = $request->getJSONObject();
122 | $response->data->id;
123 | ```
124 |
125 | Using Root certificate
126 | ----------------------
127 |
128 | If the error below occurres on your system please follow the steps below to configure curl.
129 |
130 | ```php
131 | Paymill\Services\PaymillException: SSL certificate problem, verify that the CA cert is OK. Details:
132 | error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
133 | ```
134 |
135 | Windows / OS X / Linux
136 |
137 | 1. Download http://curl.haxx.se/ca/cacert.pem and save it on your server.
138 | 2. Open php.ini with an editor and add the line `curl.cainfo=PathToYourCACertFile`
139 | 3. Restart your Webserver
140 |
141 | Update Root certificate on Linux(ubuntu)
142 |
143 | 1. Run `sudo update-ca-certificates`
144 | 2. Restart your Webserver
145 |
146 | Changelog
147 | ---------
148 |
149 | #### 3.2.1
150 |
151 | - bugfix: [#92](https://github.com/paymill/paymill-php/pull/92) remove typecheck for http response code
152 |
153 | #### 4.0.0
154 |
155 | - Added shipping and billing address
156 | - Added shopping cart (items)
157 | - Added PayPal functionality
158 | - Possible [BC break in ResponseHandler.php](https://github.com/paymill/paymill-php/pull/102#discussion_r32232137)
159 |
160 | Documentation
161 | -------------
162 |
163 | For further information, please refer to our official PHP library reference: https://developers.paymill.com/API/index
164 |
--------------------------------------------------------------------------------
/autoload.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | "name": "paymill/paymill",
4 | "type": "library",
5 | "description": "Paymill PHPLib",
6 | "keywords": ["payment", "provider"],
7 | "license": "MIT",
8 | "homepage": "https://www.paymill.de",
9 | "authors": [
10 | {
11 | "name": "Paymill GmbH",
12 | "homepage": "https://www.paymill.de"
13 | }
14 | ],
15 | "autoload": {
16 | "psr-0": {
17 | "Paymill": "lib/"
18 | }
19 | }
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/lib/Paymill/API/CommunicationAbstract.php:
--------------------------------------------------------------------------------
1 | _apiKey = $apiKey;
47 | $this->_apiUrl = $apiEndpoint;
48 | /**
49 | * Proxy support. The proxy can be SOCKS5 or HTTP.
50 | * Also the connection could be tunneled through.
51 | */
52 | $this->_extraOptions = $extracURL;
53 | }
54 |
55 | /**
56 | * Perform HTTP request to REST endpoint
57 | *
58 | * @param string $action
59 | * @param array $params
60 | * @param string $method
61 | * @return array
62 | */
63 | public function requestApi($action = '', $params = array(), $method = 'POST')
64 | {
65 | $curlOpts = array(
66 | CURLOPT_URL => $this->_apiUrl . $action,
67 | CURLOPT_RETURNTRANSFER => true,
68 | CURLOPT_CUSTOMREQUEST => $method,
69 | CURLOPT_USERAGENT => 'Paymill-php/0.0.2',
70 | CURLOPT_SSL_VERIFYPEER => true
71 | );
72 |
73 | // Add extra options to cURL if defined.
74 | if (!empty($this->_extraOptions)) {
75 | $curlOpts = $this->_extraOptions + $curlOpts;
76 | }
77 |
78 | if ('GET' === $method || 'DELETE' === $method) {
79 | if (0 !== count($params)) {
80 | $curlOpts[CURLOPT_URL] .= false === strpos($curlOpts[CURLOPT_URL], '?') ? '?' : '&';
81 | $curlOpts[CURLOPT_URL] .= http_build_query($params, null, '&');
82 | }
83 | } else {
84 | $curlOpts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
85 | }
86 |
87 | if ($this->_apiKey) {
88 | $curlOpts[CURLOPT_USERPWD] = $this->_apiKey . ':';
89 | }
90 | $curl = curl_init();
91 | $this->_curlOpts($curl, $curlOpts);
92 | $responseBody = $this->_curlExec($curl);
93 | $responseInfo = $this->_curlInfo($curl);
94 |
95 | if ($responseBody === false) {
96 | $responseBody = array('error' => $this->_curlError($curl));
97 | }
98 | curl_close($curl);
99 |
100 | if ('application/json' === $responseInfo['content_type']) {
101 | $responseBody = json_decode($responseBody, true);
102 | } elseif (strpos(strtolower($responseInfo['content_type']), 'text/csv') !== false
103 | && !isset($responseBody['error'])
104 | ) {
105 | return $responseBody;
106 | }
107 |
108 | $result = array(
109 | 'header' => array(
110 | 'status' => $responseInfo['http_code'],
111 | 'reason' => null,
112 | ),
113 | 'body' => $responseBody
114 | );
115 |
116 | return $result;
117 | }
118 |
119 | /**
120 | * Wraps the curl_setopt_array function call
121 | *
122 | * @param resource $curl curl resource handle
123 | * @param array $curlOpts array containing curl options
124 | * @return bool
125 | */
126 | protected function _curlOpts($curl, array $curlOpts)
127 | {
128 | return curl_setopt_array($curl, $curlOpts);
129 | }
130 |
131 | /**
132 | * Wraps the curlExec function call
133 | * @param resource $curl cURL handle passed to curl_exec
134 | * @return mixed
135 | */
136 | protected function _curlExec($curl)
137 | {
138 | return curl_exec($curl);
139 | }
140 |
141 | /**
142 | * Wraps the curlInfo function call
143 | * @param resource $curl cURL handle passed to curl_getinfo
144 | * @return mixed
145 | */
146 | protected function _curlInfo($curl)
147 | {
148 | return curl_getinfo($curl);
149 | }
150 |
151 | /**
152 | * Wraps the curlError function call
153 | * @param resource $curl cURL handle passed to curl_error
154 | * @return mixed
155 | */
156 | protected function _curlError($curl)
157 | {
158 | return curl_error($curl);
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Internal/AbstractAddress.php:
--------------------------------------------------------------------------------
1 | _name;
70 | }
71 |
72 | /**
73 | * Set name
74 | *
75 | * @param null|string $name
76 | *
77 | * @return $this
78 | */
79 | public function setName($name)
80 | {
81 | $this->_name = $name;
82 |
83 | return $this;
84 | }
85 |
86 | /**
87 | * Get streetAddress
88 | *
89 | * @return null|string
90 | */
91 | public function getStreetAddress()
92 | {
93 | return $this->_streetAddress;
94 | }
95 |
96 | /**
97 | * Set streetAddress
98 | *
99 | * @param null|string $streetAddress
100 | *
101 | * @return $this
102 | */
103 | public function setStreetAddress($streetAddress)
104 | {
105 | $this->_streetAddress = $streetAddress;
106 |
107 | return $this;
108 | }
109 |
110 | /**
111 | * Get streetAddressAddition
112 | *
113 | * @return null|string
114 | */
115 | public function getStreetAddressAddition()
116 | {
117 | return $this->_streetAddressAddition;
118 | }
119 |
120 | /**
121 | * Set streetAddressAddition
122 | *
123 | * @param null|string $streetAddressAddition
124 | *
125 | * @return $this
126 | */
127 | public function setStreetAddressAddition($streetAddressAddition)
128 | {
129 | $this->_streetAddressAddition = $streetAddressAddition;
130 |
131 | return $this;
132 | }
133 |
134 | /**
135 | * Get city
136 | *
137 | * @return null|string
138 | */
139 | public function getCity()
140 | {
141 | return $this->_city;
142 | }
143 |
144 | /**
145 | * Set city
146 | *
147 | * @param null|string $city
148 | *
149 | * @return $this
150 | */
151 | public function setCity($city)
152 | {
153 | $this->_city = $city;
154 |
155 | return $this;
156 | }
157 |
158 | /**
159 | * Get state
160 | *
161 | * @return null|string
162 | */
163 | public function getState()
164 | {
165 | return $this->_state;
166 | }
167 |
168 | /**
169 | * Set state
170 | *
171 | * @param null|string $state
172 | *
173 | * @return $this
174 | */
175 | public function setState($state)
176 | {
177 | $this->_state = $state;
178 |
179 | return $this;
180 | }
181 |
182 | /**
183 | * Get postalCode
184 | *
185 | * @return null|string
186 | */
187 | public function getPostalCode()
188 | {
189 | return $this->_postalCode;
190 | }
191 |
192 | /**
193 | * Set postalCode
194 | *
195 | * @param null|string $postalCode
196 | *
197 | * @return $this
198 | */
199 | public function setPostalCode($postalCode)
200 | {
201 | $this->_postalCode = $postalCode;
202 |
203 | return $this;
204 | }
205 |
206 | /**
207 | * Get country
208 | *
209 | * @return null|string
210 | */
211 | public function getCountry()
212 | {
213 | return $this->_country;
214 | }
215 |
216 | /**
217 | * Set country
218 | *
219 | * @param null|string $country
220 | *
221 | * @return $this
222 | */
223 | public function setCountry($country)
224 | {
225 | $this->_country = $country;
226 |
227 | return $this;
228 | }
229 |
230 | /**
231 | * Get phone
232 | *
233 | * @return null|string
234 | */
235 | public function getPhone()
236 | {
237 | return $this->_phone;
238 | }
239 |
240 | /**
241 | * Set phone
242 | *
243 | * @param null|string $phone
244 | *
245 | * @return $this
246 | */
247 | public function setPhone($phone)
248 | {
249 | $this->_phone = $phone;
250 |
251 | return $this;
252 | }
253 |
254 | /**
255 | * Converts model to array.
256 | *
257 | * @return array
258 | */
259 | public function toArray()
260 | {
261 | return array(
262 | static::FIELD_NAME => $this->_name,
263 | static::FIELD_STREET_ADDRESS => $this->_streetAddress,
264 | static::FIELD_STREET_ADDRESS_ADDITION => $this->_streetAddressAddition,
265 | static::FIELD_CITY => $this->_city,
266 | static::FIELD_POSTAL_CODE => $this->_postalCode,
267 | static::FIELD_COUNTRY => $this->_country,
268 | static::FIELD_STATE => $this->_state,
269 | static::FIELD_PHONE => $this->_phone,
270 | );
271 | }
272 | }
273 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Internal/BillingAddress.php:
--------------------------------------------------------------------------------
1 | _name;
52 | }
53 |
54 | /**
55 | * Set name
56 | *
57 | * @param string $name
58 | *
59 | * @return $this
60 | */
61 | public function setName($name)
62 | {
63 | $this->_name = $name;
64 |
65 | return $this;
66 | }
67 |
68 | /**
69 | * Get _description
70 | *
71 | * @return string
72 | */
73 | public function getDescription()
74 | {
75 | return $this->_description;
76 | }
77 |
78 | /**
79 | * Set description
80 | *
81 | * @param string $description
82 | *
83 | * @return $this
84 | */
85 | public function setDescription($description)
86 | {
87 | $this->_description = $description;
88 |
89 | return $this;
90 | }
91 |
92 | /**
93 | * Get _itemNumber
94 | *
95 | * @return string
96 | */
97 | public function getItemNumber()
98 | {
99 | return $this->_itemNumber;
100 | }
101 |
102 | /**
103 | * Set itemNumber
104 | *
105 | * @param string $itemNumber
106 | *
107 | * @return $this
108 | */
109 | public function setItemNumber($itemNumber)
110 | {
111 | $this->_itemNumber = $itemNumber;
112 |
113 | return $this;
114 | }
115 |
116 | /**
117 | * Get _url
118 | *
119 | * @return string
120 | */
121 | public function getUrl()
122 | {
123 | return $this->_url;
124 | }
125 |
126 | /**
127 | * Set url
128 | *
129 | * @param string $url
130 | *
131 | * @return $this
132 | */
133 | public function setUrl($url)
134 | {
135 | $this->_url = $url;
136 |
137 | return $this;
138 | }
139 |
140 | /**
141 | * Get _amount
142 | *
143 | * @return string
144 | */
145 | public function getAmount()
146 | {
147 | return $this->_amount;
148 | }
149 |
150 | /**
151 | * Set amount
152 | *
153 | * @param string $amount
154 | *
155 | * @return $this
156 | */
157 | public function setAmount($amount)
158 | {
159 | $this->_amount = $amount;
160 |
161 | return $this;
162 | }
163 |
164 | /**
165 | * Get _quantity
166 | *
167 | * @return int
168 | */
169 | public function getQuantity()
170 | {
171 | return $this->_quantity;
172 | }
173 |
174 | /**
175 | * Set quantity
176 | *
177 | * @param int $quantity
178 | *
179 | * @return $this
180 | */
181 | public function setQuantity($quantity)
182 | {
183 | $this->_quantity = $quantity;
184 |
185 | return $this;
186 | }
187 |
188 | /**
189 | * Converts model to array.
190 | *
191 | * @return array
192 | */
193 | public function toArray()
194 | {
195 | return array(
196 | static::FIELD_NAME => $this->_name,
197 | static::FIELD_DESCRIPTION => $this->_description,
198 | static::FIELD_ITEM_NUMBER => $this->_itemNumber,
199 | static::FIELD_AMOUNT => $this->_amount,
200 | static::FIELD_QUANTITY => $this->_quantity,
201 | static::FIELD_URL => $this->_url,
202 | );
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Internal/ShippingAddress.php:
--------------------------------------------------------------------------------
1 | _serviceResource;
33 | }
34 |
35 | /**
36 | * Returns this objects unique identifier
37 | * @return string identifier
38 | */
39 | public function getId()
40 | {
41 | return $this->_id;
42 | }
43 |
44 | /**
45 | * Sets the unique identifier of this object
46 | * @param string $id
47 | * @return \Paymill\Models\Request\Base
48 | */
49 | public function setId($id)
50 | {
51 | $this->_id = $id;
52 | return $this;
53 | }
54 | /**
55 | * Returns the filterArray for getAll
56 | * @return array
57 | */
58 | public function getFilter()
59 | {
60 | if (is_null($this->_filter)) {
61 | return array();
62 | }
63 | return $this->_filter;
64 | }
65 |
66 | /**
67 | * Sets the filterArray for getAll
68 | * @param array $filter
69 | * @return \Paymill\Models\Request\Base
70 | */
71 | public function setFilter($filter)
72 | {
73 | $this->_filter = $filter;
74 | return $this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Checksum.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'clients/';
31 | }
32 |
33 | /**
34 | * Returns the Mail address of this client.
35 | * @return string
36 | */
37 | public function getEmail()
38 | {
39 | return $this->_email;
40 | }
41 |
42 | /**
43 | * Sets the Mail address of this client.
44 | * @param string $email
45 | * @return \Paymill\Models\Request\Client
46 | */
47 | public function setEmail($email)
48 | {
49 | $this->_email = $email;
50 | return $this;
51 | }
52 |
53 | /**
54 | * Returns the additional description for this client, perhaps the identifier from your CRM system?
55 | * @return string
56 | */
57 | public function getDescription()
58 | {
59 | return $this->_description;
60 | }
61 |
62 | /**
63 | * Sets an additional description for this client. We recommend some sort of identifier from your CRM system
64 | * @param string $description
65 | * @return \Paymill\Models\Request\Client
66 | */
67 | public function setDescription($description)
68 | {
69 | $this->_description = $description;
70 | return $this;
71 | }
72 |
73 | /**
74 | * Returns an array of parameters customized for the argumented methodname
75 | * @param string $method
76 | * @return array
77 | */
78 | public function parameterize($method)
79 | {
80 | $parameterArray = array();
81 | switch ($method) {
82 | case 'create':
83 | case 'update':
84 | $parameterArray['email'] = $this->getEmail();
85 | $parameterArray['description'] = $this->getDescription();
86 | break;
87 | case 'getOne':
88 | $parameterArray['count'] = 1;
89 | $parameterArray['offset'] = 0;
90 | break;
91 | case 'getAll':
92 | $parameterArray = $this->getFilter();
93 | break;
94 | case 'delete':
95 | break;
96 | }
97 |
98 | return $parameterArray;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Fraud.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'Frauds/';
22 | }
23 |
24 | /**
25 | * Returns the identifier
26 | * @return string||null
27 | */
28 | public function getIdentifier()
29 | {
30 | return $this->_identifier;
31 | }
32 |
33 | /**
34 | * Sets the identifier
35 | * @param string $identifier
36 | * @return \Paymill\Models\Request\Fraud
37 | */
38 | public function setIdentifier($identifier)
39 | {
40 | $this->_identifier = $identifier;
41 | return $this;
42 | }
43 |
44 | /**
45 | * Returns an array of parameters customized for the argumented methodname
46 | * @param string $method
47 | * @return array
48 | */
49 | public function parameterize($method)
50 | {
51 | $parameterArray = array();
52 | switch ($method) {
53 | case 'create':
54 | $parameterArray['Identifier'] = $this->getIdentifier();
55 | break;
56 | case 'update':
57 | $parameterArray['Identifier'] = $this->getIdentifier();
58 | break;
59 | case 'delete':
60 | break;
61 | case 'getOne':
62 | $parameterArray['count'] = 1;
63 | $parameterArray['offset'] = 0;
64 | break;
65 | case 'getAll':
66 | $parameterArray = $this->getFilter();
67 | break;
68 | }
69 |
70 | return $parameterArray;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/KontosecureChecksum.php:
--------------------------------------------------------------------------------
1 | country;
40 | }
41 |
42 | /**
43 | * Set country ISO 3166-1 alpha-2
44 | *
45 | * @param string $country
46 | *
47 | * @return $this
48 | */
49 | public function setCountry($country)
50 | {
51 | $this->country = $country;
52 |
53 | return $this;
54 | }
55 |
56 | /**
57 | * Get clientEmail
58 | *
59 | * @return string
60 | */
61 | public function getClientEmail()
62 | {
63 | return $this->clientEmail;
64 | }
65 |
66 | /**
67 | * Set clientEmail
68 | *
69 | * @param string $clientEmail
70 | *
71 | * @return $this
72 | */
73 | public function setClientEmail($clientEmail)
74 | {
75 | $this->clientEmail = $clientEmail;
76 |
77 | return $this;
78 | }
79 |
80 | /**
81 | * Get billing address
82 | *
83 | * @return array
84 | */
85 | public function getBillingAddress()
86 | {
87 | return $this->billingAddress;
88 | }
89 |
90 | /**
91 | * Set billing address
92 | *
93 | * @param array $billingAddress Billing address
94 | *
95 | * @return $this
96 | */
97 | public function setBillingAddress(array $billingAddress)
98 | {
99 | $this->billingAddress = $billingAddress;
100 |
101 | return $this;
102 | }
103 |
104 | /**
105 | * Returns an array of parameters customized for the given method name
106 | *
107 | * @param string $method
108 | *
109 | * @return array
110 | */
111 | public function parameterize($method)
112 | {
113 | $parameterArray = parent::parameterize($method);
114 |
115 | if ('create' == $method) {
116 | if ($this->getCountry()) {
117 | $parametersArray['country'] = $this->getCountry();
118 | }
119 |
120 | if ($this->getClientEmail()) {
121 | $parametersArray['client_email'] = $this->getClientEmail();
122 | }
123 |
124 | if ($this->getBillingAddress()) {
125 | $parametersArray['billing_address'] = $this->getBillingAddress();
126 | }
127 | }
128 |
129 | return $parameterArray;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Payment.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'Payments/';
30 | }
31 |
32 | /**
33 | * Returns the identifier of a client (client-object)
34 | * @return string The identifier of a client (client-object)
35 | */
36 | public function getClient()
37 | {
38 | return $this->_client;
39 | }
40 |
41 | /**
42 | * Sets the identifier of a client (client-object)
43 | * @param string $client
44 | * @return Payment
45 | */
46 | public function setClient($client)
47 | {
48 | $this->_client = $client;
49 | return $this;
50 | }
51 |
52 | /**
53 | * Returns the Token
54 | * @return String
55 | */
56 | public function getToken()
57 | {
58 | return $this->_token;
59 | }
60 |
61 | /**
62 | * Sets the token required for payment creation
63 | * @param string $token
64 | * @return Payment
65 | */
66 | public function setToken($token)
67 | {
68 | $this->_token = $token;
69 | return $this;
70 | }
71 |
72 | /**
73 | * Returns an array of parameters customized for the argumented methodname
74 | * @param string $method
75 | * @return array
76 | */
77 | public function parameterize($method)
78 | {
79 | $parameterArray = array();
80 | switch ($method) {
81 | case 'create':
82 | $parameterArray['token'] = $this->getToken();
83 | $parameterArray['client'] = $this->getClient();
84 | break;
85 | case 'delete':
86 | break;
87 | case 'getOne':
88 | $parameterArray['count'] = 1;
89 | $parameterArray['offset'] = 0;
90 | break;
91 | case 'getAll':
92 | $parameterArray = $this->getFilter();
93 | break;
94 | }
95 |
96 | return $parameterArray;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Preauthorization.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'Preauthorizations/';
56 | }
57 |
58 | /**
59 | * Returns the amount
60 | * @return string
61 | */
62 | public function getAmount()
63 | {
64 | return $this->_amount;
65 | }
66 |
67 | /**
68 | * Sets the amount
69 | * @param string $amount
70 | * @return \Paymill\Models\Request\Preauthorization
71 | */
72 | public function setAmount($amount)
73 | {
74 | $this->_amount = $amount;
75 | return $this;
76 | }
77 |
78 | /**
79 | * Returns the currency
80 | * @return string
81 | */
82 | public function getCurrency()
83 | {
84 | return $this->_currency;
85 | }
86 |
87 | /**
88 | * Sets the currency
89 | * @param string $currency
90 | * @return \Paymill\Models\Request\Preauthorization
91 | */
92 | public function setCurrency($currency)
93 | {
94 | $this->_currency = $currency;
95 | return $this;
96 | }
97 |
98 | /**
99 | * Returns the identifier of a payment
100 | * @return string
101 | */
102 | public function getPayment()
103 | {
104 | return $this->_payment;
105 | }
106 |
107 | /**
108 | * Sets the identifier of a payment
109 | * @param string $payment
110 | * @return \Paymill\Models\Request\Preauthorization
111 | */
112 | public function setPayment($payment)
113 | {
114 | $this->_payment = $payment;
115 | return $this;
116 | }
117 |
118 | /**
119 | * Returns the token required for the creation of preAuths
120 | * @return string
121 | */
122 | public function getToken()
123 | {
124 | return $this->_token;
125 | }
126 |
127 | /**
128 | * Sets the token required for the creation of preAuths
129 | * @param string $token
130 | * @return \Paymill\Models\Request\Preauthorization
131 | */
132 | public function setToken($token)
133 | {
134 | $this->_token = $token;
135 | return $this;
136 | }
137 |
138 | /**
139 | * Sets the name of origin of the call creating the transaction.
140 | *
141 | * @param string $source Source
142 | *
143 | * @return $this
144 | */
145 | public function setSource($source)
146 | {
147 | $this->_source = $source;
148 |
149 | return $this;
150 | }
151 |
152 | /**
153 | * Gets the name of origin of the call creating the transaction.
154 | *
155 | * @return string
156 | */
157 | public function getSource()
158 | {
159 | return $this->_source;
160 | }
161 |
162 | /**
163 | * Returns the description
164 | * @return string
165 | */
166 | public function getDescription()
167 | {
168 | return $this->_description;
169 | }
170 |
171 | /**
172 | * Sets the description
173 | * @param string $description
174 | * @return \Paymill\Models\Request\Preauthorization
175 | */
176 | public function setDescription($description)
177 | {
178 | $this->_description = $description;
179 | return $this;
180 | }
181 |
182 | /**
183 | * Returns the client
184 | * @return string
185 | */
186 | public function getClient()
187 | {
188 | return $this->_client;
189 | }
190 |
191 | /**
192 | * Sets the client
193 | * @param string $client
194 | * @return \Paymill\Models\Request\Preauthorization
195 | */
196 | public function setClient($client)
197 | {
198 | $this->_client = $client;
199 | return $this;
200 | }
201 |
202 | /**
203 | * Returns an array of parameters customized for the argumented methodname
204 | * @param string $method
205 | * @return array
206 | */
207 | public function parameterize($method)
208 | {
209 | $parameterArray = array();
210 | switch ($method) {
211 | case 'create':
212 | if (!is_null($this->getPayment())) {
213 | $parameterArray['payment'] = $this->getPayment();
214 | } else {
215 | $parameterArray['token'] = $this->getToken();
216 | }
217 | $parameterArray['amount'] = $this->getAmount();
218 | $parameterArray['currency'] = $this->getCurrency();
219 | $parameterArray['description'] = $this->getDescription();
220 | if (!is_null($this->getClient())) {
221 | $parameterArray['client'] = $this->getClient();
222 | }
223 | if(!is_null($this->getSource())) {
224 | $parameterArray['source'] = $this->getSource();
225 | }
226 | break;
227 | case 'getOne':
228 | $parameterArray['count'] = 1;
229 | $parameterArray['offset'] = 0;
230 | break;
231 | case 'getAll':
232 | $parameterArray = $this->getFilter();
233 | break;
234 | case 'delete':
235 | break;
236 | }
237 |
238 | return $parameterArray;
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Refund.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'Refunds/';
38 | }
39 |
40 | /**
41 | * Returns the amount
42 | *
43 | * @return string
44 | */
45 | public function getAmount()
46 | {
47 | return $this->_amount;
48 | }
49 |
50 | /**
51 | * Sets the amount
52 | * @param string $amount
53 | *
54 | * @return \Paymill\Models\Request\Refund
55 | */
56 | public function setAmount($amount)
57 | {
58 | $this->_amount = $amount;
59 | return $this;
60 | }
61 |
62 | /**
63 | * Returns the description
64 | *
65 | * @return string
66 | */
67 | public function getDescription()
68 | {
69 | return $this->_description;
70 | }
71 |
72 | /**
73 | * Sets the description
74 | * @param string $description
75 | *
76 | * @return \Paymill\Models\Request\Refund
77 | */
78 | public function setDescription($description)
79 | {
80 | $this->_description = $description;
81 | return $this;
82 | }
83 |
84 | /**
85 | * Returns the reason
86 | * @return string
87 | */
88 | public function getReason()
89 | {
90 | return $this->_reason;
91 | }
92 |
93 | /**
94 | * Sets the reason possible Reasons are
95 | * - Refund::REASON_KEY_REQUESTED_BY_CUSTOMER (requested_by_customer)
96 | * - Refund::REASON_KEY_DUPLICATE (duplicate)
97 | * - Refund::REASON_KEY_FRAUDULENT (fraudulent)
98 | *
99 | * @param string $reason
100 | *
101 | * @return \Paymill\Models\Request\Refund
102 | */
103 | public function setReason($reason)
104 | {
105 | if (in_array(
106 | $reason,
107 | array(self::REASON_KEY_FRAUDULENT, self::REASON_KEY_REQUESTED_BY_CUSTOMER, self::REASON_KEY_DUPLICATE)
108 | )) {
109 | $this->_reason = $reason;
110 | }
111 |
112 | return $this;
113 | }
114 |
115 | /**
116 | * Returns an array of parameters customized for the argumented methodname
117 | * @param string $method
118 | *
119 | * @return array
120 | */
121 | public function parameterize($method)
122 | {
123 | $parameterArray = array();
124 | switch ($method) {
125 | case 'create':
126 | $parameterArray['amount'] = $this->getAmount();
127 | $parameterArray['description'] = $this->getDescription();
128 | if (!empty($this->_reason)) {
129 | $parameterArray['reason'] = $this->_reason;
130 | }
131 | break;
132 | case 'getOne':
133 | $parameterArray['count'] = 1;
134 | $parameterArray['offset'] = 0;
135 | break;
136 | case 'getAll':
137 | $parameterArray = $this->getFilter();
138 | break;
139 | }
140 |
141 | return $parameterArray;
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/SofortChecksum.php:
--------------------------------------------------------------------------------
1 | firstName;
55 | }
56 |
57 | /**
58 | * Set firstName
59 | *
60 | * @param string $firstName
61 | *
62 | * @return $this
63 | */
64 | public function setFirstName($firstName)
65 | {
66 | $this->firstName = $firstName;
67 |
68 | return $this;
69 | }
70 |
71 | /**
72 | * Get lastName
73 | *
74 | * @return string
75 | */
76 | public function getLastName()
77 | {
78 | return $this->lastName;
79 | }
80 |
81 | /**
82 | * Set lastName
83 | *
84 | * @param string $lastName
85 | *
86 | * @return $this
87 | */
88 | public function setLastName($lastName)
89 | {
90 | $this->lastName = $lastName;
91 |
92 | return $this;
93 | }
94 |
95 | /**
96 | * Get country
97 | *
98 | * @return string
99 | */
100 | public function getCountry()
101 | {
102 | return $this->country;
103 | }
104 |
105 | /**
106 | * Set country ISO 3166-1 alpha-2
107 | *
108 | * @param string $country
109 | *
110 | * @return $this
111 | */
112 | public function setCountry($country)
113 | {
114 | $this->country = $country;
115 |
116 | return $this;
117 | }
118 |
119 | /**
120 | * Get clientEmail
121 | *
122 | * @return string
123 | */
124 | public function getClientEmail()
125 | {
126 | return $this->clientEmail;
127 | }
128 |
129 | /**
130 | * Set clientEmail
131 | *
132 | * @param string $clientEmail
133 | *
134 | * @return $this
135 | */
136 | public function setClientEmail($clientEmail)
137 | {
138 | $this->clientEmail = $clientEmail;
139 |
140 | return $this;
141 | }
142 |
143 | /**
144 | * Get clientPhoneNumber
145 | *
146 | * @return string
147 | */
148 | public function getClientPhoneNumber()
149 | {
150 | return $this->clientPhoneNumber;
151 | }
152 |
153 | /**
154 | * Set clientPhoneNumber
155 | *
156 | * @param string $clientPhoneNumber
157 | *
158 | * @return $this
159 | */
160 | public function setClientPhoneNumber($clientPhoneNumber)
161 | {
162 | $this->clientPhoneNumber = $clientPhoneNumber;
163 |
164 | return $this;
165 | }
166 |
167 | /**
168 | * Get billing address
169 | *
170 | * @return array
171 | */
172 | public function getBillingAddress()
173 | {
174 | return $this->billingAddress;
175 | }
176 |
177 | /**
178 | * Set billing address
179 | *
180 | * @param array $billingAddress Billing address
181 | *
182 | * @return $this
183 | */
184 | public function setBillingAddress(array $billingAddress)
185 | {
186 | $this->billingAddress = $billingAddress;
187 |
188 | return $this;
189 | }
190 |
191 | /**
192 | * Returns an array of parameters customized for the given method name
193 | *
194 | * @param string $method
195 | *
196 | * @return array
197 | */
198 | public function parameterize($method)
199 | {
200 | $parameterArray = parent::parameterize($method);
201 |
202 | if ('create' == $method) {
203 | if ($this->getFirstName()) {
204 | $parameterArray['first_name'] = $this->getFirstName();
205 | }
206 |
207 | if ($this->getLastName()) {
208 | $parameterArray['last_name'] = $this->getLastName();
209 | }
210 |
211 | if ($this->getCountry()) {
212 | $parametersArray['country'] = $this->getCountry();
213 | }
214 |
215 | if ($this->getClientEmail()) {
216 | $parametersArray['client_email'] = $this->getClientEmail();
217 | }
218 |
219 | if ($this->getBillingAddress()) {
220 | $parametersArray['billing_address'] = $this->getBillingAddress();
221 | }
222 |
223 | if ($this->getClientPhoneNumber()) {
224 | $parametersArray['client_phone_number'] = $this->getClientPhoneNumber();
225 | }
226 | }
227 |
228 | return $parameterArray;
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Request/Webhook.php:
--------------------------------------------------------------------------------
1 | _serviceResource = 'Webhooks/';
39 | }
40 |
41 | /**
42 | * Returns the webhook url
43 | * @return string
44 | */
45 | public function getUrl()
46 | {
47 | return $this->_url;
48 | }
49 |
50 | /**
51 | * Sets the webhook url
52 | * @param string $url
53 | * @return \Paymill\Models\Request\Webhook
54 | */
55 | public function setUrl($url)
56 | {
57 | $this->_url = $url;
58 | return $this;
59 | }
60 |
61 | /**
62 | * Returns the event types as an array
63 | * @return array
64 | */
65 | public function getEventTypes()
66 | {
67 | return $this->_eventTypes;
68 | }
69 |
70 | /**
71 | * Sets the event types for the webhook.
72 | * There are a number of events you can react to. Each webhook can be configured to catch any kind of event
73 | * individually, so you can create different webhooks for different events. Each Webhook needs to be attached
74 | * to at least one event. For example the event subscription.succeeded is triggered every time a successful
75 | * transaction has been made in our system that is based on a subscription. Shortly after that has been triggered,
76 | * we will call every webhook you defined for this event and send detailed information to it.
77 | * @tutorial https://paymill.com/de-de/dokumentation/referenz/api-referenz/#document-webhooks
78 | * @param array $eventTypes
79 | * @return \Paymill\Models\Request\Webhook
80 | */
81 | public function setEventTypes($eventTypes)
82 | {
83 | $this->_eventTypes = $eventTypes;
84 | return $this;
85 | }
86 |
87 | /**
88 | * Returns the email registered for this webhook
89 | * @return string||null
90 | */
91 | public function getEmail()
92 | {
93 | return $this->_email;
94 | }
95 |
96 | /**
97 | * Sets the email for the webhook.
98 | * @param string $email Instead of setting the url parameter you can set the email parameter to create a webhook,
99 | * where we send mails to in case of an event.
100 | * @return \Paymill\Models\Request\Webhook
101 | */
102 | public function setEmail($email)
103 | {
104 | $this->_email = $email;
105 | return $this;
106 | }
107 |
108 | /**
109 | * Sets webhook active (or inactive)
110 | * @param boolean $active
111 | */
112 | public function setActive($active)
113 | {
114 | $this->_active = $active;
115 | return $this;
116 | }
117 |
118 | /**
119 | * Returns if webhook is active or inactive
120 | * @param boolean $active
121 | *
122 | * @return bool
123 | */
124 | public function getActive()
125 | {
126 | return $this->_active;
127 | }
128 |
129 | /**
130 | * Returns an array of parameters customized for the argumented methodname
131 | * @param string $method
132 | * @return array
133 | */
134 | public function parameterize($method)
135 | {
136 | $parameterArray = array();
137 | switch ($method) {
138 | case 'create':
139 | if(!is_null($this->getUrl())){
140 | $parameterArray['url'] = $this->getUrl();
141 | }else{
142 | $parameterArray['email'] = $this->getEmail();
143 | }
144 | $parameterArray['event_types'] = $this->getEventTypes();
145 | if (!is_null($this->getActive())) {
146 | $parameterArray['active'] = $this->getActive();
147 | }
148 | break;
149 | case 'update':
150 | if(!is_null($this->getUrl())){
151 | $parameterArray['url'] = $this->getUrl();
152 | }else{
153 | $parameterArray['email'] = $this->getEmail();
154 | }
155 | $parameterArray['event_types'] = $this->getEventTypes();
156 | if (!is_null($this->getActive())) {
157 | $parameterArray['active'] = $this->getActive();
158 | }
159 | break;
160 | case 'delete':
161 | break;
162 | case 'getOne':
163 | $parameterArray['count'] = 1;
164 | $parameterArray['offset'] = 0;
165 | break;
166 | case 'getAll':
167 | $parameterArray = $this->getFilter();
168 | break;
169 | }
170 |
171 | return $parameterArray;
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Base.php:
--------------------------------------------------------------------------------
1 | _id;
42 | }
43 |
44 | /**
45 | * Sets the Unique identifier
46 | * @param string $id
47 | * @return \Paymill\Models\Response\Base
48 | */
49 | public function setId($id)
50 | {
51 | $this->_id = $id;
52 | return $this;
53 | }
54 |
55 | /**
56 | * Returns the Unix timestamp of the creation
57 | * @return integer
58 | */
59 | public function getCreatedAt()
60 | {
61 | return $this->_createdAt;
62 | }
63 |
64 | /**
65 | * Sets the Unix timestamp of the creation
66 | * @param integer $createdAt
67 | * @return \Paymill\Models\Response\Base
68 | */
69 | public function setCreatedAt($createdAt)
70 | {
71 | $this->_createdAt = $createdAt;
72 | return $this;
73 | }
74 |
75 | /**
76 | * Returns the Unix timestamp of the last update
77 | * @return integer
78 | */
79 | public function getUpdatedAt()
80 | {
81 | return $this->_updatedAt;
82 | }
83 |
84 | /**
85 | * Sets the Unix timestamp of the last update
86 | * @param integer $updatedAt
87 | * @return \Paymill\Models\Response\Base
88 | */
89 | public function setUpdatedAt($updatedAt)
90 | {
91 | $this->_updatedAt = $updatedAt;
92 | return $this;
93 | }
94 |
95 | /**
96 | * Returns the identifier of the object which created this object instance
97 | * @return string|null
98 | */
99 | public function getAppId()
100 | {
101 | return $this->_appId;
102 | }
103 |
104 | /**
105 | * Sets the identifier of the object which created this object instance
106 | * @param string|null $appId
107 | * @return \Paymill\Models\Response\Base
108 | */
109 | public function setAppId($appId)
110 | {
111 | $this->_appId = $appId;
112 | return $this;
113 | }
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Checksum.php:
--------------------------------------------------------------------------------
1 | _checksum;
53 | }
54 |
55 | /**
56 | * Sets the checksum
57 | *
58 | * @param string $val
59 | * @return $this
60 | */
61 | public function setChecksum($val)
62 | {
63 | $this->_checksum = $val;
64 |
65 | return $this;
66 | }
67 |
68 | /**
69 | * Get type
70 | *
71 | * @return string
72 | */
73 | public function getType()
74 | {
75 | return $this->_type;
76 | }
77 |
78 | /**
79 | * Set type
80 | *
81 | * @param string $type type
82 | *
83 | * @return $this
84 | */
85 | public function setType($type)
86 | {
87 | $this->_type = $type;
88 | }
89 |
90 | /**
91 | * Get action
92 | *
93 | * @return string
94 | */
95 | public function getAction()
96 | {
97 | return $this->_action;
98 | }
99 |
100 | /**
101 | * Set action
102 | *
103 | * @param string $action action
104 | *
105 | * @return $this
106 | */
107 | public function setAction($action)
108 | {
109 | $this->_action = $action;
110 |
111 | return $this;
112 | }
113 |
114 | /**
115 | * Get data
116 | *
117 | * @return string
118 | */
119 | public function getData()
120 | {
121 | return $this->_data;
122 | }
123 |
124 | /**
125 | * Set data
126 | *
127 | * @param string $data data
128 | *
129 | * @return $this
130 | */
131 | public function setData($data)
132 | {
133 | $this->_data = $data;
134 |
135 | return $this;
136 | }
137 |
138 | /**
139 | * Returns url encoded checksum data as array
140 | *
141 | * @return array
142 | */
143 | public function getDataAsArray()
144 | {
145 | $checksumData = null;
146 | parse_str($this->getData(), $checksumData);
147 |
148 | return $checksumData;
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Client.php:
--------------------------------------------------------------------------------
1 | _email;
46 | }
47 |
48 | /**
49 | * Sets the Mail address of this client.
50 | * @param string $email
51 | * @return \Paymill\Models\Response\Client
52 | */
53 | public function setEmail($email)
54 | {
55 | $this->_email = $email;
56 | return $this;
57 | }
58 |
59 | /**
60 | * Returns the additional description for this client, perhaps the identifier from your CRM system?
61 | * @return string
62 | */
63 | public function getDescription()
64 | {
65 | return $this->_description;
66 | }
67 |
68 | /**
69 | * Sets an additional description for this client. We recommend some sort of identifier from your CRM system
70 | * @param string $description
71 | * @return \Paymill\Models\Response\Client
72 | */
73 | public function setDescription($description)
74 | {
75 | $this->_description = $description;
76 | return $this;
77 | }
78 |
79 | /**
80 | * Returns a list of payment objects associated with this client
81 | * @return \Paymill\Models\Response\Payment
82 | */
83 | public function getPayment()
84 | {
85 | return $this->_payment;
86 | }
87 |
88 | /**
89 | * Sets the payment list stored in the client model
90 | * @param \Paymill\Models\Response\Payment $payment
91 | * @return \Paymill\Models\Response\Client
92 | */
93 | public function setPayment($payment)
94 | {
95 | $this->_payment = $payment;
96 | return $this;
97 | }
98 |
99 | /**
100 | * Returns a list of subscription objects associated with this client
101 | * @return array
102 | */
103 | public function getSubscription()
104 | {
105 | return $this->_subscription;
106 | }
107 |
108 | /**
109 | * Sets the subscription list stored in the client model
110 | * @param array $subscription
111 | * @return \Paymill\Models\Response\Client
112 | */
113 | public function setSubscription($subscription)
114 | {
115 | $this->_subscription = $subscription;
116 | return $this;
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Error.php:
--------------------------------------------------------------------------------
1 | _errorResponseArray = array();
43 | }
44 |
45 | /**
46 | * Returns the error message stored in the model
47 | * @return string
48 | */
49 | public function getErrorMessage()
50 | {
51 | return $this->_errorMessage;
52 | }
53 |
54 | /**
55 | * Sets the error message stored in this model
56 | * @param string $errorMessage
57 | * @return \Paymill\Models\Response\Error
58 | */
59 | public function setErrorMessage($errorMessage)
60 | {
61 | $this->_errorMessage = $errorMessage;
62 | return $this;
63 | }
64 |
65 | /**
66 | * Returns the response code
67 | * @return int
68 | */
69 | public function getResponseCode()
70 | {
71 | return $this->_responseCode;
72 | }
73 |
74 | /**
75 | * Sets the response code
76 | * @param int $responseCode
77 | * @return \Paymill\Models\Response\Error
78 | */
79 | public function setResponseCode($responseCode)
80 | {
81 | $this->_responseCode = $responseCode;
82 | return $this;
83 | }
84 |
85 | /**
86 | * Returns the status code
87 | * @return int
88 | */
89 | public function getHttpStatusCode()
90 | {
91 | return $this->_httpStatusCode;
92 | }
93 |
94 | /**
95 | * Sets the status code
96 | * @param int $httpStatusCode
97 | * @return \Paymill\Models\Response\Error
98 | */
99 | public function setHttpStatusCode($httpStatusCode)
100 | {
101 | $this->_httpStatusCode = $httpStatusCode;
102 | return $this;
103 | }
104 |
105 | /**
106 | * Sets the raw object
107 | * @param \Paymill\Models\Response\Base $rawObject
108 | * @return \Paymill\Models\Response\Error
109 | */
110 | public function setRawObject($rawObject)
111 | {
112 | $this->_rawObject = $rawObject;
113 | return $this;
114 | }
115 |
116 | /**
117 | * Returns the raw object
118 | * @return \Paymill\Models\Response\Base
119 | */
120 | public function getRawObject()
121 | {
122 | return $this->_rawObject;
123 | }
124 |
125 | /**
126 | * Sets raw error response array
127 | * @param array $error
128 | * @return \Paymill\Models\Response\Error
129 | */
130 | public function setErrorResponseArray(array $error)
131 | {
132 | $this->_errorResponseArray = $error;
133 | return $this;
134 | }
135 |
136 | /**
137 | * Returns the raw error response array
138 | * @return array
139 | */
140 | public function getErrorResponseArray()
141 | {
142 | return $this->_errorResponseArray;
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Fraud.php:
--------------------------------------------------------------------------------
1 | _livemode;
28 | }
29 |
30 | /**
31 | * Sets the livemode flag of the fraud
32 | * @param boolean $livemode
33 | * @return \Paymill\Models\Response\Fraud
34 | */
35 | public function setLivemode($livemode)
36 | {
37 | $this->_livemode = $livemode;
38 | return $this;
39 | }
40 |
41 | /**
42 | * Returns the status for this fraud
43 | * @return string||null
44 | */
45 | public function getStatus()
46 | {
47 | return $this->_status;
48 | }
49 |
50 | /**
51 | * Sets the status
52 | * @param string $status
53 | * @return \Paymill\Models\Response\Fraud
54 | */
55 | public function setStatus($status)
56 | {
57 | $this->_status = $status;
58 | return $this;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Offer.php:
--------------------------------------------------------------------------------
1 | [integer or string], inactive => [integer or string])
47 | */
48 | private $_subscriptionCount = array();
49 |
50 | /**
51 | * Returns Your name for this offer
52 | * @return string
53 | */
54 | public function getName()
55 | {
56 | return $this->_name;
57 | }
58 |
59 | /**
60 | * Sets Your name for this offer
61 | * @param string $name
62 | * @return \Paymill\Models\Response\Offer
63 | */
64 | public function setName($name)
65 | {
66 | $this->_name = $name;
67 | return $this;
68 | }
69 |
70 | /**
71 | * Returns the amount as an integer
72 | * @return integer
73 | */
74 | public function getAmount()
75 | {
76 | return $this->_amount;
77 | }
78 |
79 | /**
80 | * Sets the amount.
81 | * Every interval the specified amount will be charged. Only integer values are allowed (e.g. 42.00 = 4200)
82 | * @param integer $amount
83 | * @return \Paymill\Models\Response\Offer
84 | */
85 | public function setAmount($amount)
86 | {
87 | $this->_amount = (int)$amount;
88 | return $this;
89 | }
90 |
91 | /**
92 | * Returns the interval defining how often the client should be charged.
93 | * @return string
94 | */
95 | public function getInterval()
96 | {
97 | return $this->_interval;
98 | }
99 |
100 | /**
101 | * Sets the interval defining how often the client should be charged.
102 | * @example Format: number DAY | WEEK | MONTH | YEAR Example: 2 DAY
103 | * @param string $interval
104 | * @return \Paymill\Models\Response\Offer
105 | */
106 | public function setInterval($interval)
107 | {
108 | $this->_interval = $interval;
109 | return $this;
110 | }
111 |
112 | /**
113 | * Returns the number of days to try
114 | * @return integer
115 | */
116 | public function getTrialPeriodDays()
117 | {
118 | return $this->_trialPeriodDays;
119 | }
120 |
121 | /**
122 | * Sets the number of days to try
123 | * @param integer $trialPeriodDays
124 | * @return \Paymill\Models\Response\Offer
125 | */
126 | public function setTrialPeriodDays($trialPeriodDays)
127 | {
128 | $this->_trialPeriodDays = $trialPeriodDays;
129 | return $this;
130 | }
131 |
132 | /**
133 | * Returns the subscriptionCount array
134 | * @return array
135 | */
136 | public function getSubscriptionCount()
137 | {
138 | return $this->_subscriptionCount;
139 | }
140 |
141 | /**
142 | * Sets the subscriptionCount array
143 | * @param string|integer $active
144 | * @param string|integer $inactive
145 | * @return \Paymill\Models\Response\Offer
146 | */
147 | public function setSubscriptionCount($active, $inactive)
148 | {
149 | $this->_subscriptionCount['active'] = $active;
150 | $this->_subscriptionCount['inactive'] = $inactive;
151 | return $this;
152 | }
153 |
154 | /**
155 | * Returns the currency
156 | * @return string
157 | */
158 | public function getCurrency()
159 | {
160 | return $this->_currency;
161 | }
162 |
163 | /**
164 | * Sets the currency
165 | * @param string $currency
166 | * @return Offer
167 | */
168 | public function setCurrency($currency)
169 | {
170 | $this->_currency = $currency;
171 | return $this;
172 | }
173 |
174 | }
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Preauthorization.php:
--------------------------------------------------------------------------------
1 | _amount;
25 | }
26 |
27 | /**
28 | * Sets the amount
29 | * @param string $amount
30 | * @return \Paymill\Models\Response\Preauthorization
31 | */
32 | public function setAmount($amount)
33 | {
34 | $this->_amount = $amount;
35 | return $this;
36 | }
37 |
38 | /**
39 | * @var string
40 | */
41 | private $_currency;
42 |
43 | /**
44 | * Returns the currency
45 | * @return string
46 | */
47 | public function getCurrency()
48 | {
49 | return $this->_currency;
50 | }
51 |
52 | /**
53 | * Sets the currency
54 | * @param string $currency
55 | * @return \Paymill\Models\Response\Preauthorization
56 | */
57 | public function setCurrency($currency)
58 | {
59 | $this->_currency = $currency;
60 | return $this;
61 | }
62 |
63 | /**
64 | * Indicates the current status (open, pending, closed, failed, deleted, preauth)
65 | * @var string
66 | */
67 | private $_status;
68 |
69 | /**
70 | * Returns the status
71 | * @return string
72 | */
73 | public function getStatus()
74 | {
75 | return $this->_status;
76 | }
77 |
78 | /**
79 | * Sets the status
80 | * @param string $status
81 | * @return \Paymill\Models\Response\Preauthorization
82 | */
83 | public function setStatus($status)
84 | {
85 | $this->_status = $status;
86 | return $this;
87 | }
88 |
89 | /**
90 | * Whether this preauthorization was issued while being in live mode or not
91 | * @var boolean
92 | */
93 | private $_livemode;
94 |
95 | /**
96 | * Returns the livemode flag of the preAuth object
97 | * @return boolean
98 | */
99 | public function getLivemode()
100 | {
101 | return $this->_livemode;
102 | }
103 |
104 | /**
105 | * Sets the livemode flag of the preAuth object
106 | * @param boolean $livemode
107 | * @return \Paymill\Models\Response\Preauthorization
108 | */
109 | public function setLivemode($livemode)
110 | {
111 | $this->_livemode = $livemode;
112 | return $this;
113 | }
114 |
115 | /**
116 | * Payment Response Model
117 | * @var Payment
118 | */
119 | private $_payment;
120 |
121 | /**
122 | * Returns the identifier of a payment
123 | * @return Payment
124 | */
125 | public function getPayment()
126 | {
127 | return $this->_payment;
128 | }
129 |
130 | /**
131 | * Sets the identifier of a payment
132 | * @param Payment $payment
133 | * @return \Paymill\Models\Response\Preauthorization
134 | */
135 | public function setPayment($payment)
136 | {
137 | $this->_payment = $payment;
138 | return $this;
139 | }
140 |
141 | /**
142 | * Client Response Model
143 | * @var Client
144 | */
145 | private $_client;
146 |
147 | /**
148 | * Returns the identifier of a client
149 | * @return Client
150 | */
151 | public function getClient()
152 | {
153 | return $this->_client;
154 | }
155 |
156 | /**
157 | * Sets the identifier of a client
158 | * @param Client $client
159 | * @return \Paymill\Models\Response\Preauthorization
160 | */
161 | public function setClient($client)
162 | {
163 | $this->_client = $client;
164 | return $this;
165 | }
166 |
167 | /**
168 | * @var string
169 | */
170 | private $_description;
171 |
172 | /**
173 | * Returns the description
174 | * @return string
175 | */
176 | public function getDescription()
177 | {
178 | return $this->_description;
179 | }
180 |
181 | /**
182 | * Sets the description
183 | * @param string $description
184 | * @return \Paymill\Models\Response\Preauthorization
185 | */
186 | public function setDescription($description)
187 | {
188 | $this->_description = $description;
189 | return $this;
190 | }
191 |
192 | /**
193 | * @var \Paymill\Models\Response\Transaction
194 | */
195 | private $_transaction;
196 |
197 | /**
198 | * Sets the transaction
199 | * @param \Paymill\Models\Response\Transaction $transaction
200 | * @return \Paymill\Models\Response\Preauthorization
201 | */
202 | public function setTransaction($transaction)
203 | {
204 | $this->_transaction = $transaction;
205 | }
206 |
207 | /**
208 | * Returns the transaction
209 | * @return \Paymill\Models\Response\Transaction
210 | */
211 | public function getTransaction()
212 | {
213 | return $this->_transaction;
214 | }
215 |
216 | }
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Refund.php:
--------------------------------------------------------------------------------
1 | _transaction;
25 | }
26 |
27 | /**
28 | * Sets the transaction model
29 | * @param \Paymill\Models\Response\Transaction $transaction
30 | *
31 | * @return \Paymill\Models\Response\Refund
32 | */
33 | public function setTransaction($transaction)
34 | {
35 | $this->_transaction = $transaction;
36 | return $this;
37 | }
38 |
39 | /**
40 | * Amount in the smallest possible unit per currency (for euro, we’re calculating the amount in cents).
41 | * @var integer
42 | */
43 | private $_amount;
44 |
45 | /**
46 | * Returns the amount
47 | * @return integer
48 | */
49 | public function getAmount()
50 | {
51 | return $this->_amount;
52 | }
53 |
54 | /**
55 | * Sets the amount
56 | * @param integer $amount
57 | *
58 | * @return \Paymill\Models\Response\Refund
59 | */
60 | public function setAmount($amount)
61 | {
62 | $this->_amount = $amount;
63 | return $this;
64 | }
65 |
66 | /**
67 | * Indicates the current status of this refund. (open, pending, refunded)
68 | * @var string
69 | */
70 | private $_status;
71 |
72 | /**
73 | * Returns the Status of the refund
74 | * @return string
75 | */
76 | public function getStatus()
77 | {
78 | return $this->_status;
79 | }
80 |
81 | /**
82 | * Sets the Status of the refund
83 | * @param string $status
84 | *
85 | * @return \Paymill\Models\Response\Refund
86 | */
87 | public function setStatus($status)
88 | {
89 | $this->_status = $status;
90 | return $this;
91 | }
92 |
93 | /**
94 | * The description given for this refund.
95 | * @var string
96 | */
97 | private $_description;
98 |
99 | /**
100 | * Returns the description of this refund
101 | * @return string
102 | */
103 | public function getDescription()
104 | {
105 | return $this->_description;
106 | }
107 |
108 | /**
109 | * Sets the description of this refund
110 | * @param string $description
111 | *
112 | * @return \Paymill\Models\Response\Refund
113 | */
114 | public function setDescription($description)
115 | {
116 | $this->_description = $description;
117 | return $this;
118 | }
119 |
120 | /**
121 | * @var string
122 | */
123 | private $_reason;
124 |
125 | /**
126 | * Sets the reason
127 | * @return string
128 | */
129 | public function getReason()
130 | {
131 | return $this->_reason;
132 | }
133 |
134 | /**
135 | * @param string $reason
136 | *
137 | * @return \Paymill\Models\Response\Refund
138 | */
139 | public function setReason($reason)
140 | {
141 | $this->_reason = $reason;
142 |
143 | return $this;
144 | }
145 |
146 | /**
147 | * Whether this refund happend in test- or in livemode.
148 | * @var boolean
149 | */
150 | private $_livemode;
151 |
152 | /**
153 | * Returns the Livemode flag of this refund
154 | * @return boolean
155 | */
156 | public function getLivemode()
157 | {
158 | return $this->_livemode;
159 | }
160 |
161 | /**
162 | * Sets the Livemode flag of this refund
163 | * @param boolean $livemode
164 | * @return \Paymill\Models\Response\Refund
165 | */
166 | public function setLivemode($livemode)
167 | {
168 | $this->_livemode = $livemode;
169 | return $this;
170 | }
171 |
172 | /**
173 | * @var integer
174 | */
175 | private $_responseCode;
176 |
177 | /**
178 | * Returns the response code
179 | * @return integer
180 | */
181 | public function getResponseCode()
182 | {
183 | return $this->_responseCode;
184 | }
185 |
186 | /**
187 | * Sets the response code
188 | * @param integer $responseCode
189 | * @return \Paymill\Models\Response\Refund
190 | */
191 | public function setResponseCode($responseCode)
192 | {
193 | $this->_responseCode = $responseCode;
194 | return $this;
195 | }
196 |
197 | }
--------------------------------------------------------------------------------
/lib/Paymill/Models/Response/Webhook.php:
--------------------------------------------------------------------------------
1 | _url;
47 | }
48 |
49 | /**
50 | * Sets the webhook url
51 | * @param string $url
52 | * @return \Paymill\Models\Response\Webhook
53 | */
54 | public function setUrl($url)
55 | {
56 | $this->_url = $url;
57 | return $this;
58 | }
59 |
60 | /**
61 | * Returns the livemode flag of the webhook
62 | * @return boolean
63 | */
64 | public function getLivemode()
65 | {
66 | return $this->_livemode;
67 | }
68 |
69 | /**
70 | * Sets the livemode flag of the webhook
71 | * @param boolean $livemode
72 | * @return \Paymill\Models\Response\Webhook
73 | */
74 | public function setLivemode($livemode)
75 | {
76 | $this->_livemode = $livemode;
77 | return $this;
78 | }
79 |
80 | /**
81 | * Returns the event types as an array
82 | * @return array
83 | */
84 | public function getEventTypes()
85 | {
86 | return $this->_eventTypes;
87 | }
88 |
89 | /**
90 | * Sets the event types for the webhook.
91 | * There are a number of events you can react to. Each webhook can be configured to catch any kind of event
92 | * individually, so you can create different webhooks for different events. Each Webhook needs to be attached
93 | * to at least one event. For example the event subscription.succeeded is triggered every time a successful
94 | * transaction has been made in our system that is based on a subscription. Shortly after that has been triggered,
95 | * we will call every webhook you defined for this event and send detailed information to it.
96 | * @tutorial https://paymill.com/de-de/dokumentation/referenz/api-referenz/#document-webhooks
97 | * @param array $eventTypes
98 | * @return \Paymill\Models\Response\Webhook
99 | */
100 | public function setEventTypes($eventTypes)
101 | {
102 | $this->_eventTypes = $eventTypes;
103 | return $this;
104 | }
105 |
106 | /**
107 | * Returns the email registered for this webhook
108 | * @return string||null
109 | */
110 | public function getEmail()
111 | {
112 | return $this->_email;
113 | }
114 |
115 | /**
116 | * Sets the email for the webhook.
117 | * @param string $email Instead of setting the url parameter you can set the email parameter to create a webhook,
118 | * where we send mails to in case of an event.
119 | * @return \Paymill\Models\Response\Webhook
120 | */
121 | public function setEmail($email)
122 | {
123 | $this->_email = $email;
124 | return $this;
125 | }
126 |
127 | /**
128 | * Sets webhook active (or inactive)
129 | * @param boolean $active
130 | */
131 | public function setActive($active)
132 | {
133 | $this->_active = $active;
134 | return $this;
135 | }
136 |
137 | /**
138 | * Returns if webhook is active or inactive
139 | * @param boolean $active
140 | *
141 | * @return bool
142 | */
143 | public function getActive()
144 | {
145 | return $this->_active;
146 | }
147 |
148 | }
--------------------------------------------------------------------------------
/lib/Paymill/Services/PaymillException.php:
--------------------------------------------------------------------------------
1 | _errorMessage = $message;
54 | $this->_responseCode = $responseCode;
55 | $this->_httpStatusCode = $code;
56 | $this->_rawObject = $rawObject;
57 | $this->_rawError = $rawError;
58 | }
59 |
60 | /**
61 | * Returns the exception message
62 | * @return string
63 | */
64 | public function getErrorMessage()
65 | {
66 | return $this->_errorMessage;
67 | }
68 |
69 | /**
70 | * Returns the PAYMILL API http status code
71 | * @return string
72 | */
73 | public function getStatusCode()
74 | {
75 | return $this->_httpStatusCode;
76 | }
77 |
78 | /**
79 | * Returns the PAYMILL API response code
80 | * @return integer
81 | */
82 | public function getResponseCode()
83 | {
84 | return $this->_responseCode;
85 | }
86 |
87 | /**
88 | * Returns the additional resource if any
89 | * @return \Paymill\Models\Response\Base|null
90 | */
91 | public function getRawObject()
92 | {
93 | return $this->_rawObject;
94 | }
95 |
96 | /**
97 | * Returns the raw error array
98 | * @return array|null
99 | */
100 | public function getRawError()
101 | {
102 | return $this->_rawError;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/lib/Paymill/Services/Util.php:
--------------------------------------------------------------------------------
1 | ';
2 | $request = new Paymill\Request($apiKey);
3 |
--------------------------------------------------------------------------------
/samples/checksums/create.php:
--------------------------------------------------------------------------------
1 | $checksum = new Paymill\Models\Request\Checksum();
2 | $checksum
3 | ->setChecksumType(\Paymill\Models\Request\Checksum::TYPE_PAYPAL) // Checksum type
4 | ->setAmount(4200) // e.g. "4200" for 42.00 EUR
5 | ->setCurrency('EUR') // Alpha-3 country code
6 | ->setDescription('My transaction description') // Optional
7 | ->setShippingAddress(array( // Optional - Shipping address
8 | 'name' => 'John Doe',
9 | 'street_address' => 'Example street 1',
10 | 'street_address_addition' => '45 floor', // Optional
11 | 'postal_code' => '12345', // Optional
12 | 'city' => 'Munich',
13 | 'state' => 'Bavaria', // Optional
14 | 'country' => 'DE', // Alpha-2 country code
15 | 'phone' => '0123 456789' // Optional
16 | ))
17 | ->setBillingAddress(array( // Optional - Billing address
18 | 'name' => 'John Doe',
19 | 'street_address' => 'Example street 1',
20 | 'street_address_addition' => '45 floor', // Optional
21 | 'postal_code' => '12345', // Optional
22 | 'city' => 'Munich',
23 | 'state' => 'Bavaria', // Optional
24 | 'country' => 'DE', // Alpha-2 country code
25 | 'phone' => '0123 456789' // Optional
26 | ))
27 | ->setItems(array( // Optional - Shopping cart items
28 | array(
29 | 'name' => 'Product orange', // Optional
30 | 'description' => 'An orange product', // Optional
31 | 'item_number' => 'PROD1OR', // Optional
32 | 'url' => 'http://www.example.com/orange-product', // Optional
33 | 'amount' => 50, // Price of a single product in cent, e.g. "50" for 0,50 €
34 | 'quantity' => 2
35 | ),
36 | array(
37 | 'name' => 'Product blue', // Optional
38 | 'description' => 'A blue product', // Optional
39 | 'item_number' => 'PROD3BL', // Optional
40 | 'url' => 'http://www.example.com/blue-product', // Optional
41 | 'amount' => 70, // Price of a single product in cent, e.g. "50" for 0,50 €
42 | 'quantity' => 1
43 | )
44 | ))
45 | ->setShippingAmount(300) // Optional - Shipping costs in cent, e.g. "50" for 0,50 €
46 | ->setHandlingAmount(250) // Optional - Other handling costs in cent, e.g. "50" for 0,50 €
47 | ->setReturnUrl('http://www.example.com/checkout/success') // Required for e.g. PayPal - Valid return URL
48 | ->setCancelUrl('http://www.example.com/checkout/canceled') // Required for e.g. PayPal - Valid cancel URL
49 | ->setFeeAmount(420) // Optional - Unite fees in cent, e.g. "50" for 0,50 €
50 | ->setFeeCurrency('EUR') // Optional - Unite fee currency
51 | ->setFeePayment('pay_3af44644dd6d25c820a8') // Optional - Unite payment ID
52 | ;
53 |
54 | $response = $request->create($checksum);
55 |
--------------------------------------------------------------------------------
/samples/checksums/get_by_id.php:
--------------------------------------------------------------------------------
1 | $checksum = new Paymill\Models\Request\Checksum();
2 | $checksum->setId('chk_9db8a1793e084a896da4289bf050');
3 |
4 | $response = $request->getOne($checksum);
5 |
--------------------------------------------------------------------------------
/samples/checksums/list.php:
--------------------------------------------------------------------------------
1 | $checksums = new Paymill\Models\Request\Checksum();
2 |
3 | $response = $request->getAll($checksums);
4 |
--------------------------------------------------------------------------------
/samples/clients/create_new_client.php:
--------------------------------------------------------------------------------
1 | $client = new Paymill\Models\Request\Client();
2 | $client->setEmail('max.mustermann@example.com')
3 | ->setDescription('Lovely Client')
4 |
5 | $response = $request->create($client);
6 |
--------------------------------------------------------------------------------
/samples/clients/export_clients_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/clients/get_client_details.php:
--------------------------------------------------------------------------------
1 | $client = new Paymill\Models\Request\Client();
2 | $client->setId('client_88a388d9dd48f86c3136');
3 |
4 | $response = $request->getOne($client);
5 |
--------------------------------------------------------------------------------
/samples/clients/list_clients.php:
--------------------------------------------------------------------------------
1 | $client = new Paymill\Models\Request\Client();
2 |
3 | $response = $request->getAll($client);
4 |
--------------------------------------------------------------------------------
/samples/clients/remove_client.php:
--------------------------------------------------------------------------------
1 | $client = new Paymill\Models\Request\Client();
2 | $client->setId('client_88a388d9dd48f86c3136');
3 |
4 | $response = $request->delete($client);
5 |
--------------------------------------------------------------------------------
/samples/clients/update_client.php:
--------------------------------------------------------------------------------
1 | $client = new Paymill\Models\Request\Client();
2 | $client->setId('client_88a388d9dd48f86c3136')
3 | ->setEmail('updated-client@example.com')
4 | ->setDescription('Updated Client');
5 |
6 | $response = $request->update($client);
7 |
--------------------------------------------------------------------------------
/samples/offers/create_new_offer.php:
--------------------------------------------------------------------------------
1 | $offer = new Paymill\Models\Request\Offer();
2 | $offer->setAmount(4200)
3 | ->setCurrency('EUR')
4 | ->setInterval('1 WEEK')
5 | ->setName('Nerd Special');
6 |
7 | $response = $request->create($offer);
8 |
--------------------------------------------------------------------------------
/samples/offers/export_offers_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/offers/get_offer_details.php:
--------------------------------------------------------------------------------
1 | $offer = new Paymill\Models\Request\Offer();
2 | $offer->setId('offer_40237e20a7d5a231d99b');
3 |
4 | $response = $request->getOne($offer);
5 |
--------------------------------------------------------------------------------
/samples/offers/list_offers.php:
--------------------------------------------------------------------------------
1 | $offer = new Paymill\Models\Request\Offer();
2 |
3 | $response = $request->getAll($offer);
4 |
--------------------------------------------------------------------------------
/samples/offers/remove_offer.php:
--------------------------------------------------------------------------------
1 | $offer = new Paymill\Models\Request\Offer();
2 | $offer->setId('offer_40237e20a7d5a231d99b')
3 | ->setRemoveWithSubscriptions(true);
4 |
5 | $response = $request->delete($offer)
6 |
--------------------------------------------------------------------------------
/samples/offers/update_offer.php:
--------------------------------------------------------------------------------
1 | $offer = new Paymill\Models\Request\Offer();
2 | $offer->setId('offer_40237e20a7d5a231d99b')
3 | ->setName('Extended Special')
4 | ->setInterval('1 MONTH')
5 | ->setAmount(3333)
6 | ->setCurrency('USD')
7 | ->setTrialPeriodDays(33)
8 | ->updateSubscriptions(true);
9 |
10 | $response = $request->update($offer)
11 |
--------------------------------------------------------------------------------
/samples/payments/create_new_credit_card_payment_with_token.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setToken('098f6bcd4621d373cade4e832627b4f6');
3 |
4 | $response = $request->create($payment);
5 |
--------------------------------------------------------------------------------
/samples/payments/create_new_credit_card_payment_with_token_and_client.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setToken('098f6bcd4621d373cade4e832627b4f6')
3 | ->setClient('client_88a388d9dd48f86c3136');
4 |
5 | $response = $request->create($payment);
6 |
--------------------------------------------------------------------------------
/samples/payments/create_new_debit_payment_with_token.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setToken('12a46bcd462sd3r3care4e8336ssb4f5');
3 |
4 | $response = $request->create($payment);
5 |
--------------------------------------------------------------------------------
/samples/payments/create_new_debit_payment_with_token_and_client.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setToken('12a46bcd462sd3r3care4e8336ssb4f5');
3 | $payment->setClient('client_88a388d9dd48f86c3136');
4 |
5 | $response = $request->create($payment);
6 |
--------------------------------------------------------------------------------
/samples/payments/export_payments_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/payments/get_payment_details.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setId('pay_3af44644dd6d25c820a8');
3 |
4 | $response = $request->getOne($payment);
5 |
--------------------------------------------------------------------------------
/samples/payments/list_payments.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 |
3 | $response = $request->getAll($payment);
4 |
--------------------------------------------------------------------------------
/samples/payments/remove_payment.php:
--------------------------------------------------------------------------------
1 | $payment = new Paymill\Models\Request\Payment();
2 | $payment->setId('pay_3af44644dd6d25c820a8');
3 |
4 | $response = $request->delete($payment);
5 |
--------------------------------------------------------------------------------
/samples/preauthorizations/create_new_preauthorization_with_payment.php:
--------------------------------------------------------------------------------
1 | $preAuth = new Paymill\Models\Request\Preauthorization();
2 | $preAuth->setPayment('pay_d43cf0ee969d9847512b')
3 | ->setAmount(4200)
4 | ->setCurrency('EUR')
5 | ->setDescription('description example');
6 |
7 | $response = $request->create($preAuth);
8 |
--------------------------------------------------------------------------------
/samples/preauthorizations/create_new_preauthorization_with_token.php:
--------------------------------------------------------------------------------
1 | $preAuth = new Paymill\Models\Request\Preauthorization();
2 | $preAuth->setToken('098f6bcd4621d373cade4e832627b4f6')
3 | ->setAmount(4200)
4 | ->setCurrency('EUR')
5 | ->setDescription('description example');
6 |
7 | $response = $request->create($preAuth);
8 |
--------------------------------------------------------------------------------
/samples/preauthorizations/export_preauthorizations_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/preauthorizations/get_preauthorization_details.php:
--------------------------------------------------------------------------------
1 | $preAuth = new Paymill\Models\Request\Preauthorization();
2 | $preAuth->setId('preauth_31eb90495837447f76b7');
3 |
4 | $response = $request->getOne($preAuth);
5 |
--------------------------------------------------------------------------------
/samples/preauthorizations/list_preauthorizations.php:
--------------------------------------------------------------------------------
1 | $preAuth = new Paymill\Models\Request\Preauthorization();
2 |
3 | $response = $request->getAll($preAuth);
4 |
--------------------------------------------------------------------------------
/samples/preauthorizations/remove_preauthorization.php:
--------------------------------------------------------------------------------
1 | $preAuth = new Paymill\Models\Request\Preauthorization();
2 | $preAuth->setId('preauth_31eb90495837447f76b7');
3 |
4 | $response = $request->delete($preAuth);
5 |
--------------------------------------------------------------------------------
/samples/refunds/create_new_refund.php:
--------------------------------------------------------------------------------
1 | $refund = new Paymill\Models\Request\Refund();
2 | $refund->setId('tran_023d3b5769321c649435')
3 | ->setAmount(4200) // e.g. "4200" for 42.00 EUR
4 | ->setDescription('Sample Description');
5 |
6 | $response = $request->create($refund);
7 |
--------------------------------------------------------------------------------
/samples/refunds/export_refunds_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/refunds/get_refund_details.php:
--------------------------------------------------------------------------------
1 | $refund = new Paymill\Models\Request\Refund();
2 | $refund->setId('refund_773ab6f9cd03428953c9');
3 |
4 | $response = $request->getOne($refund);
5 |
--------------------------------------------------------------------------------
/samples/refunds/list_refunds.php:
--------------------------------------------------------------------------------
1 | $refund = new Paymill\Models\Request\Refund();
2 |
3 | $response = $request->getAll($refund);
4 |
--------------------------------------------------------------------------------
/samples/subscriptions/cancel_subscription.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setRemove(false);
4 |
5 | $response = $request->delete($subscription);
6 |
--------------------------------------------------------------------------------
/samples/subscriptions/create_new_subscription_with_an_offer.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setClient('client_81c8ab98a8ac5d69f749')
3 | ->setOffer('offer_40237e20a7d5a231d99b');
4 | ->setPayment('pay_5e078197cde8a39e4908f8aa');
5 | ->setPeriodOfValidity('2 YEAR');
6 | ->setStartAt(1400575533);
7 |
8 | $response = $request->create($subscription);
9 |
--------------------------------------------------------------------------------
/samples/subscriptions/create_new_subscription_with_an_offer_and_different_values.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setClient('client_81c8ab98a8ac5d69f749')
3 | ->setOffer('offer_40237e20a7d5a231d99b');
4 | ->setAmount(3000);
5 | ->setPayment('pay_5e078197cde8a39e4908f8aa');
6 | ->setCurrency('EUR');
7 | ->setInterval('1 week,monday');
8 | ->setName('Example Subscription');
9 | ->setPeriodOfValidity('2 YEAR');
10 | ->setStartAt('1400575533');
11 |
12 | $response = $request->create($subscription);
13 |
--------------------------------------------------------------------------------
/samples/subscriptions/create_new_subscription_without_an_offer.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setClient('client_81c8ab98a8ac5d69f749')
3 | ->setAmount(3000);
4 | ->setPayment('pay_5e078197cde8a39e4908f8aa');
5 | ->setCurrency('EUR');
6 | ->setInterval('1 week,monday');
7 | ->setName('Example Subscription');
8 | ->setPeriodOfValidity('2 YEAR');
9 | ->setStartAt('1400575533');
10 |
11 | $response = $request->create($subscription);
12 |
--------------------------------------------------------------------------------
/samples/subscriptions/delete_subscription.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setRemove(true);
4 |
5 | $response = $request->delete($subscription);
6 |
--------------------------------------------------------------------------------
/samples/subscriptions/export_subscriptions_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/subscriptions/get_subscription_details.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dc180b755d10da324864');
3 |
4 | $response = $request->getOne($subscription);
5 |
--------------------------------------------------------------------------------
/samples/subscriptions/list_subscriptions.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 |
3 | $response = $request->getAll($subscription);
4 |
--------------------------------------------------------------------------------
/samples/subscriptions/pause_subscription.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setPause(true);
4 |
5 | $response = $request->update($subscription);
6 |
--------------------------------------------------------------------------------
/samples/subscriptions/update_subscription.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setClient('client_81c8ab98a8ac5d69f749')
4 | ->setOffer('offer_40237e20a7d5a231d99b');
5 | ->setAmount(3000);
6 | ->setPayment('pay_95ba26ba2c613ebb0ca8');
7 | ->setCurrency('USD');
8 | ->setInterval('1 month,friday');
9 | ->setName('Changed Subscription');
10 | ->setPeriodOfValidity('14 MONTH');
11 | ->setTrialEnd(false);
12 |
13 | $response = $request->update($subscription);
14 |
--------------------------------------------------------------------------------
/samples/subscriptions/update_subscription_amount.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setAmount(1234);
4 | ->setAmountChangeType(0);
5 |
6 | $response = $request->update($subscription);
7 |
--------------------------------------------------------------------------------
/samples/subscriptions/update_subscription_offer.php:
--------------------------------------------------------------------------------
1 | $subscription = new Paymill\Models\Request\Subscription();
2 | $subscription->setId('sub_dea86e5c65b2087202e3');
3 | ->setOffer('offer_d7e9813a25e89c5b78bd');
4 | ->setOfferChangeType(2);
5 |
6 | $response = $request->update($subscription);
7 |
--------------------------------------------------------------------------------
/samples/transactions/create_new_transaction_with_app_fee.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
3 | ->setCurrency('EUR')
4 | ->setToken('098f6bcd4621d373cade4e832627b4f6')
5 | ->setDescription('Test Transaction')
6 | ->setFeeAmount(420)
7 | ->setFeePayment('pay_3af44644dd6d25c820a8')
8 | ->setFeeCurrency('EUR');
9 |
10 | $response = $request->create($transaction);
11 |
--------------------------------------------------------------------------------
/samples/transactions/create_new_transaction_with_client_and_payment.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
3 | ->setCurrency('EUR')
4 | ->setClient('client_c781b1d2f7f0f664b4d9')
5 | ->setPayment('pay_2f82a672574647cd911d')
6 | ->setDescription('Test Transaction');
7 |
8 | $response = $request->create($transaction);
9 |
--------------------------------------------------------------------------------
/samples/transactions/create_new_transaction_with_payment.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
3 | ->setCurrency('EUR')
4 | ->setPayment('pay_2f82a672574647cd911d')
5 | ->setDescription('Test Transaction');
6 |
7 | $response = $request->create($transaction);
8 |
--------------------------------------------------------------------------------
/samples/transactions/create_new_transaction_with_preauthorization.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
3 | ->setCurrency('EUR')
4 | ->setPreauthorization('preauth_ec54f67e52e92051bd65')
5 | ->setDescription('Test Transaction');
6 |
7 | $response = $request->create($transaction);
8 |
--------------------------------------------------------------------------------
/samples/transactions/create_new_transaction_with_token.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
3 | ->setCurrency('EUR')
4 | ->setToken('098f6bcd4621d373cade4e832627b4f6')
5 | ->setDescription('Test Transaction');
6 |
7 | $response = $request->create($transaction);
8 |
--------------------------------------------------------------------------------
/samples/transactions/export_transactions_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/transactions/get_transaction_details_by_id.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setId('tran_023d3b5769321c649435');
3 |
4 | $response = $request->getOne($transaction);
5 |
--------------------------------------------------------------------------------
/samples/transactions/get_transaction_details_by_slv.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setId('slv_4125875679');
3 |
4 | $response = $request->getOne($transaction);
5 |
--------------------------------------------------------------------------------
/samples/transactions/list_transactions.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 |
3 | $response = $request->getAll($transaction);
4 |
--------------------------------------------------------------------------------
/samples/transactions/upate_transaction.php:
--------------------------------------------------------------------------------
1 | $transaction = new Paymill\Models\Request\Transaction();
2 | $transaction->setId('tran_023d3b5769321c649435')
3 | ->setDescription('My updated transaction description');
4 |
5 | $response = $request->update($transaction);
6 |
--------------------------------------------------------------------------------
/samples/webhooks/create_new_email_webhook.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setEmail('')
3 | ->setEventTypes(array(
4 | 'transaction.succeeded',
5 | 'transaction.failed'
6 | ));
7 |
8 | $response = $request->create($webhook);
9 |
--------------------------------------------------------------------------------
/samples/webhooks/create_new_url_webhook.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setUrl('')
3 | ->setEventTypes(array(
4 | 'transaction.succeeded',
5 | 'transaction.failed'
6 | ));
7 |
8 | $response = $request->create($webhook);
9 |
--------------------------------------------------------------------------------
/samples/webhooks/export_webhooks_list.php:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
2 |
--------------------------------------------------------------------------------
/samples/webhooks/get_webhook_details.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setId('hook_40237e20a7d5a231d99b');
3 |
4 | $response = $request->getOne($webhook);
5 |
--------------------------------------------------------------------------------
/samples/webhooks/list_webhooks.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setFilter(array(
3 | 'count' => 2,
4 | 'offset' => 0
5 | ));
6 |
7 | $response = $request->getAll($webhook);
8 |
--------------------------------------------------------------------------------
/samples/webhooks/remove_webhook.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setId('hook_40237e20a7d5a231d99b');
3 |
4 | $response = $request->delete($webhook);
5 |
--------------------------------------------------------------------------------
/samples/webhooks/update_webhook.php:
--------------------------------------------------------------------------------
1 | $webhook = new Paymill\Models\Request\Webhook();
2 | $webhook->setId('hook_40237e20a7d5a231d99b')
3 | ->setUrl('')
4 | ->setEventTypes(array(
5 | 'transaction.failed',
6 | 'subscription.failed'
7 | ));
8 |
9 | $response = $request->update($webhook);
10 |
--------------------------------------------------------------------------------
/tests/Integration/ChecksumTest.php:
--------------------------------------------------------------------------------
1 | _model = new Checksum();
24 | $this->_model->setChecksumType(Checksum::TYPE_PAYPAL);
25 | $this->_model->setChecksumAction(Checksum::ACTION_TRANSACTION);
26 | $this->_model->setAmount('200');
27 | $this->_model->setCurrency('EUR');
28 | $this->_model->setDescription('Dummy description');
29 | $this->_model->setReturnUrl('http://dummy.url');
30 | $this->_model->setCancelUrl('http://dummy.url');
31 |
32 | parent::setUp();
33 | }
34 |
35 | /**
36 | * Cleans up the environment after running a test.
37 | */
38 | protected function tearDown()
39 | {
40 | $this->_model = null;
41 | parent::tearDown();
42 | }
43 |
44 | /**
45 | * @test
46 | * @codeCoverageIgnore
47 | */
48 | public function createChecksum()
49 | {
50 | $result = $this->_service->create($this->_model);
51 | $this->assertInstanceOf('Paymill\Models\Response\Checksum', $result, var_export($result, true));
52 |
53 | return $result;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tests/Integration/ClientTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Client();
23 | parent::setUp();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_model = null;
32 | parent::tearDown();
33 | }
34 |
35 | /**
36 | * @test
37 | * @codeCoverageIgnore
38 | */
39 | public function createClient()
40 | {
41 | $this->_model->setEmail('Plugins@Paymill.de')
42 | ->setDescription('Test');
43 | $result = $this->_service->create($this->_model);
44 | $this->assertInstanceOf('Paymill\Models\Response\Client', $result);
45 | return $result;
46 | }
47 |
48 | /**
49 | * @test
50 | * @codeCoverageIgnore
51 | * @depends createClient
52 | */
53 | public function updateClient($model)
54 | {
55 | $this->_model->setId($model->getId())
56 | ->setDescription('UpdateSuccessful');
57 | $result = $this->_service->update($this->_model);
58 | $this->assertInstanceOf('Paymill\Models\Response\Client', $result, var_export($result, true));
59 | $this->assertEquals('UpdateSuccessful', $result->getDescription());
60 | }
61 |
62 | /**
63 | *
64 | * @test
65 | * @codeCoverageIgnore
66 | * @expectedException \Paymill\Services\PaymillException
67 | * @expectedExceptionMessage Client not found
68 | */
69 | public function updateClientWithWrongId()
70 | {
71 | $this->_model->setId('YouWillNeverFindMe404')
72 | ->setDescription('TEST');
73 | $this->_service->update($this->_model);
74 | }
75 |
76 | /**
77 | * @test
78 | * @codeCoverageIgnore
79 | * @depends createClient
80 | */
81 | public function getOneClient($model)
82 | {
83 | $this->_model->setId($model->getId());
84 | $result = $this->_service->getOne($this->_model);
85 | $this->assertInstanceOf('Paymill\Models\Response\Client', $result, var_export($result, true));
86 | $this->assertEquals($model->getId(), $result->getId());
87 | }
88 |
89 | /**
90 | * @test
91 | * @codeCoverageIgnore
92 | * @depends createClient
93 | */
94 | public function getAllClient()
95 | {
96 | $result = $this->_service->getAll($this->_model);
97 | $this->assertInternalType('array', $result, var_export($result, true));
98 | }
99 |
100 | /**
101 | * @test
102 | * @codeCoverageIgnore
103 | */
104 | public function getAllClientAsModel()
105 | {
106 | $result = $this->_service->getAllAsModel($this->_model);
107 | $this->assertInternalType('array', $result, var_export($result, true));
108 | $this->assertInstanceOf('Paymill\Models\Response\Client', array_pop($result));
109 | }
110 |
111 |
112 |
113 | /**
114 | * @test
115 | * @codeCoverageIgnore
116 | */
117 | public function getAllClientWithFilter()
118 | {
119 | $this->_model->setFilter(array(
120 | 'count' => 1,
121 | 'offset' => 0
122 | )
123 | );
124 | $result = $this->_service->getAll($this->_model);
125 | $this->assertEquals(1, count($result), var_export($result, true));
126 | }
127 |
128 | /**
129 | * @test
130 | * @codeCoverageIgnore
131 | * @depends createClient
132 | * @depends getOneClient
133 | * @depends updateClient
134 | */
135 | public function deleteClient($model)
136 | {
137 | $this->_model->setId($model->getId());
138 | $this->markTestIncomplete('Client does not return a empty array like the other resources.');
139 | $result = $this->_service->delete($this->_model);
140 | $this->assertInternalType('array', $result, var_export($result, true));
141 | }
142 |
143 | /**
144 | * @test
145 | * @codeCoverageIgnore
146 | * @expectedException \Paymill\Services\PaymillException
147 | * @expectedExceptionMessage 'PluginsAtPaymillDotde' is not a valid email address.
148 | */
149 | public function createClientWithInvalidEmail()
150 | {
151 | $this->_model->setEmail('PluginsAtPaymillDotde')
152 | ->setDescription('Test');
153 | $result = $this->_service->create($this->_model);
154 | $this->assertInstanceOf('Paymill\Models\Response\Client', $result);
155 | return $result;
156 | }
157 |
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/tests/Integration/IntegrationBase.php:
--------------------------------------------------------------------------------
1 | _service = new Request();
21 | $this->_service->setConnectionClass(
22 | new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
23 | );
24 |
25 | parent::setUp();
26 | }
27 |
28 | /**
29 | * Cleans up the environment after running a test.
30 | */
31 | protected function tearDown()
32 | {
33 | $this->_service = null;
34 | parent::tearDown();
35 | }
36 |
37 | public function createToken()
38 | {
39 | $params = array(
40 | 'channel_id' => API_PUBLIC_TEST_KEY,
41 | 'transaction_mode' => 'CONNECTOR_TEST',
42 | 'account_number' => '4111111111111111',
43 | 'account_holder' => 'Max Muster',
44 | 'account_expiry_month' => '12',
45 | 'account_expiry_year' => date('Y', strtotime('+1 year')),
46 |
47 | );
48 | $token = json_decode(file_get_contents(TOKEN_HOST . '?' . http_build_query($params)), true);
49 | if (isset($token['transaction']['identification']['uniqueId'])) {
50 | return $token['transaction']['identification']['uniqueId'];
51 | }
52 |
53 | return null;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tests/Integration/OfferTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Offer();
23 | parent::setUp();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_model = null;
32 | parent::tearDown();
33 | }
34 |
35 | /**
36 | * @test
37 | * @codeCoverageIgnore
38 | */
39 | public function createOffer()
40 | {
41 | $this->_model->setAmount(100)
42 | ->setCurrency('EUR')
43 | ->setInterval('2 DAY')
44 | ->setName('TestOffer');
45 | $offerModelResult = $this->_service->create($this->_model);
46 | $this->assertInstanceOf('Paymill\Models\Response\Offer', $offerModelResult, var_export($offerModelResult, true));
47 |
48 | return $offerModelResult;
49 | }
50 |
51 | /**
52 | * @test
53 | * @codeCoverageIgnore
54 | * @depends createOffer
55 | */
56 | public function updateOffer($model)
57 | {
58 | $this->_model->setId($model->getId())
59 | ->setName('NewName');
60 | $result = $this->_service->update($this->_model);
61 |
62 | $this->assertInstanceOf('Paymill\Models\Response\Offer', $result, var_export($result, true));
63 | $this->assertEquals($model->getId(), $result->getId());
64 | }
65 |
66 | /**
67 | * @test
68 | * @codeCoverageIgnore
69 | * @depends createOffer
70 | */
71 | public function getOneOffer($model)
72 | {
73 | $this->_model->setId($model->getId());
74 | $this->assertInstanceOf('Paymill\Models\Response\Offer', $result = $this->_service->getOne($this->_model), var_export($result, true));
75 | $this->assertEquals($model->getId(), $result->getId());
76 | }
77 |
78 | /**
79 | * @test
80 | * @codeCoverageIgnore
81 | * @depends createOffer
82 | */
83 | public function getAllOffer()
84 | {
85 | $this->_model;
86 | $result = $this->_service->getAll($this->_model);
87 | $this->assertInternalType('array', $result, var_export($result, true));
88 | }
89 |
90 | /**
91 | * @test
92 | * @codeCoverageIgnore
93 | * @depends createOffer
94 | */
95 | public function getAllOfferAsModel()
96 | {
97 | $this->_model;
98 | $result = $this->_service->getAllAsModel($this->_model);
99 | $this->assertInternalType('array', $result, var_export($result, true));
100 | $this->assertInstanceOf('Paymill\Models\Response\Offer', array_pop($result));
101 | }
102 |
103 | /**
104 | * @test
105 | * @codeCoverageIgnore
106 | */
107 | public function getAllOfferWithFilter()
108 | {
109 | $this->_model->setFilter(array(
110 | 'count' => 1,
111 | 'offset' => 0
112 | )
113 | );
114 | $result = $this->_service->getAll($this->_model);
115 | $this->assertEquals(1, count($result), var_export($result, true));
116 | }
117 |
118 | /**
119 | * @test
120 | * @depends createOffer
121 | */
122 | public function getRequestSubscription($offer)
123 | {
124 | $subscriptionModel = new Models\Request\Subscription();
125 | $subscriptionModel->setOffer($offer->getId());
126 | $PaymentModel = new Models\Request\Payment();
127 | $PaymentModel->setToken("098f6bcd4621d373cade4e832627b4f6");
128 | $PaymentModelResponse = $this->_service->create($PaymentModel);
129 | $this->assertInstanceOf('Paymill\Models\Response\Payment', $PaymentModelResponse, var_export($PaymentModelResponse, true));
130 |
131 | $subscriptionModel->setClient($PaymentModelResponse->getClient())
132 | ->setPayment($PaymentModelResponse->getId());
133 | $subscription = $this->_service->create($subscriptionModel);
134 |
135 | $this->assertEquals($offer->getId(), $subscription->getOffer()->getId());
136 |
137 | return $subscription;
138 | }
139 |
140 |
141 |
142 | /**
143 | * @test
144 | * @codeCoverageIgnore
145 | * @depends createOffer
146 | * @depends getRequestSubscription
147 | */
148 | public function deleteOfferWithSubscriptions($model, $subscriptionResponse)
149 | {
150 | $subscriptionRequest = new Models\Request\Subscription();
151 | $subscriptionRequest->setId($subscriptionResponse->getId());
152 |
153 | $this->assertInstanceOf('Paymill\Models\Response\Subscription', $subscriptionWithOffer = $this->_service->getOne($subscriptionRequest), var_export($subscriptionWithOffer, true));
154 |
155 | $this->_model->setRemoveWithSubscriptions(true)
156 | ->setId($model->getId());
157 |
158 | $result = $this->_service->delete($this->_model);
159 |
160 | $this->assertInternalType('array', $result, var_export($result, true));
161 |
162 | $subscriptionRequest->setId($subscriptionWithOffer->getId());
163 |
164 | $subscriptionResponse = $this->_service->getOne($subscriptionRequest);
165 |
166 | $this->assertTrue($subscriptionResponse->getIsCanceled());
167 | $this->assertTrue($subscriptionResponse->getIsDeleted());
168 | }
169 |
170 | /**
171 | * @test
172 | * @codeCoverageIgnore
173 | *
174 | *
175 | */
176 | public function deleteOfferWithoutSubscriptions()
177 | {
178 | $offer = $this->createOffer();
179 | $subscriptionResponse = $this->getRequestSubscription($offer);
180 | $subscriptionRequest = new Models\Request\Subscription();
181 | $subscriptionRequest->setId($subscriptionResponse->getId());
182 |
183 | $this->assertInstanceOf('Paymill\Models\Response\Subscription', $subscriptionWithOffer = $this->_service->getOne($subscriptionRequest), var_export($subscriptionWithOffer, true));
184 |
185 | $this->_model->setRemoveWithSubscriptions(false)
186 | ->setId($offer->getId());
187 |
188 | $result = $this->_service->delete($this->_model);
189 |
190 | $this->assertInternalType('array', $result, var_export($result, true));
191 |
192 | $subscriptionRequest->setId($subscriptionWithOffer->getId());
193 |
194 | $subscriptionResponse = $this->_service->getOne($subscriptionRequest);
195 |
196 | $this->assertFalse($subscriptionResponse->getIsCanceled());
197 | $this->assertFalse($subscriptionResponse->getIsDeleted());
198 | }
199 |
200 |
201 | }
202 |
--------------------------------------------------------------------------------
/tests/Integration/PaymentTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Payment();
23 | parent::setUp();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_model = null;
32 | parent::tearDown();
33 | }
34 |
35 | /**
36 | * @test
37 | * @codeCoverageIgnore
38 | */
39 | public function createPayment()
40 | {
41 | $this->_model->setToken("098f6bcd4621d373cade4e832627b4f6");
42 | $result = $this->_service->create($this->_model);
43 | $this->assertInstanceOf('Paymill\Models\Response\Payment', $result);
44 | return $result;
45 | }
46 |
47 | /**
48 | * @test
49 | * @codeCoverageIgnore
50 | * @depends createPayment
51 | * @expectedException \Paymill\Services\PaymillException
52 | * @expectedExceptionMessage Method not Found
53 | */
54 | public function updatePayment($model)
55 | {
56 | $this->_model->setId($model->getId());
57 | $this->_service->update($this->_model);
58 | }
59 |
60 | /**
61 | * @test
62 | * @codeCoverageIgnore
63 | * @depends createPayment
64 | */
65 | public function getOnePayment($model)
66 | {
67 | $this->_model->setId($model->getId());
68 | $result = $this->_service->getOne($this->_model);
69 | $this->assertInstanceOf('Paymill\Models\Response\Payment', $result, var_export($result, true));
70 | $this->assertEquals($model->getId(), $result->getId());
71 | }
72 |
73 | /**
74 | * @test
75 | * @codeCoverageIgnore
76 | * @depends createPayment
77 | */
78 | public function getAllPayment()
79 | {
80 | $this->_model;
81 | $result = $this->_service->getAll($this->_model);
82 | $this->assertInternalType('array', $result, var_export($result, true));
83 | }
84 |
85 | /**
86 | * @test
87 | * @codeCoverageIgnore
88 | * @depends createPayment
89 | */
90 | public function getAllPaymentAsModel()
91 | {
92 | $this->_model;
93 | $result = $this->_service->getAllAsModel($this->_model);
94 | $this->assertInternalType('array', $result, var_export($result, true));
95 | $this->assertInstanceOf('Paymill\Models\Response\Payment', array_pop($result));
96 | }
97 |
98 | /**
99 | * @test
100 | * @codeCoverageIgnore
101 | */
102 | public function getAllPaymentWithFilter()
103 | {
104 | $this->_model->setFilter(array(
105 | 'count' => 1,
106 | 'offset' => 0
107 | )
108 | );
109 | $result = $this->_service->getAll($this->_model);
110 | $this->assertEquals(1, count($result), var_export($result, true));
111 | }
112 |
113 | /**
114 | * @test
115 | * @codeCoverageIgnore
116 | * @depends createPayment
117 | * @depends getOnePayment
118 | * @depends updatePayment
119 | */
120 | public function deletePayment($model)
121 | {
122 | $this->_model->setId($model->getId());
123 | $result = $this->_service->delete($this->_model);
124 | $this->assertEquals(null, $result, var_export($result, true));
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/tests/Integration/PreauthorizationTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Preauthorization();
23 | parent::setUp();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_model = null;
32 | parent::tearDown();
33 | }
34 |
35 | /**
36 | * @test
37 | * @codeCoverageIgnore
38 | */
39 | public function createPreauthorization()
40 | {
41 | $this->_model->setToken("098f6bcd4621d373cade4e832627b4f6")
42 | ->setAmount(100)
43 | ->setCurrency('EUR');
44 | $result = $this->_service->create($this->_model);
45 | $this->assertInstanceOf('Paymill\Models\Response\Preauthorization', $result);
46 | $this->assertNotNull($result->getTransaction());
47 | return $result;
48 | }
49 |
50 | /**
51 | * @test
52 | * @codeCoverageIgnore
53 | * @depends createPreauthorization
54 | */
55 | public function updatePreauthorization($model)
56 | {
57 | $this->_model->setId($model->getId());
58 | $this->markTestIncomplete(
59 | 'Preauthorization should return a valid Object like Client "Method not found". Returns a empty 500-Response instead.'
60 | );
61 |
62 | $result = $this->_service->update($this->_model);
63 |
64 | $this->assertInstanceOf('Paymill\Models\Response\Error', $result, var_export($result, true));
65 | $this->assertEquals('Preauthorization was not found', $result->getErrorMessage());
66 | }
67 |
68 | /**
69 | * @test
70 | * @codeCoverageIgnore
71 | * @depends createPreauthorization
72 | */
73 | public function getOnePreauthorization($model)
74 | {
75 | $this->_model->setId($model->getId());
76 | $this->assertInstanceOf('Paymill\Models\Response\Preauthorization', $result = $this->_service->getOne($this->_model), var_export($result, true));
77 | $this->assertEquals($model->getId(), $result->getId());
78 | }
79 |
80 | /**
81 | * @test
82 | * @codeCoverageIgnore
83 | * @depends createPreauthorization
84 | */
85 | public function getAllPreauthorization()
86 | {
87 | $this->_model;
88 | $result = $this->_service->getAll($this->_model);
89 | $this->assertInternalType('array', $result, var_export($result, true));
90 | }
91 |
92 | /**
93 | * @test
94 | * @codeCoverageIgnore
95 | * @depends createPreauthorization
96 | */
97 | public function getAllPreauthorizationAsModel()
98 | {
99 | $this->_model;
100 | $result = $this->_service->getAllAsModel($this->_model);
101 | $this->assertInternalType('array', $result, var_export($result, true));
102 | $this->assertInstanceOf('Paymill\Models\Response\Preauthorization', array_pop($result));
103 | }
104 |
105 | /**
106 | * @test
107 | * @codeCoverageIgnore
108 | */
109 | public function getAllPreauthorizationWithFilter()
110 | {
111 | $this->_model->setFilter(array(
112 | 'count' => 1,
113 | 'offset' => 0
114 | )
115 | );
116 | $result = $this->_service->getAll($this->_model);
117 | $this->assertEquals(1, count($result), var_export($result, true));
118 | }
119 |
120 | /**
121 | * @test
122 | * @codeCoverageIgnore
123 | * @depends createPreauthorization
124 | * @depends getOnePreauthorization
125 | * @depends updatePreauthorization
126 | */
127 | public function deletePreauthorization($model)
128 | {
129 | $this->_model->setId($model->getId());
130 | $result = $this->_service->delete($this->_model);
131 | $this->assertInternalType('array', $result, var_export($result, true));
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/tests/Integration/RefundTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Refund();
23 | parent::setUp();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_model = null;
32 | parent::tearDown();
33 | }
34 |
35 | /**
36 | * @test
37 | * @codeCoverageIgnore
38 | */
39 | public function createRefund()
40 | {
41 | $transactionModel = new Models\Request\Transaction();
42 | $transactionModel->setAmount(200)
43 | ->setCurrency('EUR')
44 | ->setToken($this->createToken());
45 | $transactionModelResponse = $this->_service->create($transactionModel);
46 | $this->assertInstanceOf('Paymill\Models\Response\Transaction', $transactionModelResponse, var_export($transactionModelResponse, true));
47 |
48 | $this->_model->setAmount(100)
49 | ->setDescription('EUR')
50 | ->setId($transactionModelResponse->getId());
51 | $result = $this->_service->create($this->_model);
52 | $this->assertInstanceOf('Paymill\Models\Response\Refund', $result, var_export($result, true));
53 | return $result;
54 | }
55 |
56 | /**
57 | * @test
58 | * @codeCoverageIgnore
59 | * @depends createRefund
60 | * @expectedException \Paymill\Services\PaymillException
61 | * @expectedExceptionMessage Method not Found
62 | */
63 | public function updateRefund($model)
64 | {
65 | $this->_model->setId($model->getId());
66 | $this->_service->update($this->_model);
67 | }
68 |
69 | /**
70 | * @test
71 | * @codeCoverageIgnore
72 | * @depends createRefund
73 | */
74 | public function getOneRefund($model)
75 | {
76 | $this->_model->setId($model->getId());
77 | $this->assertInstanceOf('Paymill\Models\Response\Refund', $result = $this->_service->getOne($this->_model), var_export($result, true));
78 | $this->assertEquals($model->getId(), $result->getId());
79 | }
80 |
81 | /**
82 | * @test
83 | * @codeCoverageIgnore
84 | * @depends createRefund
85 | */
86 | public function getAllRefund()
87 | {
88 | $this->_model;
89 | $result = $this->_service->getAll($this->_model);
90 | $this->assertInternalType('array', $result, var_export($result, true));
91 | }
92 |
93 | /**
94 | * @test
95 | * @codeCoverageIgnore
96 | * @depends createRefund
97 | */
98 | public function getAllRefundAsModel()
99 | {
100 | $this->_model;
101 | $result = $this->_service->getAllAsModel($this->_model);
102 | $this->assertInternalType('array', $result, var_export($result, true));
103 | $this->assertInstanceOf('Paymill\Models\Response\Refund', array_pop($result));
104 | }
105 |
106 | /**
107 | * @test
108 | * @codeCoverageIgnore
109 | */
110 | public function getAllRefundWithFilter()
111 | {
112 | $this->_model->setFilter(array(
113 | 'count' => 1,
114 | 'offset' => 0
115 | )
116 | );
117 | $result = $this->_service->getAll($this->_model);
118 | $this->assertEquals(1, count($result), var_export($result, true));
119 | }
120 |
121 | /**
122 | * @test
123 | * @codeCoverageIgnore
124 | * @depends createRefund
125 | * @depends getOneRefund
126 | * @depends updateRefund
127 | * @expectedException \Paymill\Services\PaymillException
128 | * @expectedExceptionMessage Method not Found
129 | */
130 | public function deleteRefund($model)
131 | {
132 | $this->_model->setId($model->getId());
133 | $result = $this->_service->delete($this->_model);
134 | $this->assertInstanceOf('Paymill\Models\Response\Error', $result, var_export($result, true));
135 | $this->assertEquals('Method not Found', $result->getErrorMessage());
136 | }
137 |
138 | }
139 |
--------------------------------------------------------------------------------
/tests/Integration/WebhookTest.php:
--------------------------------------------------------------------------------
1 | _model = new Models\Request\Webhook();
33 | $this->_email = 'dummy@example.com';
34 | $this->_url = 'http://example.com/dummyCallback';
35 | parent::setUp();
36 | }
37 |
38 | /**
39 | * Cleans up the environment after running a test.
40 | */
41 | protected function tearDown()
42 | {
43 | $this->_model = null;
44 | $this->_email = null;
45 | $this->_url = null;
46 |
47 | parent::tearDown();
48 | }
49 |
50 | /**
51 | * @test
52 | * @codeCoverageIgnore
53 | */
54 | public function createWebhookWithUrl()
55 | {
56 | $this->_model->setUrl('http://example.com/dummyCallback')
57 | ->setActive(true)
58 | ->setEventTypes(array(WEBHOOK_1, WEBHOOK_2));
59 | $result = $this->_service->create($this->_model);
60 | $this->assertInstanceOf('Paymill\Models\Response\Webhook', $result, var_export($result, true));
61 | $this->assertTrue($result->getActive());
62 |
63 | return $result;
64 | }
65 |
66 | /**
67 | * @test
68 | * @codeCoverageIgnore
69 | */
70 | public function createWebhookWithEmail()
71 | {
72 | $this->_model->setEmail('dummy@example.com')
73 | ->setActive(true)
74 | ->setEventTypes(array(WEBHOOK_1, WEBHOOK_2));
75 | $result = $this->_service->create($this->_model);
76 | $this->assertInstanceOf('Paymill\Models\Response\Webhook', $result, var_export($result, true));
77 | $this->deleteWebhook($result);
78 | }
79 |
80 | /**
81 | * @test
82 | * @codeCoverageIgnore
83 | * @depends createWebhookWithUrl
84 | */
85 | public function updateWebhook($model)
86 | {
87 | $this->_model->setId($model->getId())
88 | ->setActive(false)
89 | ->setUrl('http://example.com/dummyCallbackUpdate');
90 | $result = $this->_service->update($this->_model);
91 |
92 | $this->assertInstanceOf('Paymill\Models\Response\Webhook', $result, var_export($result, true));
93 | $this->assertEquals($model->getId(), $result->getId());
94 | $this->assertFalse($result->getActive());
95 |
96 | return $result;
97 | }
98 |
99 | /**
100 | * @test
101 | * @codeCoverageIgnore
102 | * @depends createWebhookWithUrl
103 | */
104 | public function getOneWebhook($model)
105 | {
106 | $this->_model->setId($model->getId());
107 | $this->assertInstanceOf('Paymill\Models\Response\Webhook', $result = $this->_service->getOne($this->_model), var_export($result, true));
108 | $this->assertEquals($model->getId(), $result->getId());
109 |
110 | return $result;
111 | }
112 |
113 | /**
114 | * @test
115 | * @codeCoverageIgnore
116 | * @depends createWebhookWithUrl
117 | */
118 | public function getAllWebhook()
119 | {
120 | $this->_model;
121 | $result = $this->_service->getAll($this->_model);
122 | $this->assertInternalType('array', $result, var_export($result, true));
123 | }
124 |
125 | /**
126 | * @test
127 | * @codeCoverageIgnore
128 | * @depends createWebhookWithUrl
129 | */
130 | public function getAllWebhookAsModel()
131 | {
132 | $this->_model;
133 | $result = $this->_service->getAllAsModel($this->_model);
134 | $this->assertInternalType('array', $result, var_export($result, true));
135 | $this->assertInstanceOf('Paymill\Models\Response\Webhook', array_pop($result));
136 | }
137 |
138 | /**
139 | * @test
140 | * @depends createWebhookWithUrl
141 | * @codeCoverageIgnore
142 | */
143 | public function getAllWebhookWithFilter()
144 | {
145 | $this->_model->setFilter(array(
146 | 'count' => 1,
147 | 'offset' => 0
148 | )
149 | );
150 | $result = $this->_service->getAll($this->_model);
151 | $this->assertEquals(1, count($result), var_export($result, true));
152 | }
153 |
154 | /**
155 | * @test
156 | * @codeCoverageIgnore
157 | * @depends createWebhookWithUrl
158 | * @depends getOneWebhook
159 | * @depends updateWebhook
160 | */
161 | public function deleteWebhook($model)
162 | {
163 | $this->_model->setId($model->getId());
164 | $result = $this->_service->delete($this->_model);
165 | $this->assertInternalType('array', $result, var_export($result, true));
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/API/CurlTest.php:
--------------------------------------------------------------------------------
1 | false)
28 | );
29 |
30 | $this->_curlObject = $this->getMock(
31 | 'Paymill\API\Curl',
32 | array('_curlExec', '_curlInfo', '_curlError', '_curlOpts'),
33 | $constructorArgs
34 | );
35 | parent::setUp();
36 | }
37 |
38 | /**
39 | * Cleans up the environment after running a test.
40 | */
41 | protected function tearDown()
42 | {
43 | $this->_curlObject = null;
44 | parent::tearDown();
45 | }
46 |
47 |
48 | /**
49 | * Prepares the mocked curl object to return any desired value for the given method
50 | * @param string $method
51 | * @param mixed $response
52 | */
53 | private function _setMockProperties($method, $response)
54 | {
55 | $this->_curlObject->expects($this->any())->method($method)->will($this->returnValue($response));
56 | }
57 |
58 | //Testmethods
59 |
60 |
61 | /**
62 | * Tests the requestApi function using GET as the httpMethod
63 | * @test
64 | */
65 | public function requestApiTestGET()
66 | {
67 | //Desired Results
68 | $responseBody = array('test' => true);
69 | $responseInfo = array('http_code' => 200, 'content_type' => 'test');
70 | $curlOpts = array(
71 | 81 => false,
72 | 10002 => 'https://api.paymill.com/v2.1/',
73 | 19913 => true,
74 | 10036 => 'GET',
75 | 10018 => 'Paymill-php/0.0.2',
76 | 64 => true,
77 | 10005 => 'TestToken:'
78 | );
79 |
80 | $this->_setMockProperties('_curlExec', $responseBody);
81 | $this->_setMockProperties('_curlInfo', $responseInfo);
82 | $that = $this;
83 | $this->_curlObject->expects($this->once())
84 | ->method('_curlOpts')
85 | ->will($this->returnCallback(function($curl, array $options) use($curlOpts, $that) {
86 | $that->assertEquals($curlOpts, $options);
87 | return true;
88 | }));
89 |
90 | //Testing method using GET
91 | $result = $this->_curlObject->requestApi("", array(), 'GET');
92 | $this->assertEquals(
93 | array(
94 | 'header' => array(
95 | 'status' => $responseInfo['http_code'],
96 | 'reason' => null,
97 | ),
98 | 'body' => $responseBody)
99 | ,$result);
100 | }
101 |
102 | /**
103 | * Tests the requestApi function using POST as the httpMethod
104 | * @test
105 | */
106 | public function requestApiTestPost()
107 | {
108 | //Desired Results
109 | $responseBody = array('test' => true);
110 | $responseInfo = array('http_code' => 200, 'content_type' => 'test');
111 |
112 | $this->_setMockProperties('_curlExec', $responseBody);
113 | $this->_setMockProperties('_curlInfo', $responseInfo);
114 |
115 | //using POST to test the else case
116 | $result = $this->_curlObject->requestApi("", array(), 'POST');
117 | $this->assertEquals(
118 | array(
119 | 'header' => array(
120 | 'status' => $responseInfo['http_code'],
121 | 'reason' => null,
122 | ),
123 | 'body' => $responseBody)
124 | ,$result);
125 | }
126 |
127 | /**
128 | * Tests the requestApi function triggering the error case
129 | * @test
130 | */
131 | public function requestApiTestError()
132 | {
133 | //Desired Results
134 | $responseBody = false;
135 | $responseInfo = array('http_code' => 666, 'content_type' => 'test');
136 | $responseError = array('test' => true);
137 |
138 | $this->_setMockProperties('_curlExec', $responseBody);
139 | $this->_setMockProperties('_curlInfo', $responseInfo);
140 | $this->_setMockProperties('_curlError', $responseError);
141 |
142 | //using POST to test the else case
143 | $result = $this->_curlObject->requestApi("", array(), 'POST');
144 | $this->assertEquals(
145 | array(
146 | 'header' => array(
147 | 'status' => $responseInfo['http_code'],
148 | 'reason' => null,
149 | ),
150 | 'body' => array('error' => $responseError))
151 | ,$result);
152 | }
153 |
154 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Internal/BillingAddressTest.php:
--------------------------------------------------------------------------------
1 | 'Max Muster',
19 | 'street_address' => 'Musterstrasse 1',
20 | 'street_address_addition' => 'EG',
21 | 'city' => 'Musterhausen',
22 | 'state' => 'BY',
23 | 'postal_code' => '99999',
24 | 'country' => 'DE',
25 | 'phone' => '+49 89 1234567',
26 | );
27 |
28 | /**
29 | * Prepares the environment before running a test.
30 | */
31 | protected function setUp()
32 | {
33 | parent::setUp();
34 | $this->_billingAddress = new BillingAddress();
35 | $this->_billingAddress->setName($this->sample['name'])
36 | ->setStreetAddress($this->sample['street_address'])
37 | ->setStreetAddressAddition($this->sample['street_address_addition'])
38 | ->setCity($this->sample['city'])
39 | ->setState($this->sample['state'])
40 | ->setPostalCode($this->sample['postal_code'])
41 | ->setCountry($this->sample['country'])
42 | ->setPhone($this->sample['phone']);
43 | }
44 |
45 | /**
46 | * Cleans up the environment after running a test.
47 | */
48 | protected function tearDown()
49 | {
50 | $this->_billingAddress = null;
51 | parent::tearDown();
52 | }
53 |
54 | //Testmethods
55 | /**
56 | * Tests the getters and setters of the model
57 | * @test
58 | */
59 | public function setGetTest()
60 | {
61 | $this->assertEquals($this->_billingAddress->getName(), $this->sample['name']);
62 | $this->assertEquals($this->_billingAddress->getStreetAddress(), $this->sample['street_address']);
63 | $this->assertEquals($this->_billingAddress->getStreetAddressAddition(), $this->sample['street_address_addition']);
64 | $this->assertEquals($this->_billingAddress->getCity(), $this->sample['city']);
65 | $this->assertEquals($this->_billingAddress->getState(), $this->sample['state']);
66 | $this->assertEquals($this->_billingAddress->getPostalCode(), $this->sample['postal_code']);
67 | $this->assertEquals($this->_billingAddress->getCountry(), $this->sample['country']);
68 | $this->assertEquals($this->_billingAddress->getPhone(), $this->sample['phone']);
69 |
70 | return $this->_billingAddress;
71 | }
72 |
73 | /**
74 | * Tests the getters and setters of the model
75 | * @test
76 | */
77 | public function modelToArray()
78 | {
79 | $this->assertEquals($this->sample, $this->_billingAddress->toArray());
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Internal/ItemTest.php:
--------------------------------------------------------------------------------
1 | _item = new Item();
24 | }
25 |
26 | /**
27 | * Cleans up the environment after running a test.
28 | */
29 | protected function tearDown()
30 | {
31 | $this->_item = null;
32 | parent::tearDown();
33 | }
34 |
35 | //Testmethods
36 | /**
37 | * Tests the getters and setters of the model
38 | * @test
39 | */
40 | public function setGetTest()
41 | {
42 | $sample = array(
43 | 'name' => 'Product 1',
44 | 'description' => 'Product description',
45 | 'item_number' => 'ITM123456',
46 | 'url' => 'https://shop.example.com/item/1',
47 | 'amount' => '1999',
48 | 'quantity' => 1,
49 | );
50 |
51 | $this->_item->setName($sample['name'])
52 | ->setDescription($sample['description'])
53 | ->setItemNumber($sample['item_number'])
54 | ->setUrl($sample['url'])
55 | ->setAmount($sample['amount'])
56 | ->setQuantity($sample['quantity']);
57 |
58 | $this->assertEquals($this->_item->getName(), $sample['name']);
59 | $this->assertEquals($this->_item->getDescription(), $sample['description']);
60 | $this->assertEquals($this->_item->getItemNumber(), $sample['item_number']);
61 | $this->assertEquals($this->_item->getUrl(), $sample['url']);
62 | $this->assertEquals($this->_item->getAmount(), $sample['amount']);
63 | $this->assertEquals($this->_item->getQuantity(), $sample['quantity']);
64 |
65 | return $this->_item;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Internal/ShippingAddressTest.php:
--------------------------------------------------------------------------------
1 | 'Max Muster',
19 | 'street_address' => 'Musterstrasse 1',
20 | 'street_address_addition' => 'EG',
21 | 'city' => 'Musterhausen',
22 | 'state' => 'BY',
23 | 'postal_code' => '99999',
24 | 'country' => 'DE',
25 | 'phone' => '+49 89 1234567',
26 | );
27 |
28 | /**
29 | * Prepares the environment before running a test.
30 | */
31 | protected function setUp()
32 | {
33 | parent::setUp();
34 | $this->_shippingAddress = new ShippingAddress();
35 | $this->_shippingAddress->setName($this->sample['name'])
36 | ->setStreetAddress($this->sample['street_address'])
37 | ->setStreetAddressAddition($this->sample['street_address_addition'])
38 | ->setCity($this->sample['city'])
39 | ->setState($this->sample['state'])
40 | ->setPostalCode($this->sample['postal_code'])
41 | ->setCountry($this->sample['country'])
42 | ->setPhone($this->sample['phone']);
43 | }
44 |
45 | /**
46 | * Cleans up the environment after running a test.
47 | */
48 | protected function tearDown()
49 | {
50 | $this->_shippingAddress = null;
51 | parent::tearDown();
52 | }
53 |
54 | //Testmethods
55 | /**
56 | * Tests the getters and setters of the model
57 | * @test
58 | */
59 | public function setGetTest()
60 | {
61 | $this->assertEquals($this->_shippingAddress->getName(), $this->sample['name']);
62 | $this->assertEquals($this->_shippingAddress->getStreetAddress(), $this->sample['street_address']);
63 | $this->assertEquals($this->_shippingAddress->getStreetAddressAddition(), $this->sample['street_address_addition']);
64 | $this->assertEquals($this->_shippingAddress->getCity(), $this->sample['city']);
65 | $this->assertEquals($this->_shippingAddress->getState(), $this->sample['state']);
66 | $this->assertEquals($this->_shippingAddress->getPostalCode(), $this->sample['postal_code']);
67 | $this->assertEquals($this->_shippingAddress->getCountry(), $this->sample['country']);
68 | $this->assertEquals($this->_shippingAddress->getPhone(), $this->sample['phone']);
69 |
70 | return $this->_shippingAddress;
71 | }
72 |
73 | /**
74 | * Tests the toArray method
75 | * @test
76 | */
77 | public function modelToArray()
78 | {
79 | $this->assertEquals($this->sample, $this->_shippingAddress->toArray());
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/BaseTest.php:
--------------------------------------------------------------------------------
1 | _model = null;
35 | parent::tearDown();
36 | }
37 |
38 | //Testmethods
39 | /**
40 | * Tests the getters and setters of the model
41 | * @test
42 | */
43 | public function setGetTest()
44 | {
45 | $id = "This a weird test";
46 |
47 | $this->_model = new Request\Client();
48 | $this->_model->setId($id);
49 | $this->_model->setFilter(array('count' => 1));
50 |
51 | $this->assertEquals($this->_model->getId(), $id);
52 | $this->assertEquals($this->_model->getServiceResource(), "clients/");
53 | $this->assertEquals($this->_model->getFilter(), array('count' => 1));
54 | return $this->_model;
55 | }
56 |
57 | /**
58 | * Tests the parameter return from parameterize('getAll')
59 | * @param \Paymill\Models\Request\Client $model
60 | * @test
61 | * @depends setGetTest
62 | */
63 | public function parameterizeGetAll($model){
64 | $this->assertEquals($model->parameterize('getAll'), array('count' => 1));
65 | }
66 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/ClientTest.php:
--------------------------------------------------------------------------------
1 | _client = new Request\Client();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_client = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $email = "lovely-client@example.com";
44 | $description = "Lovely Client";
45 |
46 | $this->_client->setEmail($email)->setDescription($description);
47 |
48 | $this->assertEquals($this->_client->getEmail(), $email);
49 | $this->assertEquals($this->_client->getDescription(), $description);
50 | return $this->_client;
51 | }
52 |
53 | /**
54 | * Test the Parameterize function of the model
55 | * @test
56 | * @depends setGetTest
57 | * @param \Paymill\Models\Request\Client $client
58 | */
59 | public function parameterizeTest($client)
60 | {
61 | $testId = "client_88a388d9dd48f86c3136";
62 | $client->setId($testId);
63 |
64 | $creationArray = $client->parameterize("create");
65 | $updateArray = $client->parameterize("update");
66 | $getOneArray = $client->parameterize("getOne");
67 |
68 | $this->assertEquals($creationArray,
69 | array('email' => "lovely-client@example.com", 'description' => "Lovely Client"));
70 | $this->assertEquals($updateArray,
71 | array(
72 | 'email' => 'lovely-client@example.com',
73 | 'description' => 'Lovely Client'
74 | ));
75 | $this->assertEquals($getOneArray, array(
76 | 'count' => 1,
77 | 'offset' => 0
78 | ));
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/OfferTest.php:
--------------------------------------------------------------------------------
1 | _offer = new Request\Offer();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_offer = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $amount = '4200';
44 | $currency = 'EUR';
45 | $interval = '1 MONTH';
46 | $name = 'Test Offer';
47 |
48 | $this->_offer->setAmount($amount)->setCurrency($currency)->setInterval($interval)->setName($name);
49 |
50 | $this->assertEquals($this->_offer->getAmount(), $amount);
51 | $this->assertEquals($this->_offer->getCurrency(), $currency);
52 | $this->assertEquals($this->_offer->getInterval(), $interval);
53 | $this->assertEquals($this->_offer->getName(), $name);
54 |
55 | return $this->_offer;
56 | }
57 |
58 | /**
59 | * Test the Parameterize function of the model
60 | * @test
61 | * @depends setGetTest
62 | */
63 | public function parameterizeTest(Request\Offer $offer)
64 | {
65 | $testId = "offer_88a388d9dd48f86c3136";
66 | $offer->setId($testId);
67 | $creationArray = $offer->parameterize("create");
68 | $offer->setUpdateSubscriptions(true);
69 | $updateArray = $offer->parameterize("update");
70 | $getOneArray = $offer->parameterize("getOne");
71 |
72 | $this->assertEquals($creationArray, array(
73 | 'amount' => 4200, // E.g. "4200" for 42.00 EUR
74 | 'currency' => 'EUR', // ISO 4217
75 | 'interval' => '1 MONTH',
76 | 'name' => 'Test Offer',
77 | 'trial_period_days' => null
78 | ));
79 | $expectedUpdateArray = array(
80 | 'name' => $offer->getName(),
81 | 'amount' => $offer->getAmount(),
82 | 'currency' => $offer->getCurrency(),
83 | 'interval' => $offer->getInterval(),
84 | 'trial_period_days' => $offer->getTrialPeriodDays(),
85 | 'update_subscriptions' => $offer->getUpdateSubscriptions()
86 |
87 | );
88 | $this->assertEquals($expectedUpdateArray, $updateArray);
89 | $this->assertEquals($getOneArray, array(
90 | 'count' => 1,
91 | 'offset' => 0
92 | ));
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/PaymentTest.php:
--------------------------------------------------------------------------------
1 | _payment = new Request\Payment();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_payment = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $sample = array(
44 | 'client' => 'client_88a388d9dd48f86c3136',
45 | 'token' => '098f6bcd4621d373cade4e832627b4f6'
46 | );
47 |
48 | $this->_payment->setClient($sample['client'])->setToken($sample['token']);
49 |
50 | $this->assertEquals($this->_payment->getClient(), $sample['client']);
51 | $this->assertEquals($this->_payment->getToken(), $sample['token']);
52 |
53 | return $this->_payment;
54 | }
55 |
56 | /**
57 | * Test the Parameterize function of the model
58 | * @test
59 | * @depends setGetTest
60 | */
61 | public function parameterizeTest($payment)
62 | {
63 | $testId = "payment_88a388d9dd48f86c3136";
64 | $payment->setId($testId);
65 |
66 | $creationArray = $payment->parameterize("create");
67 | $getOneArray = $payment->parameterize("getOne");
68 |
69 | $this->assertEquals($creationArray, array('client' => 'client_88a388d9dd48f86c3136', 'token' => '098f6bcd4621d373cade4e832627b4f6')
70 | );
71 | $this->assertEquals($getOneArray, array(
72 | 'count' => 1,
73 | 'offset' => 0
74 | ));
75 | }
76 |
77 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/PreauthorizationTest.php:
--------------------------------------------------------------------------------
1 | _preauthorization = new Request\Preauthorization();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_preauthorization = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $sample = array(
44 | 'token' => '098f6bcd4621d373cade4e832627b4f6',
45 | 'payment' => 'pay_d43cf0ee969d9847512b',
46 | 'amount' => '4200',
47 | 'currency' => 'EUR',
48 | 'description' => 'Test Description',
49 | 'source' => 'Test Source',
50 | 'client' => 'client_4624bcfbac1f4862642f',
51 | );
52 |
53 | $this->_preauthorization
54 | ->setPayment($sample['payment'])
55 | ->setToken($sample['token'])
56 | ->setAmount($sample['amount'])
57 | ->setCurrency($sample['currency'])
58 | ->setSource(($sample['source']))
59 | ->setDescription($sample['description'])
60 | ->setClient($sample['client']);
61 |
62 | $this->assertEquals($this->_preauthorization->getToken(), $sample['token']);
63 | $this->assertEquals($this->_preauthorization->getPayment(), $sample['payment']);
64 | $this->assertEquals($this->_preauthorization->getAmount(), $sample['amount']);
65 | $this->assertEquals($this->_preauthorization->getCurrency(), $sample['currency']);
66 | $this->assertEquals($this->_preauthorization->getDescription(), $sample['description']);
67 | $this->assertEquals($this->_preauthorization->getClient(), $sample['client']);
68 | $this->assertEquals($this->_preauthorization->getSource(), $sample['source']);
69 |
70 | return $this->_preauthorization;
71 | }
72 |
73 | /**
74 | * Test the Parameterize function of the model
75 | * @test
76 | * @depends setGetTest
77 | */
78 | public function parameterizeTest($preauthorization)
79 | {
80 | $testId = "preauthorization_88a388d9dd48f86c3136";
81 | $preauthorization->setId($testId);
82 |
83 | $creationArray = $preauthorization->parameterize("create");
84 | $getOneArray = $preauthorization->parameterize("getOne");
85 |
86 | $this->assertEquals($creationArray, array(
87 | 'payment' => 'pay_d43cf0ee969d9847512b',
88 | 'amount' => '4200',
89 | 'currency' => 'EUR',
90 | 'description' => 'Test Description',
91 | 'client' => 'client_4624bcfbac1f4862642f',
92 | 'source' => 'Test Source'
93 | )
94 | );
95 | $this->assertEquals($getOneArray, array(
96 | 'count' => 1,
97 | 'offset' => 0
98 | )
99 | );
100 | }
101 |
102 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/RefundTest.php:
--------------------------------------------------------------------------------
1 | _refund = new Request\Refund();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_refund = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $sample = array(
44 | 'amount' => '4200', // e.g. "4200" for 42.00 EUR
45 | 'description' => 'Sample Description',
46 | 'reason' => 'requested_by_customer'
47 | );
48 |
49 | $this->_refund->setAmount($sample['amount'])
50 | ->setDescription($sample['description']);
51 |
52 | $this->assertEquals($this->_refund->getAmount(), $sample['amount']);
53 | $this->assertEquals($this->_refund->getDescription(), $sample['description']);
54 |
55 | return $this->_refund;
56 | }
57 |
58 | /**
59 | * Test the Parameterize function of the model
60 | * @test
61 | * @depends setGetTest
62 | */
63 | public function parameterizeTest($refund)
64 | {
65 | $testId = "refund_88a388d9dd48f86c3136";
66 | $refund->setId($testId);
67 |
68 | $creationArray = $refund->parameterize("create");
69 | $getOneArray = $refund->parameterize("getOne");
70 |
71 | $this->assertEquals($creationArray, array('amount' => '4200', 'description' => 'Sample Description'));
72 | $this->assertEquals($getOneArray, array('count' => 1, 'offset' => 0));
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/SubscriptionTest.php:
--------------------------------------------------------------------------------
1 | _subscription = new Request\Subscription();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_subscription = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $sample = array(
44 | 'client' => 'client_88a388d9dd48f86c3136',
45 | 'offer' => 'offer_40237e20a7d5a231d99b',
46 | 'payment' => 'pay_95ba26ba2c613ebb0ca8',
47 | 'mandate_reference' => 'DE1234TEST',
48 | );
49 |
50 | $this->_subscription->setPayment($sample['payment'])
51 | ->setOffer($sample['offer'])
52 | ->setClient($sample['client'])
53 | ->setMandateReference($sample['mandate_reference']);
54 |
55 | $this->assertEquals($this->_subscription->getClient(), $sample['client']);
56 | $this->assertEquals($this->_subscription->getOffer(), $sample['offer']);
57 | $this->assertEquals($this->_subscription->getPayment(), $sample['payment']);
58 | $this->assertEquals($this->_subscription->getMandateReference(), $sample['mandate_reference']);
59 |
60 | return $this->_subscription;
61 | }
62 |
63 | /**
64 | * Test the Parameterize function of the model
65 | * @test
66 | * @depends setGetTest
67 | */
68 | public function parameterizeTest($subscription)
69 | {
70 | $testId = "subscription_88a388d9dd48f86c3136";
71 | $subscription->setId($testId);
72 |
73 | $creationArray = $subscription->parameterize("create");
74 | $updateArray = $subscription->parameterize("update");
75 | $getOneArray = $subscription->parameterize("getOne");
76 |
77 | $this->assertEquals(array(
78 | 'client' => 'client_88a388d9dd48f86c3136',
79 | 'offer' => 'offer_40237e20a7d5a231d99b',
80 | 'payment' => 'pay_95ba26ba2c613ebb0ca8',
81 | 'mandate_reference' => 'DE1234TEST'
82 | ), $creationArray);
83 |
84 | $this->assertEquals($getOneArray, array(
85 | 'count' => 1,
86 | 'offset' => 0
87 | ));
88 | $this->assertEquals($updateArray, array(
89 | 'offer' => 'offer_40237e20a7d5a231d99b',
90 | 'payment' => 'pay_95ba26ba2c613ebb0ca8',
91 | 'mandate_reference' => 'DE1234TEST'
92 | ));
93 | }
94 |
95 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Request/WebhookTest.php:
--------------------------------------------------------------------------------
1 | _webhook = new Request\Webhook();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_webhook = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $sample = array(
44 | 'url' => 'your-webhook-url',
45 | 'email' => 'your-webhook-email',
46 | 'event_types' => array('transaction.succeeded', 'subscription.created'),
47 | 'state' => true
48 | );
49 |
50 | $this->_webhook
51 | ->setUrl($sample['url'])
52 | ->setEmail($sample['email'])
53 | ->setEventTypes($sample['event_types'])
54 | ->setActive($sample['state']);
55 |
56 | $this->assertEquals($this->_webhook->getUrl(), $sample['url']);
57 | $this->assertEquals($this->_webhook->getEmail(), $sample['email']);
58 | $this->assertEquals($this->_webhook->getEventTypes(), $sample['event_types']);
59 | $this->assertEquals($this->_webhook->getActive(), $sample['state']);
60 |
61 | return $this->_webhook;
62 | }
63 |
64 | /**
65 | * Test the Parameterize function of the model
66 | * @test
67 | * @depends setGetTest
68 | */
69 | public function parameterizeTest($webhook)
70 | {
71 | $testId = "webhook_88a388d9dd48f86c3136";
72 | $webhook->setId($testId);
73 |
74 | $creationArray = $webhook->parameterize("create");
75 | $updateArray = $webhook->parameterize("update");
76 | $getOneArray = $webhook->parameterize("getOne");
77 |
78 | $this->assertEquals($creationArray, array(
79 | 'url' => 'your-webhook-url',
80 | 'event_types' => array('transaction.succeeded', 'subscription.created'),
81 | 'active' => true
82 | ));
83 | $this->assertEquals($updateArray, array(
84 | 'url' => 'your-webhook-url',
85 | 'event_types' => array('transaction.succeeded', 'subscription.created'),
86 | 'active' => true
87 | ));
88 | $this->assertEquals($getOneArray, array('count' => 1, 'offset' => 0));
89 | }
90 |
91 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/BaseTest.php:
--------------------------------------------------------------------------------
1 | _payment = new Response\Payment();
26 | }
27 |
28 | /**
29 | * Cleans up the environment after running a test.
30 | */
31 | protected function tearDown()
32 | {
33 | $this->_payment = null;
34 | parent::tearDown();
35 | }
36 |
37 | //Testmethods
38 | /**
39 | * Tests the getters and setters of the model
40 | * @test
41 | */
42 | public function setGetTest()
43 | {
44 | $id = "This a weird test";
45 | $createdAt = 1;
46 | $updatedAt = 2;
47 | $appId = 1337;
48 |
49 | $this->_payment->setId($id)->setCreatedAt($createdAt)->setUpdatedAt($updatedAt)->setAppId($appId);
50 |
51 | $this->assertEquals($this->_payment->getId(), $id);
52 | $this->assertEquals($this->_payment->getCreatedAt(), $createdAt);
53 | $this->assertEquals($this->_payment->getUpdatedAt(), $updatedAt);
54 | $this->assertEquals($this->_payment->getAppId(), $appId);
55 | }
56 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/ChecksumTest.php:
--------------------------------------------------------------------------------
1 | _model = new Response\Checksum();
26 | }
27 |
28 | /**
29 | * Cleans up the environment after running a test.
30 | */
31 | protected function tearDown()
32 | {
33 | $this->_model = null;
34 | parent::tearDown();
35 | }
36 |
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $this->_model->setData('test=foo&foo[bar1]=test1&foo[bar2]=test2');
44 | $this->_model->setType('creditcard');
45 | $this->_model->setAction(Checksum::ACTION_TRANSACTION);
46 | $this->_model->setChecksum('foo-checksum');
47 | $this->_model->setAppId('app_123');
48 | $this->_model->setId('chk_123');
49 | $this->_model->setCreatedAt(23423142314);
50 | $this->_model->setUpdatedAt(23423142314);
51 |
52 | $this->assertEquals($this->_model->getData(), 'test=foo&foo[bar1]=test1&foo[bar2]=test2');
53 | $this->assertEquals($this->_model->getDataAsArray(), array(
54 | 'test' => 'foo',
55 | 'foo' => array(
56 | 'bar1' => 'test1',
57 | 'bar2' => 'test2'
58 | )
59 | ));
60 | $this->assertEquals($this->_model->getType(), 'creditcard');
61 | $this->assertEquals($this->_model->getAction(), Checksum::ACTION_TRANSACTION);
62 | $this->assertEquals($this->_model->getChecksum(), 'foo-checksum');
63 | $this->assertEquals($this->_model->getAppId(), 'app_123');
64 | $this->assertEquals($this->_model->getId(), 'chk_123');
65 | $this->assertEquals($this->_model->getCreatedAt(), 23423142314);
66 | $this->assertEquals($this->_model->getUpdatedAt(), 23423142314);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/ClientTest.php:
--------------------------------------------------------------------------------
1 | _client = new Response\Client();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_client = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $paymentModel = new Response\Payment();
44 | $email = "lovely-client@example.com";
45 | $descriptionValue = "TestDesc";
46 |
47 | $this->_client->setEmail($email)
48 | ->setDescription($descriptionValue)
49 | ->setPayment($paymentModel);
50 |
51 | $this->assertEquals($this->_client->getEmail(), $email);
52 | $this->assertEquals($this->_client->getDescription(), $descriptionValue);
53 | $this->assertEquals($this->_client->getPayment(), $paymentModel);
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/ErrorTest.php:
--------------------------------------------------------------------------------
1 | 'bar');
39 |
40 | $errorModel = new Error();
41 | $errorModel->setErrorMessage($errorMessage);
42 | $errorModel->setHttpStatusCode($httpStatusCode);
43 | $errorModel->setResponseCode($responseCode);
44 | $errorModel->setErrorResponseArray($errorResponseArray);
45 |
46 | $this->assertEquals($errorMessage, $errorModel->getErrorMessage());
47 | $this->assertEquals($httpStatusCode, $errorModel->getHttpStatusCode());
48 | $this->assertEquals($responseCode, $errorModel->getResponseCode());
49 | $this->assertEquals($errorResponseArray, $errorModel->getErrorResponseArray());
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/OfferTest.php:
--------------------------------------------------------------------------------
1 | _offer = new Response\Offer();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_offer = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $name = "Testoffer";
44 | $amount = 4200;
45 | $currency = "EUR";
46 | $interval = "1 WEEK";
47 | $trialPeriodDays = 0;
48 | $active = 3;
49 | $inactive = 0;
50 |
51 | $this->_offer->setName($name)->
52 | setAmount($amount)->
53 | setCurrency($currency)->
54 | setInterval($interval)->
55 | setTrialPeriodDays($trialPeriodDays)->
56 | setSubscriptionCount($active, $inactive);
57 |
58 | $this->assertEquals($this->_offer->getName(), $name);
59 | $this->assertEquals($this->_offer->getAmount(), $amount);
60 | $this->assertEquals($this->_offer->getCurrency(), $currency);
61 | $this->assertEquals($this->_offer->getInterval(), $interval);
62 | $this->assertEquals($this->_offer->getTrialPeriodDays(), $trialPeriodDays);
63 | $this->assertEquals($this->_offer->getSubscriptionCount(), array('active' => $active, 'inactive' => $inactive));
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/PaymentTest.php:
--------------------------------------------------------------------------------
1 | _payment = new Response\Payment();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_payment = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $type = "Test";
44 | $client = "Test";
45 | $cardType = "Test";
46 | $country = "Test";
47 | $expireMonth = 1;
48 | $expireYear = 2;
49 | $cardHolder = "Test";
50 | $lastFour = "Test";
51 | $code = "Test";
52 | $account = "Test";
53 | $holder = "Test";
54 | $iban = "Test";
55 | $bic = "Test";
56 |
57 |
58 | $this->_payment->setType($type)
59 | ->setClient($client)
60 | ->setCardType($cardType)
61 | ->setCountry($country)
62 | ->setExpireMonth($expireMonth)
63 | ->setExpireYear($expireYear)
64 | ->setCardHolder($cardHolder)
65 | ->setLastFour($lastFour)
66 | ->setCode($code)
67 | ->setAccount($account)
68 | ->setHolder($holder)
69 | ->setIban($iban)
70 | ->setBic($bic);
71 |
72 |
73 | $this->assertEquals($this->_payment->getType(),$type);
74 | $this->assertEquals($this->_payment->getClient(),$client);
75 | $this->assertEquals($this->_payment->getCardType(),$cardType);
76 | $this->assertEquals($this->_payment->getCountry(),$country);
77 | $this->assertEquals($this->_payment->getExpireMonth(),$expireMonth);
78 | $this->assertEquals($this->_payment->getExpireYear(),$expireYear);
79 | $this->assertEquals($this->_payment->getCardHolder(),$cardHolder);
80 | $this->assertEquals($this->_payment->getLastFour(),$lastFour);
81 | $this->assertEquals($this->_payment->getCode(),$code);
82 | $this->assertEquals($this->_payment->getAccount(),$account);
83 | $this->assertEquals($this->_payment->getHolder(),$holder);
84 | $this->assertEquals($this->_payment->getBic(),$bic);
85 | $this->assertEquals($this->_payment->getIban(),$iban);
86 | }
87 |
88 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/PreauthorizationTest.php:
--------------------------------------------------------------------------------
1 | _preauthorization = new Response\Preauthorization();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_preauthorization = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $amount = "4200";
44 | $currency = "EUR";
45 | $status = "closed";
46 | $livemode = false;
47 | $payment = new Response\Payment();
48 | $client = new Response\Client();
49 | $description = "Test Description";
50 |
51 | $this->_preauthorization->setAmount($amount)
52 | ->setCurrency($currency)
53 | ->setStatus($status)
54 | ->setLivemode($livemode)
55 | ->setPayment($payment)
56 | ->setClient($client)
57 | ->setDescription($description);
58 |
59 | $this->assertEquals($this->_preauthorization->getAmount(), $amount);
60 | $this->assertEquals($this->_preauthorization->getCurrency(), $currency);
61 | $this->assertEquals($this->_preauthorization->getStatus(), $status);
62 | $this->assertEquals($this->_preauthorization->getLivemode(), $livemode);
63 | $this->assertEquals($this->_preauthorization->getPayment(), $payment);
64 | $this->assertEquals($this->_preauthorization->getClient(), $client);
65 | $this->assertEquals($this->_preauthorization->getDescription(), $description);
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/RefundTest.php:
--------------------------------------------------------------------------------
1 | _refund = new Response\Refund();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_refund = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $amount = "010";
44 | $status = "closed";
45 | $description = "Test Description";
46 | $livemode = false;
47 | $responseCode = 20000;
48 | $transaction = new Response\Transaction();
49 |
50 | $this->_refund->setAmount($amount)
51 | ->setStatus($status)
52 | ->setDescription($description)
53 | ->setLivemode($livemode)
54 | ->setResponseCode($responseCode)
55 | ->setTransaction($transaction);
56 |
57 | $this->assertEquals($this->_refund->getAmount(), $amount);
58 | $this->assertEquals($this->_refund->getStatus(), $status);
59 | $this->assertEquals($this->_refund->getDescription(), $description);
60 | $this->assertEquals($this->_refund->getLivemode(), $livemode);
61 | $this->assertEquals($this->_refund->getResponseCode(), $responseCode);
62 | $this->assertEquals($this->_refund->getTransaction(), $transaction);
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/SubscriptionTest.php:
--------------------------------------------------------------------------------
1 | _subscription = new Response\Subscription();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_subscription = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $offer = new Response\Offer();
44 | $liveMode = false;
45 | $cancelAtPeriodEnd = false;
46 | $trialStart = null;
47 | $trialEnd = null;
48 | $nextCaptureAt = 1369563095;
49 | $canceledAt = null;
50 | $payment = new Response\Payment();
51 | $client = new Response\Client();
52 | $mandateReference = 'DE1234TEST';
53 | $periodOfValidity = '2 YEAR';
54 | $endOfPeriod = 1461429607;
55 |
56 | $this->_subscription->setOffer($offer)
57 | ->setLivemode($liveMode)
58 | ->setTrialStart($trialStart)
59 | ->setTrialEnd($trialEnd)
60 | ->setPeriodOfValidity($periodOfValidity)
61 | ->setEndOfPeriod($endOfPeriod)
62 | ->setNextCaptureAt($nextCaptureAt)
63 | ->setCanceledAt($canceledAt)
64 | ->setClient($client)
65 | ->setPayment($payment)
66 | ->setMandateReference($mandateReference);
67 |
68 | $this->assertEquals($this->_subscription->getOffer(), $offer);
69 | $this->assertEquals($this->_subscription->getLivemode(), $liveMode);
70 | $this->assertEquals($this->_subscription->getTrialStart(), $trialStart);
71 | $this->assertEquals($this->_subscription->getTrialEnd(), $trialEnd);
72 | $this->assertEquals($this->_subscription->getPeriodOfValidity(), $periodOfValidity);
73 | $this->assertEquals($this->_subscription->getEndOfPeriod(), $endOfPeriod);
74 | $this->assertEquals($this->_subscription->getNextCaptureAt(), $nextCaptureAt);
75 | $this->assertEquals($this->_subscription->getCanceledAt(), $canceledAt);
76 | $this->assertEquals($this->_subscription->getClient(), $client);
77 | $this->assertEquals($this->_subscription->getPayment(), $payment);
78 | $this->assertEquals($this->_subscription->getMandateReference(), $mandateReference);
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/TransactionTest.php:
--------------------------------------------------------------------------------
1 | _transaction = new Response\Transaction();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_transaction = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $amount = "4200";
44 | $originAmount = 4200;
45 | $status = "closed";
46 | $description = "Test Desc";
47 | $livemode = false;
48 | $refunds = null;
49 | $currency = "EUR";
50 | $responseCode = 200000;
51 | $shortId = "This is a short string?!";
52 | $invoices = array();
53 | $payment = new Response\Payment();
54 | $client = new Response\Client();
55 | $preAuth = new Response\Preauthorization();
56 | $fees = array();
57 | $mandateReference = 'DE1234TEST';
58 |
59 | $this->_transaction->setAmount($amount)
60 | ->setOriginAmount($originAmount)
61 | ->setStatus($status)
62 | ->setDescription($description)
63 | ->setLivemode($livemode)
64 | ->setRefunds($refunds)
65 | ->setCurrency($currency)
66 | ->setResponseCode($responseCode)
67 | ->setShortId($shortId)
68 | ->setInvoices($invoices)
69 | ->setPayment($payment)
70 | ->setClient($client)
71 | ->setPreauthorization($preAuth)
72 | ->setFees($fees)
73 | ->setMandateReference($mandateReference);
74 |
75 | $this->assertEquals($this->_transaction->getAmount(), $amount);
76 | $this->assertEquals($this->_transaction->getOriginAmount(), $originAmount);
77 | $this->assertEquals($this->_transaction->getStatus(), $status);
78 | $this->assertEquals($this->_transaction->getDescription(), $description);
79 | $this->assertEquals($this->_transaction->getLivemode(), $livemode);
80 | $this->assertEquals($this->_transaction->getRefunds(), $refunds);
81 | $this->assertEquals($this->_transaction->getCurrency(), $currency);
82 | $this->assertEquals($this->_transaction->getResponseCode(), $responseCode);
83 | $this->assertEquals($this->_transaction->getShortId(), $shortId);
84 | $this->assertEquals($this->_transaction->getInvoices(), $invoices);
85 | $this->assertEquals($this->_transaction->getPayment(), $payment);
86 | $this->assertEquals($this->_transaction->getClient(), $client);
87 | $this->assertEquals($this->_transaction->getPreauthorization(), $preAuth);
88 | $this->assertEquals($this->_transaction->getFees(), $fees);
89 | $this->assertEquals($this->_transaction->getMandateReference(), $mandateReference);
90 | }
91 |
92 | }
--------------------------------------------------------------------------------
/tests/Unit/Paymill/Models/Response/WebhookTest.php:
--------------------------------------------------------------------------------
1 | _webhook = new Response\Webhook();
25 | }
26 |
27 | /**
28 | * Cleans up the environment after running a test.
29 | */
30 | protected function tearDown()
31 | {
32 | $this->_webhook = null;
33 | parent::tearDown();
34 | }
35 |
36 | //Testmethods
37 | /**
38 | * Tests the getters and setters of the model
39 | * @test
40 | */
41 | public function setGetTest()
42 | {
43 | $url = "www.test.ing";
44 | $email = "test@test.ing";
45 | $livemode = false;
46 | $eventTypes = array(
47 | "transaction.succeeded",
48 | "transaction.failed"
49 | );
50 |
51 |
52 | $this->_webhook->setUrl($url)
53 | ->setEmail($email)
54 | ->setLivemode($livemode)
55 | ->setEventTypes($eventTypes);
56 |
57 | $this->assertEquals($this->_webhook->getUrl(), $url);
58 | $this->assertEquals($this->_webhook->getEmail(), $email);
59 | $this->assertEquals($this->_webhook->getLivemode(), $livemode);
60 | $this->assertEquals($this->_webhook->getEventTypes(), $eventTypes);
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ./Integration
5 |
6 |
7 | ./Unit
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------