Ejemplo n.º 1
0
 public function orderCreate(KCConnector $connector, $order_data)
 {
     try {
         $checkout = new KCOrder($connector);
         $checkout->create($order_data);
         return $checkout->fetch();
     } catch (\Exception $e) {
         $this->log($e->getMessage(), 1);
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Make sure that the request sent is correct and that the location is updated.
  *
  * @return void
  */
 public function testCreate()
 {
     $this->mock->addResponse(new Response(201, ['Location' => 'http://somewhere/a-path']));
     $order = new Order($this->connector);
     $location = $order->create(['data' => 'goes here'])->getLocation();
     $this->assertEquals('http://somewhere/a-path', $location);
     $request = $this->history->getLastRequest();
     $this->assertEquals('POST', $request->getMethod());
     $this->assertEquals('/checkout/v3/orders', $request->getPath());
     $this->assertEquals('application/json', $request->getHeader('Content-Type'));
     $this->assertEquals('{"data":"goes here"}', strval($request->getBody()));
     $this->assertAuthorization($request);
 }
Ejemplo n.º 3
0
 /**
  * Make sure a missing location header in the response results in an exception.
  *
  * @return void
  */
 public function testCreateNoLocation()
 {
     $this->connector->expects($this->once())->method('createRequest')->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('201'));
     $this->response->expects($this->once())->method('hasHeader')->with('Location')->will($this->returnValue(false));
     $order = new Order($this->connector);
     $this->setExpectedException('RuntimeException', 'Response is missing a Location header');
     $order->create(['data' => 'goes here']);
 }