diff --git a/samples/OrderCreate.php b/samples/OrderCreate.php index a616041..95690d4 100644 --- a/samples/OrderCreate.php +++ b/samples/OrderCreate.php @@ -15,7 +15,7 @@ $request->setDescription('Order ABC0123456789'); $request->setAmount((float)($_REQUEST['amount'] ?? 5.3)); $request->setCurrency('EUR'); -$request->setExpire(date('Y-m-d H:i:s', strtotime('+1 DAY'))); +$request->setExpire(date('c', time() + 60)); $request->setReturnurl($_REQUEST['returnUrl'] ?? 'https://yourdomain/finish.php'); $request->setExchangeUrl($_REQUEST['exchangeUrl'] ?? 'https://yourdomain/exchange.php'); $request->setPaymentMethodId((int)($_REQUEST['paymentMethodId'] ?? 10)); diff --git a/samples/OrderStatus.php b/samples/OrderStatus.php index c0257e2..97652bc 100644 --- a/samples/OrderStatus.php +++ b/samples/OrderStatus.php @@ -41,6 +41,7 @@ echo 'isRefunded: ' . ($payOrder->isRefunded() ? 'YES' : 'no') . PHP_EOL; echo 'isPartiallyRefunded: ' . ($payOrder->isRefundedPartial() ? 'YES' : 'no') . PHP_EOL . PHP_EOL; echo 'isFastcheckout: ' . ($payOrder->isFastcheckout() ? 'YES' : 'no') . PHP_EOL; +echo 'getAmountRefunded: ' . ($payOrder->getAmountRefunded()) . PHP_EOL . PHP_EOL; echo 'getStatusCode: ' . $payOrder->getStatusCode() . PHP_EOL; echo 'getStatusName: ' . $payOrder->getStatusName() . PHP_EOL; echo 'getId: ' . $payOrder->getId() . PHP_EOL; diff --git a/samples/ServiceGetConfig.php b/samples/ServiceGetConfig.php index 4b5d75e..231677e 100644 --- a/samples/ServiceGetConfig.php +++ b/samples/ServiceGetConfig.php @@ -36,7 +36,7 @@ $terminals = $config->getTerminals(); print_r($terminals); -$tguList = $config->getTguList(); +$tguList = $config->getCores(); print_r($tguList); $paymentMethods = $config->getPaymentMethods(); diff --git a/samples/TransactionStatus.php b/samples/TransactionStatus.php index 3563465..6176568 100644 --- a/samples/TransactionStatus.php +++ b/samples/TransactionStatus.php @@ -38,6 +38,8 @@ echo 'isPartialPayment: ' . ($payOrder->isPartialPayment() ? 'YES' : 'no') . PHP_EOL; echo 'isRefunded: ' . ($payOrder->isRefunded() ? 'YES' : 'no') . PHP_EOL; echo 'isPartiallyRefunded: ' . ($payOrder->isRefundedPartial() ? 'YES' : 'no') . PHP_EOL . PHP_EOL; +echo 'getAmount: ' . ($payOrder->getAmount()) . PHP_EOL; +echo 'getAmountRefunded: ' . ($payOrder->getAmountRefunded()) . PHP_EOL . PHP_EOL; echo 'getStatusCode: ' . $payOrder->getStatusCode() . PHP_EOL; echo 'getStatusName: ' . $payOrder->getStatusName() . PHP_EOL; echo 'getId: ' . $payOrder->getId() . PHP_EOL; diff --git a/src/Model/Method.php b/src/Model/Method.php index 2c61031..a380b00 100644 --- a/src/Model/Method.php +++ b/src/Model/Method.php @@ -159,7 +159,7 @@ public function setOptions(array $options): self */ public function getSettings(): array { - return $this->settings; + return $this->settings ?? []; } /** diff --git a/src/Model/Pay/PayOrder.php b/src/Model/Pay/PayOrder.php index 0f5c839..a5bde9d 100644 --- a/src/Model/Pay/PayOrder.php +++ b/src/Model/Pay/PayOrder.php @@ -130,6 +130,11 @@ class PayOrder implements ModelInterface */ protected $completedAt; + /** + * @var Amount + */ + protected $amountRefunded; + /** * @var array */ @@ -153,6 +158,27 @@ public function __construct($payload = null) } } + /** + * @return mixed + */ + public function getAmountRefunded() + { + if (!empty($this->amountRefunded) && $this->amountRefunded instanceof Amount) { + return $this->amountRefunded->getValue() / 100; + } + return null; + } + + /** + * @param $amountRefunded + * @return $this + */ + public function setAmountRefunded($amountRefunded): self + { + $this->amountRefunded = $amountRefunded; + return $this; + } + /** * @return string */ diff --git a/src/Model/Response/ServiceGetConfigResponse.php b/src/Model/Response/ServiceGetConfigResponse.php index cdc85d4..a7ad8d9 100644 --- a/src/Model/Response/ServiceGetConfigResponse.php +++ b/src/Model/Response/ServiceGetConfigResponse.php @@ -316,7 +316,7 @@ public function setCategory(array $category): void */ public function getTguList(): array { - return $this->tguList; + return $this->tguList ?? []; } /** diff --git a/src/Util/Exchange.php b/src/Util/Exchange.php index cae6240..aa63f0a 100644 --- a/src/Util/Exchange.php +++ b/src/Util/Exchange.php @@ -4,7 +4,6 @@ namespace PayNL\Sdk\Util; -use PayNL\Sdk\Config\Config as PayConfig; use PayNL\Sdk\Config\Config; use PayNL\Sdk\Model\Amount; use PayNL\Sdk\Model\Request\OrderStatusRequest; @@ -201,11 +200,11 @@ public function getPayLoad() /** * Process the exchange request. * - * @param Config|null $config + * @param Config |null $config * @return PayOrder * @throws Exception */ - public function process(PayConfig $config = null): PayOrder + public function process(Config $config = null): PayOrder { $payload = $this->getPayload();