Overview
  • Package
  • Class

Packages

  • Klarna
    • Checkout
  • Payment
    • Klarna
      • HTTP
      • Interfaces
      • Unit
        • Tests

Classes

  • Klarna_Checkout_HTTP_CURLFactory
  • Klarna_Checkout_HTTP_Transport
  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_RecurringOrder 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_RecurringOrder extends Klarna_Checkout_Resource implements
 40     Klarna_Checkout_ResourceCreateableInterface
 41 {
 42     /**
 43      * Path that is used to create resources
 44      *
 45      * @var string
 46      */
 47     protected $relativePath = '/checkout/recurring/%s/orders';
 48 
 49     /**
 50      * Content Type to use
 51      *
 52      * @var string
 53      */
 54     protected $contentType
 55         = "application/vnd.klarna.checkout.recurring-order-v1+json";
 56 
 57     /**
 58      * Accept header to use
 59      *
 60      * @var string
 61      */
 62     protected $accept
 63         = 'application/vnd.klarna.checkout.recurring-order-accepted-v1+json';
 64 
 65     /**
 66      * Create a new recurring order object
 67      *
 68      * @param Klarna_Checkout_ConnectorInterface $connector      connector to use
 69      * @param string                             $recurringToken recurring token
 70      */
 71     public function __construct(
 72         Klarna_Checkout_ConnectorInterface $connector,
 73         $recurringToken
 74     ) {
 75         parent::__construct($connector);
 76 
 77         $uri = $this->connector->getDomain() . sprintf(
 78             $this->relativePath,
 79             $recurringToken
 80         );
 81 
 82         $this->setLocation($uri);
 83     }
 84 
 85 
 86     /**
 87      * Create a new order
 88      *
 89      * @param array $data data to initialise order resource with
 90      *
 91      * @return void
 92      */
 93     public function create(array $data)
 94     {
 95         $options = array(
 96             'url' => $this->location,
 97             'data' => $data
 98         );
 99 
100         $this->connector->apply('POST', $this, $options);
101     }
102 }
103 
API documentation generated by ApiGen