diff --git a/src/Adapter/ApplepayAdapter.php b/src/Adapter/ApplepayAdapter.php index 824650a5e..b23a46366 100644 --- a/src/Adapter/ApplepayAdapter.php +++ b/src/Adapter/ApplepayAdapter.php @@ -67,7 +67,7 @@ public function validMerchantValidationDomain(string $merchantValidationURL): bo * This is necessary if the ssl cert file doesn't contain key already. * @param string|null $caCert Path to CA certificate. */ - public function init(string $sslCert, string $sslKey = null, string $caCert = null): void + public function init(string $sslCert, ?string $sslKey = null, ?string $caCert = null): void { $timeout = EnvironmentService::getTimeout(); $curlVerbose = EnvironmentService::isCurlVerbose(); diff --git a/src/Adapter/CurlAdapter.php b/src/Adapter/CurlAdapter.php index e3ddd2b98..5535eb40e 100755 --- a/src/Adapter/CurlAdapter.php +++ b/src/Adapter/CurlAdapter.php @@ -10,11 +10,10 @@ namespace UnzerSDK\Adapter; -use UnzerSDK\Unzer; -use UnzerSDK\Services\EnvironmentService; -use UnzerSDK\Exceptions\UnzerApiException; use RuntimeException; - +use UnzerSDK\Exceptions\UnzerApiException; +use UnzerSDK\Services\EnvironmentService; +use UnzerSDK\Unzer; use function extension_loaded; use function in_array; @@ -37,7 +36,7 @@ public function __construct() /** * {@inheritDoc} */ - public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void + public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void { $timeout = EnvironmentService::getTimeout(); $curlVerbose = EnvironmentService::isCurlVerbose(); diff --git a/src/Adapter/HttpAdapterInterface.php b/src/Adapter/HttpAdapterInterface.php index 4e238b87d..2e2bd0a6a 100755 --- a/src/Adapter/HttpAdapterInterface.php +++ b/src/Adapter/HttpAdapterInterface.php @@ -25,7 +25,7 @@ interface HttpAdapterInterface * @param string|null $payload Json encoded payload string. * @param string $httpMethod The Http method to perform. */ - public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void; + public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void; /** * Executes the request and returns the response. diff --git a/src/Exceptions/UnzerApiException.php b/src/Exceptions/UnzerApiException.php index 39d209288..f9e1c44dd 100644 --- a/src/Exceptions/UnzerApiException.php +++ b/src/Exceptions/UnzerApiException.php @@ -26,10 +26,10 @@ class UnzerApiException extends Exception * * @param string $merchantMessage * @param string $clientMessage - * @param string $code + * @param string|null $code * @param string|null $errorId */ - public function __construct($merchantMessage = '', $clientMessage = '', $code = null, string $errorId = null) + public function __construct($merchantMessage = '', $clientMessage = '', $code = null, ?string $errorId = null) { $merchantMessage = empty($merchantMessage) ? static::MESSAGE : $merchantMessage; $this->clientMessage = empty($clientMessage) ? static::CLIENT_MESSAGE : $clientMessage; diff --git a/src/Interfaces/CancelServiceInterface.php b/src/Interfaces/CancelServiceInterface.php index efa5314e9..5400380ad 100644 --- a/src/Interfaces/CancelServiceInterface.php +++ b/src/Interfaces/CancelServiceInterface.php @@ -8,13 +8,13 @@ namespace UnzerSDK\Interfaces; +use RuntimeException; use UnzerSDK\Constants\CancelReasonCodes; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\Payment; use UnzerSDK\Resources\TransactionTypes\Authorization; use UnzerSDK\Resources\TransactionTypes\Cancellation; use UnzerSDK\Resources\TransactionTypes\Charge; -use RuntimeException; interface CancelServiceInterface { @@ -30,7 +30,7 @@ interface CancelServiceInterface * @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 cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation; + public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation; /** * Performs a Cancellation transaction for the Authorization of the given Payment object. @@ -44,7 +44,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount * @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 cancelAuthorizationByPayment($payment, float $amount = null): Cancellation; + public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation; /** * Performs a Cancellation transaction for the given Charge and returns the resulting Cancellation object. @@ -67,11 +67,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca public function cancelChargeById( $payment, string $chargeId, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation; /** @@ -93,11 +93,11 @@ public function cancelChargeById( */ public function cancelCharge( Charge $charge, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation; /** @@ -119,11 +119,11 @@ public function cancelCharge( */ public function cancelPayment( $payment, - float $amount = null, + ?float $amount = null, ?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): array; /** @@ -167,5 +167,5 @@ public function cancelChargedPayment($payment, ?Cancellation $cancellation = nul * @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK. */ - public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation; + public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation; } diff --git a/src/Interfaces/PaymentServiceInterface.php b/src/Interfaces/PaymentServiceInterface.php index 477e03ead..d4613979e 100644 --- a/src/Interfaces/PaymentServiceInterface.php +++ b/src/Interfaces/PaymentServiceInterface.php @@ -9,6 +9,7 @@ namespace UnzerSDK\Interfaces; use DateTime; +use RuntimeException; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\AbstractUnzerResource; use UnzerSDK\Resources\Basket; @@ -24,7 +25,6 @@ use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Payout; use UnzerSDK\Resources\TransactionTypes\Shipment; -use RuntimeException; interface PaymentServiceInterface { @@ -48,8 +48,8 @@ public function performAuthorization( Authorization $authorization, $paymentType, $customer = null, - Metadata $metadata = null, - Basket $basket = null + ?Metadata $metadata = null, + ?Basket $basket = null ): Authorization; /** @@ -130,8 +130,8 @@ public function performCharge( Charge $charge, $paymentType, $customer = null, - Metadata $metadata = null, - Basket $basket = null + ?Metadata $metadata = null, + ?Basket $basket = null ): Charge; /** @@ -229,9 +229,9 @@ public function performChargeOnPayment( */ public function chargeAuthorization( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge; /** @@ -252,9 +252,9 @@ public function chargeAuthorization( */ public function chargePayment( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge; /** @@ -284,11 +284,11 @@ public function payout( $paymentType, string $returnUrl, $customer = null, - string $orderId = null, - Metadata $metadata = null, - Basket $basket = null, - string $invoiceId = null, - string $referenceText = null + ?string $orderId = null, + ?Metadata $metadata = null, + ?Basket $basket = null, + ?string $invoiceId = null, + ?string $referenceText = null ): Payout; /** @@ -303,7 +303,7 @@ public function payout( * @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 ship($payment, string $invoiceId = null, string $orderId = null): Shipment; + public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment; /** * Initializes a PayPage for charge transaction and returns the PayPage resource. @@ -328,9 +328,9 @@ public function ship($payment, string $invoiceId = null, string $orderId = null) */ public function initPayPageCharge( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage; /** @@ -356,9 +356,9 @@ public function initPayPageCharge( */ public function initPayPageAuthorize( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage; /** @@ -378,7 +378,7 @@ public function fetchInstallmentPlans( float $amount, string $currency, float $effectiveInterest, - DateTime $orderDate = null + ?DateTime $orderDate = null ): InstalmentPlans; /** diff --git a/src/Interfaces/ResourceServiceInterface.php b/src/Interfaces/ResourceServiceInterface.php index 531470dd8..6f26b0ad1 100644 --- a/src/Interfaces/ResourceServiceInterface.php +++ b/src/Interfaces/ResourceServiceInterface.php @@ -57,7 +57,7 @@ public function fetchPayout($payment): Payout; * @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 activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring; + public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring; /** * Fetch and return payment by given payment id or payment object. diff --git a/src/Interfaces/WebhookServiceInterface.php b/src/Interfaces/WebhookServiceInterface.php index 48c89e2eb..8ae6b5a03 100644 --- a/src/Interfaces/WebhookServiceInterface.php +++ b/src/Interfaces/WebhookServiceInterface.php @@ -8,10 +8,10 @@ namespace UnzerSDK\Interfaces; +use RuntimeException; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\AbstractUnzerResource; use UnzerSDK\Resources\Webhook; -use RuntimeException; interface WebhookServiceInterface { @@ -106,5 +106,5 @@ public function registerMultipleWebhooks(string $url, array $events): array; * @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 fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource; + public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource; } diff --git a/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php b/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php index 647474da1..31dfa913c 100644 --- a/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php +++ b/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php @@ -15,12 +15,7 @@ class SignedMessage extends AbstractUnzerResource /** @var string */ protected $encryptedMessage; - /** - * @param string $tag - * @param string $ephemeralPublicKey - * @param string $encryptedMessage - */ - public function __construct(string $tag = null, string $ephemeralPublicKey = null, string $encryptedMessage = null) + public function __construct(?string $tag = null, ?string $ephemeralPublicKey = null, ?string $encryptedMessage = null) { $this->tag = $tag; $this->ephemeralPublicKey = $ephemeralPublicKey; diff --git a/src/Resources/InstalmentPlan.php b/src/Resources/InstalmentPlan.php index bcdcf8591..3c9769548 100644 --- a/src/Resources/InstalmentPlan.php +++ b/src/Resources/InstalmentPlan.php @@ -3,10 +3,10 @@ namespace UnzerSDK\Resources; use DateTime; +use stdClass; use UnzerSDK\Adapter\HttpAdapterInterface; use UnzerSDK\Resources\PaymentTypes\BasePaymentType; use UnzerSDK\Traits\CanAuthorizeWithCustomer; -use stdClass; /** * Resource representing the installment plan for Installment Secured. @@ -77,17 +77,17 @@ class InstalmentPlan extends BasePaymentType * @param float|null $lastRate */ public function __construct( - int $numberOfRates = null, - string $dayOfPurchase = null, - float $totalPurchaseAmount = null, - float $totalInterestAmount = null, - float $totalAmount = null, - float $effectiveInterestRate = null, - float $nominalInterestRate = null, - float $feeFirstRate = null, - float $feePerRate = null, - float $monthlyRate = null, - float $lastRate = null + ?int $numberOfRates = null, + ?string $dayOfPurchase = null, + ?float $totalPurchaseAmount = null, + ?float $totalInterestAmount = null, + ?float $totalAmount = null, + ?float $effectiveInterestRate = null, + ?float $nominalInterestRate = null, + ?float $feeFirstRate = null, + ?float $feePerRate = null, + ?float $monthlyRate = null, + ?float $lastRate = null ) { $this->numberOfRates = $numberOfRates; $this->dayOfPurchase = $dayOfPurchase; diff --git a/src/Resources/Payment.php b/src/Resources/Payment.php index 20f956d32..4a75656b4 100755 --- a/src/Resources/Payment.php +++ b/src/Resources/Payment.php @@ -829,11 +829,11 @@ public function getExternalId(): ?string * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function cancelAmount( - float $amount = null, + ?float $amount = null, ?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL, - string $paymentReference = null, - float $amountNet = null, - float $amountVat = null + ?string $paymentReference = null, + ?float $amountNet = null, + ?float $amountVat = null ): array { return $this->getUnzerObject()->cancelPayment($this, $amount, $reasonCode, $paymentReference, $amountNet, $amountVat); } @@ -850,7 +850,7 @@ public function cancelAmount( * @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 cancelAuthorizationAmount(float $amount = null): ?Cancellation + public function cancelAuthorizationAmount(?float $amount = null): ?Cancellation { return $this->getUnzerObject()->cancelPaymentAuthorization($this, $amount); } @@ -865,7 +865,7 @@ public function cancelAuthorizationAmount(float $amount = null): ?Cancellation * @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 charge(float $amount = null): Charge + public function charge(?float $amount = null): Charge { return $this->getUnzerObject()->chargePayment($this, $amount); } @@ -881,7 +881,7 @@ public function charge(float $amount = null): Charge * @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 ship(string $invoiceId = null, string $orderId = null) + public function ship(?string $invoiceId = null, ?string $orderId = null) { return $this->getUnzerObject()->ship($this, $invoiceId, $orderId); } diff --git a/src/Resources/PaymentTypes/Card.php b/src/Resources/PaymentTypes/Card.php index 3a6888838..3ada8c562 100755 --- a/src/Resources/PaymentTypes/Card.php +++ b/src/Resources/PaymentTypes/Card.php @@ -2,6 +2,8 @@ namespace UnzerSDK\Resources\PaymentTypes; +use RuntimeException; +use stdClass; use UnzerSDK\Adapter\HttpAdapterInterface; use UnzerSDK\Resources\EmbeddedResources\CardDetails; use UnzerSDK\Traits\CanAuthorize; @@ -9,8 +11,6 @@ use UnzerSDK\Traits\CanPayout; use UnzerSDK\Traits\CanRecur; use UnzerSDK\Validators\ExpiryDateValidator; -use RuntimeException; -use stdClass; /** * This represents the card payment type which supports credit card as well as debit card payments. @@ -56,7 +56,7 @@ class Card extends BasePaymentType * @param string|null $expiryDate * @param string|null $email */ - public function __construct(?string $number, ?string $expiryDate, string $email = null) + public function __construct(?string $number, ?string $expiryDate, ?string $email = null) { $this->setNumber($number); $this->setExpiryDate($expiryDate); diff --git a/src/Resources/PaymentTypes/InstallmentSecured.php b/src/Resources/PaymentTypes/InstallmentSecured.php index 1410d7130..15a1dd04a 100644 --- a/src/Resources/PaymentTypes/InstallmentSecured.php +++ b/src/Resources/PaymentTypes/InstallmentSecured.php @@ -34,7 +34,7 @@ class InstallmentSecured extends InstalmentPlan * @param null|DateTime|string $invoiceDate * @param null|DateTime|string $invoiceDueDate */ - public function __construct(InstalmentPlan $selectedPlan = null, $iban = null, $accountHolder = null, $orderDate = null, $bic = null, $invoiceDate = null, $invoiceDueDate = null) + public function __construct(?InstalmentPlan $selectedPlan = null, $iban = null, $accountHolder = null, $orderDate = null, $bic = null, $invoiceDate = null, $invoiceDueDate = null) { parent::__construct(); diff --git a/src/Resources/PaymentTypes/OpenbankingPis.php b/src/Resources/PaymentTypes/OpenbankingPis.php index f8e07de48..c7fa5af34 100644 --- a/src/Resources/PaymentTypes/OpenbankingPis.php +++ b/src/Resources/PaymentTypes/OpenbankingPis.php @@ -9,7 +9,7 @@ class OpenbankingPis extends BasePaymentType /** @var string|null $ibanCountry */ protected $ibanCountry; - public function __construct(string $ibanCountry = null) + public function __construct(?string $ibanCountry = null) { $this->ibanCountry = $ibanCountry; } diff --git a/src/Resources/PaymentTypes/PaylaterDirectDebit.php b/src/Resources/PaymentTypes/PaylaterDirectDebit.php index fb7c3a179..8c89b5988 100644 --- a/src/Resources/PaymentTypes/PaylaterDirectDebit.php +++ b/src/Resources/PaymentTypes/PaylaterDirectDebit.php @@ -12,7 +12,7 @@ class PaylaterDirectDebit extends BasePaymentType /** @var string $holder */ protected $holder; - public function __construct(string $iban = null, string $holder = null) + public function __construct(?string $iban = null, ?string $holder = null) { $this->iban = $iban; $this->holder = $holder; diff --git a/src/Resources/TransactionTypes/Authorization.php b/src/Resources/TransactionTypes/Authorization.php index b37ac71d2..6936b8b84 100755 --- a/src/Resources/TransactionTypes/Authorization.php +++ b/src/Resources/TransactionTypes/Authorization.php @@ -2,6 +2,7 @@ namespace UnzerSDK\Resources\TransactionTypes; +use RuntimeException; use UnzerSDK\Adapter\HttpAdapterInterface; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\Payment; @@ -9,7 +10,6 @@ use UnzerSDK\Traits\HasCancellations; use UnzerSDK\Traits\HasDescriptor; use UnzerSDK\Traits\HasRecurrenceType; -use RuntimeException; /** * This represents the authorization transaction. @@ -55,7 +55,7 @@ class Authorization extends AbstractTransactionType * @param string|null $currency * @param string|null $returnUrl */ - public function __construct(float $amount = null, string $currency = null, string $returnUrl = null) + public function __construct(?float $amount = null, ?string $currency = null, ?string $returnUrl = null) { $this->setAmount($amount); $this->setCurrency($currency); @@ -250,7 +250,7 @@ protected function getResourcePath(string $httpMethod = HttpAdapterInterface::RE * @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 cancel(float $amount = null): Cancellation + public function cancel(?float $amount = null): Cancellation { return $this->getUnzerObject()->cancelAuthorization($this, $amount); } @@ -265,7 +265,7 @@ public function cancel(float $amount = null): Cancellation * @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 charge(float $amount = null): Charge + public function charge(?float $amount = null): Charge { $payment = $this->getPayment(); if (!$payment instanceof Payment) { diff --git a/src/Resources/TransactionTypes/Cancellation.php b/src/Resources/TransactionTypes/Cancellation.php index 26d92e851..ad41d1c22 100755 --- a/src/Resources/TransactionTypes/Cancellation.php +++ b/src/Resources/TransactionTypes/Cancellation.php @@ -6,7 +6,6 @@ use UnzerSDK\Constants\CancelReasonCodes; use UnzerSDK\Resources\Payment; use UnzerSDK\Resources\PaymentTypes\InstallmentSecured; - use function in_array; /** @@ -49,7 +48,7 @@ class Cancellation extends AbstractTransactionType * * @param float|null $amount The amount to be cancelled, is transferred as grossAmount in case of Installment Secured. */ - public function __construct(float $amount = null) + public function __construct(?float $amount = null) { $this->setAmount($amount); } diff --git a/src/Resources/TransactionTypes/Charge.php b/src/Resources/TransactionTypes/Charge.php index d7f16858a..278cc9c3b 100755 --- a/src/Resources/TransactionTypes/Charge.php +++ b/src/Resources/TransactionTypes/Charge.php @@ -2,6 +2,7 @@ namespace UnzerSDK\Resources\TransactionTypes; +use RuntimeException; use UnzerSDK\Adapter\HttpAdapterInterface; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Traits\HasAccountInformation; @@ -9,7 +10,6 @@ use UnzerSDK\Traits\HasChargebacks; use UnzerSDK\Traits\HasDescriptor; use UnzerSDK\Traits\HasRecurrenceType; -use RuntimeException; /** * This represents the charge transaction. @@ -47,7 +47,7 @@ class Charge extends AbstractTransactionType * @param string|null $currency * @param string|null $returnUrl */ - public function __construct(float $amount = null, string $currency = null, string $returnUrl = null) + public function __construct(?float $amount = null, ?string $currency = null, ?string $returnUrl = null) { $this->setAmount($amount); $this->setCurrency($currency); @@ -199,11 +199,11 @@ protected function getResourcePath(string $httpMethod = HttpAdapterInterface::RE * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function cancel( - float $amount = null, - string $reasonCode = null, - string $paymentReference = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $paymentReference = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation { return $this->getUnzerObject()->cancelCharge( $this, diff --git a/src/Resources/TransactionTypes/Chargeback.php b/src/Resources/TransactionTypes/Chargeback.php index 7c0c5925a..2ef22d038 100644 --- a/src/Resources/TransactionTypes/Chargeback.php +++ b/src/Resources/TransactionTypes/Chargeback.php @@ -24,7 +24,7 @@ class Chargeback extends AbstractTransactionType /** * @param float|null $amount The amount to be cancelled, is transferred as grossAmount in case of Installment Secured. */ - public function __construct(float $amount = null) + public function __construct(?float $amount = null) { $this->setAmount($amount); } diff --git a/src/Resources/TransactionTypes/Payout.php b/src/Resources/TransactionTypes/Payout.php index 39f6a93de..15f0767ca 100644 --- a/src/Resources/TransactionTypes/Payout.php +++ b/src/Resources/TransactionTypes/Payout.php @@ -24,14 +24,7 @@ class Payout extends AbstractTransactionType /** @var string $paymentReference */ protected $paymentReference; - /** - * Payout constructor. - * - * @param float|null $amount - * @param string|null $currency - * @param null $returnUrl - */ - public function __construct(float $amount = null, string $currency = null, $returnUrl = null) + public function __construct(?float $amount = null, ?string $currency = null, $returnUrl = null) { $this->setAmount($amount); $this->setCurrency($currency); diff --git a/src/Services/CancelService.php b/src/Services/CancelService.php index 354cb9011..37106177c 100644 --- a/src/Services/CancelService.php +++ b/src/Services/CancelService.php @@ -12,7 +12,6 @@ use UnzerSDK\Resources\TransactionTypes\Cancellation; use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Unzer; - use function in_array; use function is_string; @@ -67,7 +66,7 @@ public function getResourceService(): ResourceService /** * {@inheritDoc} */ - public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation + public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation { $cancellation = new Cancellation($amount); $cancellation->setPayment($authorization->getPayment())->setParentResource($authorization); @@ -80,7 +79,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount /** * {@inheritDoc} */ - public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation + public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation { $authorization = $this->getResourceService()->fetchAuthorization($payment); return $this->cancelAuthorization($authorization, $amount); @@ -92,11 +91,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca public function cancelChargeById( $payment, string $chargeId, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation { $charge = $this->getResourceService()->fetchChargeById($payment, $chargeId); return $this->cancelCharge($charge, $amount, $reasonCode, $referenceText, $amountNet, $amountVat); @@ -107,11 +106,11 @@ public function cancelChargeById( */ public function cancelCharge( Charge $charge, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation { $cancellation = new Cancellation($amount); $cancellation @@ -131,11 +130,11 @@ public function cancelCharge( */ public function cancelPayment( $payment, - float $amount = null, + ?float $amount = null, ?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): array { $paymentObject = $payment; if (is_string($payment)) { @@ -186,7 +185,7 @@ public function cancelPayment( /** * {@inheritDoc} */ - public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation + public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation { $cancellation = null; $completeCancel = $amount === null; diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index 4e4fb0604..cce644cb5 100755 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -18,7 +18,6 @@ * This service provides for functionalities concerning http transactions. * * @link https://docs.unzer.com/ - * */ class HttpService { @@ -82,26 +81,26 @@ public function setEnvironmentService(EnvironmentService $environmentService): H } /** - * @deprecated use sendRequest() instead. - * * send post request to payment server * - * @param $uri string|null uri of the target system - * @param ?AbstractUnzerResource $resource - * @param string $httpMethod - * @param string $apiVersion + * @param string|null $uri uri of the target system + * @param AbstractUnzerResource|null $resource + * @param string $httpMethod + * @param string|null $apiVersion * * @return string * * @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. + * @deprecated use sendRequest() instead. */ public function send( ?string $uri = null, ?AbstractUnzerResource $resource = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET, - string $apiVersion = null - ): string { + ?string $apiVersion = null + ): string + { if (!$resource instanceof AbstractUnzerResource) { throw new RuntimeException('Transfer object is empty!'); } @@ -115,15 +114,11 @@ public function send( /** * send post request to payment server * - * @param ApiRequest $request - * @return string - * * @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 sendRequest( - ApiRequest $request - ): string { + public function sendRequest(ApiRequest $request): string + { $unzerObj = $request->getResource()->getUnzerObject(); $apiConfig = $request->getResource()->getApiConfig(); @@ -137,8 +132,8 @@ public function sendRequest( $headers = $this->composeHttpHeaders($unzerObj, $apiConfig::getAuthorizationMethod()); $httpMethod = $request->getHttpMethod(); $this->initRequest($requestUrl, $payload, $httpMethod, $headers); - $httpAdapter = $this->getAdapter(); - $response = $httpAdapter->execute(); + $httpAdapter = $this->getAdapter(); + $response = $httpAdapter->execute(); $responseCode = $httpAdapter->getResponseCode(); $httpAdapter->close(); @@ -158,7 +153,7 @@ public function sendRequest( * @param string $uri * @param string $payload * @param string $httpMethod - * @param array $httpHeaders + * @param array $httpHeaders * * @throws RuntimeException */ @@ -174,7 +169,7 @@ private function initRequest(string $uri, string $payload, string $httpMethod, a * Handles error responses by throwing an UnzerApiException with the returned messages and error code. * Returns doing nothing if no error occurred. * - * @param string $responseCode + * @param string $responseCode * @param string|null $response * * @throws UnzerApiException @@ -187,15 +182,15 @@ private function handleErrors(string $responseCode, ?string $response): void $responseObject = json_decode($response, false); if (!is_numeric($responseCode) || (int)$responseCode >= 400 || isset($responseObject->errors)) { - $code = null; - $errorId = null; + $code = null; + $errorId = null; $customerMessage = $code; $merchantMessage = $customerMessage; if (isset($responseObject->errors[0])) { - $errors = $responseObject->errors[0]; + $errors = $responseObject->errors[0]; $merchantMessage = $errors->merchantMessage ?? ''; $customerMessage = $errors->customerMessage ?? ''; - $code = $errors->code ?? ''; + $code = $errors->code ?? ''; } if (isset($responseObject->id)) { $errorId = $responseObject->id; @@ -209,23 +204,24 @@ private function handleErrors(string $responseCode, ?string $response): void } /** - * @param Unzer $unzerObj - * @param string $payload - * @param mixed $headers - * @param string $responseCode - * @param string $httpMethod - * @param string $url + * @param Unzer $unzerObj + * @param string $payload + * @param mixed $headers + * @param string $responseCode + * @param string $httpMethod + * @param string $url * @param string|null $response */ public function debugLog( Unzer $unzerObj, string $payload, - $headers, - string $responseCode, + $headers, + string $responseCode, string $httpMethod, string $url, ?string $response - ): void { + ): void + { // mask auth string $authHeader = explode(' ', $headers['Authorization']); $authHeader[1] = ValueService::maskValue($authHeader[1]); @@ -275,16 +271,16 @@ private function buildRequestUrl(ApiRequest $request): string */ public function composeHttpHeaders(Unzer $unzer, string $authorizationMethod = AuthorizationMethods::BASIC): array { - $locale = $unzer->getLocale(); - $clientIp = $unzer->getClientIp(); - $key = $unzer->getKey(); + $locale = $unzer->getLocale(); + $clientIp = $unzer->getClientIp(); + $key = $unzer->getKey(); $httpHeaders = [ 'Authorization' => $this->findAuthentication($unzer, $authorizationMethod), - 'Content-Type' => 'application/json', - 'SDK-VERSION' => Unzer::SDK_VERSION, - 'SDK-TYPE' => Unzer::SDK_TYPE, - 'PHP-VERSION' => PHP_VERSION + 'Content-Type' => 'application/json', + 'SDK-VERSION' => Unzer::SDK_VERSION, + 'SDK-TYPE' => Unzer::SDK_TYPE, + 'PHP-VERSION' => PHP_VERSION ]; if (!empty($locale)) { $httpHeaders['Accept-Language'] = $locale; @@ -347,6 +343,7 @@ public function isApiConfig($className): bool /** * @param Unzer $unzer + * * @return string */ private function findAuthentication(Unzer $unzer, string $authorizationMethod = AuthorizationMethods::BASIC): string diff --git a/src/Services/PaymentService.php b/src/Services/PaymentService.php index c59cd819d..8eefc3597 100755 --- a/src/Services/PaymentService.php +++ b/src/Services/PaymentService.php @@ -73,12 +73,15 @@ public function getResourceService(): ResourceService return $this->getUnzer()->getResourceService(); } + /** + * {@inheritDoc} + */ public function performAuthorization( Authorization $authorization, $paymentType, $customer = null, - Metadata $metadata = null, - Basket $basket = null + ?Metadata $metadata = null, + ?Basket $basket = null ): Authorization { $payment = $this->createPayment($paymentType); $paymentType = $payment->getPaymentType(); @@ -144,7 +147,7 @@ public function authorize( /** * {@inheritDoc} */ - public function performCharge(Charge $charge, $paymentType, $customer = null, Metadata $metadata = null, Basket $basket = null): Charge + public function performCharge(Charge $charge, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Charge { $payment = $this->createPayment($paymentType); $paymentType = $payment->getPaymentType(); @@ -214,9 +217,9 @@ public function charge( */ public function chargeAuthorization( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge { return $this->chargePayment($payment, $amount, $orderId, $invoiceId); } @@ -226,9 +229,9 @@ public function chargeAuthorization( */ public function chargePayment( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge { $charge = new Charge($amount); @@ -263,11 +266,11 @@ public function payout( $paymentType, string $returnUrl, $customer = null, - string $orderId = null, - Metadata $metadata = null, - Basket $basket = null, - string $invoiceId = null, - string $referenceText = null + ?string $orderId = null, + ?Metadata $metadata = null, + ?Basket $basket = null, + ?string $invoiceId = null, + ?string $referenceText = null ): Payout { $payment = $this->createPayment($paymentType); $payout = (new Payout($amount, $currency, $returnUrl)) @@ -283,7 +286,7 @@ public function payout( /** * {@inheritDoc} */ - public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment + public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment { $shipment = new Shipment(); $shipment->setInvoiceId($invoiceId)->setOrderId($orderId); @@ -297,9 +300,9 @@ public function ship($payment, string $invoiceId = null, string $orderId = null) */ public function initPayPageCharge( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage { return $this->initPayPage($paypage, TransactionTypes::CHARGE, $customer, $basket, $metadata); } @@ -309,9 +312,9 @@ public function initPayPageCharge( */ public function initPayPageAuthorize( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage { return $this->initPayPage($paypage, TransactionTypes::AUTHORIZATION, $customer, $basket, $metadata); } @@ -323,7 +326,7 @@ public function fetchInstallmentPlans( float $amount, string $currency, float $effectiveInterest, - DateTime $orderDate = null + ?DateTime $orderDate = null ): InstalmentPlans { $ins = (new InstallmentSecured(null, null, null))->setParentResource($this->unzer); $plans = (new InstalmentPlans($amount, $currency, $effectiveInterest, $orderDate))->setParentResource($ins); @@ -365,9 +368,9 @@ public function fetchPaylaterInstallmentPlans( private function initPayPage( Paypage $paypage, string $action, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage { $paypage->setAction($action)->setParentResource($this->unzer); $payment = $this->createPayment($paypage)->setBasket($basket)->setCustomer($customer)->setMetadata($metadata)->setPayPage($paypage); diff --git a/src/Services/ResourceService.php b/src/Services/ResourceService.php index 7436fb564..2b2d1c922 100755 --- a/src/Services/ResourceService.php +++ b/src/Services/ResourceService.php @@ -110,7 +110,7 @@ public function setUnzer(Unzer $unzer): ResourceServiceInterface * * @param AbstractUnzerResource $resource * @param string $httpMethod - * @param string $apiVersion + * @param string|null $apiVersion * * @return stdClass * @@ -120,7 +120,7 @@ public function setUnzer(Unzer $unzer): ResourceServiceInterface public function send( AbstractUnzerResource $resource, string $httpMethod = HttpAdapterInterface::REQUEST_GET, - string $apiVersion = null + ?string $apiVersion = null ): stdClass { $apiConfig = $resource->getApiConfig(); @@ -338,7 +338,7 @@ public function deleteResource(AbstractUnzerResource &$resource): ?AbstractUnzer * Updates the given local resource object (id must be set) * * @param AbstractUnzerResource $resource The local resource object to update. - * @param string $apiVersion + * @param string|null $apiVersion * * @return AbstractUnzerResource The updated resource object. * @@ -346,7 +346,7 @@ public function deleteResource(AbstractUnzerResource &$resource): ?AbstractUnzer * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @throws Exception */ - public function fetchResource(AbstractUnzerResource $resource, string $apiVersion = null): AbstractUnzerResource + public function fetchResource(AbstractUnzerResource $resource, ?string $apiVersion = null): AbstractUnzerResource { $method = HttpAdapterInterface::REQUEST_GET; $response = $this->send($resource, $method, $apiVersion); @@ -379,7 +379,7 @@ public function fetchPayout($payment): Payout /** * {@inheritDoc} */ - public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring + public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring { $paymentTypeObject = $paymentType; if (is_string($paymentType)) { @@ -566,7 +566,7 @@ public function fetchBasket($basket): Basket try { $this->fetchResource($basketObj, $basketVersion); } catch (UnzerApiException $exception) { - if ($exception->getCode() !== ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND || $isV3Basket) { + if ($exception->getCode() !== ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND || $basketVersion === ApiVersions::V3) { throw $exception; } $this->fetchResource($basketObj); diff --git a/src/Services/WebhookService.php b/src/Services/WebhookService.php index c8117d185..a273bb567 100755 --- a/src/Services/WebhookService.php +++ b/src/Services/WebhookService.php @@ -2,14 +2,13 @@ namespace UnzerSDK\Services; -use UnzerSDK\Unzer; +use RuntimeException; use UnzerSDK\Interfaces\ResourceServiceInterface; use UnzerSDK\Interfaces\WebhookServiceInterface; use UnzerSDK\Resources\AbstractUnzerResource; use UnzerSDK\Resources\Webhook; use UnzerSDK\Resources\Webhooks; -use RuntimeException; - +use UnzerSDK\Unzer; use function is_string; /** @@ -165,7 +164,7 @@ public function registerMultipleWebhooks(string $url, array $events): array /** * {@inheritDoc} */ - public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource + public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource { $resourceObject = null; $eventData = json_decode($eventJson ?? $this->readInputStream(), false); diff --git a/src/Traits/CanPayout.php b/src/Traits/CanPayout.php index 4458e68d2..f03042d29 100644 --- a/src/Traits/CanPayout.php +++ b/src/Traits/CanPayout.php @@ -8,13 +8,13 @@ namespace UnzerSDK\Traits; +use RuntimeException; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Interfaces\UnzerParentInterface; use UnzerSDK\Resources\Basket; use UnzerSDK\Resources\Customer; use UnzerSDK\Resources\Metadata; use UnzerSDK\Resources\TransactionTypes\Payout; -use RuntimeException; trait CanPayout { @@ -44,11 +44,11 @@ public function payout( string $currency, string $returnUrl, $customer = null, - string $orderId = null, + ?string $orderId = null, $metadata = null, - Basket $basket = null, - string $invoiceId = null, - string $paymentReference = null + ?Basket $basket = null, + ?string $invoiceId = null, + ?string $paymentReference = null ): Payout { if ($this instanceof UnzerParentInterface) { return $this->getUnzerObject()->payout( diff --git a/src/Traits/CanPayoutWithCustomer.php b/src/Traits/CanPayoutWithCustomer.php index 389a4bf06..76c5673e3 100644 --- a/src/Traits/CanPayoutWithCustomer.php +++ b/src/Traits/CanPayoutWithCustomer.php @@ -8,13 +8,13 @@ namespace UnzerSDK\Traits; +use RuntimeException; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Interfaces\UnzerParentInterface; use UnzerSDK\Resources\Basket; use UnzerSDK\Resources\Customer; use UnzerSDK\Resources\Metadata; use UnzerSDK\Resources\TransactionTypes\Payout; -use RuntimeException; trait CanPayoutWithCustomer { @@ -42,9 +42,9 @@ public function payout( string $currency, string $returnUrl, $customer, - string $orderId = null, + ?string $orderId = null, $metadata = null, - Basket $basket = null + ?Basket $basket = null ): Payout { if ($this instanceof UnzerParentInterface) { return $this->getUnzerObject()->payout( diff --git a/src/Unzer.php b/src/Unzer.php index bc3d88b35..b86d9fb8a 100644 --- a/src/Unzer.php +++ b/src/Unzer.php @@ -95,7 +95,7 @@ class Unzer implements * Construct a new Unzer object. * * @param string $key The private key your received from your Unzer contact person. - * @param ?string $locale The locale of the customer defining defining the translation (e.g. 'en-GB' or 'de-DE'). + * @param string|null $locale The locale of the customer defining defining the translation (e.g. 'en-GB' or 'de-DE'). * * @throws RuntimeException A RuntimeException will be thrown if the key is not of type private. * @@ -358,7 +358,7 @@ public function getUri(bool $appendId = true, string $httpMethod = HttpAdapterIn /** * {@inheritDoc} */ - public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring + public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring { return $this->resourceService->activateRecurringPayment($paymentType, $returnUrl, $recurrenceType); } @@ -667,7 +667,7 @@ public function registerMultipleWebhooks(string $url, array $events): array /** * {@inheritDoc} */ - public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource + public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource { return $this->webhookService->fetchResourceFromEvent($eventJson); } @@ -679,8 +679,8 @@ public function performAuthorization( Authorization $authorization, $paymentType, $customer = null, - Metadata $metadata = null, - Basket $basket = null + ?Metadata $metadata = null, + ?Basket $basket = null ): Authorization { return $this->paymentService->performAuthorization($authorization, $paymentType, $customer, $metadata, $basket); @@ -735,8 +735,8 @@ public function performCharge( Charge $charge, $paymentType, $customer = null, - Metadata $metadata = null, - Basket $basket = null + ?Metadata $metadata = null, + ?Basket $basket = null ): Charge { return $this->paymentService->performCharge($charge, $paymentType, $customer, $metadata, $basket); @@ -786,9 +786,9 @@ public function charge( */ public function chargeAuthorization( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge { return $this->paymentService->chargeAuthorization($payment, $amount, $orderId, $invoiceId); @@ -799,9 +799,9 @@ public function chargeAuthorization( */ public function chargePayment( $payment, - float $amount = null, - string $orderId = null, - string $invoiceId = null + ?float $amount = null, + ?string $orderId = null, + ?string $invoiceId = null ): Charge { return $this->paymentService->chargePayment($payment, $amount, $orderId, $invoiceId); @@ -815,7 +815,7 @@ public function performChargeOnPayment($payment, Charge $charge): Charge /** * {@inheritDoc} */ - public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation + public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation { return $this->cancelService->cancelAuthorization($authorization, $amount); } @@ -823,7 +823,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount /** * {@inheritDoc} */ - public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation + public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation { return $this->cancelService->cancelAuthorizationByPayment($payment, $amount); } @@ -833,11 +833,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca */ public function cancelPayment( $payment, - float $amount = null, + ?float $amount = null, ?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): array { return $this->cancelService @@ -847,7 +847,7 @@ public function cancelPayment( /** * {@inheritDoc} */ - public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation + public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation { return $this->cancelService->cancelPaymentAuthorization($payment, $amount); } @@ -858,11 +858,11 @@ public function cancelPaymentAuthorization($payment, float $amount = null): ?Can public function cancelChargeById( $payment, string $chargeId, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation { return $this->cancelService @@ -874,11 +874,11 @@ public function cancelChargeById( */ public function cancelCharge( Charge $charge, - float $amount = null, - string $reasonCode = null, - string $referenceText = null, - float $amountNet = null, - float $amountVat = null + ?float $amount = null, + ?string $reasonCode = null, + ?string $referenceText = null, + ?float $amountNet = null, + ?float $amountVat = null ): Cancellation { return $this->cancelService @@ -917,7 +917,7 @@ public function createAuthToken(): Token /** * {@inheritDoc} */ - public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment + public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment { return $this->paymentService->ship($payment, $invoiceId, $orderId); } @@ -931,11 +931,11 @@ public function payout( $paymentType, string $returnUrl, $customer = null, - string $orderId = null, - Metadata $metadata = null, - Basket $basket = null, - string $invoiceId = null, - string $referenceText = null + ?string $orderId = null, + ?Metadata $metadata = null, + ?Basket $basket = null, + ?string $invoiceId = null, + ?string $referenceText = null ): Payout { return $this->paymentService->payout( @@ -1004,9 +1004,9 @@ public function fetchPaypageV2($paypage): PaypageV2 */ public function initPayPageCharge( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage { return $this->paymentService->initPayPageCharge($paypage, $customer, $basket, $metadata); @@ -1017,9 +1017,9 @@ public function initPayPageCharge( */ public function initPayPageAuthorize( Paypage $paypage, - Customer $customer = null, - Basket $basket = null, - Metadata $metadata = null + ?Customer $customer = null, + ?Basket $basket = null, + ?Metadata $metadata = null ): Paypage { return $this->paymentService->initPayPageAuthorize($paypage, $customer, $basket, $metadata); @@ -1032,7 +1032,7 @@ public function fetchInstallmentPlans( float $amount, string $currency, float $effectiveInterest, - DateTime $orderDate = null + ?DateTime $orderDate = null ): InstalmentPlans { return $this->paymentService @@ -1078,7 +1078,7 @@ public function debugLog($message): void * @param string|null $jwtToken If set, the given token will be used instead as long it is valid. * @throws UnzerApiException */ - public function prepareJwtToken(string $jwtToken = null): string + public function prepareJwtToken(?string $jwtToken = null): string { if ($jwtToken !== null && JwtService::validateExpiryTime($jwtToken)) { $this->jwtToken = $jwtToken; diff --git a/test/unit/Services/DummyAdapter.php b/test/unit/Services/DummyAdapter.php index 399d50cd8..a37787088 100755 --- a/test/unit/Services/DummyAdapter.php +++ b/test/unit/Services/DummyAdapter.php @@ -18,7 +18,7 @@ class DummyAdapter implements HttpAdapterInterface /** * {@inheritDoc} */ - public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void + public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void { // do nothing }