Skip to content

Commit

Permalink
Merge pull request #1 from thephpleague/master
Browse files Browse the repository at this point in the history
update from source
  • Loading branch information
alberto1el authored Dec 30, 2018
2 parents 229bdb2 + c109d81 commit b8bb904
Show file tree
Hide file tree
Showing 47 changed files with 1,383 additions and 108 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CiviCRM editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
29 changes: 21 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1
- 7.2

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

## Cache composer
cache:
directories:
- $HOME/.composer/cache

env:
global:
- setup=basic

matrix:
allow_failures:
- php: hhvm
include:
- php: 5.6
env: setup=lowest

before_script:
- composer install -n --dev --prefer-source
install:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi

script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ processing library for PHP 5.3+. This package implements Authorize.Net support f

## Installation

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
to your `composer.json` file:

```json
{
"require": {
"omnipay/authorizenet": "~2.0"
}
}
```

And run composer to update your dependencies:
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply require `league/omnipay` and `omnipay/authorizenet` with Composer:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
```
composer require league/omnipay omnipay/authorizenet:"3.x@dev"
```

## Basic Usage

Expand Down
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@
"psr-4": { "Omnipay\\AuthorizeNet\\" : "src/" }
},
"require": {
"omnipay/common": "~2.2"
"omnipay/common": "^3"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "^3",
"squizlabs/php_codesniffer": "^3",
"phpro/grumphp": "^0.14"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 src/",
"fix-style": "phpcbf -p --standard=PSR2 src/"
},
"prefer-stable": true
}
15 changes: 15 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
git_dir: .
bin_dir: vendor/bin
tasks:
phpunit:
config_file: ~
testsuite: ~
group: []
always_execute: false
phpcs:
standard: PSR2
warning_severity: ~
ignore_patterns:
- tests/
triggered_by: [php]
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
</listeners>
<filter>
<whitelist>
<directory>./src</directory>
Expand Down
76 changes: 76 additions & 0 deletions src/AIMGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use Omnipay\AuthorizeNet\Message\AIMAuthorizeRequest;
use Omnipay\AuthorizeNet\Message\AIMCaptureRequest;
use Omnipay\AuthorizeNet\Message\AIMPaymentPlanQueryResponse;
use Omnipay\AuthorizeNet\Message\AIMPurchaseRequest;
use Omnipay\AuthorizeNet\Message\QueryRequest;
use Omnipay\AuthorizeNet\Message\AIMRefundRequest;
use Omnipay\AuthorizeNet\Message\AIMVoidRequest;
use Omnipay\Common\AbstractGateway;
Expand All @@ -26,6 +28,7 @@ public function getDefaultParameters()
'transactionKey' => '',
'testMode' => false,
'developerMode' => false,
'hashSecret' => '',
'liveEndpoint' => 'https://api2.authorize.net/xml/v1/request.api',
'developerEndpoint' => 'https://apitest.authorize.net/xml/v1/request.api',
);
Expand Down Expand Up @@ -61,6 +64,16 @@ public function setDeveloperMode($value)
return $this->setParameter('developerMode', $value);
}

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

public function getHashSecret()
{
return $this->getParameter('hashSecret');
}

public function setEndpoints($endpoints)
{
$this->setParameter('liveEndpoint', $endpoints['live']);
Expand Down Expand Up @@ -115,6 +128,15 @@ public function capture(array $parameters = array())
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMCaptureRequest', $parameters);
}

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

/**
* @param array $parameters
* @return AIMPurchaseRequest
Expand All @@ -141,4 +163,58 @@ public function refund(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMRefundRequest', $parameters);
}

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

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

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

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

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

/**
* @param array $parameters
* @return QueryDetailResponse
*/
public function queryDetail(array $parameters = array())
{
return $this->createRequest('\Omnipay\AuthorizeNet\Message\QueryDetailRequest', $parameters);
}
}
34 changes: 32 additions & 2 deletions src/Message/AIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function getHashSecret()
{
return $this->getParameter('hashSecret');
}

public function setHashSecret($value)
{
return $this->setParameter('hashSecret', $value);
Expand Down Expand Up @@ -100,6 +101,26 @@ public function getEndpoint()
return $this->getDeveloperMode() ? $this->getDeveloperEndpoint() : $this->getLiveEndpoint();
}

public function getSolutionId()
{
return $this->getParameter('solutionId');
}

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

public function getAuthCode()
{
return $this->getParameter('authCode');
}

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

/**
* @return TransactionReference
*/
Expand Down Expand Up @@ -203,9 +224,9 @@ public function sendData($data)
$headers = array('Content-Type' => 'text/xml; charset=utf-8');

$data = $data->saveXml();
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);

return $this->response = new AIMResponse($this, $httpResponse->getBody());
return $this->response = new AIMResponse($this, $httpResponse->getBody()->getContents());
}

/**
Expand Down Expand Up @@ -249,6 +270,15 @@ protected function addTransactionType(\SimpleXMLElement $data)
$data->transactionRequest->transactionType = $this->action;
}

protected function addSolutionId(\SimpleXMLElement $data)
{
$solutionId = $this->getSolutionId();

if (!empty($solutionId)) {
$data->transactionRequest->solution->id = $solutionId;
}
}

/**
* Adds billing data to a partially filled request data object.
*
Expand Down
5 changes: 4 additions & 1 deletion src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getData()
$data = $this->getBaseData();
$data->transactionRequest->amount = $this->getAmount();
$this->addPayment($data);
$this->addSolutionId($data);
$this->addBillingData($data);
$this->addCustomerIP($data);
$this->addTransactionSettings($data);
Expand All @@ -41,7 +42,9 @@ protected function addPayment(\SimpleXMLElement $data)
$card->validate();
$data->transactionRequest->payment->creditCard->cardNumber = $card->getNumber();
$data->transactionRequest->payment->creditCard->expirationDate = $card->getExpiryDate('my');
$data->transactionRequest->payment->creditCard->cardCode = $card->getCvv();
if (!empty($card->getCvv())) {
$data->transactionRequest->payment->creditCard->cardCode = $card->getCvv();
}
}

protected function addCustomerIP(\SimpleXMLElement $data)
Expand Down
28 changes: 28 additions & 0 deletions src/Message/AIMCaptureOnlyRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Common\CreditCard;

/**
* Authorize.Net AIM Capture Only Request
*/
class AIMCaptureOnlyRequest extends AIMAuthorizeRequest
{
protected $action = 'captureOnlyTransaction';

public function getData()
{
$this->validate('amount');
$data = $this->getBaseData();
$data->transactionRequest->amount = $this->getAmount();
$this->addPayment($data);
$data->transactionRequest->authCode = $this->getAuthCode();
$this->addSolutionId($data);
$this->addBillingData($data);
$this->addCustomerIP($data);
$this->addTransactionSettings($data);

return $data;
}
}
Loading

0 comments on commit b8bb904

Please sign in to comment.