Skip to content

Commit

Permalink
Название товара обрезается до 127 символов, кавычки-ёлочки («, »)…
Browse files Browse the repository at this point in the history
… заменяются на обычные (`"`)
  • Loading branch information
jhaoda committed Feb 22, 2018
1 parent 7c6a387 commit 5f0caa9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/YaKassaPaymentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@ private function convertItemToArray(YaKassaOrderItem54FZ $item): array
'price' => [
'amount' => \number_format($item->getAmount(), 2, '.', '')
],
'text' => \mb_substr($item->getTitle(), 0, 127, 'UTF-8'),
'tax' => $item->getTaxRate(),
'quantity' => $this->formatQuantity($item->getQuantity()),
'currency' => $item->getCurrency(),
'text' => $this->formatTitle($item->getTitle()),
'quantity' => $this->formatQuantity($item->getQuantity()),
]);
}

private function formatQuantity($quantity)
{
return \is_int($quantity) ? $quantity : (float) \number_format($quantity, 3, '.', '');
}

private function formatTitle(string $title): string
{
return \preg_replace('~[«»]~um', '"', \mb_substr($title, 0, 127, 'UTF-8'));
}
}

0 comments on commit 5f0caa9

Please sign in to comment.