1 <?php
2 /**
3 * Copyright 2015 Klarna AB
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * File containing the Klarna_Checkout_RecurringStatus class
18 *
19 * PHP version 5.3
20 *
21 * @category Payment
22 * @package Klarna_Checkout
23 * @author Klarna <support@klarna.com>
24 * @copyright 2015 Klarna AB
25 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0
26 * @link http://developers.klarna.com/
27 */
28
29 /**
30 * Implementation of the recurring order resource
31 *
32 * @category Payment
33 * @package Klarna_Checkout
34 * @author Matthias Feist <matthias.feist@klarna.com>
35 * @copyright 2015 Klarna AB
36 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0
37 * @link http://developers.klarna.com/
38 */
39 class Klarna_Checkout_RecurringStatus extends Klarna_Checkout_Resource implements
40 Klarna_Checkout_ResourceFetchableInterface
41 {
42 /**
43 * Path that is used to create resources
44 *
45 * @var string
46 */
47 protected $relativePath = '/checkout/recurring/%s';
48
49 /**
50 * Content Type to use
51 *
52 * @var string
53 */
54 protected $contentType
55 = "application/vnd.klarna.checkout.recurring-status-v1+json";
56
57 /**
58 * Create a new recurring status object
59 *
60 * @param Klarna_Checkout_ConnectorInterface $connector connector to use
61 * @param string $recurringToken recurring token
62 */
63 public function __construct(
64 Klarna_Checkout_ConnectorInterface $connector,
65 $recurringToken
66 ) {
67 parent::__construct($connector);
68
69 $uri = $this->connector->getDomain() . sprintf(
70 $this->relativePath,
71 $recurringToken
72 );
73
74 $this->setLocation($uri);
75 }
76
77 /**
78 * Fetch order data
79 *
80 * @return void
81 */
82 public function fetch()
83 {
84 $options = array(
85 'url' => $this->location
86 );
87 $this->connector->apply('GET', $this, $options);
88 }
89 }
90