Exemplo n.º 1
0
 public function testRefundFailure()
 {
     $this->setMockHttpResponse('CIMRefundFailure.txt');
     $response = $this->gateway->refund($this->refundOptions)->send();
     $this->assertFalse($response->isSuccessful());
     $this->assertNull($response->getTransactionReference());
     $this->assertSame('The referenced transaction does not meet the criteria for issuing a credit.', $response->getMessage());
 }
Exemplo n.º 2
0
 public function testShouldVoidTransactionIfTryingToRefundAnUnsettledTransaction()
 {
     $this->setMockHttpResponse(array('AIMRefundFailure.txt', 'AIMVoidSuccess.txt'));
     $this->refundOptions['voidIfRefundFails'] = true;
     $response = $this->gateway->refund($this->refundOptions)->send();
     $this->assertTrue($response->isSuccessful());
     $this->assertNotNull($response->getTransactionReference());
     $this->assertEquals('This transaction has been approved.', $response->getMessage());
 }
 public function testPurchaseRefundAutoVoid()
 {
     $cardRef = $this->createCard();
     // Purchase
     $params = array('cardReference' => $cardRef, 'amount' => 110.0);
     $request = $this->gateway->purchase($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Purchase transaction should get created');
     $transactionReference = $response->getTransactionReference();
     $this->assertNotNull($transactionReference, 'Transaction reference should exist');
     // Refund (should fail)
     $request = $this->gateway->refund(array('amount' => 110.0, 'transactionReference' => $transactionReference));
     $request->setDeveloperMode(true);
     $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('amount' => 110.0, 'transactionReference' => $transactionReference, 'voidIfRefundFails' => true));
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Refund should succeed as a void transaction');
     $this->assertNotNull($response->getTransactionReference(), 'Transaction reference should exist');
 }
 public function testIntegration()
 {
     // Create card
     $rand = rand(100000, 999999);
     $params = array('card' => $this->getValidCard(), 'name' => 'Kaywinnet Lee Frye', 'email' => "kaylee{$rand}@serenity.com");
     $request = $this->gateway->createCard($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Profile should get created');
     $this->assertNotNull($response->getCardReference(), 'Card reference should be returned');
     $cardRef = $response->getCardReference();
     // Try different creating card for same user
     $params = array('card' => $this->getValidCard(), 'name' => 'Kaywinnet Lee Frye', 'email' => "kaylee{$rand}@serenity.com");
     $params['card']['number'] = '4007000000027';
     $request = $this->gateway->createCard($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Should be a success as we create a payment profile');
     $this->assertNotNull($response->getCardReference(), 'Card reference should be returned');
     // Try creating same card for the same user without force card update flag.
     $params = array('card' => $this->getValidCard(), 'name' => 'Kaywinnet Lee Frye', 'email' => "kaylee{$rand}@serenity.com");
     $request = $this->gateway->createCard($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertFalse($response->isSuccessful(), 'Should not success as we tried creating duplicate profile');
     $this->assertNull($response->getCardReference(), 'Card reference should be returned');
     // Try creating same card for the same user again with force card update flag.
     $params = array('card' => $this->getValidCard(), 'name' => 'Kaywinnet Lee Frye', 'email' => "kaylee{$rand}@serenity.com", 'forceCardUpdate' => true);
     $request = $this->gateway->createCard($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Should succeed updating of the existing payment profile');
     $this->assertEquals($cardRef, $response->getCardReference(), 'Card reference should be same as with the one newly created');
     // Create Authorize only transaction
     $params = array('cardReference' => $cardRef, 'amount' => 100.0, 'description');
     $request = $this->gateway->authorize($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Authorize transaction should get created');
     $this->assertNotNull($response->getTransactionReference(), 'Transaction reference should exist');
     $transRef = $response->getTransactionReference();
     // Capture the authorised transaction
     $params = array('transactionReference' => $transRef, 'amount' => 100.0);
     $request = $this->gateway->capture($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Capture transaction should get created');
     $this->assertNotNull($response->getTransactionReference(), 'Transaction reference should exist');
     $captureTransRef = $response->getTransactionReference();
     // Make a purchase using the saved card. i.e auth and capture
     $params = array('cardReference' => $cardRef, 'amount' => 110.0);
     $request = $this->gateway->purchase($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     $this->assertTrue($response->isSuccessful(), 'Purchase transaction should get created');
     $this->assertNotNull($response->getTransactionReference(), 'Transaction reference should exist');
     $purchaseTransRef = $response->getTransactionReference();
     // Make a refund on the purchase transaction
     $params = array('transactionReference' => $purchaseTransRef, 'amount' => 110.0);
     $request = $this->gateway->refund($params);
     $request->setDeveloperMode(true);
     $response = $request->send();
     // todo: Fix refunds, and add unit tests using mocks
     //        $this->assertTrue($response->isSuccessful(), 'Refund transaction should get created');
     //        $this->assertNotNull($response->getTransactionReference(), 'Transaction reference should exist');
 }