Skip to content

Commit

Permalink
Merge pull request #3 from zmonteca/master
Browse files Browse the repository at this point in the history
Update Customer Record
  • Loading branch information
iddqdidkfa authored Jul 13, 2017
2 parents 5783c84 + f66c6f2 commit 1ce9be9
Show file tree
Hide file tree
Showing 34 changed files with 159 additions and 99 deletions.
10 changes: 9 additions & 1 deletion src/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function authorize(array $params = [])
$params
);
}

public function createCard(array $params = [])
{
return $this->createRequest(
Expand All @@ -37,6 +37,14 @@ public function createCard(array $params = [])
);
}

public function updateCard(array $params = [])
{
return $this->createRequest(
'\Omnipay\Paytrace\Message\\' . static::GATEWAY_TYPE . '\UpdateCardRequest',
$params
);
}

public function capture(array $params = [])
{
return $this->createRequest('\Omnipay\Paytrace\Message\\' . static::GATEWAY_TYPE . '\CaptureRequest', $params);
Expand Down
10 changes: 10 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function setInvoiceId($value)
return $this->setParameter('invoiceId', $value);
}

public function getCardReference()
{
return $this->getParameter('custid');
}

public function setCardReference($value)
{
return $this->setParameter('custid', $value);
}

/**
* @return \Omnipay\Common\CreditCard|\Omnipay\Paytrace\Check
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Message/Check/UpdateCardRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Omnipay\Paytrace\Message\Check;

class UpdateCardRequest extends CreateCardRequest
{
protected $type = 'UpdateCustomer';
}
7 changes: 7 additions & 0 deletions src/Message/CreditCard/UpdateCardRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace Omnipay\Paytrace\Message\CreditCard;

class UpdateCardRequest extends CreateCardRequest
{
protected $type = 'UpdateCustomer';
}
22 changes: 11 additions & 11 deletions tests/CheckGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function setUp()

public function testAuthorizeSuccess()
{
$this->setMockHttpResponse('Check_ResponseSuccess.txt');
$this->setMockHttpResponse('Check/ResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->authorize($this->options)->send();
$this->assertInstanceOf('\Omnipay\Paytrace\Message\Check\Response', $response);
Expand All @@ -43,8 +43,8 @@ public function testAuthorizeSuccess()

public function testAuthorizeFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('Check/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->authorize($this->options)->send();
$this->assertInstanceOf('\Omnipay\Paytrace\Message\Check\Response', $response);
Expand All @@ -55,7 +55,7 @@ public function testAuthorizeFailure()

public function testPurchaseSuccess()
{
$this->setMockHttpResponse('Check_ResponseSuccess.txt');
$this->setMockHttpResponse('Check/ResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->purchase($this->options)->send();
Expand All @@ -72,8 +72,8 @@ public function testPurchaseSuccess()

public function testPurchaseFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('Check/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->purchase($this->options)->send();
$this->assertInstanceOf('\Omnipay\Paytrace\Message\Check\Response', $response);
Expand All @@ -84,7 +84,7 @@ public function testPurchaseFailure()

public function testRefundSuccess()
{
$this->setMockHttpResponse('Check_RefundResponseSuccess.txt');
$this->setMockHttpResponse('Check/RefundResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->refund($this->options)->send();
Expand All @@ -101,7 +101,7 @@ public function testRefundSuccess()

public function testRefundTransactionReferenceSuccess()
{
$this->setMockHttpResponse('Check_RefundResponseSuccess.txt');
$this->setMockHttpResponse('Check/RefundResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$options = array_merge(array('transactionReference' => 89731989), $this->options);
Expand All @@ -120,7 +120,7 @@ public function testRefundTransactionReferenceSuccess()

public function testRefundFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('Check/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->refund($this->options)->send();
Expand All @@ -132,7 +132,7 @@ public function testRefundFailure()

public function testCreateCardSuccess()
{
$this->setMockHttpResponse('CreateCardResponseSuccess.txt');
$this->setMockHttpResponse('Check/CreateCardResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->createCard($this->options)->send();
Expand Down
42 changes: 33 additions & 9 deletions tests/CreditCardGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function setUp()

public function testAuthorizeSuccess()
{
$this->setMockHttpResponse('Credit_AuthorizeResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/AuthorizeResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->authorize($this->options)->send();
Expand All @@ -39,7 +39,7 @@ public function testAuthorizeSuccess()

public function testAuthorizeFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('CreditCard/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->authorize($this->options)->send();
Expand All @@ -51,7 +51,7 @@ public function testAuthorizeFailure()

public function testPurchaseSuccess()
{
$this->setMockHttpResponse('Credit_AuthorizeResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/AuthorizeResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->purchase($this->options)->send();
Expand All @@ -68,7 +68,7 @@ public function testPurchaseSuccess()

public function testPurchaseCreditReferenceSuccess()
{
$this->setMockHttpResponse('Credit_AuthorizeResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/AuthorizeResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$options = array_merge(array('cardReference' => 1234567890), $this->options);
Expand All @@ -86,7 +86,7 @@ public function testPurchaseCreditReferenceSuccess()

public function testPurchaseFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('CreditCard/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->purchase($this->options)->send();
Expand All @@ -98,7 +98,7 @@ public function testPurchaseFailure()

public function testRefundSuccess()
{
$this->setMockHttpResponse('Credit_RefundResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/RefundResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->refund($this->options)->send();
Expand All @@ -115,7 +115,7 @@ public function testRefundSuccess()

public function testRefundTransactionReferenceSuccess()
{
$this->setMockHttpResponse('Credit_RefundResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/RefundResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$options = array_merge(array('transactionReference' => 89731989), $this->options);
Expand All @@ -134,7 +134,7 @@ public function testRefundTransactionReferenceSuccess()

public function testRefundFailure()
{
$this->setMockHttpResponse('ResponseFailed.txt');
$this->setMockHttpResponse('CreditCard/ResponseFailed.txt');

$this->gateway->setPassword('111');
$response = $this->gateway->refund($this->options)->send();
Expand All @@ -146,7 +146,7 @@ public function testRefundFailure()

public function testCreateCardSuccess()
{
$this->setMockHttpResponse('CreateCardResponseSuccess.txt');
$this->setMockHttpResponse('CreditCard/CreateCardResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$response = $this->gateway->createCard($this->options)->send();
Expand All @@ -161,4 +161,28 @@ public function testCreateCardSuccess()
$response->getMessage()
);
}

public function testUpdateCardSuccess()
{
$customer_id = 14496097;
$this->setMockHttpResponse('CreditCard/UpdateCardResponseSuccess.txt');

$this->gateway->setPassword('demo123');
$request = $this->gateway->updateCard($this->options);
// set our paytrace customer id
$request->setCardReference($customer_id);

$response = $request->send();

$this->assertInstanceOf('\Omnipay\Paytrace\Message\CreditCard\CreateCardResponse', $response);
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertNull($response->getTransactionReference());
$this->assertSame('161', $response->getCode());
$this->assertSame('14496097', $response->getCardReference());
$this->assertSame(
'The customer profile for 14496097\/John Doe was successfully updated.',
$response->getMessage()
);
}
}
1 change: 1 addition & 0 deletions tests/Messages/Check/Mock/empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty
4 changes: 2 additions & 2 deletions tests/Messages/Check/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ResponseTest extends TestCase
{
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('ResponseSuccess.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/Check/ResponseSuccess.txt');
$response = new Response($this->getMockRequest(), $httpResponse->getBody());
$this->assertTrue($response->isSuccessful());
$this->assertSame('121', $response->getCode());
Expand All @@ -20,7 +20,7 @@ public function testSuccess()

public function testFail()
{
$httpResponse = $this->getMockHttpResponse('ResponseFailed.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/Check/ResponseFailed.txt');
$response = new Response($this->getMockRequest(), $httpResponse->getBody());
$this->assertFalse($response->isSuccessful());
$this->assertSame('998', $response->getCode());
Expand Down
2 changes: 1 addition & 1 deletion tests/Messages/CreditCard/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testGetData()
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '07',
'expiryYear' => '2020',
'expiryYear' => '2050',
'cvv' => '123',
'billingAddress1' => '123 Billing St',
'billingAddress2' => 'Billsville',
Expand Down
4 changes: 2 additions & 2 deletions tests/Messages/CreditCard/AuthorizeResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AuthorizeResponseTest extends TestCase
{
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('AuthorizeResponseSuccess.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/AuthorizeResponseSuccess.txt');
$response = new AuthorizeResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertTrue($response->isSuccessful());
$this->assertSame('104', $response->getCode());
Expand All @@ -20,7 +20,7 @@ public function testSuccess()

public function testFail()
{
$httpResponse = $this->getMockHttpResponse('AuthorizeResponseFailed.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/AuthorizeResponseFailed.txt');
$response = new AuthorizeResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertFalse($response->isSuccessful());
$this->assertSame('105', $response->getCode());
Expand Down
4 changes: 2 additions & 2 deletions tests/Messages/CreditCard/CaptureResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CaptureResponseTest extends TestCase
{
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('CaptureResponseSuccess.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/CaptureResponseSuccess.txt');
$response = new CaptureResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertTrue($response->isSuccessful());
$this->assertSame('114', $response->getCode());
Expand All @@ -20,7 +20,7 @@ public function testSuccess()

public function testFail()
{
$httpResponse = $this->getMockHttpResponse('ResponseFailed.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/ResponseFailed.txt');
$response = new CaptureResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertFalse($response->isSuccessful());
$this->assertSame('998', $response->getCode());
Expand Down
2 changes: 1 addition & 1 deletion tests/Messages/CreditCard/CreateCardRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testGetData()
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '07',
'expiryYear' => '2020',
'expiryYear' => '2050',
'cvv' => '123',
'billingAddress1' => '123 Billing St',
'billingAddress2' => 'Billsville',
Expand Down
4 changes: 2 additions & 2 deletions tests/Messages/CreditCard/CreateCardResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateCardResponseTest extends TestCase
{
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('CreateCardResponseSuccess.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/CreateCardResponseSuccess.txt');
$response = new CreateCardResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertTrue($response->isSuccessful());
$this->assertSame('160', $response->getCode());
Expand All @@ -20,7 +20,7 @@ public function testSuccess()

public function testFail()
{
$httpResponse = $this->getMockHttpResponse('ResponseFailed.txt');
$httpResponse = $this->getMockHttpResponse('../../../Mock/CreditCard/ResponseFailed.txt');
$response = new CreateCardResponse($this->getMockRequest(), $httpResponse->getBody());
$this->assertFalse($response->isSuccessful());
$this->assertSame('998', $response->getCode());
Expand Down
1 change: 1 addition & 0 deletions tests/Messages/CreditCard/Mock/empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty
2 changes: 1 addition & 1 deletion tests/Messages/CreditCard/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testGetData()
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '07',
'expiryYear' => '2020',
'expiryYear' => '2050',
'cvv' => '123',
'billingAddress1' => '123 Billing St',
'billingAddress2' => 'Billsville',
Expand Down
Loading

0 comments on commit 1ce9be9

Please sign in to comment.