public function orderUpdate(KCConnector $connector, $order_id, $order_data)
 {
     try {
         $checkout = new KCOrder($connector, $order_id);
         $checkout->update($order_data);
         return $checkout->fetch();
     } catch (\Exception $e) {
         $this->log($e->getMessage(), 1);
         return false;
     }
 }
Example #2
0
    /**
     * Make sure that the request sent and retrieved data is correct.
     *
     * @return void
     */
    public function testFetch()
    {
        $json = <<<JSON
{
    "order_id": "0002",
    "updated": "from json"
}
JSON;
        $this->mock->addResponse(new Response(200, ['Content-Type' => 'application/json'], Stream::factory($json)));
        $order = new Order($this->connector, '0002');
        $order['updated'] = 'not from json';
        $order->fetch();
        $this->assertEquals('from json', $order['updated']);
        $this->assertEquals('0002', $order->getId());
        $request = $this->history->getLastRequest();
        $this->assertEquals('GET', $request->getMethod());
        $this->assertEquals('/checkout/v3/orders/0002', $request->getPath());
        $this->assertAuthorization($request);
    }
Example #3
0
 /**
  * Make sure a non-JSON response results in an exception.
  *
  * @return void
  */
 public function testFetchNotJson()
 {
     $this->connector->expects($this->once())->method('createRequest')->with('/checkout/v3/orders/12345', 'GET', [])->will($this->returnValue($this->request));
     $this->connector->expects($this->once())->method('send')->with($this->request)->will($this->returnValue($this->response));
     $this->response->expects($this->once())->method('getStatusCode')->will($this->returnValue('200'));
     $this->response->expects($this->once())->method('hasHeader')->with('Content-Type')->will($this->returnValue(true));
     $this->response->expects($this->once())->method('getHeader')->with('Content-Type')->will($this->returnValue('text/plain'));
     $order = new Order($this->connector, '12345');
     $order['data'] = 'is overwritten';
     $this->setExpectedException('RuntimeException', 'Unexpected Content-Type header received: text/plain');
     $order->fetch();
 }