File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Omnipay \WebMoney \Message ;
4
4
5
+ use Omnipay \Common \Exception \InvalidRequestException ;
6
+
5
7
/**
6
8
* WebMoney Payout Request
7
9
* http://wiki.wmtransfer.com/projects/webmoney/wiki/Interface_X2.
@@ -203,9 +205,14 @@ public function getData()
203
205
'sslKey ' ,
204
206
'transactionId ' ,
205
207
'description ' ,
208
+ 'currency ' ,
206
209
'amount '
207
210
);
208
211
212
+ if ($ this ->getCurrencyByPurse ($ this ->getMerchantPurse ()) !== $ this ->getCurrency ()) {
213
+ throw new InvalidRequestException ('Invalid currency for this merchant purse ' );
214
+ }
215
+
209
216
$ document = new \DOMDocument ('1.0 ' , 'utf-8 ' );
210
217
$ document ->formatOutput = false ;
211
218
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function setUp()
23
23
$ httpClient ->addSubscriber ($ mockPlugin );
24
24
25
25
$ this ->request = new PayoutRequest ($ httpClient , $ this ->getHttpRequest ());
26
- $ this ->request ->initialize (array (
26
+ $ this ->request ->initialize ([
27
27
'webMoneyId ' => '811333344777 ' ,
28
28
'merchantPurse ' => 'Z123428476799 ' ,
29
29
'secretKey ' => '226778888 ' ,
@@ -37,8 +37,20 @@ public function setUp()
37
37
'invoiceId ' => '12345678 ' ,
38
38
'onlyAuth ' => false ,
39
39
'description ' => 'Payout ' ,
40
+ 'currency ' => 'USD ' ,
40
41
'amount ' => '12.46 '
41
- ));
42
+ ]);
43
+ }
44
+
45
+ public function testException ()
46
+ {
47
+ $ this ->request ->setCurrency ('EUR ' );
48
+
49
+ try {
50
+ $ this ->request ->getData ();
51
+ } catch (\Exception $ e ) {
52
+ $ this ->assertEquals ('Omnipay\Common\Exception\InvalidRequestException ' , get_class ($ e ));
53
+ }
42
54
}
43
55
44
56
public function testGetData ()
You can’t perform that action at this time.
0 commit comments