@@ -186,96 +186,85 @@ class="payment_btn__link"
186186 ' ;
187187 }
188188
189-
190-
191189 /**
192- * @deprecated
193- * @param array $params
190+ * Транслитерация
191+ * @param $string
194192 * @return string
195- * @throws PaymentException
196193 */
197- public static function drawYpmnButton__old (array $ params ): string
198- {
199- if (!isset ($ params ['url ' ])) {
200- throw new PaymentException ('Передайте в метод drawYpmnButton параметр url ' );
201- }
194+ public static function rus2translit ($ string ) {
195+ $ converter = [
196+ 'а ' => 'a ' , 'б ' => 'b ' , 'в ' => 'v ' ,
197+ 'г ' => 'g ' , 'д ' => 'd ' , 'е ' => 'e ' ,
198+ 'ё ' => 'e ' , 'ж ' => 'zh ' , 'з ' => 'z ' ,
199+ 'и ' => 'i ' , 'й ' => 'y ' , 'к ' => 'k ' ,
200+ 'л ' => 'l ' , 'м ' => 'm ' , 'н ' => 'n ' ,
201+ 'о ' => 'o ' , 'п ' => 'p ' , 'р ' => 'r ' ,
202+ 'с ' => 's ' , 'т ' => 't ' , 'у ' => 'u ' ,
203+ 'ф ' => 'f ' , 'х ' => 'h ' , 'ц ' => 'c ' ,
204+ 'ч ' => 'ch ' , 'ш ' => 'sh ' , 'щ ' => 'sch ' ,
205+ 'ь ' => '\'' , 'ы ' => 'y ' , 'ъ ' => '\'' ,
206+ 'э ' => 'e ' , 'ю ' => 'yu ' , 'я ' => 'ya ' ,
207+ 'А ' => 'A ' , 'Б ' => 'B ' , 'В ' => 'V ' ,
208+ 'Г ' => 'G ' , 'Д ' => 'D ' , 'Е ' => 'E ' ,
209+ 'Ё ' => 'E ' , 'Ж ' => 'Zh ' , 'З ' => 'Z ' ,
210+ 'И ' => 'I ' , 'Й ' => 'Y ' , 'К ' => 'K ' ,
211+ 'Л ' => 'L ' , 'М ' => 'M ' , 'Н ' => 'N ' ,
212+ 'О ' => 'O ' , 'П ' => 'P ' , 'Р ' => 'R ' ,
213+ 'С ' => 'S ' , 'Т ' => 'T ' , 'У ' => 'U ' ,
214+ 'Ф ' => 'F ' , 'Х ' => 'H ' , 'Ц ' => 'C ' ,
215+ 'Ч ' => 'Ch ' , 'Ш ' => 'Sh ' , 'Щ ' => 'Sch ' ,
216+ 'Ь ' => '\'' , 'Ы ' => 'Y ' , 'Ъ ' => '\'' ,
217+ 'Э ' => 'E ' , 'Ю ' => 'Yu ' , 'Я ' => 'Ya ' ,
218+ ];
202219
203- $ allowedParams = [
204- 'url ' ,
205- 'shadow ' ,
206- 'currency ' ,
207- 'sum ' ,
208- 'order_id ' ,
209- 'newpage ' ,
220+ return strtr ($ string , $ converter );
221+ }
222+
223+ /**
224+ * Транслитерация JSON
225+ * @param $json_str
226+ * @return array|string|string[]
227+ */
228+ public static function json_fix_cyr ($ json_str ) {
229+ $ cyr_chars = [
230+ '\u0430 ' => 'а ' , '\u0410 ' => 'А ' ,
231+ '\u0431 ' => 'б ' , '\u0411 ' => 'Б ' ,
232+ '\u0432 ' => 'в ' , '\u0412 ' => 'В ' ,
233+ '\u0433 ' => 'г ' , '\u0413 ' => 'Г ' ,
234+ '\u0434 ' => 'д ' , '\u0414 ' => 'Д ' ,
235+ '\u0435 ' => 'е ' , '\u0415 ' => 'Е ' ,
236+ '\u0451 ' => 'ё ' , '\u0401 ' => 'Ё ' ,
237+ '\u0436 ' => 'ж ' , '\u0416 ' => 'Ж ' ,
238+ '\u0437 ' => 'з ' , '\u0417 ' => 'З ' ,
239+ '\u0438 ' => 'и ' , '\u0418 ' => 'И ' ,
240+ '\u0439 ' => 'й ' , '\u0419 ' => 'Й ' ,
241+ '\u043a ' => 'к ' , '\u041a ' => 'К ' ,
242+ '\u043b ' => 'л ' , '\u041b ' => 'Л ' ,
243+ '\u043c ' => 'м ' , '\u041c ' => 'М ' ,
244+ '\u043d ' => 'н ' , '\u041d ' => 'Н ' ,
245+ '\u043e ' => 'о ' , '\u041e ' => 'О ' ,
246+ '\u043f ' => 'п ' , '\u041f ' => 'П ' ,
247+ '\u0440 ' => 'р ' , '\u0420 ' => 'Р ' ,
248+ '\u0441 ' => 'с ' , '\u0421 ' => 'С ' ,
249+ '\u0442 ' => 'т ' , '\u0422 ' => 'Т ' ,
250+ '\u0443 ' => 'у ' , '\u0423 ' => 'У ' ,
251+ '\u0444 ' => 'ф ' , '\u0424 ' => 'Ф ' ,
252+ '\u0445 ' => 'х ' , '\u0425 ' => 'Х ' ,
253+ '\u0446 ' => 'ц ' , '\u0426 ' => 'Ц ' ,
254+ '\u0447 ' => 'ч ' , '\u0427 ' => 'Ч ' ,
255+ '\u0448 ' => 'ш ' , '\u0428 ' => 'Ш ' ,
256+ '\u0449 ' => 'щ ' , '\u0429 ' => 'Щ ' ,
257+ '\u044a ' => 'ъ ' , '\u042a ' => 'Ъ ' ,
258+ '\u044b ' => 'ы ' , '\u042b ' => 'Ы ' ,
259+ '\u044c ' => 'ь ' , '\u042c ' => 'Ь ' ,
260+ '\u044d ' => 'э ' , '\u042d ' => 'Э ' ,
261+ '\u044e ' => 'ю ' , '\u042e ' => 'Ю ' ,
262+ '\u044f ' => 'я ' , '\u042f ' => 'Я ' ,
210263 ];
211264
212- foreach ($ params as $ key =>$ value ) {
213- if (!in_array ($ key , $ allowedParams )) {
214- throw new PaymentException ('Недопустимый параметр кнопки оплаты ' );
215- }
265+ foreach ($ cyr_chars as $ cyr_char_key => $ cyr_char ) {
266+ $ json_str = str_replace ($ cyr_char_key , $ cyr_char , $ json_str );
216267 }
217-
218- return '
219- <a
220- ' .( isset ($ params ['order_id ' ]) ? 'data-id=" ' .htmlspecialchars ($ params ['order_id ' ]). '" ' : '' ).'
221- ' .( isset ($ params ['newpage ' ]) ? 'target="_blank" ' : '' ).'
222- href=" ' . $ params ['url ' ] . '"
223- href=" ' . $ params ['url ' ] . '"
224- id="ypmn_button"
225- rel="noindex nofollow"
226- title="Оплатить"
227- style="
228- max-width: 400px;
229- max-height: 150px;
230- display: inline-block;
231- justify-content: space-between;
232- background: #ffffff;
233- color: #000000;
234- border: 1px solid #000000;
235- border-radius: 5px;
236- padding: 16px;
237- ">
238- <svg xmlns="http://www.w3.org/2000/svg"
239- width="50"
240- height="50"
241- viewBox="0 0 160 162"
242- style="
243- display: inline;
244- padding-right: 16px;
245- float: left;
246- "
247- ><style>
248-
249- @keyframes a1_t { 0% { transform: translate(100px,43.74px) rotate(0deg); animation-timing-function: cubic-bezier(0,0,.58,1); } 16.625% { transform: translate(100px,43.74px) rotate(-15deg); } 100% { transform: translate(100px,43.74px) rotate(0deg); } }
250- @keyframes a0_t { 0% { transform: scale(1,1) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(0,0,.58,1); } 16.625% { transform: scale(1.2,1.2) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(.42,0,1,1); } 100% { transform: scale(1,1) translate(-126.64px,-77.99px); } }
251- @keyframes a3_t { 0% { transform: translate(100px,43.74px) rotate(0deg); animation-timing-function: cubic-bezier(0,0,.58,1); } 33.3% { transform: translate(100px,43.74px) rotate(-15deg); } 100% { transform: translate(100px,43.74px) rotate(0deg); } }
252- @keyframes a2_t { 0% { transform: scale(1,1) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(0,0,.58,1); } 33.3% { transform: scale(1.2,1.2) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(.42,0,1,1); } 100% { transform: scale(1,1) translate(-126.64px,-77.99px); } }
253- @keyframes a5_t { 0% { transform: translate(100px,43.74px) rotate(0deg); animation-timing-function: cubic-bezier(0,0,.58,1); } 50% { transform: translate(100px,43.74px) rotate(-15deg); } 100% { transform: translate(100px,43.74px) rotate(0deg); } }
254- @keyframes a4_t { 0% { transform: scale(1,1) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(0,0,.58,1); } 50% { transform: scale(1.15,1.15) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(.42,0,1,1); } 100% { transform: scale(1,1) translate(-126.64px,-77.99px); } }
255- @keyframes a7_t { 0% { transform: translate(100px,43.74px) rotate(0deg); animation-timing-function: cubic-bezier(0,0,.58,1); } 75% { transform: translate(100px,43.74px) rotate(-12deg); animation-timing-function: cubic-bezier(0,0,.58,1); } 100% { transform: translate(100px,43.74px) rotate(0deg); } }
256- @keyframes a6_t { 0% { transform: scale(1,1) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(0,0,.58,1); } 75% { transform: scale(1.1,1.1) translate(-126.64px,-77.99px); animation-timing-function: cubic-bezier(.42,0,1,1); } 100% { transform: scale(1,1) translate(-126.64px,-77.99px); } }
257- </style><g fill="none" transform="translate(7.26,3.76)"><g style="animation: 4s linear infinite both a1_t;"><path d="M131.59 67.09c-9.79-7.14-35.57-2.34-39.37 12.79c-4.63 18.41 17.27 34.97 34.42 25.09c12.29-7.08 14.72-30.73 4.95-37.88Z" fill="#80f3ae" transform="translate(100,43.74) translate(-126.64,-77.99)" style="animation: 4s linear infinite both a0_t;"/></g><g style="animation: 4s linear infinite both a3_t;"><path fill-rule="evenodd" clip-rule="evenodd" d="M141.97 78.4c-1.01-5.78-3.36-10.6-6.98-13.72c-7.43-6.39-20.66-7.64-33.03-4.13c-12.36 3.51-22.48 11.36-24.53 21.57c-2.46 12.22 .86 23.11 8.04 30.52c7.17 7.4 18.43 11.56 32.31 9.78c11.45-1.92 19.75-12.66 23.13-25.4c1.67-6.3 2.06-12.85 1.06-18.62Zm4.08 19.98c-3.65 13.73-13.03 26.9-27.45 29.28l-0.04 .01l-0.05 .01c-15.35 1.98-28.36-2.58-36.85-11.34c-8.49-8.77-12.21-21.48-9.44-35.27c2.63-13.04 15.08-21.88 28.29-25.63c13.22-3.75 28.6-2.83 37.95 5.22c4.81 4.15 7.59 10.23 8.74 16.83c1.15 6.62 .69 13.95-1.15 20.89Z" fill="#65d988" transform="translate(100,43.74) translate(-126.64,-77.99)" style="animation: 4s linear infinite both a2_t;"/></g><g style="animation: 4s linear infinite both a5_t;"><path fill-rule="evenodd" clip-rule="evenodd" d="M149.39 108.93c6.2-19.26 4.28-40.16-8.67-51.67c-9.52-8.46-27.12-10.8-44.45-6.22c-17.21 4.56-33.25 15.73-39.76 33.1c-5.38 14.34-0.85 31.2 10.01 43.98c10.84 12.74 27.65 21.02 46.21 18.44c16.64-2.3 30.46-18.37 36.66-37.63Zm5.06 1.62c-6.5 20.18-21.45 38.56-40.99 41.28c-20.65 2.86-39.18-6.39-50.98-20.27c-11.77-13.84-17.17-32.69-10.95-49.29c7.3-19.43 25.04-31.51 43.38-36.36c18.23-4.82 37.96-2.73 49.33 7.38c15.22 13.53 16.7 37.08 10.21 57.26Z" fill="#4fc694" transform="translate(100,43.74) translate(-126.64,-77.99)" style="animation: 4s linear infinite both a4_t;"/></g><g style="animation: 4s linear infinite both a7_t;"><path fill-rule="evenodd" clip-rule="evenodd" d="M161.81 78.82c-1.86-11.83-6.31-21.63-13.19-27.62c-14.81-12.89-40.55-14.61-64.49-7.42c-23.92 7.18-44.72 22.87-50.15 43.16c-6.14 22.97 2.18 45.73 17.83 61.91c15.68 16.19 38.43 25.49 60.7 21.76c24.19-4.05 40.57-27.22 47.14-53.46c3.26-13.02 4.02-26.54 2.16-38.33Zm2.99 39.62c-6.78 27.08-24.14 52.84-51.41 57.41c-24.28 4.07-48.73-6.09-65.39-23.31c-16.69-17.23-25.86-41.86-19.15-66.97c6.11-22.84 28.99-39.44 53.75-46.88c24.74-7.43 52.71-6.12 69.51 8.5c8.15 7.1 12.97 18.27 14.95 30.8c1.98 12.58 1.16 26.82-2.26 40.45Z" fill="#48a992" transform="translate(100,43.74) translate(-126.64,-77.99)" style="animation: 4s linear infinite both a6_t;"/></g></g>
258- </svg>
259-
260- <div style="display: inline-block;"
261- <strong style="
262- display: inline-block;
263- vertical-align: center;
264- text-align: justify;
265- padding-left: 10px;
266- padding-right: 10px;
267- font-size: 14pt;
268- ">Оплатить</strong>
269- ' .(isset ($ params ['sum ' ]) ? '<br><strong style="
270- font-size: 14pt;
271- text-align: justify;
272- float: left
273- "> '
274- . number_format ($ params ['sum ' ], 2 , '. ' , ' ' )
275- . ' '
276- . ( isset ($ params ['currency ' ]) ? htmlspecialchars ($ params ['currency ' ]) : '₽ ' ) .'</strong> ' : '' ) .'
277- </div>
278- </a>
279- ' ;
268+ return $ json_str ;
280269 }
281270}
0 commit comments