private function send(Checkout $checkout)
 {
     $request = new Request();
     $request->getHeaders()->addHeaders(array('Content-Type: application/xml; charset=ISO-8859-1'));
     $request->setUri($this->options->getWsUrl());
     $request->setMethod(Request::METHOD_POST);
     $request->setContent($checkout->parseXML());
     $client = new Client();
     $response = $client->dispatch($request);
     if ($response->getBody() == 'Unauthorized') {
         throw new \Exception('Unauthorized access to PagSeguro');
     }
     $xml = '';
     try {
         $xml = simplexml_load_string($response->getBody());
     } catch (\Exception $e) {
         throw new \Exception('Error on parse reponse xml. ' . $response->getBody(), 500, $e);
     }
     if ($xml->code) {
         return $xml->code;
     }
     throw new \Exception('An error has occurred: ' . $response->getBody());
 }
 public function testIntegrated()
 {
     $checkout = new Checkout();
     $checkout->addItem(new Item('001', 'Plano 1', 1, 12.9));
     $checkout->addItem(new Item('002', 'Plano 2', 1, 99.90000000000001));
     $sender = new Sender('*****@*****.**', 'Adelar Tiemann Junior');
     $sender->setBornDate(new \DateTime('1990-07-05'));
     $checkout->setSender($sender);
     $shipping = new Shipping(1, 12.9);
     $shipping->setAddress('SC', 'Joinville', 12345678, 'Anita Garilbaldi', 'AAAAAAA', 123, 'casa');
     $checkout->setShipping($shipping);
     $module = new ModuleOptions();
     $module->setIsSendBox(true);
     $module->setEmail('*****@*****.**');
     $module->setToken('é para dar erro');
     $request = new PagSeguroRequest($module);
     $this->setExpectedException('\\Exception');
     $request->getResponse($checkout);
 }