Skip to content

Commit

Permalink
Merge pull request #8 from dachcom-digital/total_tax
Browse files Browse the repository at this point in the history
update deps, added totalTax to transaction extender
  • Loading branch information
solverat authored Aug 12, 2024
2 parents 0fa00d4 + 0435922 commit ac2cb26
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 12 additions & 2 deletions Transaction/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand All @@ -113,7 +125,5 @@ public function toArray(): array
return array_filter($data, static function ($row) {
return $row !== null;
});

}

}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
}
],
"require": {
"payum/core": "^1.6"
"payum/core": "^1.6",
"postfinancecheckout/sdk": "^4.1"
},
"extra": {
"branch-alias": {
Expand Down

0 comments on commit ac2cb26

Please sign in to comment.