/** * @expectedException SZ\EZCash\Exception\CrypterException */ public function testInvalidCryptingOperation() { $public_key = m::mock('SZ\\EZCash\\Key\\PublicKey', array(__DIR__ . '/shared/public_key.key'))->shouldReceive('getFormattedKey')->times(1)->andReturn('invalid_key')->getMock(); $c = new Crypter(); $c->setKey($public_key); $to_encrypt = m::mock('SZ\\EZCash\\Cryptable')->shouldReceive('getCryptableData')->andReturn('test')->getMock(); $c->process($to_encrypt); }
/** * Get receipt object from an encrypted response * @param string $response * @return Receipt */ public function getReceipt($response) { $res = new Response($response); $c = new Crypter(); $c->setKey($this->private_key); $data = $c->process($res); $receipt = new Receipt($data); $receipt->validate(); return $receipt; }
public function testSample() { $receipt = 'xbWNp6KqkCcTC81uvniHfWUt9C3+LspvPTTCajzkSlPXod4hYDDOOsXF/Dq/hT3RWRgQJ6hA1DcRqAvYZ/Xm8fgqJGhtlPmv/OSDcfo4H+Yn63cLYAX2IJ5bfNaPDoEppS6atohYoZ3RPoxwLa8ESMy5nj3rboxEjBEIk08UP18='; $to_decrypt = m::mock('SZ\\EZCash\\Cryptable')->shouldReceive('getCryptableData')->andReturn($receipt)->getMock(); $c = new E\Crypter(); $c->setKey($this->private_key); $receipt_data = $c->process($to_decrypt); $receipt = new Receipt($receipt_data); $expected = array('transaction_id' => 'TX_1403351950', 'status_code' => '14', 'status_description' => 'Insufficient balance in your eZ Cash account.', 'transaction_amount' => '20.00', 'merchant_code' => 'TESTMERCHANT', 'wallet_reference_id' => NULL); $this->assertEquals($expected, $receipt->toArray()); }