Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 30, 2017
1 parent 34348e4 commit 2bfc706
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
40 changes: 36 additions & 4 deletions Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Dfe\YandexKassa;
use Df\Core\Exception as DFE;
use Dfe\YandexKassa\Source\Option;
use Magento\Sales\Model\Order as O;
use Magento\Sales\Model\Order\Item as OI;
/**
* 2017-09-16
Expand Down Expand Up @@ -357,7 +358,7 @@ function($i, array $a) {return dfa_key_transform($a, function($k) use($i) {retur
* @used-by pCharge()
* @return array(string => mixed)
*/
private function pTax() {$o = $this->o(); return [
private function pTax() {return [
/**
* 2017-09-25
* «Buyer's phone number or email address.
Expand All @@ -373,14 +374,45 @@ private function pTax() {$o = $this->o(); return [
* Required, string(64).
*/
'customerContact' => $this->customerEmail()
,'items' => array_merge($this->oiLeafs(function(OI $i) {return $this->pTaxLeaf(
$i->getName(), df_oqi_price($i, false, true), floatval($i->getTaxPercent()), df_oqi_qty($i)
);}), [$this->pTaxLeaf('Доставка', $o->getShippingInclTax(), df_tax_rate_shipping($o))])
// 2017-09-30 «Products» / «Товары». Required, object.
,'items' => $this->pTaxLeafs()
];}

/**
* 2017-09-30
* @used-by pTax()
* @return array(string => mixed)
*/
private function pTaxLeafs() {
$o = $this->o(); /** @var O $o */
/** @var array(string => mixed) $r */
$r = array_merge($this->oiLeafs(function(OI $i) {return $this->pTaxLeaf(
$i->getName(), df_oqi_price($i, false, true), floatval($i->getTaxPercent()), df_oqi_qty($i)
);}), [$this->pTaxLeaf('Доставка', $o->getShippingInclTax(), df_tax_rate_shipping($o))]);
/**
* 2017-09-30
* It is really a string, not float: @see \Dfe\YandexKassa\Method::amountFormat()
* @var string $amoutFromTotalS
*/
$amoutFromTotalS = $this->amountF();
/** @var float $amountCalculated */
$amountCalculated = array_sum(array_map(function(array $i) {return
$i['quantity'] * $i['price']['amount']
;}, $r));
if (!dff_eq($amoutFromTotalS, $amountCalculated)) {
df_error_html(
"Unable to generate tax data for Yandex.Kassa."
."<br/>The order's grand total is <b>%1</b>."
."<br/>The calculated grand total from tax data is <b>%2</b>."
,$amoutFromTotalS, dff_2($amountCalculated)
);
}
return $r;
}

/**
* 2017-09-30
* @used-by pTaxLeafs()
* @param string $name
* @param float $amount
* @param float $taxPercent
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/yandex-kassa"
,"version": "0.3.1"
,"version": "0.3.2"
,"description": "The «Yandex.Kassa» (Яндекс.Касса, Yandex.Checkout) payment extension for Magento 2."
,"type": "magento2-module"
,"homepage": "https://mage2.pro/c/extensions/yandex-kassa"
Expand All @@ -11,7 +11,7 @@
"homepage": "https://mage2.pro/users/dmitry_fedyuk",
"role": "Developer"
}]
,"require": {"mage2pro/core": ">=2.12.31"}
,"require": {"mage2pro/core": ">=2.12.32"}
,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\YandexKassa\\": ""}}
,"keywords": [
"API"
Expand Down

0 comments on commit 2bfc706

Please sign in to comment.