function testFindWithWorkflowError() { $request = $this->schemaRequest('reconcile.xml'); $response = $this->schemaResponse('WpfPayment_error_400.xml'); $this->curl->shouldReceive('xmlPost')->with('https://testpayment.hypercharge.net/payment/reconcile', $request)->andReturn($response); $payment = Payment::find('61c06cf0a03d01307dde542696cde09d'); $this->assertIsA($payment, 'Hypercharge\\Payment'); $this->assertTrue($payment->isFatalError()); $error = $payment->error; $this->assertIsA($error, 'Hypercharge\\Errors\\WorkflowError'); $this->assertEqual($error->status_code, 400); $this->assertEqual($error->technical_message, 'payment not found.'); $this->assertEqual($error->message, 'Something went wrong, please contact support!'); }
function testMobileFindWithWrongId() { $data = $this->fixture('mobile_payment_request_simple.json'); $this->injectRedirectUrls($data); $payment = Payment::mobile($data); $this->assertIsA($payment, 'Hypercharge\\Payment'); $this->assertTrue($payment->isNew()); $this->assertPattern('/^[0-9a-f]{32}$/', $payment->unique_id); $response = Payment::find('000111222333444555666777888999ab'); // wrong ID $this->assertIsA($response, 'Hypercharge\\Payment'); $this->assertTrue($response->isFatalError()); $error = $response->error; // check the fixture fields correspond to gateway response $fixture = $this->parseXml($this->schemaResponse('WpfPayment_error_400.xml')); $this->assertIsA($error, 'Hypercharge\\Errors\\WorkflowError'); $this->assertEqual($error->status_code, 400); $this->assertEqual($error->status_code, $fixture['payment']['code']); $this->assertEqual($error->message, $fixture['payment']['message']); $this->assertEqual($error->technical_message, $fixture['payment']['technical_message']); }