diff --git a/composer.json b/composer.json index aa9880e..86491b7 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "ext-dom": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2.1", + "guzzlehttp/guzzle": "^7.0.1", "psr/log": "^1.0" }, "require-dev": { diff --git a/example/App.php b/example/App.php index 0c1220e..4635342 100644 --- a/example/App.php +++ b/example/App.php @@ -25,7 +25,7 @@ public function getSecretKey(): string public function getBaseUrl(): string { - return getenv('OTPSP_BASE_URL') ?: 'http://127.0.0.1:1234'; + return getenv('OTPSP_BASE_URL') ?: 'http://otpsp-client.test'; } public function twig() diff --git a/example/docroot/start-query.php b/example/docroot/start-query.php new file mode 100644 index 0000000..50dc3c6 --- /dev/null +++ b/example/docroot/start-query.php @@ -0,0 +1,46 @@ +setSecretKey($app->getSecretKey()); +$timeout = new DateInterval('PT5M'); + +$queryRequest = new QueryRequest(); +$queryRequest->merchant = $app->getMerchantId(); +//$queryRequest->orderRefs[] = 'my-order-id-2020-12-07-09-35-51'; +$queryRequest->salt = 'd471d2fb24c5a395563ff60f8ba769d1'; +$queryRequest->transactionIds[] = '500748082'; +//$queryRequest->salt = 'TV0ywJZVdf62p5nAJkldHWDzr2dLJRPe'; + +$startQueryResponse = $otpSimple->startQuery($queryRequest); + +// In a real application do not print anything, +// just redirect the client to $startPaymentResponse->paymentURL. +echo $app + ->twig() + ->render( + 'start-query.html.twig', + [ + 'queryRequest' => $queryRequest, + 'queryRequestJson' => $app->jsonEncode($queryRequest), + 'queryPaymentResponse' => $startQueryResponse, + 'startQueryResponseJson' => $app->jsonEncode($startQueryResponse), + 'logEntriesJson' => $app->jsonEncode($logger->records), + ] + ); diff --git a/example/templates/start-query.html.twig b/example/templates/start-query.html.twig new file mode 100644 index 0000000..90d5248 --- /dev/null +++ b/example/templates/start-query.html.twig @@ -0,0 +1,32 @@ + + + + + + Start query response + + +
+

Start payment response

+
+

queryRequestJson

+
{{ queryRequestJson }}
+
+
+

startQueryResponseJson

+
{{ startQueryResponseJson }}
+
+
+

logEntriesJson

+
{{ logEntriesJson }}
+
+{# {% if startQueryResponse.paymentUrl -%}#} +{#
#} +{#

paymentURL

#} +{# Go to SimplePay#} +{#
#} +{# {%- endif %}#} +
+{% include 'footer.html.twig' %} + + diff --git a/src/DataType/InstantPaymentNotification.php b/src/DataType/InstantPaymentNotification.php index 1f466fb..bf9c42b 100644 --- a/src/DataType/InstantPaymentNotification.php +++ b/src/DataType/InstantPaymentNotification.php @@ -9,11 +9,6 @@ class InstantPaymentNotification extends ResponseBase implements JsonSerializable { - /** - * @var string - */ - public $cardMask = ''; - /** * @var string */ @@ -24,11 +19,6 @@ class InstantPaymentNotification extends ResponseBase implements JsonSerializabl */ public $finishDate = ''; - /** - * @var string - */ - public $expiry = ''; - /** * @var string */ @@ -57,10 +47,8 @@ public function jsonSerialize() case 'merchant': case 'orderRef': case 'transactionId': - case 'cardMask': case 'method': case 'finishDate': - case 'expiry': case 'paymentDate': case 'status': case 'receiveDate': diff --git a/src/DataType/PaymentRequest.php b/src/DataType/PaymentRequest.php index adbb60a..3952296 100644 --- a/src/DataType/PaymentRequest.php +++ b/src/DataType/PaymentRequest.php @@ -49,6 +49,16 @@ public static function __set_state($values) return $instance; } + /** + * @var string + */ + public $orderRef = ''; + + /** + * @var string + */ + public $currency = ''; + /** * @var string */ diff --git a/src/DataType/QueryRequest.php b/src/DataType/QueryRequest.php new file mode 100644 index 0000000..bd9d044 --- /dev/null +++ b/src/DataType/QueryRequest.php @@ -0,0 +1,45 @@ + $value) { + $data[$key] = $value; + + } + return $data; + } +} diff --git a/src/DataType/QueryResponse.php b/src/DataType/QueryResponse.php new file mode 100644 index 0000000..63fac0a --- /dev/null +++ b/src/DataType/QueryResponse.php @@ -0,0 +1,15 @@ +sendRequest($queryRequest, 'query'); + $body = $this->getMessageBody($response); + + return QueryResponse::__set_state($body); + } + /** * @throws Exception */ @@ -286,7 +302,7 @@ public function getInstantPaymentNotificationSuccessParts(InstantPaymentNotifica } /** - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function sendRequest(RequestBase $requestType, string $path): ResponseInterface {