diff --git a/.travis.yml b/.travis.yml index 30b6769..544f674 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,15 +6,12 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 - hhvm -matrix: - allow_failures: - - php: 7.0 - 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 +after_script: vendor/bin/coveralls -v \ No newline at end of file diff --git a/README.md b/README.md index 8933eec..a1b2620 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,8 @@ **WebMoney driver for the Omnipay PHP payment processing library** -[![Build Status](https://travis-ci.org/dercoder/omnipay-webmoney.png?branch=master)](https://travis-ci.org/dercoder/omnipay-webmoney) +[![Build Status](https://travis-ci.org/dercoder/omnipay-webmoney.svg?branch=master)](https://travis-ci.org/dercoder/omnipay-webmoney) [![Coverage Status](https://coveralls.io/repos/dercoder/omnipay-webmoney/badge.svg?branch=master&service=github)](https://coveralls.io/github/dercoder/omnipay-webmoney?branch=master) -[![Dependency Status](https://www.versioneye.com/user/projects/561d2ed236d0ab0021000009/badge.png)](https://www.versioneye.com/user/projects/561d2ed236d0ab0021000009) [![Latest Stable Version](https://poser.pugx.org/dercoder/omnipay-webmoney/v/stable.png)](https://packagist.org/packages/dercoder/omnipay-webmoney) [![Total Downloads](https://poser.pugx.org/dercoder/omnipay-webmoney/downloads.png)](https://packagist.org/packages/dercoder/omnipay-webmoney) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index ccf4555..9513b28 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -155,11 +155,11 @@ public function setCancelMethod($value) * Redirect method conversion table. */ private static $methodsTable = array( - '1' => '1', - '2' => '2', - 'GET' => '0', - 'POST' => '1', - 'LINK' => '2', + '1' => '1', + '2' => '2', + 'GET' => '0', + 'POST' => '1', + 'LINK' => '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'; } @@ -252,7 +252,7 @@ public function getCurrencyByPurse($purse) case 'X': return 'BTC'; default: - return; + return null; } } } diff --git a/src/Message/CompletePurchaseResponse.php b/src/Message/CompletePurchaseResponse.php index 6d54a90..fae0dbf 100644 --- a/src/Message/CompletePurchaseResponse.php +++ b/src/Message/CompletePurchaseResponse.php @@ -85,7 +85,7 @@ public function getHashType() case 132: return 'sign'; default: - return; + return null; } } diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 809a20b..4b393cb 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -9,11 +9,37 @@ * https://merchant.wmtransfer.com/conf/guide.asp. * * @author Alexander Fedra - * @copyright 2015 DerCoder + * @copyright 2017 DerCoder * @license http://opensource.org/licenses/mit-license.php MIT */ class PurchaseRequest extends AbstractRequest { + /** + * @return int + */ + public function getHold() + { + if ($hold = $this->getParameter('hold')) { + return (string) $hold; + } + + return '0'; + } + + /** + * @param int $value + * + * @return $this + */ + public function setHold($value) + { + return $this->setParameter('hold', $value); + } + + /** + * @return array + * @throws InvalidRequestException + */ public function getData() { $this->validate( @@ -32,19 +58,25 @@ public function getData() } return array( - 'LMI_PAYEE_PURSE' => $this->getMerchantPurse(), - 'LMI_PAYMENT_AMOUNT' => $this->getAmount(), - 'LMI_PAYMENT_NO' => $this->getTransactionId(), + 'LMI_PAYEE_PURSE' => $this->getMerchantPurse(), + 'LMI_PAYMENT_AMOUNT' => $this->getAmount(), + 'LMI_PAYMENT_NO' => $this->getTransactionId(), 'LMI_PAYMENT_DESC_BASE64' => base64_encode($this->getDescription()), - 'LMI_SIM_MODE' => $this->getTestMode() ? '2' : '0', - 'LMI_RESULT_URL' => $this->getNotifyUrl(), - 'LMI_SUCCESS_URL' => $this->getReturnUrl(), - 'LMI_SUCCESS_METHOD' => $this->getReturnMethod(), - 'LMI_FAIL_URL' => $this->getCancelUrl(), - 'LMI_FAIL_METHOD' => $this->getCancelMethod(), + 'LMI_SIM_MODE' => $this->getTestMode() ? '2' : '0', + 'LMI_RESULT_URL' => $this->getNotifyUrl(), + 'LMI_SUCCESS_URL' => $this->getReturnUrl(), + 'LMI_SUCCESS_METHOD' => $this->getReturnMethod(), + 'LMI_FAIL_URL' => $this->getCancelUrl(), + 'LMI_FAIL_METHOD' => $this->getCancelMethod(), + 'LMI_HOLD' => $this->getHold() ); } + /** + * @param array $data + * + * @return PurchaseResponse + */ public function sendData($data) { return $this->response = new PurchaseResponse($this, $data); diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index 3fd6dac..d5f7079 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -53,6 +53,7 @@ public function testGetData() $this->assertSame('1', $data['LMI_SUCCESS_METHOD']); $this->assertSame('https://www.foodstore.com/failure', $data['LMI_FAIL_URL']); $this->assertSame('2', $data['LMI_FAIL_METHOD']); + $this->assertSame('0', $data['LMI_HOLD']); } public function testSendData() diff --git a/tests/Message/PurchaseResponseTest.php b/tests/Message/PurchaseResponseTest.php index 10452de..c951719 100644 --- a/tests/Message/PurchaseResponseTest.php +++ b/tests/Message/PurchaseResponseTest.php @@ -14,15 +14,16 @@ public function setUp() $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'merchantPurse' => 'Z123428476799', - 'secretKey' => '226778888', - 'returnUrl' => 'https://www.foodstore.com/success', - 'cancelUrl' => 'https://www.foodstore.com/failure', - 'notifyUrl' => 'https://www.foodstore.com/notify', - 'description' => 'Test Transaction', + 'secretKey' => '226778888', + 'returnUrl' => 'https://www.foodstore.com/success', + 'cancelUrl' => 'https://www.foodstore.com/failure', + 'notifyUrl' => 'https://www.foodstore.com/notify', + 'description' => 'Test Transaction', 'transactionId' => '1234567890', - 'amount' => '14.65', - 'currency' => 'USD', - 'testMode' => true + 'amount' => '14.65', + 'currency' => 'USD', + 'testMode' => true, + 'hold' => 2 )); } @@ -37,16 +38,17 @@ public function testSuccess() $this->assertSame('POST', $response->getRedirectMethod()); $this->assertSame('https://merchant.wmtransfer.com/lmi/payment.asp', $response->getRedirectUrl()); $this->assertSame(array( - 'LMI_PAYEE_PURSE' => 'Z123428476799', - 'LMI_PAYMENT_AMOUNT' => '14.65', - 'LMI_PAYMENT_NO' => '1234567890', + 'LMI_PAYEE_PURSE' => 'Z123428476799', + 'LMI_PAYMENT_AMOUNT' => '14.65', + 'LMI_PAYMENT_NO' => '1234567890', 'LMI_PAYMENT_DESC_BASE64' => 'VGVzdCBUcmFuc2FjdGlvbg==', - 'LMI_SIM_MODE' => '2', - 'LMI_RESULT_URL' => 'https://www.foodstore.com/notify', - 'LMI_SUCCESS_URL' => 'https://www.foodstore.com/success', - 'LMI_SUCCESS_METHOD' => '0', - 'LMI_FAIL_URL' => 'https://www.foodstore.com/failure', - 'LMI_FAIL_METHOD' => '0' + 'LMI_SIM_MODE' => '2', + 'LMI_RESULT_URL' => 'https://www.foodstore.com/notify', + 'LMI_SUCCESS_URL' => 'https://www.foodstore.com/success', + 'LMI_SUCCESS_METHOD' => '0', + 'LMI_FAIL_URL' => 'https://www.foodstore.com/failure', + 'LMI_FAIL_METHOD' => '0', + 'LMI_HOLD' => '2' ), $response->getRedirectData()); } }