Skip to content

Commit

Permalink
Merge pull request #4 from dachcom-digital/total_tax
Browse files Browse the repository at this point in the history
update deps, added totalTaxes to transaction line item
  • Loading branch information
solverat authored Aug 12, 2024
2 parents 4fd900a + 7b00860 commit 6930072
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CoreShop >= 3.0
## Installation

```json
"dachcom-digital/payum-postfinance-flex-bundle": "~1.1.0"
"dachcom-digital/payum-postfinance-flex-bundle": "~1.2.0"
```

Add Bundle to `bundles.php`:
Expand All @@ -24,10 +24,21 @@ Go to CoreShop -> PaymentProvider and add a new Provider. Choose `postfinance_fl

## Changelog

### 1.2.0
- Dependency `dachcom-digital/payum-postfinance-flex` requirement set to `^1.2`
- Unnecessary dependency `postfinancecheckout/sdk` removed
- `totalTaxes` added to line item
- rate `title` gets translated by key: `coreshop.payum.postfinance.line_item.tax_title_[TAX_RATE]`
- where `[TAX_RATE]` represents the tax rate (`.` gets replaced by `_`)
- Example: If your taxrate represents `8.1`, the generated title would be `coreshop.payum.postfinance.line_item.tax_title_8_1`

### 1.1.0
- add integration type config
- add `allowedPaymentMethodConfigurations` option

### 1.0.1
- add `setAllowedPaymentMethodBrands` option

## Copyright and License
Copyright: [DACHCOM.DIGITAL](https://www.dachcom-digital.ch)
For licensing details please visit [LICENSE.md](LICENSE.md)
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"type": "pimcore-bundle",
"require": {
"payum/core": "^1.6",
"dachcom-digital/payum-postfinance-flex": "^1.0",
"postfinancecheckout/sdk": "^3.1"
"dachcom-digital/payum-postfinance-flex": "^1.2"
},
"keywords": [
"payment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use CoreShop\Bundle\PaymentBundle\Doctrine\ORM\PaymentRepository;
use CoreShop\Component\Core\Model\OrderInterface;
use CoreShop\Component\Core\Model\PaymentProviderInterface;
use CoreShop\Component\Taxation\Model\TaxItemInterface;
use DachcomDigital\Payum\PostFinance\Flex\Request\Api\TransactionExtender;
use Payum\Core\Extension\Context;
use Payum\Core\Extension\ExtensionInterface;
use Payum\Core\Model\Payment;
use Symfony\Contracts\Translation\TranslatorInterface;

class ConvertPaymentExtension implements ExtensionInterface
{
public function __construct(
protected TranslatorInterface $translator,
protected PaymentRepository $paymentRepository
) {

Expand Down Expand Up @@ -94,6 +97,28 @@ public function onPostExecute(Context $context)
$transaction->setAllowedPaymentMethodConfigurations(explode(',', $optionalParameters['allowedPaymentMethodConfigurations']));
}

$taxes = [];
foreach ($order->getTaxes() as $tax) {

if (!$tax instanceof TaxItemInterface) {
continue;
}

$taxes[] = [
'rate' => $tax->getRate(),
'title' => $this->translator->trans(
sprintf('coreshop.payum.postfinance.line_item.tax_title_%s', str_replace('.', '_', $tax->getRate())),
[],
'admin',
$order->getLocaleCode()
)
];
}

if (count($taxes) > 0) {
$transaction->setTotalTaxes($taxes);
}

$request->setTransaction($transaction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
autowire: true
public: true
arguments:
- '@translator'
- '@coreshop.repository.payment'
tags:
- { name: payum.extension, alias: postfinance_flex_coreshop_convert_payment, factory: postfinance_flex, prepend: false }

0 comments on commit 6930072

Please sign in to comment.