8000 First commit · dercoder/omnipay-paysafecard@4225c0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 4225c0b

Browse files
committed
First commit
0 parents  commit 4225c0b

32 files changed

+1969
-0
lines changed

.gitignore

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

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tools:
2+
external_code_coverage: true

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
- 5.6
8+
- hhvm
9+
10+
before_script:
11+
- composer install -n --dev --prefer-source
12+
13+
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2015 Alexander Fedra
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Omnipay: Paysafecard
2+
3+
**Paysafecard driver for the Omnipay PHP payment processing library**

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "dercoder/omnipay-paysafecard",
3+
"type": "library",
4+
"description": "Paysafecard driver for the Omnipay payment processing library",
5+
"keywords": [
6+
"paysafecard",
7+
"gateway",
8+
"merchant",
9+
"omnipay",
10+
"pay",
11+
"payment"
12+
],
13+
"homepage": "https://github.com/dercoder/omnipay-paysafecard",
14+
"license": "MIT",
15+
"autoload": {
16+
"psr-0": { "Omnipay\\Paysafecard\\" : "src/" }
17+
},
18+
"require": {
19+
"omnipay/common": "~2.3",
20+
"league/url": "~3.0"
21+
},
22+
"require-dev": {
23+
"omnipay/tests": "~2.0"
24+
},
25+
"extra": {
26+
"branch-alias": {
27+
"dev-master": "1.0.x-dev"
28+
}
29+
}
30+
}

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="tests/bootstrap.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<testsuites>
13+
<testsuite name="Ecopayz Test Suite">
14+
<directory>./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<listeners>
18+
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
19+
</listeners>
20+
<filter>
21+
<whitelist>
22+
<directory>./src</directory>
23+
</whitelist>
24+
</filter>
25+
<logging>
26+
<log type="coverage-clover" target="./clover.xml" />
27+
</logging>
28+
</phpunit>

