@@ -86,44 +86,45 @@ public function testGetPaymentParameters(): void
8686 password2: 'password#2 ' ,
8787 );
8888
89- $ paymentParameters = $ robokassa ->getPaymentParameters (
90- new InvoiceOptions (
91- outSum: 100 ,
92- invId: 999 ,
93- description: 'Description ' ,
94- receipt: new Receipt (
95- items: [
96- new Item (
97- name: 'Название товара 1 (50%) ' ,
98- quantity: 1 ,
99- sum: 100 ,
100- tax: Tax::vat10,
101- payment_method: PaymentMethod::full_payment,
102- payment_object: PaymentObject::commodity
103- ),
104- new Item (
105- name: 'Название товара 2 ' ,
106- quantity: 3 ,
107- sum: 450 ,
108- tax: Tax::vat120,
109- payment_method: PaymentMethod::full_payment,
110- payment_object: PaymentObject::excise,
111- nomenclature_code: '04620034587217 '
112- ),
113- ],
114- sno: Sno::osn,
115- ),
116- culture: Culture::en,
89+ $ invoiceOptions = new InvoiceOptions (
90+ outSum: 100 ,
91+ invId: 999 ,
92+ description: "Description \"'><b> " ,
93+ receipt: new Receipt (
94+ items: [
95+ new Item (
96+ name: 'Название товара 1 (50%) ' ,
97+ quantity: 1 ,
98+ sum: 100 ,
99+ tax: Tax::vat10,
100+ payment_method: PaymentMethod::full_payment,
101+ payment_object: PaymentObject::commodity
102+ ),
103+ new Item (
104+ name: "Название товара 2 \"'><b> " ,
105+ quantity: 3 ,
106+ sum: 450 ,
107+ tax: Tax::vat120,
108+ payment_method: PaymentMethod::full_payment,
109+ payment_object: PaymentObject::excise,
110+ nomenclature_code: '04620034587217 '
111+ ),
112+ ],
113+ sno: Sno::osn,
117114 ),
115+ culture: Culture::en,
116+ );
117+ $ paymentParameters = $ robokassa ->getPaymentParameters (
118+ $ invoiceOptions ,
118119 );
119120
120121 $ expectedPaymentParameters = [
121122 'MerchantLogin ' => 'robo-demo ' ,
122123 'OutSum ' => '100.00 ' ,
123- 'Description ' => ' Description ' ,
124- 'SignatureValue ' => '9da55279722ba167a1384b05a2c5e330 ' ,
124+ 'Description ' => " Description \" '><b> " ,
125+ 'SignatureValue ' => '7c6a95094fa5c3e5e2baf83c8817e8c0 ' ,
125126 'IncCurrLabel ' => null ,
126- 'InvId ' => 999 ,
127+ 'InvId ' => ' 999 ' ,
127128 'Culture ' => 'en ' ,
128129 'Encoding ' => 'utf-8 ' ,
129130 'Email ' => null ,
@@ -133,12 +134,27 @@ public function testGetPaymentParameters(): void
133134 'Receipt ' => '{"items":[ '
134135 . '{"sum":"100.00","name":"Название товара 1 (50%)","quantity":1,"tax":"vat10", '
135136 . '"payment_method":"full_payment","payment_object":"commodity"}, '
136- . '{"sum":"450.00","name":"Название товара 2","quantity":3,"tax":"vat120", '
137+ . '{"sum":"450.00","name":"Название товара 2\" \' ><b> ","quantity":3,"tax":"vat120", '
137138 . '"payment_method":"full_payment","payment_object":"excise","nomenclature_code":"04620034587217"} '
138139 . '],"sno":"osn"} ' ,
139140 'IsTest ' => null ,
140141 ];
141142 $ this ->assertEquals ($ expectedPaymentParameters , $ paymentParameters );
143+
144+ $ paymentParametersAsJson = $ robokassa ->getPaymentParametersAsJson ($ invoiceOptions );
145+ $ expectedPaymentParametersAsJson = '{"MerchantLogin":"robo-demo","OutSum":"100.00","Description":"Description\" \'><b>", '
146+ . '"SignatureValue":"7c6a95094fa5c3e5e2baf83c8817e8c0","IncCurrLabel":null,"InvId":"999","Culture":"en", '
147+ . '"Encoding":"utf-8","Email":null,"ExpirationDate":null,"OutSumCurrency":null,"UserIp":null, '
148+ . '"Receipt":"{\"items\":[ '
149+ . '{\"sum\":\"100.00\",\"name\":\"Название товара 1 (50%)\",\"quantity\":1,\"tax\":\"vat10\", '
150+ . '\"payment_method\":\"full_payment\",\"payment_object\":\"commodity\"}, '
151+ . '{ \\"sum \\": \\"450.00 \\", \\"name \\": \\"Название товара 2 \\\\\\" \'><b> \\", \\"quantity \\":3, \\"tax \\": \\"vat120 \\", '
152+ . '\"payment_method\":\"full_payment\",\"payment_object\":\"excise\",\"nomenclature_code\":\"04620034587217\"}], '
153+ . '\"sno\":\"osn\"}","IsTest":null} ' ;
154+ $ this ->assertEquals ($ expectedPaymentParametersAsJson , $ paymentParametersAsJson );
155+
156+ $ decodedJson = json_decode ($ paymentParametersAsJson , true , 512 , JSON_THROW_ON_ERROR );
157+ $ this ->assertEquals ($ expectedPaymentParameters , $ decodedJson );
142158 }
143159
144160 public function testPaymentReceipt (): void
0 commit comments