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'); }
public function testRefundFailure() { $this->setMockHttpResponse('AIMRefundFailure.txt'); $response = $this->gateway->refund($this->refundOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertSame('0', $response->getTransactionReference()); $this->assertSame('The referenced transaction does not meet the criteria for issuing a credit.', $response->getMessage()); }
public function testRefundFailure() { $this->setMockHttpResponse('AIMRefundFailure.txt'); $response = $this->gateway->refund($this->refundOptions)->send(); $this->assertFalse($response->isSuccessful()); $expiry = $this->getExpiry($this->refundOptions['card']); $this->assertSame('{"approvalCode":"","transId":"0","card":{"number":"1111","expiry":"' . $expiry . '"}}', $response->getTransactionReference()); $this->assertSame('The referenced transaction does not meet the criteria for issuing a credit.', $response->getMessage()); }