diff --git a/.travis.yml b/.travis.yml
index 544f674..24f877f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,19 @@
language: php
php:
- - 5.3
- - 5.4
- - 5.5
- - 5.6
- 7.0
- 7.1
- - hhvm
+ - 7.2
+ - 7.3
+ - 7.4
+ - 8.0
+ - 8.1
+ - 8.2
+ - 8.3
before_script:
- composer install -n --dev --prefer-source
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
-after_script: vendor/bin/coveralls -v
\ No newline at end of file
+after_script: vendor/bin/coveralls -v
diff --git a/README.md b/README.md
index a1b2620..67e0956 100644
--- a/README.md
+++ b/README.md
@@ -2,16 +2,15 @@
**WebMoney driver for the Omnipay PHP payment processing library**
-[](https://travis-ci.org/dercoder/omnipay-webmoney)
+[](https://app.travis-ci.com/github/dercoder/omnipay-webmoney)
[](https://coveralls.io/github/dercoder/omnipay-webmoney?branch=master)
-[](https://packagist.org/packages/dercoder/omnipay-webmoney)
-[](https://packagist.org/packages/dercoder/omnipay-webmoney)
-[](https://packagist.org/packages/dercoder/omnipay-webmoney)
-[](https://packagist.org/packages/dercoder/omnipay-webmoney)
+[](https://packagist.org/packages/dercoder/omnipay-webmoney)
+[](https://packagist.org/packages/dercoder/omnipay-webmoney)
+[](https://packagist.org/packages/dercoder/omnipay-webmoney)
[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
-processing library for PHP 5.3+. This package implements [WebMoney](https://www.webmoney.az) support for Omnipay.
+processing library for PHP 7.0+. This package implements [WebMoney](https://www.webmoney.az) support for Omnipay.
## Installation
@@ -21,7 +20,7 @@ to your `composer.json` file:
```json
{
"require": {
- "dercoder/omnipay-webmoney": "~1.0"
+ "dercoder/omnipay-webmoney": "^5.0"
}
}
```
@@ -51,4 +50,4 @@ or ask more detailed questions, there is also a [mailing list](https://groups.go
you can subscribe to.
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/dercoder/omnipay-webmoney/issues),
-or better yet, fork the library and submit a pull request.
\ No newline at end of file
+or better yet, fork the library and submit a pull request.
diff --git a/composer.json b/composer.json
index 13d18d6..eb17311 100644
--- a/composer.json
+++ b/composer.json
@@ -1,32 +1,41 @@
{
- "name": "dercoder/omnipay-webmoney",
- "type": "library",
- "description": "WebMoney driver for the Omnipay payment processing library",
- "keywords": [
- "webmoney",
- "gateway",
- "merchant",
- "omnipay",
- "pay",
- "payment"
- ],
- "homepage": "https://github.com/dercoder/omnipay-webmoney",
- "license": "MIT",
- "autoload": {
- "psr-4": {
- "Omnipay\\WebMoney\\": "src/"
- }
- },
- "require": {
- "omnipay/common": "~2.3"
- },
- "require-dev": {
- "omnipay/tests": "~2.0",
- "satooshi/php-coveralls": "1.0.0"
- },
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
+ "name": "dercoder/omnipay-webmoney",
+ "type": "library",
+ "description": "WebMoney driver for the Omnipay payment processing library",
+ "keywords": [
+ "webmoney",
+ "gateway",
+ "merchant",
+ "omnipay",
+ "pay",
+ "payment"
+ ],
+ "homepage": "https://github.com/dercoder/omnipay-webmoney",
+ "license": "MIT",
+ "autoload": {
+ "psr-4": {
+ "Omnipay\\WebMoney\\": "src/"
}
+ },
+ "require": {
+ "php": "^7.0|^8.0",
+ "ext-simplexml": "*",
+ "ext-dom": "*",
+ "omnipay/common": "^3.2"
+ },
+ "require-dev": {
+ "omnipay/tests": "^4.1",
+ "satooshi/php-coveralls": "1.0.0",
+ "guzzlehttp/guzzle": "^6.5.5",
+ "squizlabs/php_codesniffer": "3.*"
+ },
+ "suggest": {
+ "guzzlehttp/guzzle": "To handle WebMoney payouts",
+ "ext-curl": "To handle WebMoney payouts"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0.x-dev"
+ }
+ }
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 9797d8e..5692c91 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -9,6 +9,9 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
+
+
+
./tests/
@@ -22,7 +25,4 @@
./src
-
-
-
-
\ No newline at end of file
+
diff --git a/src/Certificate/WMUsedRootCAs.crt b/src/Certificate/WMUsedRootCAs.crt
index a9e1453..fe9712f 100644
--- a/src/Certificate/WMUsedRootCAs.crt
+++ b/src/Certificate/WMUsedRootCAs.crt
@@ -1,4 +1,40 @@
-----BEGIN CERTIFICATE-----
+MIIGRzCCBC+gAwIBAgIKNl4/iwAAAAnF+TANBgkqhkiG9w0BAQsFADBrMSswKQYD
+VQQLEyJXTSBUcmFuc2ZlciBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzMRgwFgYDVQQK
+Ew9XTSBUcmFuc2ZlciBMdGQxIjAgBgNVBAMTGVdlYk1vbmV5IFRyYW5zZmVyIFJv
+b3QgQ0EwHhcNMTYxMTIyMTQxOTQ0WhcNMjExMTIyMTQyOTQ0WjCBhzELMAkGA1UE
+BhMCUlUxDzANBgNVBAgTBk1vc2NvdzEPMA0GA1UEBxMGTW9zY293MRowGAYDVQQK
+ExFXZWJNb25leSBUcmFuc2ZlcjEdMBsGA1UECxMUV2ViTW9uZXkgV2ViIFNlcnZp
+Y2UxGzAZBgNVBAMTEnczcy53bXRyYW5zZmVyLmNvbTCCASIwDQYJKoZIhvcNAQEB
+BQADggEPADCCAQoCggEBAJ0drRG+bzqrBk3IWMbtYMQZdYr501/c1NdnOWjyeFKt
+Ho8N2PKiAf9OOFywSSdCoFdDxp0PNK1GoBESyhi2xIuXRpvCzNyRb2Se3V3IpFS8
+VOu6V2GzFjc7xqS37MAgR6THCvULumh6w7DMY+HBU51CinuRbComR9+D4Yq8c6wx
+NnlI0HnkKE1H6fqLwDU+JhVrEJ64it6emghIazcEoZ+9Ld0rHdhrYsthxTwmC9mr
+YR6ayhde7BOn/B66XWtZE+7sFYkmC/547NuU+gMw7FoZ/iu3Vy3HPOvwtzbXbwVk
+lltVMtU2JD4+3UWlwMTbbPOQc5pDbC6GP56mIOy976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M8med8vSTYqZEX
-c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
-mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
------END CERTIFICATE-----
------BEGIN CERTIFICATE-----
-MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
-A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
-cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
-MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
-BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
-YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
-ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
-BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
-I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
-CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
-lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
-AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
------END CERTIFICATE-----
\ No newline at end of file
diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php
index 9513b28..af2e6b2 100644
--- a/src/Message/AbstractRequest.php
+++ b/src/Message/AbstractRequest.php
@@ -154,13 +154,13 @@ public function setCancelMethod($value)
/**
* Redirect method conversion table.
*/
- private static $methodsTable = array(
+ private static $methodsTable = [
'1' => '1',
'2' => '2',
'GET' => '0',
'POST' => '1',
'LINK' => '2',
- );
+ ];
/**
* Converts redirect method to WebMoney code: 0, 1 or 2.
@@ -171,7 +171,7 @@ public function setCancelMethod($value)
*/
public function formatMethod($method)
{
- $method = strtoupper((string) $method);
+ $method = strtoupper((string)$method);
return isset(self::$methodsTable[$method]) ? self::$methodsTable[$method] : '0';
}
@@ -251,8 +251,22 @@ public function getCurrencyByPurse($purse)
return 'BYR';
case 'X':
return 'BTC';
+ case 'T':
+ return 'USDT';
default:
return null;
}
}
+
+ public function getCurrencies()
+ {
+ if ($this->currencies === null) {
+ $this->currencies = new \Money\Currencies\AggregateCurrencies([
+ new \Money\Currencies\CryptoCurrencies(),
+ new \Money\Currencies\ISOCurrencies(),
+ ]);
+ }
+
+ return $this->currencies;
+ }
}
diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php
index 6abea0c..8bb81f6 100644
--- a/src/Message/CompletePurchaseRequest.php
+++ b/src/Message/CompletePurchaseRequest.php
@@ -23,35 +23,35 @@ public function getData()
'secretKey'
);
- return array(
- 'LMI_PAYEE_PURSE' => $this->httpRequest->request->get('LMI_PAYEE_PURSE'),
- 'LMI_PAYMENT_AMOUNT' => $this->httpRequest->request->get('LMI_PAYMENT_AMOUNT'),
- 'LMI_PAYMENT_NO' => $this->httpRequest->request->get('LMI_PAYMENT_NO'),
- 'LMI_MODE' => $this->httpRequest->request->get('LMI_MODE'),
- 'LMI_SYS_INVS_NO' => $this->httpRequest->request->get('LMI_SYS_INVS_NO'),
- 'LMI_SYS_TRANS_NO' => $this->httpRequest->request->get('LMI_SYS_TRANS_NO'),
- 'LMI_PAYER_PURSE' => $this->httpRequest->request->get('LMI_PAYER_PURSE'),
- 'LMI_PAYER_WM' => $this->httpRequest->request->get('LMI_PAYER_WM'),
- 'LMI_CAPITALLER_WMID' => $this->httpRequest->request->get('LMI_CAPITALLER_WMID'),
- 'LMI_PAYMER_NUMBER' => $this->httpRequest->request->get('LMI_PAYMER_NUMBER'),
- 'LMI_PAYMER_EMAIL' => $this->httpRequest->request->get('LMI_PAYMER_EMAIL'),
- 'LMI_EURONOTE_NUMBER' => $this->httpRequest->request->get('LMI_EURONOTE_NUMBER'),
- 'LMI_EURONOTE_EMAIL' => $this->httpRequest->request->get('LMI_EURONOTE_EMAIL'),
- 'LMI_WMCHECK_NUMBER' => $this->httpRequest->request->get('LMI_WMCHECK_NUMBER'),
+ return [
+ 'LMI_PAYEE_PURSE' => $this->httpRequest->request->get('LMI_PAYEE_PURSE'),
+ 'LMI_PAYMENT_AMOUNT' => $this->httpRequest->request->get('LMI_PAYMENT_AMOUNT'),
+ 'LMI_PAYMENT_NO' => $this->httpRequest->request->get('LMI_PAYMENT_NO'),
+ 'LMI_MODE' => $this->httpRequest->request->get('LMI_MODE'),
+ 'LMI_SYS_INVS_NO' => $this->httpRequest->request->get('LMI_SYS_INVS_NO'),
+ 'LMI_SYS_TRANS_NO' => $this->httpRequest->request->get('LMI_SYS_TRANS_NO'),
+ 'LMI_PAYER_PURSE' => $this->httpRequest->request->get('LMI_PAYER_PURSE'),
+ 'LMI_PAYER_WM' => $this->httpRequest->request->get('LMI_PAYER_WM'),
+ 'LMI_CAPITALLER_WMID' => $this->httpRequest->request->get('LMI_CAPITALLER_WMID'),
+ 'LMI_PAYMER_NUMBER' => $this->httpRequest->request->get('LMI_PAYMER_NUMBER'),
+ 'LMI_PAYMER_EMAIL' => $this->httpRequest->request->get('LMI_PAYMER_EMAIL'),
+ 'LMI_EURONOTE_NUMBER' => $this->httpRequest->request->get('LMI_EURONOTE_NUMBER'),
+ 'LMI_EURONOTE_EMAIL' => $this->httpRequest->request->get('LMI_EURONOTE_EMAIL'),
+ 'LMI_WMCHECK_NUMBER' => $this->httpRequest->request->get('LMI_WMCHECK_NUMBER'),
'LMI_TELEPAT_PHONENUMBER' => $this->httpRequest->request->get('LMI_TELEPAT_PHONENUMBER'),
- 'LMI_TELEPAT_ORDERID' => $this->httpRequest->request->get('LMI_TELEPAT_ORDERID'),
- 'LMI_PAYMENT_CREDITDAYS' => $this->httpRequest->request->get('LMI_PAYMENT_CREDITDAYS'),
- 'LMI_HASH' => $this->httpRequest->request->get('LMI_HASH'),
- 'LMI_SYS_TRANS_DATE' => $this->httpRequest->request->get('LMI_SYS_TRANS_DATE'),
- 'LMI_SECRET_KEY' => $this->httpRequest->request->get('LMI_SECRET_KEY'),
- 'LMI_SDP_TYPE' => $this->httpRequest->request->get('LMI_SDP_TYPE'),
- 'LMI_PAYMENT_DESC' => $this->httpRequest->request->get('LMI_PAYMENT_DESC'),
- 'LMI_PAYER_COUNTRYID' => $this->httpRequest->request->get('LMI_PAYER_COUNTRYID'),
- 'LMI_PAYER_PCOUNTRYID' => $this->httpRequest->request->get('LMI_PAYER_PCOUNTRYID'),
- 'LMI_PAYER_IP' => $this->httpRequest->request->get('LMI_PAYER_IP'),
- 'LMI_LANG' => $this->httpRequest->request->get('LMI_LANG'),
- 'LMI_DBLCHK' => $this->httpRequest->request->get('LMI_DBLCHK'),
- );
+ 'LMI_TELEPAT_ORDERID' => $this->httpRequest->request->get('LMI_TELEPAT_ORDERID'),
+ 'LMI_PAYMENT_CREDITDAYS' => $this->httpRequest->request->get('LMI_PAYMENT_CREDITDAYS'),
+ 'LMI_HASH' => $this->httpRequest->request->get('LMI_HASH'),
+ 'LMI_SYS_TRANS_DATE' => $this->httpRequest->request->get('LMI_SYS_TRANS_DATE'),
+ 'LMI_SECRET_KEY' => $this->httpRequest->request->get('LMI_SECRET_KEY'),
+ 'LMI_SDP_TYPE' => $this->httpRequest->request->get('LMI_SDP_TYPE'),
+ 'LMI_PAYMENT_DESC' => $this->httpRequest->request->get('LMI_PAYMENT_DESC'),
+ 'LMI_PAYER_COUNTRYID' => $this->httpRequest->request->get('LMI_PAYER_COUNTRYID'),
+ 'LMI_PAYER_PCOUNTRYID' => $this->httpRequest->request->get('LMI_PAYER_PCOUNTRYID'),
+ 'LMI_PAYER_IP' => $this->httpRequest->request->get('LMI_PAYER_IP'),
+ 'LMI_LANG' => $this->httpRequest->request->get('LMI_LANG'),
+ 'LMI_DBLCHK' => $this->httpRequest->request->get('LMI_DBLCHK'),
+ ];
}
/**
diff --git a/src/Message/CompletePurchaseResponse.php b/src/Message/CompletePurchaseResponse.php
index fae0dbf..8e787b4 100644
--- a/src/Message/CompletePurchaseResponse.php
+++ b/src/Message/CompletePurchaseResponse.php
@@ -62,7 +62,7 @@ public function getCurrency()
public function getTestMode()
{
- return (bool) $this->getMode();
+ return (bool)$this->getMode();
}
public function getMode()
@@ -114,18 +114,20 @@ private function calculateHash()
throw new InvalidResponseException('Invalid signature type');
}
- return strtoupper(hash(
- $hashType,
- $this->data['LMI_PAYEE_PURSE'].
- $this->data['LMI_PAYMENT_AMOUNT'].
- $this->data['LMI_PAYMENT_NO'].
- $this->data['LMI_MODE'].
- $this->data['LMI_SYS_INVS_NO'].
- $this->data['LMI_SYS_TRANS_NO'].
- $this->data['LMI_SYS_TRANS_DATE'].
- $this->request->getSecretkey().
- $this->data['LMI_PAYER_PURSE'].
- $this->data['LMI_PAYER_WM']
- ));
+ return strtoupper(
+ hash(
+ $hashType,
+ $this->data['LMI_PAYEE_PURSE'] .
+ $this->data['LMI_PAYMENT_AMOUNT'] .
+ $this->data['LMI_PAYMENT_NO'] .
+ $this->data['LMI_MODE'] .
+ $this->data['LMI_SYS_INVS_NO'] .
+ $this->data['LMI_SYS_TRANS_NO'] .
+ $this->data['LMI_SYS_TRANS_DATE'] .
+ $this->request->getSecretkey() .
+ $this->data['LMI_PAYER_PURSE'] .
+ $this->data['LMI_PAYER_WM']
+ )
+ );
}
}
diff --git a/src/Message/FetchTransactionRequest.php b/src/Message/FetchTransactionRequest.php
index dfc332c..0ef745e 100644
--- a/src/Message/FetchTransactionRequest.php
+++ b/src/Message/FetchTransactionRequest.php
@@ -55,9 +55,10 @@ public function getData()
public function sendData($data)
{
- $httpResponse = $this->httpClient->post($this->endpoint, null, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->endpoint, [], $data);
+ $xml = simplexml_load_string($httpResponse->getBody()->getContents());
- return $this->createResponse($httpResponse->xml());
+ return $this->createResponse($xml);
}
protected function createResponse($data)
@@ -69,9 +70,9 @@ protected function calculateSignature($algorithm)
{
return hash(
$algorithm,
- $this->getWebMoneyId().
- $this->getMerchantPurse().
- $this->getTransactionId().
+ $this->getWebMoneyId() .
+ $this->getMerchantPurse() .
+ $this->getTransactionId() .
$this->getSecretKey()
);
}
diff --git a/src/Message/FetchTransactionResponse.php b/src/Message/FetchTransactionResponse.php
index 4f3c484..7d08f96 100644
--- a/src/Message/FetchTransactionResponse.php
+++ b/src/Message/FetchTransactionResponse.php
@@ -28,33 +28,33 @@ public function isSuccessful()
public function getCode()
{
- return (int) $this->data->retval;
+ return (int)$this->data->retval;
}
public function getMessage()
{
- $message = (string) $this->data->retdesc;
+ $message = (string)$this->data->retdesc;
return $message ? $message : null;
}
public function getTransactionReference()
{
- return $this->data->operation ? (string) $this->data->operation->attributes()->wmtransid : null;
+ return $this->data->operation ? (string)$this->data->operation->attributes()->wmtransid : null;
}
public function getDescription()
{
- return $this->data->operation ? (string) $this->data->operation->purpose : null;
+ return $this->data->operation ? (string)$this->data->operation->purpose : null;
}
public function getAmount()
{
- return $this->data->operation ? (string) $this->data->operation->amount : null;
+ return $this->data->operation ? (string)$this->data->operation->amount : null;
}
public function getClientIp()
{
- return $this->data->operation ? (string) $this->data->operation->IPAddress : null;
+ return $this->data->operation ? (string)$this->data->operation->IPAddress : null;
}
}
diff --git a/src/Message/PayoutRequest.php b/src/Message/PayoutRequest.php
index e30e279..05763a1 100644
--- a/src/Message/PayoutRequest.php
+++ b/src/Message/PayoutRequest.php
@@ -2,6 +2,7 @@
namespace Omnipay\WebMoney\Message;
+use Guzzle\Http\Client;
use Omnipay\Common\Exception\InvalidRequestException;
/**
@@ -57,7 +58,7 @@ public function getRequestNumber()
{
$requestNumber = $this->getParameter('requestNumber');
- return $requestNumber ? $requestNumber : (string) time();
+ return $requestNumber ? $requestNumber : (string)time();
}
/**
@@ -86,7 +87,7 @@ public function setRequestNumber($value)
*/
public function getProtectionPeriod()
{
- return (int) $this->getParameter('protectionPeriod');
+ return (int)$this->getParameter('protectionPeriod');
}
/**
@@ -142,7 +143,7 @@ public function setProtectionCode($value)
*/
public function getInvoiceId()
{
- return (int) $this->getParameter('invoiceId');
+ return (int)$this->getParameter('invoiceId');
}
/**
@@ -174,7 +175,7 @@ public function setInvoiceId($value)
*/
public function getOnlyAuth()
{
- return (int) $this->getParameter('onlyAuth');
+ return (int)$this->getParameter('onlyAuth');
}
/**
@@ -275,20 +276,29 @@ public function getData()
return $document->saveXML();
}
+ /**
+ * @return Client
+ */
+ protected function getHttpClient()
+ {
+ return new Client($this->endpoint);
+ }
+
public function sendData($data)
{
- $this->httpClient->setConfig(array(
- 'curl.options' => array(
- CURLOPT_CAINFO => $this->getCertificatePath('WMUsedRootCAs.crt'),
- CURLOPT_SSLCERT => $this->getSslFile(),
- CURLOPT_SSLKEY => $this->getSslKey(),
- CURLOPT_SSLVERSION => 1,
+ $client = $this->getHttpClient();
+ $client->setConfig([
+ Client::CURL_OPTIONS => [
+ CURLOPT_CAINFO => $this->getCertificatePath('WMUsedRootCAs.crt'),
+ CURLOPT_SSLCERT => $this->getSslFile(),
+ CURLOPT_SSLKEY => $this->getSslKey(),
+ CURLOPT_SSLVERSION => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => 1,
- ),
- ));
+ ],
+ ]);
- $httpResponse = $this->httpClient->post($this->endpoint, null, $data)->send();
+ $httpResponse = $client->post($this->endpoint, [], $data)->send();
return $this->createResponse($httpResponse->xml());
}
@@ -300,10 +310,6 @@ protected function createResponse($data)
protected function getCertificatePath($fileName)
{
- $class = new \ReflectionObject($this);
- $directory = dirname($class->getFileName());
- $file = realpath($directory.'/../Certificate/'.$fileName);
-
- return $file;
+ return __DIR__ . '/../Certificate/' . $fileName;
}
}
diff --git a/src/Message/PayoutResponse.php b/src/Message/PayoutResponse.php
index fb9e094..4f8aa3f 100644
--- a/src/Message/PayoutResponse.php
+++ b/src/Message/PayoutResponse.php
@@ -28,33 +28,33 @@ public function isSuccessful()
public function getCode()
{
- return (int) $this->data->retval;
+ return (int)$this->data->retval;
}
public function getMessage()
{
- $message = (string) $this->data->retdesc;
+ $message = (string)$this->data->retdesc;
return $message ? $message : null;
}
public function getTransactionId()
{
- return $this->data->operation ? (string) $this->data->operation->tranid : null;
+ return $this->data->operation ? (string)$this->data->operation->tranid : null;
}
public function getTransactionReference()
{
- return $this->data->operation ? (string) $this->data->operation->attributes()->id : null;
+ return $this->data->operation ? (string)$this->data->operation->attributes()->id : null;
}
public function getDescription()
{
- return $this->data->operation ? (string) $this->data->operation->desc : null;
+ return $this->data->operation ? (string)$this->data->operation->desc : null;
}
public function getAmount()
{
- return $this->data->operation ? (string) $this->data->operation->amount : null;
+ return $this->data->operation ? (string)$this->data->operation->amount : null;
}
}
diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php
index 4b393cb..c14acde 100644
--- a/src/Message/PurchaseRequest.php
+++ b/src/Message/PurchaseRequest.php
@@ -15,12 +15,12 @@
class PurchaseRequest extends AbstractRequest
{
/**
- * @return int
+ * @return string
*/
public function getHold()
{
if ($hold = $this->getParameter('hold')) {
- return (string) $hold;
+ return (string)$hold;
}
return '0';
@@ -36,6 +36,51 @@ public function setHold($value)
return $this->setParameter('hold', $value);
}
+ /**
+ * @return array
+ */
+ public function getCustomFields()
+ {
+ return $this->getParameter('customFields') ?? [];
+ }
+
+ /**
+ * @param array $fields
+ *
+ * @return $this
+ * @throws \Exception
+ */
+ public function setCustomFields(array $fields)
+ {
+ $customFields = [];
+ foreach ($fields as $field => $value) {
+ if (is_numeric($field)) {
+ $field++;
+ $field = "FIELD_$field";
+ }
+
+ $field = strtoupper($field);
+
+ if (substr($field, 0, 1) === '_') {
+ throw new \Exception('"_" prefix is not allowed for custom fields');
+ }
+
+ if (substr($field, 0, 4) === 'LMI_') {
+ throw new \Exception('"LMI_" prefix is not allowed for custom fields');
+ }
+
+ if (!is_scalar($value)) {
+ throw new \Exception('Value must be a scalar');
+ }
+
+ $customFields[$field] = (string)$value;
+ }
+
+ $this->setParameter('customFields', $customFields);
+
+ return $this;
+ }
+
/**
* @return array
* @throws InvalidRequestException
@@ -57,7 +102,7 @@ public function getData()
throw new InvalidRequestException('Invalid currency for this merchant purse');
}
- return array(
+ $data = [
'LMI_PAYEE_PURSE' => $this->getMerchantPurse(),
'LMI_PAYMENT_AMOUNT' => $this->getAmount(),
'LMI_PAYMENT_NO' => $this->getTransactionId(),
@@ -68,8 +113,16 @@ public function getData()
'LMI_SUCCESS_METHOD' => $this->getReturnMethod(),
'LMI_FAIL_URL' => $this->getCancelUrl(),
'LMI_FAIL_METHOD' => $this->getCancelMethod(),
- 'LMI_HOLD' => $this->getHold()
- );
+ 'LMI_HOLD' => $this->getHold(),
+ ];
+
+ foreach ($this->getCustomFields() as $variable => $value) {
+ if (!isset($data[$variable])) {
+ $data[$variable] = $value;
+ }
+ }
+
+ return $data;
}
/**
diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php
index 47785e5..ed5937a 100644
--- a/tests/GatewayTest.php
+++ b/tests/GatewayTest.php
@@ -9,7 +9,7 @@ class GatewayTest extends GatewayTestCase
public $sslFile;
public $sslKey;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/Message/CompletePurchaseRequestTest.php b/tests/Message/CompletePurchaseRequestTest.php
index 6776893..83b8423 100644
--- a/tests/Message/CompletePurchaseRequestTest.php
+++ b/tests/Message/CompletePurchaseRequestTest.php
@@ -1,4 +1,5 @@
'1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $httpRequest = new HttpRequest([], [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
- $this->request->initialize(array(
+ $this->request->initialize([
'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'testMode' => true
- ));
+ 'secretKey' => '226778888',
+ 'testMode' => true,
+ ]);
}
public function testGetData()
@@ -63,6 +64,6 @@ public function testSendData()
{
$data = $this->request->getData();
$response = $this->request->sendData($data);
- $this->assertSame('Omnipay\WebMoney\Message\CompletePurchaseResponse', get_class($response));
+ $this->assertInstanceOf(CompletePurchaseResponse::class, $response);
}
}
diff --git a/tests/Message/CompletePurchaseResponseTest.php b/tests/Message/CompletePurchaseResponseTest.php
index 7360f29..74d5f3b 100644
--- a/tests/Message/CompletePurchaseResponseTest.php
+++ b/tests/Message/CompletePurchaseResponseTest.php
@@ -1,87 +1,91 @@
request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
- $this->request->initialize(array(
+ $this->request->initialize([
'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'testMode' => true
- ));
+ 'secretKey' => '226778888',
+ 'testMode' => true,
+ ]);
}
public function testSignHashException()
{
- $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Invalid hash');
- new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $this->expectException(InvalidResponseException::class);
+ $this->expectExceptionMessage('Invalid hash');
+ new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E1',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E1',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
}
public function testInvalidTestModeException()
{
- $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Invalid test mode');
- new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '0',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $this->expectException(InvalidResponseException::class);
+ $this->expectExceptionMessage('Invalid test mode');
+ new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '0',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '4F7D9FD1177DFDAE182F0E470296080DC47A843A32826147555F5C8959E7F6DD',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '4F7D9FD1177DFDAE182F0E470296080DC47A843A32826147555F5C8959E7F6DD',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
}
public function testSuccess()
{
- $response = new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $response = new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getCode());
@@ -98,23 +102,23 @@ public function testSuccess()
public function testSha256Hash()
{
- $response = new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $response = new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '0B12E75431284D6FCC05D8AF02B90AC28A0788FB95C9FF6B655344022F0746E5',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getCode());
@@ -132,23 +136,23 @@ public function testSha256Hash()
public function testMd5Hash()
{
- $response = new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $response = new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '1D3FFAFA982B134479C4AD1AE2CABB5C',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '1D3FFAFA982B134479C4AD1AE2CABB5C',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getCode());
@@ -166,45 +170,47 @@ public function testMd5Hash()
public function testInvalidHashTypeException()
{
- $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Control sign forming method "SIGN" is not supported');
- new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $this->expectException(InvalidResponseException::class);
+ $this->expectExceptionMessage('Control sign forming method "SIGN" is not supported');
+ new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => '2E2A8871CBB577DE4AB3E47EBFA100EB8AD9C7AF6FB5580169B8273409863941BDA16647D2D2619D8FFF946D319FE35D758844214B02F46CBA7AE35AFE3F86940069',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => '2E2A8871CBB577DE4AB3E47EBFA100EB8AD9C7AF6FB5580169B8273409863941BDA16647D2D2619D8FFF946D319FE35D758844214B02F46CBA7AE35AFE3F86940069',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
}
public function testInvalidSignatureTypeException()
{
- $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Invalid signature type');
- new CompletePurchaseResponse($this->request, array(
- 'LMI_MODE' => '1',
- 'LMI_PAYMENT_AMOUNT' => '14.65',
- 'LMI_PAYEE_PURSE' => 'Z123428476799',
- 'LMI_PAYMENT_NO' => '1444212666',
- 'LMI_PAYER_WM' => '404521188333',
- 'LMI_PAYER_PURSE' => 'Z366393600555',
+ $this->expectException(InvalidResponseException::class);
+ $this->expectExceptionMessage('Invalid signature type');
+ new CompletePurchaseResponse($this->request, [
+ 'LMI_MODE' => '1',
+ 'LMI_PAYMENT_AMOUNT' => '14.65',
+ 'LMI_PAYEE_PURSE' => 'Z123428476799',
+ 'LMI_PAYMENT_NO' => '1444212666',
+ 'LMI_PAYER_WM' => '404521188333',
+ 'LMI_PAYER_PURSE' => 'Z366393600555',
'LMI_PAYER_COUNTRYID' => 'AZ',
- 'LMI_PAYER_IP' => '127.0.0.1',
- 'LMI_SYS_INVS_NO' => '897',
- 'LMI_SYS_TRANS_NO' => '892',
- 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
- 'LMI_HASH' => 'ABD',
- 'LMI_PAYMENT_DESC' => 'Test',
- 'LMI_LANG' => 'en-US',
- 'LMI_DBLCHK' => 'SMS'
- ));
+ 'LMI_PAYER_IP' => '127.0.0.1',
+ 'LMI_SYS_INVS_NO' => '897',
+ 'LMI_SYS_TRANS_NO' => '892',
+ 'LMI_SYS_TRANS_DATE' => '20151007 13:07:36',
+ 'LMI_HASH' => 'ABD',
+ 'LMI_PAYMENT_DESC' => 'Test',
+ 'LMI_LANG' => 'en-US',
+ 'LMI_DBLCHK' => 'SMS',
+ ]);
}
}
diff --git a/tests/Message/FetchTransactionRequestTest.php b/tests/Message/FetchTransactionRequestTest.php
index e74d688..e5c3f36 100644
--- a/tests/Message/FetchTransactionRequestTest.php
+++ b/tests/Message/FetchTransactionRequestTest.php
@@ -1,4 +1,5 @@
addResponse($this->getMockHttpResponse('FetchTransactionSuccess.txt'));
+ $this->getMockClient()->addResponse(
+ $this->getMockHttpResponse('FetchTransactionSuccess.txt')
+ );
$httpClient = $this->getHttpClient();
- $httpClient->addSubscriber($mockPlugin);
$this->request = new FetchTransactionRequest($httpClient, $this->getHttpRequest());
- $this->request->initialize(array(
- 'webMoneyId' => '811333344777',
+ $this->request->initialize([
+ 'webMoneyId' => '811333344777',
'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'transactionId' => '1444212666'
- ));
+ 'secretKey' => '226778888',
+ 'transactionId' => '1444212666',
+ ]);
}
public function testGetData()
@@ -31,17 +32,17 @@ public function testGetData()
$data = $this->request->getData();
$request = new \SimpleXMLElement($data);
- $this->assertSame('811333344777', (string) $request->wmid);
- $this->assertSame('Z123428476799', (string) $request->lmi_payee_purse);
- $this->assertSame('1444212666', (string) $request->lmi_payment_no);
- $this->assertSame('0b1fbe2eaccf29e86e144c486b2ccf258b56fb54c295f195af7a749f6f5c79d4', (string) $request->sha256);
- $this->assertSame('edd00dcbfed2c3846393e9ce315b3af2', (string) $request->md5);
+ $this->assertSame('811333344777', (string)$request->wmid);
+ $this->assertSame('Z123428476799', (string)$request->lmi_payee_purse);
+ $this->assertSame('1444212666', (string)$request->lmi_payment_no);
+ $this->assertSame('0b1fbe2eaccf29e86e144c486b2ccf258b56fb54c295f195af7a749f6f5c79d4', (string)$request->sha256);
+ $this->assertSame('edd00dcbfed2c3846393e9ce315b3af2', (string)$request->md5);
}
public function testSendData()
{
$data = $this->request->getData();
$response = $this->request->sendData($data);
- $this->assertSame('Omnipay\WebMoney\Message\FetchTransactionResponse', get_class($response));
+ $this->assertInstanceOf(\Omnipay\WebMoney\Message\FetchTransactionResponse::class, $response);
}
}
diff --git a/tests/Message/FetchTransactionResponseTest.php b/tests/Message/FetchTransactionResponseTest.php
index 310e7b7..2d1449b 100644
--- a/tests/Message/FetchTransactionResponseTest.php
+++ b/tests/Message/FetchTransactionResponseTest.php
@@ -1,4 +1,5 @@
request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest());
- $this->request->initialize(array(
+ $this->request->initialize([
'webMoneyId' => '811333344777',
'merchantPurse' => 'Z123428476799',
'secretKey' => '226778888',
- 'transactionId' => '1444212666'
- ));
+ 'transactionId' => '1444212666',
+ ]);
}
public function testFailure()
{
$httpResponse = $this->getMockHttpResponse('FetchTransactionFailure.txt');
- $response = new FetchTransactionResponse($this->request, $httpResponse->xml());
+ $xml = simplexml_load_string($httpResponse->getBody()->getContents());
+ $response = new FetchTransactionResponse($this->request, $xml);
$this->assertFalse($response->isSuccessful());
$this->assertSame(7, $response->getCode());
- $this->assertSame('Payment with lmi_payment_no number not found for this merchant purse:7 step=50', $response->getMessage());
+ $this->assertSame(
+ 'Payment with lmi_payment_no number not found for this merchant purse:7 step=50',
+ $response->getMessage()
+ );
$this->assertNull($response->getTransactionReference());
$this->assertNull($response->getDescription());
$this->assertNull($response->getAmount());
@@ -38,7 +43,8 @@ public function testFailure()
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('FetchTransactionSuccess.txt');
- $response = new FetchTransactionResponse($this->request, $httpResponse->xml());
+ $xml = simplexml_load_string($httpResponse->getBody()->getContents());
+ $response = new FetchTransactionResponse($this->request, $xml);
$this->assertTrue($response->isSuccessful());
$this->assertSame(0, $response->getCode());
diff --git a/tests/Message/PayoutRequestTest.php b/tests/Message/PayoutRequestTest.php
index 11900c8..d81324d 100644
--- a/tests/Message/PayoutRequestTest.php
+++ b/tests/Message/PayoutRequestTest.php
@@ -1,45 +1,56 @@
getFileName());
$sslFile = realpath($directory . '/../Certificate/webmoney.pem');
$sslKey = realpath($directory . '/../Certificate/webmoney.key');
$mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
- $mockPlugin->addResponse($this->getMockHttpResponse('PayoutSuccess.txt'));
+ $mockPlugin->addResponse(__DIR__ . '/../Mock/PayoutSuccess.txt');
- $httpClient = $this->getHttpClient();
+ $httpClient = new Client();
$httpClient->addSubscriber($mockPlugin);
- $this->request = new PayoutRequest($httpClient, $this->getHttpRequest());
- $this->request->initialize(array(
- 'webMoneyId' => '811333344777',
- 'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'sslFile' => $sslFile,
- 'sslKey' => $sslKey,
- 'transactionId' => '1444111666',
- 'requestNumber' => '111222333',
- 'customerPurse' => 'Z123428476700',
- 'protectionPeriod' => '60',
- 'protectionCode' => 'xyZ123',
- 'invoiceId' => '12345678',
- 'onlyAuth' => false,
- 'description' => 'Payout',
- 'currency' => 'USD',
- 'amount' => '12.46'
- ));
+ $this->request = $this->getMockBuilder(PayoutRequest::class)
+ ->onlyMethods(['getHttpClient'])
+ ->setConstructorArgs([$this->getHttpClient(), $this->getHttpRequest()])
+ ->getMock();
+
+ $this->request->method('getHttpClient')->willReturn($httpClient);
+ $this->request->initialize([
+ 'webMoneyId' => '811333344777',
+ 'merchantPurse' => 'Z123428476799',
+ 'secretKey' => '226778888',
+ 'sslFile' => $sslFile,
+ 'sslKey' => $sslKey,
+ 'transactionId' => '1444111666',
+ 'requestNumber' => '111222333',
+ 'customerPurse' => 'Z123428476700',
+ 'protectionPeriod' => '60',
+ 'protectionCode' => 'xyZ123',
+ 'invoiceId' => '12345678',
+ 'onlyAuth' => false,
+ 'description' => 'Payout',
+ 'currency' => 'USD',
+ 'amount' => '12.46',
+ ]
+ );
}
public function testException()
@@ -49,33 +60,26 @@ public function testException()
try {
$this->request->getData();
} catch (\Exception $e) {
- $this->assertEquals('Omnipay\Common\Exception\InvalidRequestException', get_class($e));
+ $this->assertInstanceOf(\Omnipay\Common\Exception\InvalidRequestException::class, $e);
}
}
public function testGetData()
{
$data = $this->request->getData();
- $request = new \SimpleXMLElement($data);
-
- $this->assertSame('111222333', (string) $request->reqn);
- $this->assertSame('', (string) $request->wmid);
- $this->assertSame('', (string) $request->sign);
- $this->assertSame('1444111666', (string) $request->trans->tranid);
- $this->assertSame('Z123428476799', (string) $request->trans->pursesrc);
- $this->assertSame('Z123428476700', (string) $request->trans->pursedest);
- $this->assertSame('12.46', (string) $request->trans->amount);
- $this->assertSame('60', (string) $request->trans->period);
- $this->assertSame('xyZ123', (string) $request->trans->pcode);
- $this->assertSame('Payout', (string) $request->trans->desc);
- $this->assertSame('12345678', (string) $request->trans->wminvid);
- $this->assertSame('0', (string) $request->trans->onlyauth);
- }
+ $request = new SimpleXMLElement($data);
- public function testSendData()
- {
- $data = $this->request->getData();
- $response = $this->request->sendData($data);
- $this->assertSame('Omnipay\WebMoney\Message\PayoutResponse', get_class($response));
+ $this->assertSame('111222333', (string)$request->reqn);
+ $this->assertSame('', (string)$request->wmid);
+ $this->assertSame('', (string)$request->sign);
+ $this->assertSame('1444111666', (string)$request->trans->tranid);
+ $this->assertSame('Z123428476799', (string)$request->trans->pursesrc);
+ $this->assertSame('Z123428476700', (string)$request->trans->pursedest);
+ $this->assertSame('12.46', (string)$request->trans->amount);
+ $this->assertSame('60', (string)$request->trans->period);
+ $this->assertSame('xyZ123', (string)$request->trans->pcode);
+ $this->assertSame('Payout', (string)$request->trans->desc);
+ $this->assertSame('12345678', (string)$request->trans->wminvid);
+ $this->assertSame('0', (string)$request->trans->onlyauth);
}
}
diff --git a/tests/Message/PayoutResponseTest.php b/tests/Message/PayoutResponseTest.php
index 3bfed6b..308cf8e 100644
--- a/tests/Message/PayoutResponseTest.php
+++ b/tests/Message/PayoutResponseTest.php
@@ -1,4 +1,5 @@
request = new PayoutRequest($this->getHttpClient(), $this->getHttpRequest());
- $this->request->initialize(array(
- 'webMoneyId' => '811333344777',
- 'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'sslFile' => $sslFile,
- 'sslKey' => $sslKey,
- 'transactionId' => '1444111666',
- 'requestNumber' => '111222333',
- 'customerPurse' => 'Z123428476700',
+ $this->request->initialize([
+ 'webMoneyId' => '811333344777',
+ 'merchantPurse' => 'Z123428476799',
+ 'secretKey' => '226778888',
+ 'sslFile' => $sslFile,
+ 'sslKey' => $sslKey,
+ 'transactionId' => '1444111666',
+ 'requestNumber' => '111222333',
+ 'customerPurse' => 'Z123428476700',
'protectionPeriod' => '60',
- 'protectionCode' => 'xyZ123',
- 'invoiceId' => '12345678',
- 'onlyAuth' => false,
- 'description' => 'Payout',
- 'amount' => '12.46'
- ));
+ 'protectionCode' => 'xyZ123',
+ 'invoiceId' => '12345678',
+ 'onlyAuth' => false,
+ 'description' => 'Payout',
+ 'amount' => '12.46',
+ ]);
}
public function testFailure()
{
$httpResponse = $this->getMockHttpResponse('PayoutFailure.txt');
- $response = new PayoutResponse($this->request, $httpResponse->xml());
+ $xml = simplexml_load_string($httpResponse->getBody()->getContents());
+ $response = new PayoutResponse($this->request, $xml);
$this->assertFalse($response->isSuccessful());
$this->assertSame(17, $response->getCode());
@@ -53,7 +55,8 @@ public function testFailure()
public function testSuccess()
{
$httpResponse = $this->getMockHttpResponse('PayoutSuccess.txt');
- $response = new PayoutResponse($this->request, $httpResponse->xml());
+ $xml = simplexml_load_string($httpResponse->getBody()->getContents());
+ $response = new PayoutResponse($this->request, $xml);
$this->assertTrue($response->isSuccessful());
$this->assertSame(0, $response->getCode());
diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php
index d5f7079..97e7bab 100644
--- a/tests/Message/PurchaseRequestTest.php
+++ b/tests/Message/PurchaseRequestTest.php
@@ -1,31 +1,40 @@
request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
- $this->request->initialize(array(
+ $this->request->initialize([
'merchantPurse' => 'Z123428476799',
- 'secretKey' => '226778888',
- 'returnUrl' => 'https://www.foodstore.com/success',
- 'cancelUrl' => 'https://www.foodstore.com/failure',
- 'notifyUrl' => 'https://www.foodstore.com/notify',
- 'returnMethod' => 'POST',
- 'cancelMethod' => 'link',
- 'description' => 'Test Transaction',
+ 'secretKey' => '226778888',
+ 'returnUrl' => 'https://www.foodstore.com/success',
+ 'cancelUrl' => 'https://www.foodstore.com/failure',
+ 'notifyUrl' => 'https://www.foodstore.com/notify',
+ 'returnMethod' => 'POST',
+ 'cancelMethod' => 'link',
+ 'description' => 'Test Transaction',
'transactionId' => '1234567890',
- 'amount' => '14.65',
- 'currency' => 'USD',
- 'testMode' => true
- ));
+ 'amount' => '14.65',
+ 'currency' => 'USD',
+ 'testMode' => true,
+ 'customFields' => [
+ 'customerId' => 123,
+ 'first_name' => 'John',
+ 'last_name' => 'Doe',
+ 'No-Key',
+ '1' => 'Numeric-Key',
+ ],
+ ]);
}
public function testException()
@@ -34,8 +43,8 @@ public function testException()
try {
$this->request->getData();
- } catch (\Exception $e) {
- $this->assertEquals('Omnipay\Common\Exception\InvalidRequestException', get_class($e));
+ } catch (Exception $e) {
+ $this->assertInstanceOf(\Omnipay\Common\Exception\InvalidRequestException::class, $e);
}
}
@@ -54,13 +63,18 @@ public function testGetData()
$this->assertSame('https://www.foodstore.com/failure', $data['LMI_FAIL_URL']);
$this->assertSame('2', $data['LMI_FAIL_METHOD']);
$this->assertSame('0', $data['LMI_HOLD']);
+ $this->assertSame('123', $data['CUSTOMERID']);
+ $this->assertSame('John', $data['FIRST_NAME']);
+ $this->assertSame('Doe', $data['LAST_NAME']);
+ $this->assertSame('No-Key', $data['FIELD_1']);
+ $this->assertSame('Numeric-Key', $data['FIELD_2']);
}
public function testSendData()
{
$data = $this->request->getData();
$response = $this->request->sendData($data);
- $this->assertSame('Omnipay\WebMoney\Message\PurchaseResponse', get_class($response));
+ $this->assertInstanceOf(\Omnipay\WebMoney\Message\PurchaseResponse::class, $response);
}
public function testGetCurrencyByPurse()
@@ -73,6 +87,42 @@ public function testGetCurrencyByPurse()
$this->assertSame('UZS', $this->request->getCurrencyByPurse('Y123428476799'));
$this->assertSame('BYR', $this->request->getCurrencyByPurse('B123428476799'));
$this->assertSame('BTC', $this->request->getCurrencyByPurse('X123428476799'));
+ $this->assertSame('USDT', $this->request->getCurrencyByPurse('T123428476799'));
$this->assertNull($this->request->getCurrencyByPurse('A123428476799'));
}
+
+ public function testCustomFields()
+ {
+ $this->request->setCustomFields([
+ 'field1' => 'John',
+ 'Field_2' => 'Doe',
+ ]);
+
+ $this->assertArrayHasKey('FIELD1', $this->request->getCustomFields());
+ $this->assertArrayHasKey('FIELD_2', $this->request->getCustomFields());
+ }
+
+ public function testInvalidCustomFields1()
+ {
+ $this->expectException('Exception');
+ $this->request->setCustomFields([
+ 'lmi_' => 'John',
+ ]);
+ }
+
+ public function testInvalidCustomFields2()
+ {
+ $this->expectException('Exception');
+ $this->request->setCustomFields([
+ '_test' => 'Doe',
+ ]);
+ }
+
+ public function testInvalidCustomFields3()
+ {
+ $this->expectException('Exception');
+ $this->request->setCustomFields([
+ 'array' => [1, 2, 3],
+ ]);
+ }
}
diff --git a/tests/Message/PurchaseResponseTest.php b/tests/Message/PurchaseResponseTest.php
index c951719..e38e576 100644
--- a/tests/Message/PurchaseResponseTest.php
+++ b/tests/Message/PurchaseResponseTest.php
@@ -1,4 +1,5 @@
request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
- $this->request->initialize(array(
+ $this->request->initialize([
'merchantPurse' => 'Z123428476799',
'secretKey' => '226778888',
'returnUrl' => 'https://www.foodstore.com/success',
@@ -23,8 +24,8 @@ public function setUp()
'amount' => '14.65',
'currency' => 'USD',
'testMode' => true,
- 'hold' => 2
- ));
+ 'hold' => 2,
+ ]);
}
public function testSuccess()
@@ -37,7 +38,7 @@ public function testSuccess()
$this->assertNull($response->getMessage());
$this->assertSame('POST', $response->getRedirectMethod());
$this->assertSame('https://merchant.wmtransfer.com/lmi/payment.asp', $response->getRedirectUrl());
- $this->assertSame(array(
+ $this->assertSame([
'LMI_PAYEE_PURSE' => 'Z123428476799',
'LMI_PAYMENT_AMOUNT' => '14.65',
'LMI_PAYMENT_NO' => '1234567890',
@@ -48,7 +49,7 @@ public function testSuccess()
'LMI_SUCCESS_METHOD' => '0',
'LMI_FAIL_URL' => 'https://www.foodstore.com/failure',
'LMI_FAIL_METHOD' => '0',
- 'LMI_HOLD' => '2'
- ), $response->getRedirectData());
+ 'LMI_HOLD' => '2',
+ ], $response->getRedirectData());
}
}