function testCancelNoPaymentDataResponse() { $unique_id = '4b356b29d49bca88a7e36666db1cc839'; // see payment_cancel_request.xml $requestXml = $this->fixture('payment_cancel_request.xml'); $responseXml = $this->fixture('no_payment_data_supplied_response.xml'); $this->curl->shouldReceive('xmlPost')->with('https://testpayment.hypercharge.net/payment/cancel', $requestXml)->andReturn($responseXml); $payment = Payment::cancel($unique_id); $this->assertIsA($payment, 'Hypercharge\\Payment'); $this->assertNull($payment->type); $this->assertTrue($payment->isError()); $this->assertNull($payment->unique_id); $error = $payment->error; $this->assertIsA($error, 'Hypercharge\\Errors\\InputDataMissingError'); $this->assertEqual($error->status_code, 320); $this->assertEqual($error->message, 'Please check input data for errors!'); $this->assertEqual($error->technical_message, 'No payment data supplied'); }
function testCancelWithWrongId() { $response = Payment::cancel('2dba69127788f34b5fde7e09128b74ed'); // hex 32 $this->assertIsA($response, 'Hypercharge\\Payment'); $this->assertTrue($response->isError()); $this->assertNull($response->unique_id); $this->assertNull(@$response->amount); $this->assertNull(@$response->currency); $this->assertTrue($response->isFatalError()); $error = $response->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!'); }