forked from terdelyi/omnipay-wirecard
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
Showing
14 changed files
with
507 additions
and
62 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
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
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
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,56 @@ | ||
<?php | ||
|
||
namespace Omnipay\Wirecard\Message; | ||
|
||
use Omnipay\Wirecard\Support\Helper; | ||
|
||
/** | ||
* Class PayoutRequest | ||
* @package Omnipay\Wirecard\Message | ||
*/ | ||
class PayoutRequest extends AbstractRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $endpoint = 'https://checkout.wirecard.com/page/toolkit.php'; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getData() | ||
{ | ||
$this->validate( | ||
'customerId', | ||
'secret', | ||
'toolkitPassword', | ||
'transactionReference', | ||
'currency', | ||
'amount', | ||
'language' | ||
); | ||
|
||
$data = array( | ||
'customerId' => $this->getCustomerId(), | ||
'shopId' => $this->getShopId(), | ||
'toolkitPassword' => $this->getToolkitPassword(), | ||
'secret' => $this->getSecret(), | ||
'command' => 'refund', | ||
'language' => $this->getLanguage(), | ||
'orderNumber' => $this->getTransactionReference(), | ||
'amount' => $this->getAmount(), | ||
'currency' => $this->getCurrency() | ||
); | ||
|
||
$data['requestFingerprint'] = Helper::getPayoutRequestFingerprint($data, $this->getSecret()); | ||
unset($data['secret']); | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$httpResponse = $this->httpClient->post($this->endpoint, null, $data)->send(); | ||
return new PayoutResponse($this, $httpResponse->getBody(true)); | ||
} | ||
} |
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,80 @@ | ||
<?php | ||
|
||
namespace Omnipay\Wirecard\Message; | ||
|
||
use Omnipay\Common\Message\AbstractResponse; | ||
use Omnipay\Common\Message\RequestInterface; | ||
|
||
/** | ||
* Class PayoutResponse | ||
* @package Omnipay\Wirecard\Message | ||
*/ | ||
class PayoutResponse extends AbstractResponse | ||
{ | ||
/** | ||
* PayoutResponse constructor. | ||
* | ||
* @param RequestInterface $request | ||
* @param string $data | ||
*/ | ||
public function __construct(RequestInterface $request, $data) | ||
{ | ||
parent::__construct($request, []); | ||
foreach (explode('&', $data) as $keyValue) { | ||
$param = explode('=', $keyValue); | ||
if (sizeof($param) == 2) { | ||
$key = urldecode($param[0]); | ||
$value = urldecode($param[1]); | ||
$this->data[$key] = $value; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isSuccessful() | ||
{ | ||
return $this->getStatus() === '0'; | ||
} | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getTransactionReference() | ||
{ | ||
return $this->getCreditNumber(); | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getStatus() | ||
{ | ||
return isset($this->data['status']) ? $this->data['status'] : null; | ||
} | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getCode() | ||
{ | ||
return isset($this->data['errorCode']) ? (int) $this->data['errorCode'] : null; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getMessage() | ||
{ | ||
return isset($this->data['message']) ? $this->data['message'] : null; | ||
} | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getCreditNumber() | ||
{ | ||
return isset($this->data['creditNumber']) ? (int) $this->data['creditNumber'] : null; | ||
} | ||
} |
Oops, something went wrong.