Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the XML API for AIM gateway #6

Closed
wants to merge 72 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d584200
Completely separated AIM and SIM classes. Updated AIM to use the new …
anush Aug 2, 2014
7c7578b
AIM request classes construct XML requests
anush Aug 2, 2014
f055372
PSR-2 formatting
anush Aug 2, 2014
69fe39d
Removed missed dependencies between AIM and SIM
anush Aug 2, 2014
69eb1c4
Added functional tests
anush Aug 2, 2014
426bc3f
Update AuthorizeNet_AIM to support refunds
rushi Aug 13, 2014
47f47be
Add tests for success and failure responses in AIMGatewayTest
rushi Aug 13, 2014
9f078db
Remove support for description attribute. This is because description…
rushi Aug 13, 2014
e17f7a7
Decouple SIMGateway from AIMGateway
rushi Aug 13, 2014
00d0f8e
Code formatting
anush Aug 14, 2014
881d9d4
Code formatting
anush Aug 14, 2014
c121250
Do not validate credit card for Refund transactions because it is not…
rushi Aug 18, 2014
2e39772
Merge pull request #2 from rushi/master
rushi Aug 18, 2014
4426ff1
CC last 4 to string
rushi Aug 18, 2014
7c2b2c0
CC last 4 to string
rushi Aug 18, 2014
0f5f96d
Create card implemented with integration test for Authorize.net CIM
kotrakrishna Sep 16, 2014
d1b6501
Abstract out common method for CIM requests
kotrakrishna Sep 17, 2014
f7abefc
Implement all transactions in CIM Gateway
kotrakrishna Sep 17, 2014
9d43913
Add unit tests using mocks. CIM response also checks and parses Error…
kotrakrishna Sep 18, 2014
6ad83f6
Clean up logging used during development
kotrakrishna Sep 18, 2014
58e4de3
Use Developer mode rather than test mode for setting the dev context …
kotrakrishna Sep 18, 2014
de9ef97
Use customer shipping address id only if present while making a tran…
kotrakrishna Sep 18, 2014
87e594d
If create card fails due to duplicate profile error, then create a pa…
kotrakrishna Sep 19, 2014
b076d75
Unit test using mocks for get profile, update payment profile
kotrakrishna Sep 22, 2014
9967d32
Add forceCardUpdate parameter to createCard.
kotrakrishna Sep 23, 2014
d697e2f
Create card will always return customer profile as response. Card ref…
kotrakrishna Sep 23, 2014
c7022a5
Create card always returns response of a perticular payment profile
kotrakrishna Sep 23, 2014
d398f93
Response is always an array. Create card response is augmented with f…
kotrakrishna Sep 26, 2014
808e673
Add expiry month and expiry year to the CIM create card response.
kotrakrishna Sep 26, 2014
5084452
Merge pull request #1 from kotrakrishna/master
rushi Nov 13, 2014
5efb7c2
Cleanup code, fix failing unit tests
rushi Nov 13, 2014
c6b1e3f
Move dependencies into require-dev
rushi Nov 13, 2014
a95b5ca
Fix xml2array and issues that arise because of it.
rushi Nov 14, 2014
169edbd
Do not format the amount as it voids the XML schema.
rushi Nov 14, 2014
e9e0c44
Fix duplicate payment profile handling
rushi Nov 17, 2014
81343c3
Update unit tests
rushi Nov 17, 2014
36d7c3a
Remove dev dependencies that are no longer required
rushi Nov 19, 2014
a57d213
Merge pull request #4 from rushi/master
juzerali Nov 25, 2014
e1e590c
Fix PSR-2 issues
rushi Nov 27, 2014
e8e986e
Update README.md to include mention of AuthorizeNet_CIM
rushi Nov 27, 2014
6ca8e75
Add ability to specify custom 'billTo' information
rushi Jan 28, 2015
9a227cc
Change populateBillTo to defaultBillTo. Set flags at a gateway level
rushi Jan 28, 2015
d4ff08b
Merge pull request #5 from rushi/master
anush Jan 28, 2015
1287a3f
Merge remote-tracking branch 'origin/master'
anush Mar 22, 2015
8fb8087
PHP 5.3 compatible array style
anush Mar 22, 2015
cf540fa
PHP 5.3 compatible array style
anush Mar 22, 2015
16140f8
Merge branch 'master' of github.com:thephpleague/omnipay-authorizenet
anush Aug 20, 2015
70e6c9c
XOL-2533 Adding extraOptions payload to request XML
sachinsudheendra Aug 27, 2015
87a39f0
XOL-2533 Parameterizing x_duplicate_window value and using it across …
sachinsudheendra Aug 28, 2015
6bfdef7
XOL-2533 Using the value of the parameter passed in for x_duplicate_w…
sachinsudheendra Sep 10, 2015
9344b3e
Merge pull request #7 from sachinsudheendra/XOL-2533
rushi Sep 10, 2015
9af958e
Fix CodeSniffer issue. Line should be <= 120 chars
rushi Feb 23, 2016
131d7cf
Fix test that failed due to change in SIMGateway's parent
rushi Feb 23, 2016
44e7a06
SIMGateway should inherit AIMGateway
rushi Feb 23, 2016
84b2c3f
Make CVV optional
anush Feb 29, 2016
90329a3
Merge pull request #9 from rushi/fix_codesniffer
anush Feb 29, 2016
6f24297
Merge branch 'master' of github.com:xola/authorizenet into optional-cvv
anush Feb 29, 2016
a0de700
Fix codesniffer and namespace issues
rushi Mar 1, 2016
35fc3a7
Do not validate card if no cvv provided
anush Mar 1, 2016
68d4382
CS-137 Look for duplicate payment profiles even if you reach maximum …
rushi Mar 2, 2016
4d5c93a
CS-137 Use PHP 5.3 array() syntax so tests pass
rushi Mar 2, 2016
d1e7f10
CS-137 Add tests for verification of duplicate payment profile logic
rushi Mar 2, 2016
10442c6
CS-137 Set constants for the profile response codes
rushi Mar 2, 2016
d9d1156
Merge pull request #11 from rushi/CS-137
anush Mar 2, 2016
0d5b940
XOL-2788 Ability to void a transaction and auto-void if refund fails
rushi Mar 3, 2016
b6edd12
XOL-2788 Fix transactionReference bug
rushi Mar 3, 2016
599386e
XOL-2788 Fix array syntax for PHP 5.3 compatibility
rushi Mar 3, 2016
2b5ad5e
Merge branch 'master' of github.com:xola/authorizenet into optional-cvv
rushi Mar 3, 2016
adfd19b
Merge pull request #10 from anushr/optional-cvv
rushi Mar 3, 2016
f9f1397
XOL-2788 Update test name
rushi Mar 3, 2016
c7d9a71
XOL-2788 Address code review comment
rushi Mar 3, 2016
f4fc378
Merge pull request #12 from rushi/XOL-2788
anush Mar 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AIM request classes construct XML requests
  • Loading branch information
