diff --git a/config/config.global.php b/config/config.global.php index bbf76e6..5325fd4 100644 --- a/config/config.global.php +++ b/config/config.global.php @@ -4,9 +4,11 @@ return [ 'authentication' => [ - 'username' => '', # Use AT-Code or SL-Code. Use AT-code together with API-Token. - 'password' => '', # Use API-Token or secret. Use Secret in combination with SL-Code. + #'username' => 'AT-0045-3283', # Use AT-Code or SL-Code. Use AT-code together with API-Token. + #'password' => 'a3e314eef828b10d53eb9c1142b00f0262c14ab2', # Use API-Token or secret. Use Secret in combination with SL-Code. ], 'debug' => false, + #'failoverUrl' => 'https://dev-wouter.tintel.dev/sandbox_sdk3.php', + #'api' => ['url' => ''] # Core #'api' => ['url' => ''] # Core ]; \ No newline at end of file diff --git a/samples/OrderAbort.php b/samples/OrderAbort.php index 8aec20e..0d66147 100644 --- a/samples/OrderAbort.php +++ b/samples/OrderAbort.php @@ -37,8 +37,8 @@ echo 'getTransactionId: ' . $transaction->getOrderId() . PHP_EOL; echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getAmount getValue: ' . $transaction->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $transaction->getAmount()->getCurrency() . PHP_EOL; +echo 'getAmount getValue: ' . $transaction->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $transaction->getAmount() . PHP_EOL; echo 'getAuthorizedAmount getCurrency: ' . $transaction->getAuthorizedAmount()->getCurrency() . PHP_EOL; echo 'getAuthorizedAmount getValue: ' . $transaction->getAuthorizedAmount()->getValue() . PHP_EOL; echo 'getStatus:' . print_r($transaction->getStatus(), true) . PHP_EOL; diff --git a/samples/OrderApprove.php b/samples/OrderApprove.php index 8abd72c..c921097 100644 --- a/samples/OrderApprove.php +++ b/samples/OrderApprove.php @@ -20,7 +20,7 @@ $orderApproveRequest->setConfig($config); try { - $transaction = $orderApproveRequest->start(); + $payOrder = $orderApproveRequest->start(); } catch (PayException $e) { echo '
'; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -33,20 +33,17 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $transaction->getId() . PHP_EOL; -echo 'getTransactionId: ' . $transaction->getOrderId() . PHP_EOL; -echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; -echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getAmount getValue: ' . $transaction->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $transaction->getAmount()->getCurrency() . PHP_EOL; -echo 'getAuthorizedAmount getCurrency: ' . $transaction->getAuthorizedAmount()->getCurrency() . PHP_EOL; -echo 'getAuthorizedAmount getValue: ' . $transaction->getAuthorizedAmount()->getValue() . PHP_EOL; -echo 'getStatus:' . print_r($transaction->getStatus(), true) . PHP_EOL; -echo 'getPaymentData:' . print_r($transaction->getPayments(), true) . PHP_EOL; -echo 'getIntegration:' . print_r($transaction->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $transaction->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $transaction->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $transaction->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $transaction->getModifiedBy() . PHP_EOL; - +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCapture.php b/samples/OrderCapture.php index bef1dc8..7197a25 100644 --- a/samples/OrderCapture.php +++ b/samples/OrderCapture.php @@ -21,7 +21,7 @@ $orderCaptureRequest->setConfig($config); try { - $capture = $orderCaptureRequest->start(); + $payOrder = $orderCaptureRequest->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -33,21 +33,17 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $capture->getId() . PHP_EOL; -echo 'getTransactionId: ' . $capture->getOrderId() . PHP_EOL; -echo 'getServiceCode: ' . $capture->getServiceCode() . PHP_EOL; -echo 'getDescription: ' . $capture->getDescription() . PHP_EOL; -echo 'getReference: ' . $capture->getReference() . PHP_EOL; -echo 'getIpAddress: ' . $capture->getIpAddress() . PHP_EOL; -echo 'getAmount getValue: ' . $capture->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $capture->getAmount()->getCurrency() . PHP_EOL; -echo 'getStatus:' . print_r($capture->getStatus(), true) . PHP_EOL; - -echo 'getIntegration:' . print_r($capture->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $capture->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $capture->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $capture->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $capture->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $capture->getModifiedBy() . PHP_EOL; -echo 'getDeletedAt: ' . $capture->getDeletedAt() . PHP_EOL; -echo 'getDeletedBy: ' . $capture->getDeletedBy() . PHP_EOL; \ No newline at end of file +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCaptureAmount.php b/samples/OrderCaptureAmount.php index 8c5b723..945c665 100644 --- a/samples/OrderCaptureAmount.php +++ b/samples/OrderCaptureAmount.php @@ -23,7 +23,7 @@ $orderCaptureRequest->setConfig($config); try { - $capture = $orderCaptureRequest->start(); + $payOrder = $orderCaptureRequest->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -35,21 +35,17 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $capture->getId() . PHP_EOL; -echo 'getTransactionId: ' . $capture->getOrderId() . PHP_EOL; -echo 'getServiceCode: ' . $capture->getServiceCode() . PHP_EOL; -echo 'getDescription: ' . $capture->getDescription() . PHP_EOL; -echo 'getReference: ' . $capture->getReference() . PHP_EOL; -echo 'getIpAddress: ' . $capture->getIpAddress() . PHP_EOL; -echo 'getAmount getValue: ' . $capture->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $capture->getAmount()->getCurrency() . PHP_EOL; -echo 'getStatus:' . print_r($capture->getStatus(), true) . PHP_EOL; - -echo 'getIntegration:' . print_r($capture->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $capture->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $capture->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $capture->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $capture->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $capture->getModifiedBy() . PHP_EOL; -echo 'getDeletedAt: ' . $capture->getDeletedAt() . PHP_EOL; -echo 'getDeletedBy: ' . $capture->getDeletedBy() . PHP_EOL; \ No newline at end of file +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCaptureProduct.php b/samples/OrderCaptureProduct.php index f203e47..510f96d 100644 --- a/samples/OrderCaptureProduct.php +++ b/samples/OrderCaptureProduct.php @@ -25,7 +25,7 @@ $orderCaptureRequest->setConfig($config); try { - $capture = $orderCaptureRequest->start(); + $payOrder = $orderCaptureRequest->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -35,23 +35,20 @@ exit(); } + echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $capture->getId() . PHP_EOL; -echo 'getTransactionId: ' . $capture->getOrderId() . PHP_EOL; -echo 'getServiceCode: ' . $capture->getServiceCode() . PHP_EOL; -echo 'getDescription: ' . $capture->getDescription() . PHP_EOL; -echo 'getReference: ' . $capture->getReference() . PHP_EOL; -echo 'getIpAddress: ' . $capture->getIpAddress() . PHP_EOL; -echo 'getAmount getValue: ' . $capture->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $capture->getAmount()->getCurrency() . PHP_EOL; -echo 'getStatus:' . print_r($capture->getStatus(), true) . PHP_EOL; - -echo 'getIntegration:' . print_r($capture->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $capture->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $capture->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $capture->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $capture->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $capture->getModifiedBy() . PHP_EOL; -echo 'getDeletedAt: ' . $capture->getDeletedAt() . PHP_EOL; -echo 'getDeletedBy: ' . $capture->getDeletedBy() . PHP_EOL; \ No newline at end of file +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCreate.php b/samples/OrderCreate.php index 025df40..065db05 100644 --- a/samples/OrderCreate.php +++ b/samples/OrderCreate.php @@ -108,7 +108,8 @@ $request->setConfig($config); try { - $transaction = $request->start(); + $payOrder = $request->start(); + echo get_class($payOrder); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -120,20 +121,20 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getId: ' . $transaction->getId() . PHP_EOL; -echo 'getServiceId: ' . $transaction->getServiceId() . PHP_EOL; -echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; -echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getManualTransferCode: ' . $transaction->getManualTransferCode() . PHP_EOL; -echo 'getOrderId: ' . $transaction->getOrderId() . PHP_EOL; -echo 'getPaymentUrl: ' . '' . $transaction->getPaymentUrl() . '' . PHP_EOL; -echo 'getStatusUrl: ' . $transaction->getStatusUrl() . PHP_EOL; -echo 'getAmount value: ' . $transaction->getAmount()->getValue() . PHP_EOL; -echo 'getAmount currency: ' . $transaction->getAmount()->getCurrency() . PHP_EOL; -echo 'getUuid: ' . $transaction->getUuid() . PHP_EOL; -echo 'expiresAt: ' . $transaction->getExpiresAt() . PHP_EOL; -echo 'createdAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'createdBy: ' . $transaction->getCreatedBy() . PHP_EOL; -echo 'getCreatedAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'modifiedAt: ' . $transaction->getModifiedAt() . PHP_EOL; -echo 'modifiedBy: ' . $transaction->getModifiedBy() . PHP_EOL; +echo 'getId: ' . $payOrder->getId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getManualTransferCode: ' . $payOrder->getManualTransferCode() . PHP_EOL; +echo 'getOrderId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getPaymentUrl: ' . '' . $payOrder->getPaymentUrl() . '' . PHP_EOL; +echo 'getStatusUrl: ' . $payOrder->getStatusUrl() . PHP_EOL; +echo 'getAmount value: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount currency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getUuid: ' . $payOrder->getUuid() . PHP_EOL; +echo 'expiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'createdAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'createdBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'modifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'modifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCreateFastCheckout.php b/samples/OrderCreateFastCheckout.php index aa2ee0b..8303978 100644 --- a/samples/OrderCreateFastCheckout.php +++ b/samples/OrderCreateFastCheckout.php @@ -39,7 +39,7 @@ $request->setConfig($config); try { - $transaction = $request->start(); + $payOrder = $request->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -51,20 +51,20 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getId: ' . $transaction->getId() . PHP_EOL; -echo 'getServiceId: ' . $transaction->getServiceId() . PHP_EOL; -echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; -echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getManualTransferCode: ' . $transaction->getManualTransferCode() . PHP_EOL; -echo 'getOrderId: ' . $transaction->getOrderId() . PHP_EOL; -echo 'getPaymentUrl: ' . '' . $transaction->getPaymentUrl() . '' . PHP_EOL; -echo 'getStatusUrl: ' . $transaction->getStatusUrl() . PHP_EOL; -echo 'getAmount value: ' . $transaction->getAmount()->getValue() . PHP_EOL; -echo 'getAmount currency: ' . $transaction->getAmount()->getCurrency() . PHP_EOL; -echo 'getUuid: ' . $transaction->getUuid() . PHP_EOL; -echo 'expiresAt: ' . $transaction->getExpiresAt() . PHP_EOL; -echo 'createdAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'createdBy: ' . $transaction->getCreatedBy() . PHP_EOL; -echo 'getCreatedAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'modifiedAt: ' . $transaction->getModifiedAt() . PHP_EOL; -echo 'modifiedBy: ' . $transaction->getModifiedBy() . PHP_EOL; +echo 'getId: ' . $payOrder->getId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getManualTransferCode: ' . $payOrder->getManualTransferCode() . PHP_EOL; +echo 'getOrderId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getPaymentUrl: ' . '' . $payOrder->getPaymentUrl() . '' . PHP_EOL; +echo 'getStatusUrl: ' . $payOrder->getStatusUrl() . PHP_EOL; +echo 'getAmount value: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount currency: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getUuid: ' . $payOrder->getUuid() . PHP_EOL; +echo 'expiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'createdAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'createdBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'modifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'modifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderCreateMinimal.php b/samples/OrderCreateMinimal.php index f25f4d4..0ce0d68 100644 --- a/samples/OrderCreateMinimal.php +++ b/samples/OrderCreateMinimal.php @@ -21,7 +21,7 @@ $request->setConfig($config); try { - $transaction = $request->start(); + $payOrder = $request->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -33,4 +33,5 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getPaymentUrl: ' . '' . $transaction->getPaymentUrl() . '' . PHP_EOL; +echo 'getOrderId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getPaymentUrl: ' . '' . $payOrder->getPaymentUrl() . '' . PHP_EOL; diff --git a/samples/OrderCreatePin.php b/samples/OrderCreatePin.php index 4f53a6d..fcdf231 100644 --- a/samples/OrderCreatePin.php +++ b/samples/OrderCreatePin.php @@ -92,7 +92,7 @@ $request->setConfig($config); try { - $transaction = $request->start(); + $payOrder = $request->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -104,5 +104,5 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getId: ' . $transaction->getId() . PHP_EOL; -echo 'getPaymentUrl: ' . '' . $transaction->getPaymentUrl() . '' . PHP_EOL; \ No newline at end of file +echo 'getId: ' . $payOrder->getId() . PHP_EOL; +echo 'getPaymentUrl: ' . '' . $payOrder->getPaymentUrl() . '' . PHP_EOL; \ No newline at end of file diff --git a/samples/OrderDecline.php b/samples/OrderDecline.php index 6ccc5ee..fc424eb 100644 --- a/samples/OrderDecline.php +++ b/samples/OrderDecline.php @@ -20,7 +20,7 @@ $orderDeclineRequest->setConfig($config); try { - $transaction = $orderDeclineRequest->start(); + $payOrder = $orderDeclineRequest->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -32,20 +32,17 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $transaction->getId() . PHP_EOL; -echo 'getTransactionId: ' . $transaction->getOrderId() . PHP_EOL; -echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; -echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getAmount getValue: ' . $transaction->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $transaction->getAmount()->getCurrency() . PHP_EOL; -echo 'getAuthorizedAmount getCurrency: ' . $transaction->getAuthorizedAmount()->getCurrency() . PHP_EOL; -echo 'getAuthorizedAmount getValue: ' . $transaction->getAuthorizedAmount()->getValue() . PHP_EOL; -echo 'getStatus:' . print_r($transaction->getStatus(), true) . PHP_EOL; -echo 'getPaymentData:' . print_r($transaction->getPayments(), true) . PHP_EOL; -echo 'getIntegration:' . print_r($transaction->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $transaction->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $transaction->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $transaction->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $transaction->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $transaction->getModifiedBy() . PHP_EOL; - +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceId: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/samples/OrderStatus.php b/samples/OrderStatus.php index ccc8ae3..4bd5b72 100644 --- a/samples/OrderStatus.php +++ b/samples/OrderStatus.php @@ -17,7 +17,7 @@ $request->setConfig($config); try { - $transaction = $request->start(); + $payOrder = $request->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -30,23 +30,21 @@ echo ''; echo 'Success, values:' . PHP_EOL.PHP_EOL; -echo 'isPending: ' . ($transaction->isPending() ? 'YES' : 'no') . PHP_EOL; -echo 'isPaid: ' . ($transaction->isPaid() ? 'YES' : 'no') . PHP_EOL; -echo 'isAuthorized: ' . ($transaction->isAuthorized() ? 'YES' : 'no') . PHP_EOL; -echo 'isCancelled: ' . ($transaction->isCancelled() ? 'YES' : 'no') . PHP_EOL; -echo 'isBeingVerified: ' . ($transaction->isBeingVerified() ? 'YES' : 'no') . PHP_EOL; -echo 'isChargeBack: ' . ($transaction->isChargeBack() ? 'YES' : 'no') . PHP_EOL; -echo 'isPartialPayment: ' . ($transaction->isPartialPayment() ? 'YES' : 'no') . PHP_EOL; -echo 'isRefunded: ' . ($transaction->isRefunded() ? 'YES' : 'no') . PHP_EOL; -echo 'isPartiallyRefunded: ' . ($transaction->isPartiallyRefunded() ? 'YES' : 'no') . PHP_EOL . PHP_EOL; -echo 'getStatusCode: ' . $transaction->getStatusCode() . PHP_EOL; -echo 'getStatusName: ' . $transaction->getStatusName() . PHP_EOL; -echo 'getId: ' . $transaction->getId() . PHP_EOL; -echo 'getOrderId: ' . $transaction->getOrderId() . PHP_EOL; -echo 'getServiceCode: ' . $transaction->getServiceCode() . PHP_EOL; -echo 'getDescription: ' . $transaction->getDescription() . PHP_EOL; -echo 'getReference: ' . $transaction->getReference() . PHP_EOL; -echo 'getIpAddress: ' . $transaction->getIpAddress() . PHP_EOL.PHP_EOL; -echo 'getAmount: ' . $transaction->getAmount() . PHP_EOL; -echo 'getCurrency: ' . $transaction->getCurrency() . PHP_EOL; -echo 'paymentMethod: ' . $transaction->getPaymentMethod() . PHP_EOL; \ No newline at end of file +echo 'isPending: ' . ($payOrder->isPending() ? 'YES' : 'no') . PHP_EOL; +echo 'isPaid: ' . ($payOrder->isPaid() ? 'YES' : 'no') . PHP_EOL; +echo 'isAuthorized: ' . ($payOrder->isAuthorized() ? 'YES' : 'no') . PHP_EOL; +echo 'isCancelled: ' . ($payOrder->isCancelled() ? 'YES' : 'no') . PHP_EOL; +echo 'isBeingVerified: ' . ($payOrder->isBeingVerified() ? 'YES' : 'no') . PHP_EOL; +echo 'isChargeBack: ' . ($payOrder->isChargeBack() ? 'YES' : 'no') . PHP_EOL; +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 'getStatusCode: ' . $payOrder->getStatusCode() . PHP_EOL; +echo 'getStatusName: ' . $payOrder->getStatusName() . PHP_EOL; +echo 'getId: ' . $payOrder->getId() . PHP_EOL; +echo 'getOrderId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount: ' . $payOrder->getAmount(). PHP_EOL; +echo 'getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'paymentMethod: ' . $payOrder->getPaymentMethod() . PHP_EOL; \ No newline at end of file diff --git a/samples/OrderVoid.php b/samples/OrderVoid.php index 0a21f2e..da79278 100644 --- a/samples/OrderVoid.php +++ b/samples/OrderVoid.php @@ -21,7 +21,7 @@ try { - $capture = $orderVoidRequest->start(); + $payOrder = $orderVoidRequest->start(); } catch (PayException $e) { echo ''; echo 'Technical message: ' . $e->getMessage() . PHP_EOL; @@ -33,20 +33,17 @@ echo ''; echo 'Success, values:' . PHP_EOL; -echo 'getOrderId: ' . $capture->getId() . PHP_EOL; -echo 'getTransactionId: ' . $capture->getOrderId() . PHP_EOL; -echo 'getServiceCode: ' . $capture->getServiceCode() . PHP_EOL; -echo 'getDescription: ' . $capture->getDescription() . PHP_EOL; -echo 'getReference: ' . $capture->getReference() . PHP_EOL; -echo 'getIpAddress: ' . $capture->getIpAddress() . PHP_EOL; -echo 'getAmount getValue: ' . $capture->getAmount()->getValue() . PHP_EOL; -echo 'getAmount getCurrency: ' . $capture->getAmount()->getCurrency() . PHP_EOL; -echo 'getStatus:' . print_r($capture->getStatus(), true) . PHP_EOL; -echo 'getIntegration:' . print_r($capture->getIntegration(), true) . PHP_EOL; -echo 'getExpiresAt: ' . $capture->getExpiresAt() . PHP_EOL; -echo 'getCreatedAt: ' . $capture->getCreatedAt() . PHP_EOL; -echo 'getCreatedBy: ' . $capture->getCreatedBy() . PHP_EOL; -echo 'getModifiedAt: ' . $capture->getModifiedAt() . PHP_EOL; -echo 'getModifiedBy: ' . $capture->getModifiedBy() . PHP_EOL; -echo 'getDeletedAt: ' . $capture->getDeletedAt() . PHP_EOL; -echo 'getDeletedBy: ' . $capture->getDeletedBy() . PHP_EOL; \ No newline at end of file +echo 'getOrderId: ' . $payOrder->getId() . PHP_EOL; +echo 'getTransactionId: ' . $payOrder->getOrderId() . PHP_EOL; +echo 'getServiceCode: ' . $payOrder->getServiceId() . PHP_EOL; +echo 'getDescription: ' . $payOrder->getDescription() . PHP_EOL; +echo 'getReference: ' . $payOrder->getReference() . PHP_EOL; +echo 'getAmount getValue: ' . $payOrder->getAmount() . PHP_EOL; +echo 'getAmount getCurrency: ' . $payOrder->getCurrency() . PHP_EOL; +echo 'getStatus:' . print_r($payOrder->getStatus(), true) . PHP_EOL; +echo 'getTestmode: ' . ($payOrder->isTestmode() === true ? 'test order' : 'live order') . PHP_EOL; +echo 'getExpiresAt: ' . $payOrder->getExpiresAt() . PHP_EOL; +echo 'getCreatedAt: ' . $payOrder->getCreatedAt() . PHP_EOL; +echo 'getCreatedBy: ' . $payOrder->getCreatedBy() . PHP_EOL; +echo 'getModifiedAt: ' . $payOrder->getModifiedAt() . PHP_EOL; +echo 'getModifiedBy: ' . $payOrder->getModifiedBy() . PHP_EOL; diff --git a/src/Config/Config.php b/src/Config/Config.php index 3d010fe..a334f0f 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -300,6 +300,17 @@ public function getDebug(): bool return $this->data['debug'] == 1; } + /** + * @return string + */ + public function getFailoverUrl(): string + { + if (!empty($this->data['failoverUrl'])) { + return trim($this->data['failoverUrl']); + } + return ''; + } + /** * Set destination(core) url * @@ -676,6 +687,17 @@ public function getDebug(): bool return $this->data['debug'] == 1; } + /** + * @return string + */ + public function getFailoverUrl(): string + { + if (!empty($this->data['failoverUrl'])) { + return trim($this->data['failoverUrl']); + } + return ''; + } + /** * Set destination(core) url * diff --git a/src/Mapper/ConfigProvider.php b/src/Mapper/ConfigProvider.php index e109053..3a9778b 100644 --- a/src/Mapper/ConfigProvider.php +++ b/src/Mapper/ConfigProvider.php @@ -87,13 +87,13 @@ public function getMap(): array 'TokenizeTransaction' => 'Transaction', 'TransactionRefund' => 'TransactionRefundResponse', 'TransactionStatus' => 'TransactionStatusResponse', - 'OrderCreate' => 'OrderCreateResponse', - 'OrderCapture' => 'OrderCaptureResponse', - 'OrderVoid' => 'OrderVoidResponse', - 'OrderAbort' => 'OrderAbortResponse', - 'orderStatus' => 'OrderStatusResponse', - 'orderApprove' => 'OrderApproveResponse', - 'orderDecline' => 'OrderDeclineResponse', + 'OrderCreate' => 'PayOrder', + 'OrderCapture' => 'PayOrder', + 'OrderVoid' => 'PayOrder', + 'OrderAbort' => 'PayOrder', + 'orderStatus' => 'PayOrder', + 'orderApprove' => 'PayOrder', + 'orderDecline' => 'PayOrder', 'TerminalsGet' => 'Terminal', 'TerminalsBrowse' => 'Terminals' ], diff --git a/src/Model/ConfigProvider.php b/src/Model/ConfigProvider.php index cfe8840..83a2d09 100644 --- a/src/Model/ConfigProvider.php +++ b/src/Model/ConfigProvider.php @@ -191,6 +191,8 @@ public function getModelConfig(): array 'OrderAbortResponse' => Response\OrderAbortResponse::class, 'ServiceGetConfigResponse' => Response\ServiceGetConfigResponse::class, + 'PayOrder' => Pay\PayOrder::class, + 'CheckoutOptions' => CheckoutOptions::class, 'CheckoutOption' => CheckoutOption::class, 'Method' => Method::class, diff --git a/src/Model/Pay/PayOrder.php b/src/Model/Pay/PayOrder.php index a92184b..7663b8b 100644 --- a/src/Model/Pay/PayOrder.php +++ b/src/Model/Pay/PayOrder.php @@ -4,105 +4,308 @@ namespace PayNL\Sdk\Model\Pay; +use PayNL\Sdk\Model\ModelInterface; +use PayNL\Sdk\Model\Amount; use PayNL\Sdk\Model\Pay\PayStatus; -class PayOrder +/** + * Class PayOrder + * + * @package PayNL\Sdk\Model + */ +class PayOrder implements ModelInterface { - private int $stateId = 0; - private array $processedPayload; - private string $message; - private array $payload = []; - - private $id; - private $uuid; - private $amount; - private $status; - private $orderId; - private $receipt; - private $payments; - private $reference; - private $description; - private $integration; - private $checkoutData; - private $capturedAmount; - private $authorizedAmount; - private $manualTransferCode; - - /** - * @var mixed - */ - private $paymentProfileId; - - /** - * @param $payload - */ - public function __construct($payload) - { - if (!empty($payload)) { - foreach ($payload as $_key => $_val) { - $method = 'set' . ucfirst((string)$_key); - if (method_exists($this, $method)) { - $this->$method($_val); - } - } - } + + /** + * @var string + */ + private $stateId; + + /** + * @var string + */ + protected string $id; + + /** + * @var string + */ + protected $serviceId; + + /** + * @var string + */ + protected $description; + + /** + * @var string + */ + protected $reference; + + /** + * @var string + */ + protected $manualTransferCode; + + /** + * @var string + */ + protected $orderId; + + /** + * @var string + */ + protected $uuid; + + /** + * @var string + */ + protected $customerKey; + + /** + * @var array + */ + protected $status; + + /** + * @var string + */ + protected $receipt; + + /** + * @var array + */ + protected $integration; + + /** + * @var Amount + */ + protected $amount; + + /** + * @var Amount + */ + protected $authorizedAmount; + + /** + * @var Amount + */ + protected $capturedAmount; + + /** + * @var Object + */ + protected $checkoutData; + + /** + * @var array + */ + protected $payments; + + /** + * @var string + */ + protected $createdAt; + + /** + * @var string + */ + protected $createdBy; + + /** + * @var string + */ + protected $modifiedAt; + + /** + * @var string + */ + protected $modifiedBy; + + /** + * @var string + */ + protected $expiresAt; + + /** + * @var string + */ + protected $completedAt; + + /** + * @var array + */ + protected $links; + + /** + * @return int + */ + public function getStatusCode(): int + { + return (int)$this->status['code']; } /** - * @return bool + * @return string */ - public function failed() + public function getStatusName(): string { - return $this->stateId === 0; + return (string)($this->status['action'] ?? ''); } + /** - * @param $p + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id * @return $this */ - public function setPaymentProfileId($p) + public function setId(string $id): self { - $this->paymentProfileId = $p; + $this->id = $id; return $this; } /** - * @return mixed + * @return string */ - public function getPaymentProfileId() + public function getServiceId(): string { - return $this->paymentProfileId; + return $this->serviceId; } /** - * @return int|mixed + * @param string $serviceId + * @return $this */ - public function getLastUsedProfileId() + public function setServiceId(string $serviceId): self { - $lastUsed = 0; - foreach ($this->payload['payments'] as $payment) { - $lastUsed = $payment['paymentMethod']['id']; - } + $this->serviceId = $serviceId; + return $this; + } - return $lastUsed; + /** + * @return string + */ + public function getDescription(): string + { + return (string)$this->description; } /** - * @return bool + * @param string $description + * @return $this + */ + public function setDescription(string $description): self + { + $this->description = $description; + return $this; + } + + /** + * @return string + */ + public function getReference(): string + { + return (string)$this->reference; + } + + /** + * @param string $reference + * @return $this + */ + public function setReference(string $reference): self + { + $this->reference = $reference; + return $this; + } + + /** + * @return string */ - public function isFastCheckout() + public function getManualTransferCode(): string { - return !empty($this->processedPayload['checkoutData'] ?? []); + return $this->manualTransferCode; + } + + /** + * @param string $manualTransferCode + * @return $this + */ + public function setManualTransferCode(string $manualTransferCode): self + { + $this->manualTransferCode = $manualTransferCode; + return $this; + } + + /** + * @return string + */ + public function getOrderId(): string + { + return $this->orderId; + } + + /** + * @param string $orderId + * @return $this + */ + public function setOrderId(string $orderId): self + { + $this->orderId = $orderId; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $uuid + * @return $this + */ + public function setUuid(string $uuid): self + { + $this->uuid = $uuid; + return $this; + } + + /** + * @return string + */ + public function getCustomerKey(): string + { + return $this->customerKey; + } + + /** + * @param string $customerKey + * @return $this + */ + public function setCustomerKey(string $customerKey): self + { + $this->customerKey = $customerKey; + return $this; } /** * @return array */ - public function getCheckoutData() + public function getStatus(): array { - return (array)$this->processedPayload['checkoutData'] ?? []; + return $this->status; } + /** * @return int */ @@ -111,6 +314,7 @@ public function getStateId(): int return $this->stateId; } + /** * @param $stateId * @return void @@ -120,256 +324,403 @@ public function setStateId($stateId): void $this->stateId = $stateId; } + /** + * @param array $status + * @return $this + */ + public function setStatus(array $status): self + { + $this->status = $status; + return $this; + } + /** * @return string */ - public function getReference(): string + public function getReceipt(): string { - return (string)$this->reference; + return $this->receipt; } /** - * @param string $reference - * @return void + * @param string $receipt + * @return $this */ - public function setReference(string $reference): void + public function setReceipt(string $receipt): self { - $this->reference = $reference; + $this->receipt = $receipt; + return $this; } + /** + * @return bool + */ + public function isTestmode(): bool + { + $testmodeEnabled = $this->integration['test'] ?? false; + return $testmodeEnabled === true; + } + /** * @return array */ - public function getProcessedPayload(): array + public function getIntegration(): array { - return $this->processedPayload; + return $this->integration; } /** - * @return bool + * @param array $integration + * @return $this */ - public function isPaid() + public function setIntegration(array $integration): self { - return $this->stateId === PayStatus::PAID; + $this->integration = $integration; + return $this; } /** - * @return bool + * @return float|int */ - public function isPending() + public function getAmount() { - return $this->stateId === PayStatus::PENDING; + return $this->amount->getValue() / 100; } /** - * @return bool + * @return string */ - public function isPartialPayment() + public function getCurrency(): string { - return $this->stateId === PayStatus::PARTIAL_PAYMENT; + return (string)$this->amount->getCurrency(); } + /** - * @return bool + * @return mixed|null */ - public function isAuthorized(): bool + public function getPaymentMethod() { - return $this->stateId === PayStatus::AUTHORIZE; + return $this->payments[0]['paymentMethod']['id'] ?? null; } + + /** - * @return bool + * @param Amount $amount + * @return $this */ - public function isCancelled() + public function setAmount(Amount $amount): self { - return $this->stateId === PayStatus::CANCEL; + $this->amount = $amount; + return $this; } /** - * @return bool + * @return Amount */ - public function isRefundedFully() + public function getAuthorizedAmount(): Amount { - return $this->stateId === PayStatus::REFUND; + return $this->authorizedAmount; } /** - * @return bool + * @param Amount $authorizedAmount + * @return $this */ - public function isRefundedPartial() + public function setAuthorizedAmount(Amount $authorizedAmount): self { - return $this->stateId === PayStatus::PARTIAL_REFUND; + $this->authorizedAmount = $authorizedAmount; + return $this; } /** - * @return bool + * @return Amount */ - public function isBeingVerified() + public function getCapturedAmount(): Amount { - return $this->stateId === PayStatus::VERIFY; + return $this->capturedAmount; } /** - * @return string + * @param Amount $capturedAmount + * @return $this */ - public function getMessage(): string + public function setCapturedAmount(Amount $capturedAmount): self { - return $this->message; + $this->capturedAmount = $capturedAmount; + return $this; } /** - * @param string $message + * @return Object + */ + public function getCheckoutData(): object + { + return $this->checkoutData; + } + + /** + * @param Object $checkoutData * @return $this */ - public function setMessage(string $message): self + public function setCheckoutData(object $checkoutData): self { - $this->message = $message; + $this->checkoutData = $checkoutData; return $this; } /** * @return array */ - public function getPayload(): array + public function getPayments(): array { - return (array)$this->payload; + return $this->payments; } /** - * @param array $payload - * @return void + * @param array $payments + * @return $this */ - public function setPayload(array $payload): void + public function setPayments(array $payments): self { - $this->payload = $payload; + $this->payments = $payments; + return $this; } /** - * @return mixed + * @return string */ - public function getId() + public function getCreatedAt(): string { - return $this->id; + return $this->createdAt; } /** - * @param mixed $id + * @param string $createdAt + * @return $this */ - public function setId($id): void + public function setCreatedAt(string $createdAt): self { - $this->id = $id; + $this->createdAt = $createdAt; + return $this; } /** - * @return mixed + * @return string */ - public function getUuid() + public function getCreatedBy(): string { - return $this->uuid; + return $this->createdBy; } /** - * @param mixed $uuid + * @param string $createdBy + * @return $this */ - public function setUuid($uuid): void + public function setCreatedBy(string $createdBy): self { - $this->uuid = $uuid; + $this->createdBy = $createdBy; + return $this; } /** - * @return mixed + * @return string */ - public function getAmount() + public function getModifiedAt(): string { - return $this->amount; + return $this->modifiedAt; } /** - * @param mixed $amount + * @param string $modifiedAt + * @return $this */ - public function setAmount($amount): void + public function setModifiedAt(string $modifiedAt): self { - $this->amount = $amount; + $this->modifiedAt = $modifiedAt; + return $this; } /** - * @return mixed + * @return string */ - public function getStatus() + public function getModifiedBy(): string { - return $this->status; + return (string)$this->modifiedBy; } /** - * @param mixed $status + * @param string $modifiedBy + * @return $this */ - public function setStatus($status): void + public function setModifiedBy(string $modifiedBy): self { - $this->status = $status; + $this->modifiedBy = $modifiedBy; + return $this; } /** - * @return mixed + * @return string */ - public function getOrderId() + public function getExpiresAt(): string { - return $this->orderId; + return (string)$this->expiresAt; } /** - * @param mixed $orderId + * @param string $expiresAt + * @return $this */ - public function setOrderId($orderId): void + public function setExpiresAt(string $expiresAt): self { - $this->orderId = $orderId; + $this->expiresAt = $expiresAt; + return $this; } /** - * @return mixed + * @return string */ - public function getPayments() + public function getCompletedAt(): string { - return $this->payments; + return (string)$this->completedAt; } /** - * @param mixed $payments + * @param string $completedAt + * @return $this */ - public function setPayments($payments): void + public function setCompletedAt(string $completedAt): self { - $this->payments = $payments; + $this->completedAt = $completedAt; + return $this; } /** - * @return mixed + * @return array */ - public function getDescription() + public function getLinks(): array { - return $this->description; + return $this->links; } /** - * @param mixed $description + * @param array $links + * @return $this */ - public function setDescription($description): void + public function setLinks(array $links): self { - $this->description = $description; + $this->links = $links; + return $this; } /** - * @return mixed + * @return mixed|string */ - public function getCapturedAmount() + public function getPaymentUrl() { - return $this->capturedAmount; + return $this->links['redirect'] ?? ''; } /** - * @param mixed $capturedAmount + * @return mixed|string */ - public function setCapturedAmount($capturedAmount): void + public function getStatusUrl() { - $this->capturedAmount = $capturedAmount; + return $this->links['status'] ?? ''; + } + + + /** + * @return bool + */ + public function isPaid() + { + return $this->stateId === PayStatus::PAID; + } + + /** + * @return bool + */ + public function isPending() + { + return $this->stateId === PayStatus::PENDING; + } + + /** + * @return bool + */ + public function isPartialPayment() + { + return $this->stateId === PayStatus::PARTIAL_PAYMENT; + } + + /** + * @return bool + */ + public function isAuthorized(): bool + { + return $this->stateId === PayStatus::AUTHORIZE; + } + + /** + * @return bool + */ + public function isCancelled() + { + return $this->stateId === PayStatus::CANCEL; + } + + /** + * @return bool + */ + public function isRefundedFully() + { + return $this->stateId === PayStatus::REFUND; + } + + /** + * @return bool + */ + public function isRefundedPartial() + { + return $this->stateId === PayStatus::PARTIAL_REFUND; + } + + /** + * @return bool + */ + public function isBeingVerified() + { + return $this->stateId === PayStatus::VERIFY; + } + + /** + * Check whether the status of the transaction is chargeback + * + * @return bool + */ + public function isChargeBack(): bool + { + return ($this->status['action'] ?? '') === 'CHARGEBACK'; + } + + /** + * @param bool $allowPartialRefunds + * + * @return bool + */ + public function isRefunded(bool $allowPartialRefunds = true): bool + { + if (($this->status['action'] ?? '') === 'REFUND') { + return true; + } + + if ($allowPartialRefunds && ($this->status['action'] ?? '') === 'PARTIAL_REFUND') { + return true; + } + + return false; } -} \ No newline at end of file +} diff --git a/src/Model/Request/OrderAbortRequest.php b/src/Model/Request/OrderAbortRequest.php index 47872a3..d122c07 100644 --- a/src/Model/Request/OrderAbortRequest.php +++ b/src/Model/Request/OrderAbortRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderAbortResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; /** @@ -44,10 +44,10 @@ public function getBodyParameters(): array } /** - * @return OrderAbortResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderAbortResponse + public function start(): PayOrder { return parent::start(); } diff --git a/src/Model/Request/OrderApproveRequest.php b/src/Model/Request/OrderApproveRequest.php index 8ac90a8..09d0cef 100644 --- a/src/Model/Request/OrderApproveRequest.php +++ b/src/Model/Request/OrderApproveRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderApproveResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; /** @@ -44,10 +44,10 @@ public function getBodyParameters(): array } /** - * @return OrderApproveResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderApproveResponse + public function start(): PayOrder { return parent::start(); } diff --git a/src/Model/Request/OrderCaptureRequest.php b/src/Model/Request/OrderCaptureRequest.php index 2ef180a..3032342 100644 --- a/src/Model/Request/OrderCaptureRequest.php +++ b/src/Model/Request/OrderCaptureRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderCaptureResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; /** @@ -90,10 +90,10 @@ public function setAmount(float $amount): self } /** - * @return OrderCaptureResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderCaptureResponse + public function start(): PayOrder { if ($this->mode == 'amount') { $this->uri = '/orders/%transactionId%/capture/amount'; diff --git a/src/Model/Request/OrderCreateRequest.php b/src/Model/Request/OrderCreateRequest.php index d60969f..abd722f 100644 --- a/src/Model/Request/OrderCreateRequest.php +++ b/src/Model/Request/OrderCreateRequest.php @@ -8,7 +8,7 @@ use PayNL\Sdk\Model\Customer; use PayNL\Sdk\Model\Order; use PayNL\Sdk\Model\Stats; -use PayNL\Sdk\Model\Response\OrderCreateResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestData; use PayNL\Sdk\Request\RequestInterface; use PayNL\Sdk\Util\Vat; @@ -427,10 +427,10 @@ public function setTerminal(string $terminalCode): void } /** - * @return OrderCreateResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderCreateResponse + public function start(): PayOrder { $this->config->setversion(1); return parent::start(); diff --git a/src/Model/Request/OrderDeclineRequest.php b/src/Model/Request/OrderDeclineRequest.php index 4bed87b..ccb0170 100644 --- a/src/Model/Request/OrderDeclineRequest.php +++ b/src/Model/Request/OrderDeclineRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderDeclineResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; /** @@ -44,10 +44,10 @@ public function getBodyParameters(): array } /** - * @return OrderDeclineResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderDeclineResponse + public function start(): PayOrder { return parent::start(); } diff --git a/src/Model/Request/OrderStatusRequest.php b/src/Model/Request/OrderStatusRequest.php index 482375e..7ebd508 100644 --- a/src/Model/Request/OrderStatusRequest.php +++ b/src/Model/Request/OrderStatusRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderStatusResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; use PayNL\Sdk\Config\Config; @@ -42,13 +42,14 @@ public function getBodyParameters(): array } /** - * @return OrderStatusResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderStatusResponse + public function start(): PayOrder { # Always use TGU-1 for orderStatus $this->config->setCore(Config::TGU1); + return parent::start(); } } \ No newline at end of file diff --git a/src/Model/Request/OrderVoidRequest.php b/src/Model/Request/OrderVoidRequest.php index 6bf9aa0..c751504 100644 --- a/src/Model/Request/OrderVoidRequest.php +++ b/src/Model/Request/OrderVoidRequest.php @@ -6,7 +6,7 @@ use PayNL\Sdk\Exception\PayException; use PayNL\Sdk\Request\RequestData; -use PayNL\Sdk\Model\Response\OrderVoidResponse; +use PayNL\Sdk\Model\Pay\PayOrder; use PayNL\Sdk\Request\RequestInterface; /** @@ -44,10 +44,10 @@ public function getBodyParameters(): array } /** - * @return OrderVoidResponse + * @return PayOrder * @throws PayException */ - public function start(): OrderVoidResponse + public function start(): PayOrder { return parent::start(); } diff --git a/src/Request/RequestData.php b/src/Request/RequestData.php index 0154b4a..4be65d4 100644 --- a/src/Request/RequestData.php +++ b/src/Request/RequestData.php @@ -58,6 +58,10 @@ public function start() $config->merge($this->config); } + if (!empty($config->getFailoverUrl())) { + $config->setCore($config->getFailoverUrl()); + } + try { $response = (Application::init($config))->request($this)->run(); } catch (\Throwable $e) { diff --git a/src/Util/Exchange.php b/src/Util/Exchange.php index b9c23d8..74dd387 100644 --- a/src/Util/Exchange.php +++ b/src/Util/Exchange.php @@ -203,20 +203,21 @@ public function getPayLoad() public function process(PayConfig $config = null): PayOrder { $payload = $this->getPayload(); - $payStatus = new PayStatus(); + $payOrder = new PayOrder(); if (empty($config)) { $config = Config::getConfig(); } - $payOrder = new PayOrder($payload->getFullPayLoad()); - $payOrder->setAmount($payload->getAmount()); - $payOrder->setPaymentProfileId($payload->getPaymentProfile()); - $payOrder->setOrderId($payload->getPayOrderId()); - $payOrder->setReference($payload->getReference()); - - if ($this->isSignExchange()) { + if ($this->isSignExchange()) + { $signingResult = $this->checkSignExchange($config->getUsername(), $config->getPassword()); + $payOrder = new PayOrder($payload->getFullPayLoad()); + $payOrder->setAmount($payload->getAmount()); + $payOrder->setPaymentProfileId($payload->getPaymentProfile()); + $payOrder->setOrderId($payload->getPayOrderId()); + $payOrder->setReference($payload->getReference()); + if ($signingResult === true) { $paymentState = $payload->getInternalStateId(); } else { @@ -224,7 +225,7 @@ public function process(PayConfig $config = null): PayOrder } } else { try { - $payloadState = $payStatus->get($payload->getInternalStateId()); + $payloadState = (new PayStatus())->get($payload->getInternalStateId()); } catch (\Throwable $e) { $payloadState = null; } @@ -248,12 +249,10 @@ public function process(PayConfig $config = null): PayOrder $request = new OrderStatusRequest($payload->getPayOrderId()); } - $transaction = $request->setConfig($config)->start(); - $paymentState = $transaction->getStatusCode(); + $payOrder = $request->setConfig($config)->start(); + $paymentState = $payOrder->getStatusCode(); dbg('amount_payload: ' . $payload->getAmount()); - dbg('amount_trans: ' . $transaction->getAmount()); - - $payOrder->setAmount($transaction->getAmount()); + dbg('amount_trans: ' . $payOrder->getAmount()); } catch (PayException $e) { dbg($e->getMessage()); @@ -262,7 +261,7 @@ public function process(PayConfig $config = null): PayOrder } } - $payOrder->setStateId($payStatus->get($paymentState)); + $payOrder->setStateId((new PayStatus())->get($paymentState)); return $payOrder; }