-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
f79d9d4
commit 794c3a6
Showing
12 changed files
with
566 additions
and
1 deletion.
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,55 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/dictionaries | ||
.idea/vcs.xml | ||
.idea/jsLibraryMappings.xml | ||
|
||
# Sensitive or high-churn files: | ||
.idea/dataSources.ids | ||
.idea/dataSources.xml | ||
.idea/dataSources.local.xml | ||
.idea/sqlDataSources.xml | ||
.idea/dynamic.xml | ||
.idea/uiDesigner.xml | ||
|
||
# Gradle: | ||
.idea/gradle.xml | ||
.idea/libraries | ||
|
||
# Mongo Explorer plugin: | ||
.idea/mongoSettings.xml | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
/out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
### Example user template template | ||
### Example user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen | ||
vendor |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Aleksandr Zhiliaev | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# omnipay-payeer | ||
Payeer gateway for Omnipay payment processing library | ||
Payeer gateway for [Omnipay](https://github.com/thephpleague/omnipay) payment processing library. | ||
|
||
## To-do | ||
- Full documentation | ||
- Handling all custom parameters | ||
- Unit tests |
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 @@ | ||
{ | ||
"name": "aleksandrzhiliaev/omnipay-payeer", | ||
"type": "library", | ||
"description": "Payeer gateway for Omnipay payment processing library", | ||
"keywords": [ | ||
"gateway", | ||
"merchant", | ||
"omnipay", | ||
"pay", | ||
"payment", | ||
"payeer", | ||
"purchase" | ||
], | ||
"homepage": "http://sassoft.ru", | ||
"license": "", | ||
"authors": [ | ||
{ | ||
"name": "Aleksandr Zhiliaev", | ||
"email": "sassoftinc@gmail.com" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { "Omnipay\\Payeer\\" : "src/" } | ||
}, | ||
"require": { | ||
"omnipay/common": "~2.0" | ||
}, | ||
"require-dev": { | ||
"omnipay/tests": "~2.0" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.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,92 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payeer; | ||
|
||
use Omnipay\Common\AbstractGateway; | ||
|
||
/** | ||
* Gateway Class | ||
*/ | ||
class Gateway extends AbstractGateway | ||
{ | ||
public function getName() | ||
{ | ||
return 'Payeer'; | ||
} | ||
|
||
public function getAccount() | ||
{ | ||
return $this->getParameter('account'); | ||
} | ||
|
||
public function setAccount($value) | ||
{ | ||
return $this->setParameter('account', $value); | ||
} | ||
|
||
public function getApiId() | ||
{ | ||
return $this->getParameter('api_id'); | ||
} | ||
|
||
public function setApiId($value) | ||
{ | ||
return $this->setParameter('api_id', $value); | ||
} | ||
|
||
public function getApiSecret() | ||
{ | ||
return $this->getParameter('api_secret'); | ||
} | ||
|
||
public function setApiSecret($value) | ||
{ | ||
return $this->setParameter('api_secret', $value); | ||
} | ||
|
||
public function getShopId() | ||
{ | ||
return $this->getParameter('shop_id'); | ||
} | ||
|
||
public function setShopId($value) | ||
{ | ||
return $this->setParameter('shop_id', $value); | ||
} | ||
|
||
public function getShopSecret() | ||
{ | ||
return $this->getParameter('shop_secret'); | ||
} | ||
|
||
public function setShopSecret($value) | ||
{ | ||
return $this->setParameter('shop_secret', $value); | ||
} | ||
|
||
public function getDefaultParameters() | ||
{ | ||
return array( | ||
'account' => '', | ||
'api_id' => '', | ||
'api_secret' => '', | ||
'shop_id' => '', | ||
'shop_secret' => '', | ||
); | ||
} | ||
|
||
public function purchase(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Payeer\Message\PurchaseRequest', $parameters); | ||
} | ||
|
||
public function completePurchase(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Payeer\Message\CompletePurchaseRequest', $parameters); | ||
} | ||
|
||
public function refund(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Payeer\Message\RefundRequest', $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,17 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payeer\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest as OmnipayRequest; | ||
|
||
abstract class AbstractRequest extends OmnipayRequest | ||
{ | ||
protected $liveMerchantEndpoint = '//payeer.com/api/merchant/m.php'; | ||
protected $liveApiEndpoint = 'https://payeer.com/ajax/api/api.php'; | ||
|
||
|
||
protected function getMerchantEndpoint() | ||
{ | ||
return $this->liveMerchantEndpoint; | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payeer\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidResponseException; | ||
|
||
class CompletePurchaseRequest extends AbstractRequest | ||
{ | ||
public function getShopSecret() | ||
{ | ||
return $this->getParameter('shop_secret'); | ||
} | ||
|
||
public function setShopSecret($value) | ||
{ | ||
return $this->setParameter('shop_secret', $value); | ||
} | ||
|
||
public function getData() | ||
{ | ||
if ($this->httpRequest->request->get('m_curr') != $this->getCurrency()) { | ||
throw new InvalidResponseException("Invalid m_curr:".$this->httpRequest->request->get('m_curr')); | ||
} | ||
|
||
if ($this->httpRequest->request->get('m_status') != 'success') { | ||
throw new InvalidResponseException("Invalid m_status:".$this->httpRequest->request->get('m_status')); | ||
} | ||
|
||
$arHash = [ | ||
$this->httpRequest->request->get('m_operation_id'), | ||
$this->httpRequest->request->get('m_operation_ps'), | ||
$this->httpRequest->request->get('m_operation_date'), | ||
$this->httpRequest->request->get('m_operation_pay_date'), | ||
$this->httpRequest->request->get('m_shop'), | ||
$this->httpRequest->request->get('m_orderid'), | ||
$this->httpRequest->request->get('m_amount'), | ||
$this->httpRequest->request->get('m_curr'), | ||
$this->httpRequest->request->get('m_desc'), | ||
$this->httpRequest->request->get('m_status'), | ||
$this->getShopSecret(), | ||
]; | ||
$sign_hash = strtoupper(hash('sha256', implode(':', $arHash))); | ||
|
||
if ($this->httpRequest->request->get('m_sign') != $sign_hash) { | ||
throw new InvalidResponseException("Invalid m_sign"); | ||
} | ||
|
||
echo $this->httpRequest->request->get('m_orderid').'|success'; | ||
|
||
return $this->httpRequest->request->all(); | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
return $this->response = new CompletePurchaseResponse($this, $data); | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payeer\Message; | ||
|
||
use Omnipay\Common\Message\AbstractResponse; | ||
use Omnipay\Common\Message\RedirectResponseInterface; | ||
|
||
class CompletePurchaseResponse extends AbstractResponse implements RedirectResponseInterface | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return ($this->data['m_status'] == 'success') ? true : false; | ||
} | ||
|
||
public function isCancelled() | ||
{ | ||
return ($this->data['m_status'] != 'success') ? true : false; | ||
} | ||
|
||
public function isRedirect() | ||
{ | ||
return false; | ||
} | ||
|
||
public function getRedirectUrl() | ||
{ | ||
return null; | ||
} | ||
|
||
public function getRedirectMethod() | ||
{ | ||
return null; | ||
} | ||
|
||
public function getRedirectData() | ||
{ | ||
return null; | ||
} | ||
|
||
public function getTransactionId() | ||
{ | ||
return intval($this->data['m_orderid']); | ||
} | ||
|
||
public function getAmount() | ||
{ | ||
return floatval($this->data['m_amount']); | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return null; | ||
} | ||
} |
Oops, something went wrong.