Skip to content

Commit

Permalink
Added LMI_HOLD
Browse files Browse the repository at this point in the history
  • Loading branch information
dercoder committed Jan 21, 2017
1 parent 4097622 commit 7696c97
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 42 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

/**
Expand All @@ -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';
}

Expand Down Expand Up @@ -252,7 +252,7 @@ public function getCurrencyByPurse($purse)
case 'X':
return 'BTC';
default:
return;
return null;
}
}
}
2 changes: 1 addition & 1 deletion src/Message/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getHashType()
case 132:
return 'sign';
default:
return;
return null;
}
}

Expand Down
52 changes: 42 additions & 10 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,37 @@
* https://merchant.wmtransfer.com/conf/guide.asp.
*
* @author Alexander Fedra <[email protected]>
* @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(
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/Message/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
36 changes: 19 additions & 17 deletions tests/Message/PurchaseResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}

Expand All @@ -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());
}
}

0 comments on commit 7696c97

Please sign in to comment.