Skip to content

Commit 611da7c

Browse files
committed
Initial commit
0 parents  commit 611da7c

18 files changed

+1673
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.lock
3+
composer.phar
4+
phpunit.xml

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: php
2+
3+
dist: trusty
4+
php:
5+
- "7.2"
6+
- "7.1"
7+
- "7.0"
8+
- "5.6"
9+
- "5.5"
10+
- "5.4"
11+
12+
matrix:
13+
include:
14+
- php: "5.3"
15+
dist: precise
16+
17+
before_script:
18+
- composer install -n --dev --prefer-source
19+
20+
script:
21+
- vendor/bin/phpcs --standard=PSR2 src
22+
- vendor/bin/phpunit --verbose --coverage-clover coverage.clover
23+
24+
after_success:
25+
- wget https://scrutinizer-ci.com/ocular.phar
26+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributing Guidelines
2+
3+
* Fork the project.
4+
* Make your feature addition or bug fix.
5+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
6+
* Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files.
7+
* Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
8+
style and that all tests pass.
9+
* Send the pull request.
10+
* Check that the Travis CI build passed. If not, rinse and repeat.

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2019 Leith Caldwell
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Omnipay: CyberSource
2+
3+
**CyberSource driver for the Omnipay PHP payment processing library**
4+
5+
[![Build Status](https://travis-ci.org/PatronBase/omnipay-cybersource-hosted.png?branch=master)](https://travis-ci.org/PatronBase/omnipay-cybersource-hosted)
6+
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/PatronBase/omnipay-cybersource-hosted.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-cybersource-hosted/code-structure)
7+
[![Code Quality](https://img.shields.io/scrutinizer/g/PatronBase/omnipay-cybersource-hosted.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-cybersource-hosted/?branch=master)
8+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
9+
[![Latest Stable Version](https://poser.pugx.org/PatronBase/omnipay-cybersource-hosted/version.png)](https://packagist.org/packages/patronbase/omnipay-cybersource-hosted)
10+
[![Total Downloads](https://poser.pugx.org/patronbase/omnipay-cybersource-hosted/d/total.png)](https://packagist.org/packages/patronbase/omnipay-cybersource-hosted)
11+
12+
13+
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
14+
processing library for PHP 5.3+. This package implements CyberSource support for Omnipay. It includes
15+
support for the Secure Acceptance Hosted Checkout (formerly Web/Mobile) version of the gateway.
16+
17+
## Installation
18+
19+
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
20+
to your `composer.json` file:
21+
22+
```json
23+
{
24+
"require": {
25+
"PatronBase/omnipay-cybersource-hosted": "~2.0"
26+
}
27+
}
28+
```
29+
30+
And run composer to update your dependencies:
31+
32+
$ curl -s http://getcomposer.org/installer | php
33+
$ php composer.phar update
34+
35+
## Basic Usage
36+
37+
The following gateways are provided by this package:
38+
39+
* CyberSource_Hosted
40+
41+
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
42+
repository.
43+
44+
## Support
45+
46+
If you are having general issues with Omnipay, we suggest posting on
47+
[Stack Overflow](http://stackoverflow.com/). Be sure to add the
48+
[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.
49+
50+
If you want to keep up to date with release anouncements, discuss ideas for the project,
51+
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
52+
you can subscribe to.
53+
54+
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/PatronBase/omnipay-cybersource-hosted/issues),
55+
or better yet, fork the library and submit a pull request.

composer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "patronbase/omnipay-cybersource-hosted",
3+
"type": "library",
4+
"description": "CyberSource Secure Acceptance Hosted Checkout driver for the Omnipay payment processing library",
5+
"keywords": [
6+
"gateway",
7+
"merchant",
8+
"omnipay",
9+
"pay",
10+
"payment",
11+
"cybersource",
12+
"secure",
13+
"acceptance",
14+
"hosted",
15+
"checkout",
16+
"web",
17+
"mobile",
18+
"redirect"
19+
],
20+
"homepage": "https://github.com/PatronBase/omnipay-cybersource-hosted",
21+
"license": "MIT",
22+
"authors": [
23+
{
24+
"name": "Leith Caldwell",
25+
"email": "[email protected]"
26+
}
27+
],
28+
"autoload": {
29+
"psr-4": { "Omnipay\\CyberSource\\" : "src/" }
30+
},
31+
"autoload-dev": {
32+
"psr-4": { "Omnipay\\CyberSource\\" : "tests/" }
33+
},
34+
"require": {
35+
"omnipay/common": "~2.0"
36+
},
37+
"require-dev": {
38+
"omnipay/tests": "~2.0"
39+
},
40+
"extra": {
41+
"branch-alias": {
42+
"dev-master": "2.0.x-dev"
43+
}
44+
}
45+
}

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<php>
13+
<ini name="date.timezone" value="UTC" />
14+
</php>
15+
<testsuites>
16+
<testsuite name="Omnipay Test Suite">
17+
<directory>./tests/</directory>
18+
</testsuite>
19+
</testsuites>
20+
<listeners>
21+
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
22+
</listeners>
23+
<filter>
24+
<whitelist>
25+
<directory>./src</directory>
26+
</whitelist>
27+
</filter>
28+
</phpunit>

src/HostedGateway.php

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
3+
namespace Omnipay\CyberSource;
4+
5+
use Omnipay\Common\AbstractGateway;
6+
use Omnipay\CyberSource\Message\CompletePurchaseRequest;
7+
use Omnipay\CyberSource\Message\PurchaseRequest;
8+
9+
/**
10+
* CyberSource Secure Acceptance Hosted Checkout Gateway
11+
*
12+
* @link https://www.cybersource.com/developers/getting_started/integration_methods/secure_acceptance_wm/
13+
*/
14+
class HostedGateway extends AbstractGateway
15+
{
16+
public function getName()
17+
{
18+
return 'CyberSource Hosted';
19+
}
20+
21+
public function getDefaultParameters()
22+
{
23+
return array(
24+
'profileId' => '',
25+
'accessKey' => '',
26+
'secretKey' => '',
27+
'testMode' => false,
28+
);
29+
}
30+
31+
/**
32+
* Get the profile ID for the merchant account
33+
*
34+
* @return string
35+
*/
36+
public function getProfileId()
37+
{
38+
return $this->getParameter('profileId');
39+
}
40+
41+
/**
42+
* Set the profile ID for the merchant account
43+
*
44+
* @param string $value ASCII Alphanumeric + punctuation string, maximum 36 characters
45+
*
46+
* @return AbstractRequest
47+
*/
48+
public function setProfileId($value)
49+
{
50+
return $this->setParameter('profileId', $value);
51+
}
52+
53+
/**
54+
* Get the secret key for the merchant account
55+
*
56+
* @return string
57+
*/
58+
public function getSecretKey()
59+
{
60+
return $this->getParameter('secretKey');
61+
}
62+
63+
/**
64+
* Set the secret key for the merchant account
65+
*
66+
* @param string $value Alphanumeric string, maximum 32 characters
67+
*
68+
* @return AbstractRequest
69+
*/
70+
public function setSecretKey($value)
71+
{
72+
return $this->setParameter('secretKey', $value);
73+
}
74+
75+
/**
76+
* Get the access key for the merchant account
77+
*
78+
* @return string
79+
*/
80+
public function getAccessKey()
81+
{
82+
return $this->getParameter('accessKey');
83+
}
84+
85+
/**
86+
* Set the access key for the merchant account
87+
*
88+
* @param string $value Alphanumeric string, maximum 32 characters
89+
*
90+
* @return AbstractRequest
91+
*/
92+
public function setAccessKey($value)
93+
{
94+
return $this->setParameter('accessKey', $value);
95+
}
96+
97+
/**
98+
* Redirect the customer to CyberSource to make a purchase
99+
*
100+
* @param array $parameters
101+
*
102+
* @return \Omnipay\Common\Message\AbstractRequest
103+
*/
104+
public function purchase(array $parameters = array())
105+
{
106+
return $this->createRequest('\Omnipay\CyberSource\Message\PurchaseRequest', $parameters);
107+
}
108+
109+
/**
110+
* Complete a purchase process
111+
*
112+
* @param array $parameters
113+
*
114+
* @return \Omnipay\Common\Message\AbstractRequest
115+
*/
116+
public function completePurchase(array $parameters = array())
117+
{
118+
return $this->createRequest('\Omnipay\CyberSource\Message\CompletePurchaseRequest', $parameters);
119+
}
120+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Omnipay\CyberSource\Message;
4+
5+
/**
6+
* CyberSource Complete Purchase Request
7+
*/
8+
class CompletePurchaseRequest extends PurchaseRequest
9+
{
10+
public function getData()
11+
{
12+
return $this->httpRequest->request->all();
13+
}
14+
15+
public function sendData($data)
16+
{
17+
return $this->response = new CompletePurchaseResponse($this, $data);
18+
}
19+
}

0 commit comments

Comments
 (0)