Skip to content

Adds CustomerId to fields in Abstract request. #2

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm

env:
- SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.1"
- SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.1"
- SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.*"
- SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.*"
matrix:
allow_failures:
- php: hhvm

before_script:
- composer self-update
- composer --version
- composer require symfony/http-foundation:${SYMFONY_VERSION} --no-update
- composer require guzzle/http:${GUZZLE_VERSION} --no-update
- composer install -n --dev --prefer-source

script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

**Authorize.Net driver for the Omnipay PHP payment processing library**

[![Build Status](https://travis-ci.org/omnipay/authorizenet.png?branch=master)](https://travis-ci.org/omnipay/authorizenet)
[![Build Status](https://travis-ci.org/thephpleague/omnipay-authorizenet.png?branch=master)](https://travis-ci.org/thephpleague/omnipay-authorizenet)
[![Latest Stable Version](https://poser.pugx.org/omnipay/authorizenet/version.png)](https://packagist.org/packages/omnipay/authorizenet)
[![Total Downloads](https://poser.pugx.org/omnipay/authorizenet/d/total.png)](https://packagist.org/packages/omnipay/authorizenet)

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements Authorize.Net support for Omnipay.

## Installation
Expand Down Expand Up @@ -34,7 +34,7 @@ The following gateways are provided by this package:
* AuthorizeNet_AIM
* AuthorizeNet_SIM

For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

## Support
Expand All @@ -47,5 +47,5 @@ If you want to keep up to date with release anouncements, discuss ideas for the
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/omnipay/authorizenet/issues),
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-authorizenet/issues),
or better yet, fork the library and submit a pull request.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pay",
"payment"
],
"homepage": "https://github.com/omnipay/authorizenet",
"homepage": "https://github.com/thephpleague/omnipay-authorizenet",
"license": "MIT",
"authors": [
{
Expand All @@ -21,11 +21,11 @@
},
{
"name": "Omnipay Contributors",
"homepage": "https://github.com/omnipay/authorizenet/contributors"
"homepage": "https://github.com/thephpleague/omnipay-authorizenet/contributors"
}
],
"autoload": {
"psr-0": { "Omnipay\\AuthorizeNet\\" : "src/" }
"psr-4": { "Omnipay\\AuthorizeNet\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions src/Message/AIMPurchaseRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

/**
* Authorize.Net AIM Purchase Request
*/
class AIMPurchaseRequest extends AIMAuthorizeRequest
{
protected $action = 'AUTH_CAPTURE';
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,15 @@ public function getTransactionReference()
{
return $this->data[6];
}

public function getAccountNumber()
{
return $this->data[50];
}

public function getCardType()
{
return $this->data[51];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected function getBillingData()
$data['x_amount'] = $this->getAmount();
$data['x_invoice_num'] = $this->getTransactionId();
$data['x_description'] = $this->getDescription();
$data['x_cust_id'] = $this->getCustomerId();

if ($card = $this->getCard()) {
// customer billing details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RequestInterface;
use Omnipay\Common\Message\RedirectResponseInterface;

/**
* Authorize.Net SIM Authorize Response
*/
class SIMAuthorizeResponse extends AbstractResponse
class SIMAuthorizeResponse extends AbstractResponse implements RedirectResponseInterface
{
protected $redirectUrl;

Expand Down
29 changes: 0 additions & 29 deletions src/Omnipay/AuthorizeNet/Message/AIMPurchaseRequest.php

This file was deleted.

File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions tests/Message/AIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Tests\TestCase;

class AIMAuthorizeRequestTest extends TestCase
{
public function setUp()
{
$this->request = new AIMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'clientIp' => '10.0.0.1',
'amount' => '12.00',
'customerId' => 'cust-id',
'card' => $this->getValidCard(),
)
);
}

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);
}

public function testGetDataTestMode()
{
$this->request->setTestMode(true);

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

$this->assertSame('TRUE', $data['x_test_request']);
}
}
31 changes: 31 additions & 0 deletions tests/Message/AIMPurchaseRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Tests\TestCase;

class AIMPurchaseRequestTest extends TestCase
{
public function setUp()
{
$this->request = new AIMPurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'clientIp' => '10.0.0.1',
'amount' => '12.00',
'customerId' => 'cust-id',
'card' => $this->getValidCard(),
)
);
}

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);
}
}
66 changes: 66 additions & 0 deletions tests/Message/SIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Tests\TestCase;

class SIMAuthorizeRequestTest extends TestCase
{
public function setUp()
{
$this->request = new SIMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'clientIp' => '10.0.0.1',
'amount' => '12.00',
'returnUrl' => 'https://www.example.com/return',
)
);
}

public function testGetData()
{
$data = $this->request->getData();

$this->assertSame('AUTH_ONLY', $data['x_type']);
$this->assertSame('PAYMENT_FORM', $data['x_show_form']);
$this->assertArrayNotHasKey('x_test_request', $data);
}

public function testGetDataTestMode()
{
$this->request->setTestMode(true);

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

$this->assertSame('TRUE', $data['x_test_request']);
}

public function testGetHash()
{
$this->request->setApiLoginId('user');
$this->request->setTransactionKey('key');
$data = array(
'x_fp_sequence' => 'a',
'x_fp_timestamp' => 'b',
'x_amount' => 'c',
);

$expected = hash_hmac('md5', 'user^a^b^c^', 'key');

$this->assertSame($expected, $this->request->getHash($data));
}

public function testSend()
{
$response = $this->request->send();

$this->assertFalse($response->isSuccessful());
$this->assertTrue($response->isRedirect());
$this->assertNotEmpty($response->getRedirectUrl());
$this->assertSame('POST', $response->getRedirectMethod());

$redirectData = $response->getRedirectData();
$this->assertSame('https://www.example.com/return', $redirectData['x_relay_url']);
}
}
56 changes: 56 additions & 0 deletions tests/Message/SIMCompleteAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Tests\TestCase;

class SIMCompleteAuthorizeRequestTest extends TestCase
{
public function setUp()
{
$this->request = new SIMCompleteAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
* @expectedExceptionMessage Incorrect hash
*/
public function testGetDataInvalid()
{
$this->getHttpRequest()->request->replace(array('x_MD5_Hash' => 'invalid'));
$this->request->getData();
}

public function testGetHash()
{
$this->assertSame(md5(''), $this->request->getHash());

$this->request->setHashSecret('hashsec');
$this->request->setApiLoginId('apilogin');
$this->request->setTransactionId('trnid');
$this->request->setAmount('10.00');

$this->assertSame(md5('hashsecapilogintrnid10.00'), $this->request->getHash());
}

public function testSend()
{
$this->getHttpRequest()->request->replace(
array(
'x_response_code' => '1',
'x_trans_id' => '12345',
'x_MD5_Hash' => md5('shhhuser9910.00'),
)
);
$this->request->setApiLoginId('user');
$this->request->setHashSecret('shhh');
$this->request->setAmount('10.00');
$this->request->setTransactionId(99);

$response = $this->request->send();

$this->assertTrue($response->isSuccessful());
$this->assertSame('12345', $response->getTransactionReference());
$this->assertNull($response->getMessage());
}
}

This file was deleted.

File renamed without changes.
9 changes: 0 additions & 9 deletions tests/bootstrap.php

This file was deleted.