Skip to content

Commit 3a07721

Browse files
committed
init test
1 parent 359b4bf commit 3a07721

9 files changed

+59
-138
lines changed

.hidev/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: omnipay-okpay
33
namespace: Omnipay\OKPAY
4-
headline: Omnipay: OKPAY
4+
headline: "Omnipay: OKPAY"
55
title: OKPAY driver for Omnipay PHP payment library
66
type: library
77
license: MIT

composer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,30 @@
2828
{
2929
"name": "Dmitry Naumenko",
3030
"role": "Lead backend developer",
31-
"email": "silverfire@hiqdev.com",
31+
"email": "d.naumenko.a@gmail.com",
3232
"homepage": "http://silverfire.me/"
3333
},
3434
{
3535
"name": "Andrey Klochok",
3636
"role": "Lead frontend developer",
37-
"email": "tafid@hiqdev.com",
37+
"email": "andreyklochok@gmail.com",
3838
"homepage": "http://hiqdev.com/"
3939
},
4040
{
4141
"name": "Yuriy Myronchuk",
4242
"role": "QA Lead",
43-
"email": "bladeroot@hiqdev.com",
43+
"email": "bladeroot@gmail.com",
4444
"homepage": "http://hiqdev.com/"
4545
}
4646
],
4747
"require": {
4848
"omnipay/common": "~2.3"
4949
},
50+
"require-dev": {
51+
"omnipay/tests": "~2.0",
52+
"hiqdev/hidev-php": "*",
53+
"hiqdev/hidev-hiqdev": "*"
54+
},
5055
"autoload": {
5156
"psr-4": {
5257
"Omnipay\\OKPAY\\": "src"

src/Gateway.php

+3-23
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,14 @@ public function getName()
1414
return 'OKPAY';
1515
}
1616

17-
public function getAccount()
18-
{
19-
return $this->getParameter('account');
20-
}
21-
22-
public function setAccount($value)
23-
{
24-
return $this->setParameter('account', $value);
25-
}
26-
2717
public function getPurse()
2818
{
29-
return $this->getAccount();
19+
return $this->getParameter('purse');
3020
}
3121

3222
public function setPurse($value)
3323
{
34-
return $this->setAccount($value);
35-
}
36-
37-
public function getAccountName()
38-
{
39-
return $this->getParameter('account_name');
40-
}
41-
42-
public function setAccountName($value)
43-
{
44-
return $this->setParameter('account_name', $value);
24+
return $this->setParameter('purse', $value);
4525
}
4626

4727
public function getSecret()
@@ -57,7 +37,7 @@ public function setSecret($value)
5737
public function getDefaultParameters()
5838
{
5939
return array(
60-
'account_name' => '',
40+
'purse' => '',
6141
'secret' => '',
6242
);
6343
}

src/Merchant.php

-61
This file was deleted.

src/Message/AbstractRequest.php

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,38 @@ abstract class AbstractRequest extends OmnipayRequest
99
protected $liveEndpoint = 'https://www.okpay.com/process.html';
1010
protected $testEndpoint = 'https://www.okpay.com/process.html';
1111

12-
protected function getEndpoint()
12+
public function getPurse()
13+
{
14+
return $this->getParameter('purse');
15+
}
16+
17+
public function setPurse($value)
18+
{
19+
return $this->setParameter('purse', $value);
20+
}
21+
22+
public function getSecret()
23+
{
24+
return $this->getParameter('secret');
25+
}
26+
27+
public function setSecret($value)
28+
{
29+
return $this->setParameter('secret', $value);
30+
}
31+
32+
public function getEndpoint()
1333
{
1434
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
1535
}
36+
37+
public function setDescription($value)
38+
{
39+
return $this->setParameter('description', $value);
40+
}
41+
42+
public function getDescriotion()
43+
{
44+
return $this->getParameter('description');
45+
}
1646
}

src/Message/CompletePurchaseResponse.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getRedirectData()
3939

4040
public function getTransactionId()
4141
{
42-
return intval($this->data['ok_invoice']);
42+
return intval($this->data['ok_txn_id']);
4343
}
4444

