Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

* `recurring` flag on `\UnzerSDK\Resources\PaymentTypes\SepaDirectDebit` for registering a payment type for recurring (mandate-based) collection.
* `getRawResponse()` on `\UnzerSDK\Resources\Keypair`, exposing the exact raw API response string from a Keypair fetch.
* `Unzer::fetchPaylaterPlans(BasePaymentType $paymentType, PaylaterPlansQuery $query)` to fetch the available plans (including the `secciUrl`) for any paylater payment type, e.g. `new PaylaterInvoice()` or `new PaylaterDirectDebit()`. The SECCI PDF locale follows the client locale set via `Unzer::setLocale()` (`Accept-Language` header). The payment type and query values are passed through to the API unchanged; invalid input is rejected by the API with an `UnzerApiException`.
* `\UnzerSDK\Resources\PaylaterPlans` and `\UnzerSDK\Resources\EmbeddedResources\Paylater\PaylaterPlansQuery` as the generalized plan result/query models.
* `minimumInstallmentFee` is now exposed on `\UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlan` via `getMinimumInstallmentFee()` (previously present in the API response but dropped by the SDK).

### Deprecated

* `\UnzerSDK\Resources\PaymentTypes\PIS` (Unzer Bank Transfer / FlexiPay Direct) payment type. It is no longer supported and will be removed in a future major version.
* `\UnzerSDK\Resources\PaymentTypes\Sofort` payment type. It is no longer supported and will be removed in a future major version.
* `\UnzerSDK\Resources\PaylaterInstallmentPlans` (use `\UnzerSDK\Resources\PaylaterPlans`) and `\UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlansQuery` (use `\UnzerSDK\Resources\EmbeddedResources\Paylater\PaylaterPlansQuery`). The legacy classes are left unchanged as standalone deprecated aliases with their original public signatures (no inheritance from the new generalized classes), so existing code keeps working. `Unzer::fetchPaylaterInstallmentPlans()` is unchanged.

### Removed

Expand Down
19 changes: 19 additions & 0 deletions src/Interfaces/PaymentServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
use UnzerSDK\Resources\Basket;
use UnzerSDK\Resources\Customer;
use UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlansQuery;
use UnzerSDK\Resources\EmbeddedResources\Paylater\PaylaterPlansQuery;
use UnzerSDK\Resources\InstalmentPlans;
use UnzerSDK\Resources\Metadata;
use UnzerSDK\Resources\PaylaterInstallmentPlans;
use UnzerSDK\Resources\PaylaterPlans;
use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\PaymentTypes\Paypage;
Expand Down Expand Up @@ -391,6 +393,23 @@ public function fetchInstallmentPlans(
*/
public function fetchPaylaterInstallmentPlans(InstallmentPlansQuery $plansRequest): PaylaterInstallmentPlans;

/**
* Returns a PaylaterPlans object containing all available plan options for the given paylater payment type
* (e.g. Paylater Installment, Paylater Invoice, Paylater Direct Debit).
*
* The payment type is passed through to the API as-is; the SDK neither validates it nor the query values.
* An unsupported payment type or invalid input is rejected by the API with an UnzerApiException.
*
* @param BasePaymentType $paymentType The paylater payment type the plans are requested for.
* @param PaylaterPlansQuery $query The query holding amount, currency, country and customer type.
*
* @return PaylaterPlans The object containing all available plans.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function fetchPaylaterPlans(BasePaymentType $paymentType, PaylaterPlansQuery $query): PaylaterPlans;

/**
* Perform an SCA transaction.
*
Expand Down
23 changes: 22 additions & 1 deletion src/Resources/EmbeddedResources/Paylater/InstallmentPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class InstallmentPlan extends AbstractUnzerResource

private $totalAmount;

private $minimumInstallmentFee;

private $nominalInterestRate;

/** @var float $effectiveInterestRate */
Expand Down Expand Up @@ -87,6 +89,25 @@ public function setTotalAmount($totalAmount)
return $this;
}

/**
* @return mixed
*/
public function getMinimumInstallmentFee()
{
return $this->minimumInstallmentFee;
}

/**
* @param mixed $minimumInstallmentFee
*
* @return InstallmentPlan
*/
public function setMinimumInstallmentFee($minimumInstallmentFee)
{
$this->minimumInstallmentFee = $minimumInstallmentFee;
return $this;
}

/**
* @return mixed
*/
Expand Down Expand Up @@ -154,7 +175,7 @@ public function handleResponse(stdClass $response, string $method = HttpAdapterI
if (isset($response->installmentRates)) {
$rates = [];
foreach ($response->installmentRates as $rate) {
$rates[] = new InstallmentRate($rate->date, $rate->rate);
$rates[] = new InstallmentRate($rate->date ?? null, $rate->rate ?? null);
}
$this->setInstallmentRates($rates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* This class contains the query properties which are used to fetch paylater installment plans.
*
* @deprecated since the introduction of the generalized paylater plans endpoint. Use
* {@see PaylaterPlansQuery} together with Unzer::fetchPaylaterPlans() instead.
* @link https://docs.unzer.com/
*
*/
Expand Down
111 changes: 111 additions & 0 deletions src/Resources/EmbeddedResources/Paylater/PaylaterPlansQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace UnzerSDK\Resources\EmbeddedResources\Paylater;

use UnzerSDK\Constants\CustomerTypes;
use UnzerSDK\Resources\AbstractUnzerResource;

/**
* This class contains the query properties which are used to fetch paylater plans
* (e.g. Paylater Installment, Paylater Invoice, Paylater Direct Debit).
*
* @link https://docs.unzer.com/
*
*/
class PaylaterPlansQuery extends AbstractUnzerResource
{
protected float $amount;
protected string $currency;
protected string $country;
protected string $customerType;

/**
* @param float $amount
* @param string $currency
* @param string $country
* @param string $customerType
*/
public function __construct(float $amount, string $currency, string $country, string $customerType = CustomerTypes::B2C)
{
$this->amount = $amount;
$this->currency = $currency;
$this->country = $country;
$this->customerType = $customerType;
}

/**
* @return float
*/
public function getAmount(): float
{
return $this->amount;
}

/**
* @param float $amount
*
* @return PaylaterPlansQuery
*/
public function setAmount(float $amount): PaylaterPlansQuery
{
$this->amount = $amount;
return $this;
}

/**
* @return string
*/
public function getCurrency(): string
{
return $this->currency;
}

/**
* @param string $currency
*
* @return PaylaterPlansQuery
*/
public function setCurrency(string $currency): PaylaterPlansQuery
{
$this->currency = $currency;
return $this;
}

/**
* @return string
*/
public function getCountry(): string
{
return $this->country;
}

/**
* @param string $country
*
* @return PaylaterPlansQuery
*/
public function setCountry(string $country): PaylaterPlansQuery
{
$this->country = $country;
return $this;
}

/**
* @return string
*/
public function getCustomerType(): string
{
return $this->customerType;
}

/**
* @param string $customerType
*
* @return PaylaterPlansQuery
*/
public function setCustomerType(string $customerType): PaylaterPlansQuery
{
$this->customerType = $customerType;
return $this;
}
}
2 changes: 2 additions & 0 deletions src/Resources/PaylaterInstallmentPlans.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Please use Unzer methods to fetch the list of instalment plans
* (e.g. Unzer::fetchInstallmentPlans(...)).
*
* @deprecated since the introduction of the generalized paylater plans endpoint. Use
* {@see PaylaterPlans} together with Unzer::fetchPaylaterPlans() instead.
* @link https://docs.unzer.com/
*
*/
Expand Down
Loading
Loading