From 0435922f3ebdf45b2f072ddbfcdda46ad0c1c889 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Mon, 12 Aug 2024 10:38:28 +0200 Subject: [PATCH] update deps, added totalTax to transaction extender --- Api.php | 1 + README.md | 12 ++++++++++++ Transaction/Transaction.php | 14 ++++++++++++-- composer.json | 3 ++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Api.php b/Api.php index 4728997..c932381 100644 --- a/Api.php +++ b/Api.php @@ -56,6 +56,7 @@ public function prepareTransaction(ArrayObject $details, string $returnUrl, stri $lineItem = $this->createPostFinanceModel(LineItemCreate::class, [ 'quantity' => 1, 'amountIncludingTax' => $transactionExtender['amount'] / 100, + 'taxes' => $transactionExtender['totalTaxes'] ?? null, 'uniqueId' => $transactionExtender['id'], 'name' => $transactionExtender['id'], 'sku' => $transactionExtender['id'], diff --git a/README.md b/README.md index a429130..0f5a33b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ Payum Gateway For [PostFinance Checkout](https://checkout.postfinance.ch) - PHP 8.0+ - [Payum](https://github.com/Payum/Payum) +## Information +This extension currently **does not** support multiple line items. +It only creates one line item which contains all the total information of the given order. + +*** + ## BackOffice ### Environments @@ -13,7 +19,13 @@ Use multiple spaces to determine test/production. ### Webhook You need to define a global webhook: `https://your-domain.com/payment/notify/unsafe/[YOUR_POSTFINANCE_FLEX_GATEWAY_NAME]` +*** + ## Changelog + +### 1.2.0 +- dependency `postfinancecheckout/sdk:^4.1` added +- added `totalTaxes` to transaction extender to allow tax rates submission to line item ### 1.1.1 - change payment state to `authorized` if transaction state is `completed` ### 1.1.0 diff --git a/Transaction/Transaction.php b/Transaction/Transaction.php index 6778aef..66b6877 100644 --- a/Transaction/Transaction.php +++ b/Transaction/Transaction.php @@ -11,6 +11,7 @@ class Transaction protected int|float $amount; protected ?string $currency; protected ?string $language = null; + protected ?array $totalTaxes = null; protected ?array $allowedPaymentMethodBrands = null; protected ?array $allowedPaymentMethodConfigurations = null; @@ -57,6 +58,16 @@ public function setLanguage(?string $language): void $this->language = $language; } + public function getTotalTaxes(): ?array + { + return $this->totalTaxes; + } + + public function setTotalTaxes(?array $totalTaxes): void + { + $this->totalTaxes = $totalTaxes; + } + public function getAllowedPaymentMethodBrands(): ?array { return $this->allowedPaymentMethodBrands; @@ -104,6 +115,7 @@ public function toArray(): array 'amount' => $this->getAmount(), 'currency' => $this->getCurrency(), 'language' => $this->getLanguage(), + 'totalTaxes' => $this->getTotalTaxes(), 'allowedPaymentMethodBrands' => $this->getAllowedPaymentMethodBrands(), 'allowedPaymentMethodConfigurations' => $this->getAllowedPaymentMethodConfigurations(), 'shippingAddress' => $this->shippingAddress === null ? [] : (array) ObjectSerializer::sanitizeForSerialization($this->shippingAddress), @@ -113,7 +125,5 @@ public function toArray(): array return array_filter($data, static function ($row) { return $row !== null; }); - } - } diff --git a/composer.json b/composer.json index c82a6de..706c33d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ } ], "require": { - "payum/core": "^1.6" + "payum/core": "^1.6", + "postfinancecheckout/sdk": "^4.1" }, "extra": { "branch-alias": {