4545
public function getAmount()
@@ -52,8 +52,13 @@ public function getCurrency()
5252
return $this->data['ok_txn_currency'];
5353
}
5454

55-
public function getMessage()
55+
public function getDescription()
5656
{
57-
return null;
57+
return $this->data['ok_item_1_name'];
58+
}
59+
60+
public function getPurse()
61+
{
62+
return $this->data['ok_receiver'];
5863
}
5964
}

src/Message/PurchaseRequest.php

+3-30
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,14 @@
44

55
class PurchaseRequest extends AbstractRequest
66
{
7-
public function getAccount()
8-
{
9-
return $this->getParameter('account');
10-
}
11-
12-
public function setAccount($value)
13-
{
14-
return $this->setParameter('account', $value);
15-
}
16-
17-
public function getAccountName()
18-
{
19-
return $this->getParameter('accountName');
20-
}
21-
22-
public function setAccountName($value)
23-
{
24-
return $this->setParameter('accountName', $value);
25-
}
26-
27-
public function getEndpoint()
28-
{
29-
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
30-
}
31-
327
public function getData()
338
{
34-
$this->validate('account', 'accountName', 'currency', 'amount');
35-
36-
$data['ok_receiver'] = $this->getAccount();
37-
$data['ok_item_1_name'] = $this->getAccountName();
9+
$this->validate('purse', 'currency', 'amount', 'description');
10+
$data['ok_receiver'] = $this->getPurse();
11+
$data['ok_item_1_name'] = $this->getDescription();
3812
$data['ok_currency'] = $this->getCurrency();
3913
$data['ok_item_1_price'] = $this->getAmount();
4014
$data['ok_invoice'] = $this->getTransactionId();
41-
4215
return $data;
4316
}
4417

src/Message/PurchaseResponse.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class PurchaseResponse extends AbstractResponse implements RedirectResponseInter
1313
public function __construct(RequestInterface $request, $data, $redirectUrl)
1414
{
1515
parent::__construct($request, $data);
16+
1617
$this->redirectUrl = $redirectUrl;
1718
}
1819

src/Message/RefundRequest.php

+4-16
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ class RefundRequest extends AbstractRequest
88
{
99
protected $endpoint = 'https://api.okpay.com/OkPayAPI?wsdl';
1010

11-
public function getAccount()
12-
{
13-
return $this->getParameter('account');
14-
}
15-
16-
public function setAccount($value)
17-
{
18-
return $this->setParameter('account', $value);
19-
}
20-
2111
public function getSecret()
2212
{
2313
return $this->getParameter('secret');
@@ -40,10 +30,10 @@ public function setPayeeAccount($value)
4030

4131
public function getData()
4232
{
43-
$this->validate('account', 'payeeAccount', 'amount', 'secret', 'description');
33+
$this->validate('purse', 'payeeAccount', 'amount', 'secret', 'description');
4434

4535
$data['secret'] = $this->getSecret();
46-
$data['walletId'] = $this->getAccount();
36+
$data['walletId'] = $this->getPurse();
4737
$data['receiver'] = $this->getPayeeAccount();
4838
$data['amount'] = $this->getAmount();
4939
$data['currency'] = $this->getCurrency();
@@ -61,11 +51,9 @@ public function sendData($data)
6151

6252
private function soapCall($data)
6353
{
64-
$secWord = $data['secret'];
65-
$WalletID = $data['walletId'];
6654
$datePart = gmdate("Ymd");
6755
$timePart = gmdate("H");
68-
$authString = $secWord.":".$datePart.":".$timePart;
56+
$authString = "{$data['secret']}:{$datePart}:{$timePart}";
6957

7058
$sha256 = bin2hex(hash('sha256', $authString, true));
7159
$secToken = strtoupper($sha256);
@@ -85,7 +73,7 @@ private function soapCall($data)
8573
]
8674
);
8775

88-
$this->WalletID = $WalletID;
76+
$this->WalletID = $data['walletId'];
8977
$this->SecurityToken = $secToken;
9078
$this->Currency = $data['currency'];
9179
$this->Receiver = $data['receiver'];

0 commit comments

Comments
 (0)