public function omRefund(KCConnector $connector, $order_id, $data) { try { $order = new KCOrder($connector, $order_id); return $order->refund($data); } catch (\Exception $e) { $this->log($e->getMessage()); return false; } }
/** * Make sure that the request sent is correct when performing a refund. * * @return void */ public function testRefund() { $this->mock->addResponse(new Response(204)); $order = new Order($this->connector, '0002'); $order->refund(['data' => 'sent in']); $request = $this->history->getLastRequest(); $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/ordermanagement/v1/orders/0002/refunds', $request->getPath()); $this->assertEquals('application/json', $request->getHeader('Content-Type')); $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); $this->assertAuthorization($request); }
/** * Make sure an unknown status code response results in an exception. * * @return void */ public function testRefundInvalidStatusCode() { $data = ['data' => 'goes here']; $this->connector->expects($this->once())->method('createRequest')->with('/ordermanagement/v1/orders/12345/refunds', 'POST', ['json' => $data])->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')); $order = new Order($this->connector, '12345'); $this->setExpectedException('RuntimeException', 'Unexpected response status code: 200'); $order->refund($data); }