Skip to content

Commit

Permalink
Merge pull request #34 from anushr/xml-api
Browse files Browse the repository at this point in the history
Migrate to XML API for AIM + CIM support
  • Loading branch information
judgej committed Apr 30, 2016
2 parents dde369f + e35e615 commit bd9523c
Show file tree
Hide file tree
Showing 84 changed files with 3,377 additions and 327 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
composer.phar
phpunit.xml
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ And run composer to update your dependencies:
The following gateways are provided by this package:

* AuthorizeNet_AIM
* AuthorizeNet_CIM
* AuthorizeNet_SIM
* AuthorizeNet_DPM

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"psr-4": { "Omnipay\\AuthorizeNet\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
"omnipay/common": "~2.2"
},
"require-dev": {
"omnipay/tests": "~2.0"
Expand Down
41 changes: 38 additions & 3 deletions src/AIMGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Omnipay\AuthorizeNet;

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

/**
Expand All @@ -21,8 +26,8 @@ public function getDefaultParameters()
'transactionKey' => '',
'testMode' => false,
'developerMode' => false,
'liveEndpoint' => 'https://secure2.authorize.net/gateway/transact.dll',
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll',
'liveEndpoint' => 'https://api.authorize.net/xml/v1/request.api',
'developerEndpoint' => 'https://apitest.authorize.net/xml/v1/request.api',
);
}

Expand Down Expand Up @@ -82,26 +87,56 @@ public function setDeveloperEndpoint($value)
return $this->setParameter('developerEndpoint', $value);
}

public function getDuplicateWindow()
{
return $this->getParameter('duplicateWindow');
}

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

/**
* @param array $parameters
* @return AIMAuthorizeRequest
*/
public function authorize(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMAuthorizeRequest', $parameters);
}

/**
* @param array $parameters
* @return AIMCaptureRequest
*/
public function capture(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CaptureRequest', $parameters);
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMCaptureRequest', $parameters);
}

/**
* @param array $parameters
* @return AIMPurchaseRequest
*/
public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMPurchaseRequest', $parameters);
}

/**
* @param array $parameters
* @return AIMVoidRequest
*/
public function void(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMVoidRequest', $parameters);
}

/**
* @param array $parameters
* @return AIMRefundRequest
*/
public function refund(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMRefundRequest', $parameters);
Expand Down
73 changes: 73 additions & 0 deletions src/CIMGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Omnipay\AuthorizeNet;

use Omnipay\AuthorizeNet\Message\CIMCreateCardRequest;

/**
* Authorize.Net CIM Class
*/
class CIMGateway extends AIMGateway
{
public function getName()
{
return 'Authorize.Net CIM';
}

public function setForceCardUpdate($forceCardUpdate)
{
return $this->setParameter('forceCardUpdate', $forceCardUpdate);
}

public function getForceCardUpdate()
{
return $this->getParameter('forceCardUpdate');
}

public function setDefaultBillTo($defaultBillTo)
{
return $this->setParameter('defaultBillTo', $defaultBillTo);
}

public function getDefaultBillTo()
{
return $this->getParameter('defaultBillTo');
}

/**
* Create a new debit or credit card
*
* @param array $parameters
*
* @return CIMCreateCardRequest
*/
public function createCard(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMCreateCardRequest', $parameters);
}

public function authorize(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMAuthorizeRequest', $parameters);
}

public function capture(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMCaptureRequest', $parameters);
}

public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMPurchaseRequest', $parameters);
}

public function refund(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMRefundRequest', $parameters);
}

public function void(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMVoidRequest', $parameters);
}
}
Loading

0 comments on commit bd9523c

Please sign in to comment.