public function testPurchaseFailure()
 {
     $this->setMockHttpResponse('AIMPurchaseFailure.txt');
     $response = $this->gateway->purchase($this->purchaseOptions)->send();
     $this->assertFalse($response->isSuccessful());
     $this->assertSame('0', $response->getTransactionReference());
     $this->assertSame('A valid amount is required.', $response->getMessage());
 }
示例#2
0
 public function testPurchaseFailure()
 {
     $this->setMockHttpResponse('AIMPurchaseFailure.txt');
     $response = $this->gateway->purchase($this->purchaseOptions)->send();
     $this->assertFalse($response->isSuccessful());
     $expiry = $this->getExpiry($this->purchaseOptions['card']);
     $this->assertSame('{"approvalCode":"","transId":"0","card":{"number":"1111","expiry":"' . $expiry . '"}}', $response->getTransactionReference());
     $this->assertSame('A valid amount is required.', $response->getMessage());
 }
 public function testPurchaseAndVoid()
 {
     $request = $this->gateway->purchase(array('amount' => '10.01', 'card' => $this->getValidCard()));
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Purchase should succeed');
     $transactionRef = $response->getTransactionReference();
     $request = $this->gateway->void(array('transactionReference' => $transactionRef));
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Void should succeed');
 }
 public function testPurchaseRefundAutoVoid()
 {
     // Purchase
     $request = $this->gateway->purchase(array('amount' => 10.01, 'card' => $this->getValidCard()));
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Purchase should succeed');
     $transactionRef = $response->getTransactionReference();
     // Refund (should fail)
     $request = $this->gateway->refund(array('transactionReference' => $transactionRef, 'amount' => 10.01));
     $response = $request->send();
     $this->assertFalse($response->isSuccessful(), 'Refund should fail since the transaction has not been settled');
     // Refund with auto-void
     $request = $this->gateway->refund(array('transactionReference' => $transactionRef, 'amount' => 10.01, 'voidIfRefundFails' => true));
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Automatic void should succeed');
 }