-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris de Jong
committed
Mar 2, 2017
0 parents
commit ad033d4
Showing
9 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor | ||
composer.lock | ||
composer.phar | ||
phpunit.xml | ||
/nbproject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
|
||
before_script: | ||
- composer install -n --dev --prefer-source | ||
|
||
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "eventix/omnipay-backoffice", | ||
"type": "library", | ||
"description": "Backoffice driver for the Omnipay payment processing library", | ||
"keywords": [ | ||
"gateway", | ||
"merchant", | ||
"paynl", | ||
"omnipay", | ||
"pay", | ||
"payment" | ||
], | ||
"homepage": "https://www.eventix.nl", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Chris de Jong", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { "Omnipay\\Backoffice\\" : "src/" } | ||
}, | ||
"require": { | ||
"omnipay/common": "~2.2" | ||
}, | ||
"require-dev": { | ||
"omnipay/tests": "~2.0" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "2.0.x-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice; | ||
|
||
use Omnipay\Common\AbstractGateway; | ||
|
||
/** | ||
* Backoffice Payment methods | ||
* | ||
* Used for 'offline' payment methods as | ||
* PIN / Cash which will be paid directly | ||
* withouth any 'online' paymentProvider. | ||
* | ||
*/ | ||
class Gateway extends AbstractGateway | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'Backoffice'; | ||
} | ||
|
||
/** | ||
* @param array $parameters | ||
* @return \Omnipay\Backoffice\Message\PurchaseRequest | ||
*/ | ||
public function purchase(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Backoffice\Message\PurchaseRequest', $parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice\Message; | ||
|
||
use Guzzle\Common\Event; | ||
|
||
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { | ||
|
||
protected $endpoint = 'https://rest-api.pay.nl/v5/'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getApitoken() { | ||
return $this->getParameter('apitoken'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* @return $this | ||
*/ | ||
public function setApitoken($value) { | ||
return $this->setParameter('apitoken', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getServiceId() { | ||
return $this->getParameter('serviceId'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* @return $this | ||
*/ | ||
public function setServiceId($value) { | ||
return $this->setParameter('serviceId', $value); | ||
} | ||
|
||
protected function sendRequest($method, $endpoint, array $data = array()) { | ||
$this->httpClient->getEventDispatcher()->addListener('request.error', function (Event $event) { | ||
/** | ||
* @var \Guzzle\Http\Message\Response $response | ||
*/ | ||
$response = $event['response']; | ||
|
||
if ($response->isError()) { | ||
$event->stopPropagation(); | ||
} | ||
}); | ||
|
||
$data['token'] = $this->getApitoken(); | ||
$data['serviceId'] = $this->getServiceId(); | ||
|
||
$httpRequest = $this->httpClient->createRequest( | ||
$method, $this->endpoint . $endpoint.'/json', array(), $data | ||
); | ||
|
||
return $httpRequest->send(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice\Message; | ||
|
||
class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return true; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice\Message; | ||
|
||
use Omnipay\Common\Message\RedirectResponseInterface; | ||
|
||
class FetchTransactionResponse extends AbstractResponse implements RedirectResponseInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isRedirect() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getRedirectUrl() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getRedirectMethod() | ||
{ | ||
return 'GET'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getRedirectData() | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isSuccessful() | ||
{ | ||
return parent::isSuccessful(); | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function isOpen() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function isCancelled() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function isPaid() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function isExpired() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getTransactionReference() | ||
{ | ||
if(isset($this->data['paymentMethod'])) { | ||
return $this->data['paymentMethod']; | ||
} | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getStatus() | ||
{ | ||
return 'paid'; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getAmount() | ||
{ | ||
if(isset($this->data['amount'])) { | ||
return $this->data['amount']; | ||
} | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isPending() | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice\Message; | ||
|
||
/** | ||
* Backoffice Purchase Request | ||
* | ||
* @method \Omnipay\Backoffice\Message\PurchaseResponse send() | ||
*/ | ||
class PurchaseRequest extends AbstractRequest { | ||
|
||
/** | ||
* Return the data formatted for PAY.nl | ||
* @return array | ||
*/ | ||
public function getData() { | ||
$this->validate('paymentMethod'); | ||
$data['amount'] = round($this->getAmount() * 100); | ||
$data['transaction']['description'] = $this->getDescription(); | ||
$data['finishUrl'] = $this->getReturnUrl(); | ||
$data['ipAddress'] = $this->getClientIp(); | ||
$data['paymentMethod'] = $this->getPaymentMethod(); | ||
|
||
$data['testMode'] = $this->getTestMode() ? 1 : 0; | ||
return $data; | ||
} | ||
|
||
/** | ||
* Send the data | ||
* @param array $data | ||
* @return AbstractResponse | ||
*/ | ||
public function sendData($data) { | ||
return $this->response = new PurchaseResponse($this, $this->getData()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Omnipay\Backoffice\Message; | ||
|
||
class PurchaseResponse extends FetchTransactionResponse | ||
{ | ||
/** | ||
* A Payment made through this gateway is always instant successful | ||
* | ||
*/ | ||
public function isSuccessful() | ||
{ | ||
return true; | ||
} | ||
|
||
} |