Skip to content

Commit 4928c24

Browse files
author
Vladislav Veselinov
committed
Merge remote-tracking branch 'upstream/master'
2 parents 5237132 + 39eec26 commit 4928c24

File tree

111 files changed

+1932
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1932
-160
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ language: php
33
php:
44
- 5.3
55
- 5.4
6+
- 5.5
67

78
env:
8-
- SYMFONY_VERSION="2.1.*"
9-
- SYMFONY_VERSION="2.2.*"
9+
- SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.1"
10+
- SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.1"
11+
- SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.*"
12+
- SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.*"
1013

1114
before_script:
1215
- composer self-update
1316
- composer require symfony/http-foundation:${SYMFONY_VERSION} --no-update
17+
- composer require guzzle/http:${GUZZLE_VERSION} --no-update
1418
- composer install -n --dev --prefer-source
1519

1620
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog :zap:
2+
3+
# v1.0.1 (2013-06-29)
4+
5+
* Added Buckaroo gateway
6+
* Added eWAY Rapid 3.0 gateway
7+
* Added `getRedirectResponse()` method to `AbstractResponse`
8+
* A few minor bug fixes & typos
9+
10+
# v1.0.0 (2013-06-24)
11+
12+
`amount` is now specified as a decimal (i.e. `'10.00'` instead of `1000`
13+
to represent $10.00. Passing integers will throw an exception, reminding you
14+
to update your application code. To be clear, that means instead of this:
15+
16+
$gateway->purchase(array('amount' => 1000, 'currency' => 'USD'));
17+
18+
You must now create the request like so:
19+
20+
$gateway->purchase(array('amount' => '10.00', 'currency' => 'USD'));
21+
22+
This should avoid any further confusion over how to specify the amount.
23+
24+
* Added Mollie payment gateway
25+
* Added `notifyUrl` and `issuer` fields to example app

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ is fully unit tested, and even comes with an example application to get you star
1919
* Because most payment gateways have exceptionally poor documentation
2020
* Because you are writing a shopping cart and need to support multiple gateways
2121

22+
**Important Note: Upgrading from <1.0**
23+
24+
If you are upgrading from a pre-1.0 version of Omnipay, please note that the currency format has changed.
25+
See the [changelog](https://github.com/adrianmacneil/omnipay/blob/master/CHANGELOG.md) for more details.
26+
2227
## TL;DR
2328

2429
Just want to see some code?
@@ -30,7 +35,7 @@ $gateway = GatewayFactory::create('Stripe');
3035
$gateway->setApiKey('abc123');
3136

3237
$formData = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];
33-
$response = $gateway->purchase(['amount' => 1000, 'currency' => 'USD', 'card' => $formData])->send();
38+
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();
3439

3540
if ($response->isSuccessful()) {
3641
// payment was successful: update database
@@ -66,7 +71,7 @@ to your `composer.json` file:
6671
```json
6772
{
6873
"require": {
69-
"omnipay/omnipay": "0.9.*"
74+
"omnipay/omnipay": "1.*"
7075
}
7176
}
7277
```
@@ -86,12 +91,15 @@ The following gateways are already implemented:
8691
* 2Checkout
8792
* Authorize.Net AIM
8893
* Authorize.Net SIM
94+
* Buckaroo
8995
* CardSave
9096
* Dummy
97+
* eWAY Rapid 3.0
9198
* GoCardless
9299
* Manual
93100
* Migs 2-Party
94101
* Migs 3-Party
102+
* Mollie
95103
* Netaxept (BBS)
96104
* Netbanx
97105
* PayFast
@@ -107,9 +115,6 @@ The following gateways are already implemented:
107115
* Stripe
108116
* WorldPay
109117

110-
More are coming soon! [All of these](https://github.com/expressodev/ci-merchant/tree/develop/libraries/merchant)
111-
will be implemented before we reach 1.0.
112-
113118
Gateways are created and initialized like so:
114119

115120
```php
@@ -251,7 +256,7 @@ Pass the options through to the method like so:
251256
```php
252257
$card = new CreditCard($formData);
253258
$request = $gateway->authorize([
254-
'amount' => 1000, // this represents $10.00
259+
'amount' => '10.00', // this represents $10.00
255260
'card' => $card,
256261
'returnUrl' => 'https://www.example.com/return',
257262
]);
@@ -280,7 +285,7 @@ For a successful responses, a reference will normally be generated, which can be
280285
at a later date. The following methods are always available:
281286

282287
```php
283-
$response = $gateway->purchase(['amount' => 1000, 'card' => $card])->send();
288+
$response = $gateway->purchase(['amount' => '10.00', 'card' => $card])->send();
284289

285290
$response->isSuccessful(); // is the response successful?
286291
$response->isRedirect(); // is the response a redirect?
@@ -298,7 +303,7 @@ POST (FormRedirectResponse). These could potentially be combined into a single r
298303
After processing a payment, the cart should check whether the response requires a redirect, and if so, redirect accordingly:
299304

300305
```php
301-
$response = $gateway->purchase(['amount' => 1000, 'card' => $card])->send();
306+
$response = $gateway->purchase(['amount' => '10.00', 'card' => $card])->send();
302307
if ($response->isSuccessful()) {
303308
// payment is complete
304309
} elseif ($response->isRedirect()) {
@@ -331,7 +336,7 @@ You can handle both scenarios by wrapping the entire request in a try-catch bloc
331336

332337
```php
333338
try {
334-
$response = $gateway->purchase(['amount' => 1000, 'card' => $card])->send();
339+
$response = $gateway->purchase(['amount' => '10.00', 'card' => $card])->send();
335340
if ($response->isSuccessful()) {
336341
// mark order as complete
337342
} elseif ($response->isRedirect()) {
@@ -358,7 +363,7 @@ are available:
358363

359364
Once you have a `cardReference`, you can use it instead of the `card` parameter when creating a charge:
360365

361-
$gateway->purchase(['amount' => 1000, 'cardReference' => 'abc']);
366+
$gateway->purchase(['amount' => '10.00', 'cardReference' => 'abc']);
362367

363368
## Recurring Billing
364369

composer.json

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
{
22
"name": "omnipay/omnipay",
33
"type": "library",
4-
"description": "Omnipay is a framework agnostic multi-gateway payment processing library",
4+
"description": "A framework agnostic, multi-gateway payment processing library",
55
"keywords": [
6-
"payment", "gateway", "merchant", "authorize", "purchase", "authorize.net",
7-
"auth.net", "cardsave", "gocardless", "netaxept", "payflow", "dps", "paymentexpress",
8-
"paypal", "pin", "sagepay", "sage pay", "stripe", "2co", "2checkout", "twocheckout",
9-
"worldpay", "tala", "tala-payments"],
6+
"2checkout",
7+
"2co",
8+
"auth.net",
9+
"authorize",
10+
"authorize.net",
11+
"buckaroo",
12+
"cardsave",
13+
"commweb",
14+
"dps",
15+
"egate",
16+
"eway",
17+
"express",
18+
"gateway",
19+
"gocardless",
20+
"ideal",
21+
"merchant",
22+
"migs",
23+
"mollie",
24+
"netaxept",
25+
"netbanx",
26+
"pay",
27+
"payfast",
28+
"payflow",
29+
"payment",
30+
"paymentexpress",
31+
"paypal",
32+
"pin",
33+
"purchase",
34+
"rapid",
35+
"sagepay",
36+
"securepay",
37+
"stripe",
38+
"tala",
39+
"tala-payments",
40+
"twocheckout",
41+
"worldpay"
42+
],
1043
"homepage": "https://github.com/adrianmacneil/omnipay",
1144
"license": "MIT",
1245
"authors": [
@@ -20,11 +53,11 @@
2053
},
2154
"require": {
2255
"php": ">=5.3.2",
23-
"guzzle/http": "~3.0",
56+
"guzzle/http": "~3.1",
2457
"symfony/http-foundation": "~2.1"
2558
},
2659
"require-dev": {
27-
"guzzle/plugin-mock": "~3.0",
60+
"guzzle/plugin-mock": "~3.1",
2861
"mockery/mockery": "~0.7",
2962
"phpunit/phpunit": "~3.7.16",
3063
"silex/silex": "1.0.*@dev",

example/views/request.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $response = $gateway->{{ method }}($params);</pre>
1414
<p>The following parameters are available. Not all options are required by all gateways.</p>
1515
<p><span class="label label-info">Note</span> Normally these parameters would be generated by your application and not set via form input.</p>
1616

17-
{% for key in ["amount", "currency", "description", "transactionId", "transactionReference", "cardReference", "returnUrl", "cancelUrl"] %}
17+
{% for key in ["amount", "currency", "description", "transactionId", "transactionReference", "cardReference", "returnUrl", "cancelUrl", "notifyUrl", "issuer"] %}
1818

1919
<div class="control-group">
2020
<label class="control-label" for="params_{{key}}">{{ key }}</label>

src/Omnipay/AuthorizeNet/Message/AbstractRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function getBaseData()
7777
protected function getBillingData()
7878
{
7979
$data = array();
80-
$data['x_amount'] = $this->getAmountDecimal();
80+
$data['x_amount'] = $this->getAmount();
8181
$data['x_invoice_num'] = $this->getTransactionId();
8282
$data['x_description'] = $this->getDescription();
8383

src/Omnipay/AuthorizeNet/Message/CaptureRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getData()
2323
$this->validate('amount', 'transactionReference');
2424

2525
$data = $this->getBaseData();
26-
$data['x_amount'] = $this->getAmountDecimal();
26+
$data['x_amount'] = $this->getAmount();
2727
$data['x_trans_id'] = $this->getTransactionReference();
2828

2929
return $data;

src/Omnipay/AuthorizeNet/Message/SIMCompleteAuthorizeRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getData()
2929

3030
public function getHash()
3131
{
32-
return md5($this->getApiLoginId().$this->getTransactionId().$this->getAmountDecimal());
32+
return md5($this->getApiLoginId().$this->getTransactionId().$this->getAmount());
3333
}
3434

3535
public function send()

src/Omnipay/Buckaroo/Gateway.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Omnipay package.
5+
*
6+
* (c) Adrian Macneil <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Omnipay\Buckaroo;
13+
14+
use Omnipay\Common\AbstractGateway;
15+
16+
/**
17+
* Buckaroo Gateway
18+
*/
19+
class Gateway extends AbstractGateway
20+
{
21+
public function getName()
22+
{
23+
return 'Buckaroo';
24+
}
25+
26+
public function getDefaultParameters()
27+
{
28+
return array(
29+
'merchantId' => '',
30+
'secret' => '',
31+
'testMode' => false,
32+
);
33+
}
34+
35+
public function getMerchantId()
36+
{
37+
return $this->getParameter('merchantId');
38+
}
39+
40+
public function setMerchantId($value)
41+
{
42+
return $this->setParameter('merchantId', $value);
43+
}
44+
45+
public function getSecret()
46+
{
47+
return $this->getParameter('secret');
48+
}
49+
50+
public function setSecret($value)
51+
{
52+
return $this->setParameter('secret', $value);
53+
}
54+
55+
public function purchase(array $parameters = array())
56+
{
57+
return $this->createRequest('\Omnipay\Buckaroo\Message\PurchaseRequest', $parameters);
58+
}
59+
60+
public function completePurchase(array $parameters = array())
61+
{
62+
return $this->createRequest('\Omnipay\Buckaroo\Message\CompletePurchaseRequest', $parameters);
63+
}
64+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Omnipay package.
5+
*
6+
* (c) Adrian Macneil <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Omnipay\Buckaroo\Message;
13+
14+
use Omnipay\Common\Exception\InvalidRequestException;
15+
16+
/**
17+
* Buckaroo Complete Purchase Request
18+
*/
19+
class CompletePurchaseRequest extends PurchaseRequest
20+
{
21+
public function getData()
22+
{
23+
$this->validate('merchantId', 'secret', 'amount');
24+
25+
if (strtolower($this->httpRequest->request->get('bpe_signature2')) !== $this->generateResponseSignature()) {
26+
throw new InvalidRequestException('Incorrect signature');
27+
}
28+
29+
return $this->httpRequest->request->all();
30+
}
31+
32+
public function generateResponseSignature()
33+
{
34+
return md5(
35+
$this->httpRequest->request->get('bpe_trx').
36+
$this->httpRequest->request->get('bpe_timestamp').
37+
$this->getMerchantId().
38+
$this->getTransactionId().
39+
$this->getCurrency().
40+
$this->getAmountInteger().
41+
$this->httpRequest->request->get('bpe_result').
42+
(int) $this->getTestMode().
43+
$this->getSecret()
44+
);
45+
}
46+
47+
public function send()
48+
{
49+
return $this->response = new CompletePurchaseResponse($this, $this->getData());
50+
}
51+
}

0 commit comments

Comments
 (0)