src/Omnipay/Paysafecard/Gateway.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace Omnipay\Paysafecard;
4+
5+
use Omnipay\Common\AbstractGateway;
6+
7+
/**
8+
* Paysafecard Gateway.
9+
*
10+
* @author Alexander Fedra <contact@dercoder.at>
11+
* @copyright 2015 DerCoder
12+
* @license http://opensource.org/licenses/mit-license.php MIT
13+
*/
14+
class Gateway extends AbstractGateway
15+
{
16+
/**
17+
* {@inheritdoc}
18+
*/
19+
public function getName()
20+
{
21+
return 'Paysafecard';
22+
}
23+
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function getDefaultParameters()
28+
{
29+
return array(
30+
'username' => '',
31+
'password' => '',
32+
'testMode' => false,
33+
);
34+
}
35+
36+
/**
37+
* Get the username.
38+
*
39+
* Custom account username provided by paysafecard for the authentication.
40+
*
41+
* @return string username
42+
*/
43+
public function getUsername()
44+
{
45+
return $this->getParameter('username');
46+
}
47+
48+
/**
49+
* Set the username.
50+
*
51+
* Custom account username provided by paysafecard for the authentication.
52+
*
53+
* @param string $value username
54+
*
55+
* @return self
56+
*/
57+
public function setUsername($value)
58+
{
59+
return $this->setParameter('username', $value);
60+
}
61+
62+
/**
63+
* Get the password.
64+
*
65+
* Custom account password provided by paysafecard for the authentication.
66+
*
67+
* @return string password
68+
*/
69+
public function getPassword()
70+
{
71+
return $this->getParameter('password');
72+
}
73+
74+
/**
75+
* Set the password.
76+
*
77+
* Custom account password provided by paysafecard for the authentication.
78+
*
79+
* @param string $value password
80+
*
81+
* @return self
82+
*/
83+
public function setPassword($value)
84+
{
85+
return $this->setParameter('password', $value);
86+
}
87+
88+
/**
89+
* @param array $parameters
90+
*
91+
* @return \Omnipay\Paysafecard\Message\PurchaseRequest
92+
*/
93+
public function purchase(array $parameters = array())
94+
{
95+
return $this->createRequest('\Omnipay\Paysafecard\Message\PurchaseRequest', $parameters);
96+
}
97+
98+
/**
99+
* @param array $parameters
100+
*
101+
* @return \Omnipay\Paysafecard\Message\CompletePurchaseRequest
102+
*/
103+
public function completePurchase(array $parameters = array())
104+
{
105+
return $this->createRequest('\Omnipay\Paysafecard\Message\CompletePurchaseRequest', $parameters);
106+
}
107+
108+
/**
109+
* @param array $parameters
110+
*
111+
* @return \Omnipay\Paysafecard\Message\FetchTransactionRequest
112+
*/
113+
public function fetchTransaction(array $parameters = array())
114+
{
115+
return $this->createRequest('\Omnipay\Paysafecard\Message\FetchTransactionRequest', $parameters);
116+
}
117+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
namespace Omnipay\Paysafecard\Message;
4+
5+
use Omnipay\Common\Exception\InvalidResponseException;
6+
use Omnipay\Common\Message\AbstractResponse;
7+
8+
/**
9+
* Paysafecard Abstract Request.
10+
*
11+
* @author Alexander Fedra <contact@dercoder.at>
12+
* @copyright 2015 DerCoder
13+
* @license http://opensource.org/licenses/mit-license.php MIT
14+
*
15+
* @version 1.1 Paysafecard API Specification
16+
*/
17+
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
18+
{
19+
protected $liveEndpoint = 'https://soa.paysafecard.com/psc/services/PscService';
20+
protected $testEndpoint = 'https://soatest.paysafecard.com/psc/services/PscService';
21+
22+
/**
23+
* Get the method for this request.
24+
*
25+
* @return string method
26+
*/
27+
abstract protected function getMethod();
28+
29+
/**
30+
* Get the username.
31+
*
32+
* Custom account username provided by paysafecard for the authentication.
33+
*
34+
* @return string username
35+
*/
36+
public function getUsername()
37+
{
38+
return $this->getParameter('username');
39+
}
40+
41+
/**
42+
* Set the username.
43+
*
44+
* Custom account username provided by paysafecard for the authentication.
45+
*
46+
* @param string $value username
47+
*
48+
* @return self
49+
*/
50+
public function setUsername($value)
51+
{
52+
return $this->setParameter('username', $value);
53+
}
54+
55+
/**
56+
* Get the password.
57+
*
58+
* Custom account password provided by paysafecard for the authentication.
59+
*
60+
* @return string password
61+
*/
62+
public function getPassword()
63+
{
64+
return $this->getParameter('password');
65+
}
66+
67+
/**
68+
* Set the password.
69+
*
70+
* Custom account password provided by paysafecard for the authentication.
71+
*
72+
* @param string $value password
73+
*
74+
* @return self
75+
*/
76+
public function setPassword($value)
77+
{
78+
return $this->setParameter('password', $value);
79+
}
80+
81+
/**
82+
* Get the sub ID.
83+
*
84+
* mandatory parameter, value must be left empty if nothing else is agreed.
85+
* so-called ‘reporting criteria’, offers the possibility to classify transactions.
86+
* max. length: 8 characters (case sensitive)
87+
* agreement with paysafecard needed
88+
* example: shop1
89+
*
90+
* @return string sub id
91+
*/
92+
public function getSubId()
93+
{
94+
return $this->getParameter('subId');
95+
}
96+
97+
/**
98+
* Set the sub ID.
99+
*
100+
* mandatory parameter, value must be left empty if nothing else is agreed.
101+
* so-called ‘reporting criteria’, offers the possibility to classify transactions.
102+
* max. length: 8 characters (case sensitive)
103+
* agreement with paysafecard needed
104+
* example: shop1
105+
*
106+
* @param string $value sub id
107+
*
108+
* @return self
109+
*/
110+
public function setSubId($value)
111+
{
112+
return $this->setParameter('subId', $value);
113+
}
114+
115+
/**
116+
* Get the endpoint for this request.
117+
*
118+
* @return string endpoint
119+
*/
120+
public function getEndpoint()
121+
{
122+
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
123+
}
124+
125+
/**
126+
* Send the request with specified data.
127+
*
128+
* @param mixed $data The data to send
129+
*
130+
* @throws InvalidResponseException
131+
*
132+
* @return AbstractResponse
133+
*/
134+
public function sendData($data)
135+
{
136+
$endpoint = $this->getEndpoint();
137+
$headers = array(
138+
'Content-Type' => 'text/xml; charset=utf-8',
139+
'SOAPAction' => $endpoint.'/'.$this->getMethod(),
140+
);
141+
142+
$httpResponse = $this->httpClient->post($endpoint, $headers, $data)->send();
143+
//var_dump($httpResponse->getRawHeaders());
144+
//var_dump((string)$httpResponse->getBody());
145+
return $this->createResponse($httpResponse->xml());
146+
}
147+
148+
/**
149+
* Get the response from request.
150+
*
151+
* @param \SimpleXMLElement $xml
152+
*
153+
* @return AbstractResponse
154+
*/
155+
abstract protected function createResponse(\SimpleXMLElement $xml);
156+
}

0 commit comments

Comments
 (0)
0