anush committed Aug 2, 2014
commit 7c7578bcbaa1c9b5905a2bd5c481df6debbb4ce5
4 changes: 2 additions & 2 deletions src/AIMGateway.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@
namespace Omnipay\AuthorizeNet;

use Omnipay\AuthorizeNet\Message\AIMAuthorizeRequest;
use Omnipay\AuthorizeNet\Message\AIMCaptureRequest;
use Omnipay\AuthorizeNet\Message\AIMPurchaseRequest;
use Omnipay\AuthorizeNet\Message\AIMVoidRequest;
use Omnipay\AuthorizeNet\Message\SIMCaptureRequest;
use Omnipay\Common\AbstractGateway;

/**
@@ -69,7 +69,7 @@ public function authorize(array $parameters = array())

/**
* @param array $parameters
* @return SIMCaptureRequest
* @return AIMCaptureRequest
*/
public function capture(array $parameters = array())
{
114 changes: 64 additions & 50 deletions src/Message/AIMAbstractRequest.php
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Common\CreditCard;
use Omnipay\Common\Exception\InvalidRequestException;
use Omnipay\Common\Message\AbstractRequest;

/**
@@ -12,6 +14,8 @@ abstract class AIMAbstractRequest extends AbstractRequest
protected $liveEndpoint = 'https://api.authorize.net/xml/v1/request.api';
protected $developerEndpoint = 'https://apitest.authorize.net/xml/v1/request.api';

protected $action = null;

public function getApiLoginId()
{
return $this->getParameter('apiLoginId');
@@ -52,66 +56,76 @@ public function setCustomerId($value)
return $this->setParameter('customerId', $value);
}

public function getHashSecret()
/**
* @return mixed|\SimpleXMLElement
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getData()
{
return $this->getParameter('hashSecret');
}
$data = new \SimpleXMLElement('<createTransactionRequest/>');
$data->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');

public function setHashSecret($value)
{
return $this->setParameter('hashSecret', $value);
}
// Credentials
$data->merchantAuthentication->name = $this->getApiLoginId();
$data->merchantAuthentication->transactionKey = $this->getTransactionKey();

protected function getBaseData()
{
$data = array();
$data['x_login'] = $this->getApiLoginId();
$data['x_tran_key'] = $this->getTransactionKey();
$data['x_type'] = $this->action;
$data['x_version'] = '3.1';
$data['x_delim_data'] = 'TRUE';
$data['x_delim_char'] = ',';
$data['x_encap_char'] = '|';
$data['x_relay_response'] = 'FALSE';
// User-assigned transaction ID
$txnId = $this->getTransactionId();
if (!empty($txnId)) $data->refId = $this->getTransactionId();

// Transaction type
if (!$this->action) throw new InvalidRequestException();
$data->transactionRequest->transactionType = $this->action;

// Test mode setting
$data->transactionRequest->transactionSettings->setting->settingName = 'testRequest';
$data->transactionRequest->transactionSettings->setting->settingValue = $this->getTestMode() ? 'true' : 'false';

return $data;
}

protected function getBillingData()
/**
* Adds billing data to a partially filled request data object.
*
* @param \SimpleXMLElement $data
* @return \SimpleXMLElement
*/
protected function addBillingData(\SimpleXMLElement $data)
{
$data = array();
$data['x_amount'] = $this->getAmount();
$data['x_invoice_num'] = $this->getTransactionId();
$data['x_description'] = $this->getDescription();
/** @var mixed $req */
$req = $data->transactionRequest;

// Amount of the purchase
$req->amount = $this->getAmount();

// Description of the purchase
$description = $this->getDescription();
if (!empty($description)) $req->lineItems->lineItem->description = $description;

// Merchant assigned customer ID
$customer = $this->getCustomerId();
if (!empty($customer)) $req->customer->id = $customer;

/** @var CreditCard $card */
if ($card = $this->getCard()) {
// customer billing details
$data['x_first_name'] = $card->getBillingFirstName();
$data['x_last_name'] = $card->getBillingLastName();
$data['x_company'] = $card->getBillingCompany();
$data['x_address'] = trim(
$card->getBillingAddress1() . " \n" .
$card->getBillingAddress2()
);
$data['x_city'] = $card->getBillingCity();
$data['x_state'] = $card->getBillingState();
$data['x_zip'] = $card->getBillingPostcode();
$data['x_country'] = $card->getBillingCountry();
$data['x_phone'] = $card->getBillingPhone();
$data['x_email'] = $card->getEmail();

// customer shipping details
$data['x_ship_to_first_name'] = $card->getShippingFirstName();
$data['x_ship_to_last_name'] = $card->getShippingLastName();
$data['x_ship_to_company'] = $card->getShippingCompany();
$data['x_ship_to_address'] = trim(
$card->getShippingAddress1() . " \n" .
$card->getShippingAddress2()
);
$data['x_ship_to_city'] = $card->getShippingCity();
$data['x_ship_to_state'] = $card->getShippingState();
$data['x_ship_to_zip'] = $card->getShippingPostcode();
$data['x_ship_to_country'] = $card->getShippingCountry();
// A card is present, so include billing and shipping details
$req->billTo->firstName = $card->getBillingFirstName();
$req->billTo->lastName = $card->getBillingLastName();
$req->billTo->company = $card->getBillingCompany();
$req->billTo->address = trim($card->getBillingAddress1() . " \n" . $card->getBillingAddress2());
$req->billTo->city = $card->getBillingCity();
$req->billTo->state = $card->getBillingState();
$req->billTo->zip = $card->getBillingPostcode();
$req->billTo->country = $card->getBillingCountry();

$req->shipTo->firstName = $card->getShippingLastName();
$req->shipTo->lastName = $card->getShippingLastName();
$req->shipTo->company = $card->getShippingCompany();
$req->shipTo->address = trim($card->getShippingAddress1() . " \n" . $card->getShippingAddress2());
$req->shipTo->city = $card->getShippingCity();
$req->shipTo->state = $card->getShippingState();
$req->shipTo->zip = $card->getShippingPostcode();
$req->shipTo->country = $card->getShippingCountry();
}

return $data;
26 changes: 14 additions & 12 deletions src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
@@ -2,29 +2,31 @@

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Common\CreditCard;

/**
* Authorize.Net AIM Authorize Request
*/
class AIMAuthorizeRequest extends AIMAbstractRequest
{
protected $action = 'AUTH_ONLY';
protected $action = 'authOnlyTransaction';

public function getData()
{
$this->validate('amount', 'card');
$this->getCard()->validate();

$data = $this->getBaseData();
$data['x_customer_ip'] = $this->getClientIp();
$data['x_card_num'] = $this->getCard()->getNumber();
$data['x_exp_date'] = $this->getCard()->getExpiryDate('my');
$data['x_card_code'] = $this->getCard()->getCvv();
$data['x_cust_id'] = $this->getCustomerId();
/** @var CreditCard $card */
$card = $this->getCard();
$card->validate();

$data = parent::getData();
$data->transactionRequest->customerIP = $this->getClientIp();
$data->transactionRequest->payment->creditCard->cardNumber = $card->getNumber();
$data->transactionRequest->payment->creditCard->expirationDate = $card->getExpiryDate('my');
$data->transactionRequest->payment->creditCard->cardCode = $card->getCvv();

if ($this->getTestMode()) {
$data['x_test_request'] = 'TRUE';
}
$this->addBillingData($data);

return array_merge($data, $this->getBillingData());
return $data;
}
}
8 changes: 4 additions & 4 deletions src/Message/AIMCaptureRequest.php
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@
*/
class AIMCaptureRequest extends AIMAbstractRequest
{
protected $action = 'PRIOR_AUTH_CAPTURE';
protected $action = 'priorAuthCaptureTransaction';

public function getData()
{
$this->validate('amount', 'transactionReference');

$data = $this->getBaseData();
$data['x_amount'] = $this->getAmount();
$data['x_trans_id'] = $this->getTransactionReference();
$data = parent::getData();
$data->transactionRequest->amount = $this->getAmount();
$data->transactionRequest->refTransId = $this->getTransactionReference();

return $data;
}
2 changes: 1 addition & 1 deletion src/Message/AIMPurchaseRequest.php
Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
*/
class AIMPurchaseRequest extends AIMAuthorizeRequest
{
protected $action = 'AUTH_CAPTURE';
protected $action = 'authCaptureTransaction';
}
6 changes: 3 additions & 3 deletions src/Message/AIMVoidRequest.php
Original file line number Diff line number Diff line change
@@ -7,14 +7,14 @@
*/
class AIMVoidRequest extends SIMAbstractRequest
{
protected $action = 'VOID';
protected $action = 'voidTransaction';

public function getData()
{
$this->validate('transactionReference');

$data = $this->getBaseData();
$data['x_trans_id'] = $this->getTransactionReference();
$data = parent::getData();
$data->transactionRequest->refTransId = $this->getTransactionReference();

return $data;
}
18 changes: 13 additions & 5 deletions tests/Message/AIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@

class AIMAuthorizeRequestTest extends TestCase
{
/** @var AIMAuthorizeRequest */
protected $request;

public function setUp()
{
$this->request = new AIMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
@@ -23,10 +26,13 @@ public function testGetData()
{
$data = $this->request->getData();

$this->assertSame('AUTH_ONLY', $data['x_type']);
$this->assertSame('10.0.0.1', $data['x_customer_ip']);
$this->assertSame('cust-id', $data['x_cust_id']);
$this->assertArrayNotHasKey('x_test_request', $data);
$this->assertEquals('authOnlyTransaction', $data->transactionRequest->transactionType);
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
$this->assertEquals('cust-id', $data->transactionRequest->customer->id);

$setting = $data->transactionRequest->transactionSettings->setting[0];
$this->assertEquals('testRequest', $setting->settingName);
$this->assertEquals('false', $setting->settingValue);
}

public function testGetDataTestMode()
@@ -35,6 +41,8 @@ public function testGetDataTestMode()

$data = $this->request->getData();

$this->assertSame('TRUE', $data['x_test_request']);
$setting = $data->transactionRequest->transactionSettings->setting[0];
$this->assertEquals('testRequest', $setting->settingName);
$this->assertEquals('true', $setting->settingValue);
}
}
13 changes: 8 additions & 5 deletions tests/Message/AIMPurchaseRequestTest.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

class AIMPurchaseRequestTest extends TestCase
{
/** @var AIMPurchaseRequest */
private $request;

public function setUp()
@@ -25,10 +26,12 @@ public function testGetData()
{
$data = $this->request->getData();

$this->assertSame('AUTH_CAPTURE', $data['x_type']);
$this->assertSame('10.0.0.1', $data['x_customer_ip']);
$this->assertSame('cust-id', $data['x_cust_id']);
$this->assertArrayNotHasKey('x_test_request', $data);
//<testRequest>1</testRequest>
$this->assertEquals('authCaptureTransaction', $data->transactionRequest->transactionType);
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
$this->assertEquals('cust-id', $data->transactionRequest->customer->id);

$setting = $data->transactionRequest->transactionSettings->setting[0];
$this->assertEquals('testRequest', $setting->settingName);
$this->assertEquals('false', $setting->settingValue);
}
}