diff --git a/.github/contributing.md b/.github/contributing.md new file mode 100644 index 0000000..3ff9d72 --- /dev/null +++ b/.github/contributing.md @@ -0,0 +1,30 @@ +# Contributing to this library + +🎉 Thanks for being interested in contributing to this library! + +## Basics + +* Follow [Symfony coding standards](http://symfony.com/doc/current/contributing/code/standards.html) +* Write useful commit messages +* Be nice and respect others + +## Technical guidelines + +### Request containers + +* Put mandatory properties into the constructor +* No setters for data which is set in constructor + +Note that some data seems to be mandatory, but is not marked as such in the Saferpay docs. We strictly follow the +information in the Saferpay docs and keep all data optional unless Saferpay explicity marks +it as mandatory. + +### Response containers + +* No constructors +* No setters +* All properties are optional + +Even though in the Saferpay doc some data is marked as mandatory in responses, we keep them all optional in this +library because it is not in our control whether this data will actually be provided or not. + diff --git a/README.md b/README.md index 1db6f1c..426c4d5 100644 --- a/README.md +++ b/README.md @@ -15,29 +15,29 @@ composer require ticketpark/saferpay-json-api ``` ## Usage -See [example folder](/example). +In order to perform a payment as you would typically do it in an online shop, you need to handle the following steps: +1. Initialize the payment page (see [/example/PaymentPage/example-initialize.php](/example/PaymentPage/example-initialize.php)) +2. Redirect the user to the payment page and let them enter their payment data +3. Assert that the payment was successfully done (see [/example/PaymentPage/example-assert.php](/example/PaymentPage/example-assert.php)) +4. Capture the payment to make it final (see [/example/Transaction/example-capture.php](/example/Transaction/example-capture.php)) -## Documentation +Have a look at the [example folder](/example) for more. -This library is based on v1.2 of the Saferpay JSON API: -https://saferpay.github.io/jsonapi/1.2/ +## Documentation -## Roadmap +Find the most current documentation of the Saferpay JSON API here:
+https://saferpay.github.io/jsonapi/ -* v3 will be based on the most recent version of the Saferpay API (currently v1.17) -* v2.3 added support for PHP 7.4 -* v2 added type-hints with major refactoring and required PHP 7.3 -* v1 was the initial version of this library based on PHP 5.6 and the Saferpay API v1.2 +This library is currently based on v1.17 of the Saferpay JSON API. ## Contribution -You are welcome to contribute to this repo. +You are [welcome to contribute](/.github/contributing.md) to this repo. -* Follow [Symfony coding standards](http://symfony.com/doc/current/contributing/code/standards.html) -* Write useful commit messages -* Be nice and respect others -## License -This bundle is under the MIT license. See the complete license in the bundle: +## History - Resources/meta/LICENSE +* v3 added more major refactoring and based on current version of Saferpay API +* v2.3 added support for PHP 7.4 +* v2 added type-hints with major refactoring and required PHP 7.3 +* v1 was the initial version of this library based on PHP 5.6 and the Saferpay API v1.2 \ No newline at end of file diff --git a/example/PaymentPage/1-example-initialize.php b/example/PaymentPage/1-example-initialize.php deleted file mode 100644 index 646a703..0000000 --- a/example/PaymentPage/1-example-initialize.php +++ /dev/null @@ -1,75 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$amount = (new Container\Amount()) - ->setCurrencyCode('CHF') - ->setValue(5000); // amount in cents - -$payment = (new Container\Payment()) - ->setAmount($amount) - ->setOrderId('12839') - ->setDescription('Order No. 12839'); - -$address = (new Container\Address()) - ->setFirstName('Alex') - ->setLastName('Tschäppät') - ->setStreet('Marktgasse 1') - ->setZip('3000') - ->setCity('Bern') - ->setCountryCode('CH'); - -$payer = (new Container\Payer()) - ->setLanguageCode('en') - ->setBillingAddress($address); - -$returnUrls = (new Container\ReturnUrls()) - ->setSuccess('http://www.mysite.ch/success?orderId=12839') - ->setFail('http://www.mysite.ch/fail') - ->setAbort('http://www.mysite.ch/abort'); - -$notification = (new Container\Notification()) - ->setNotifyUrl('https://www.mysite.ch/notification'); - -$response = (new InitializeRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setPayment($payment) - ->setTerminalId($terminalId) - ->setReturnUrls($returnUrls) - ->setNotification($notification) - ->execute(); - -// Step 2: -// Check for successful response -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -// Step 3: -// Save the response token, you will need it later to verify the payment -echo 'Payment token: ' . $response->getToken() . "
\n"; - -// Step 4: -// Redirect to the payment page -echo 'Redirect to: ' . $response->getRedirectUrl() ."
\n"; - -// Step 5: -// Fill in test payment page. For dummy credit card numbers see -// https://saferpay.github.io/sndbx/paymentmeans.html - -// Step 6: -// On success page and notification url, assert the payment has been successful. -// -> see 2-example-assert.php diff --git a/example/PaymentPage/2-example-assert.php b/example/PaymentPage/2-example-assert.php deleted file mode 100644 index 899c0f9..0000000 --- a/example/PaymentPage/2-example-assert.php +++ /dev/null @@ -1,38 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$response = (new AssertRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setToken($token) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId(); - -// Step 3: -// Capture the transaction to get the cash flowing. -// See ../Transaction/1-example-capture.php diff --git a/example/PaymentPage/3-example-recurring.php b/example/PaymentPage/3-example-recurring.php deleted file mode 100644 index cd1e7bf..0000000 --- a/example/PaymentPage/3-example-recurring.php +++ /dev/null @@ -1,50 +0,0 @@ -setRecurring(new Recurring(true)) -$transactionId = 'xx'; - -// Step 1: -// Prepare the recurring paymen request -// See https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Transaction_AuthorizeReferenced - -$requestHeader = (new Container\RequestHeader()) - ->setCustomerId($customerId) - ->setRequestId(uniqid()); - -$amount = (new Container\Amount()) - ->setCurrencyCode('CHF') - ->setValue(5000); // amount in cents - -$response = (new AuthorizeReferencedRequest($apiKey, $apiSecret, true)) - ->setRequestHeader($requestHeader) - ->setPayment((new Container\Payment())->setAmount($amount)) - ->setTransactionReference((new Container\TransactionReference())->setTransactionId($transactionId)) - ->setTerminalId($terminalId) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -/** @var AuthorizeReferencedResponse $response */ -echo sprintf( - "Transaction ID: %s, Status: %s, via %s (%s)", - $response->getTransaction()->getId(), - $response->getTransaction()->getStatus(), - $response->getPaymentMeans()->getBrand()->getName(), - $response->getPaymentMeans()->getDisplayText() -); - -// Recurring payment transactions still need to be captured. -// see: Transaction/1-example-capture.php diff --git a/example/PaymentPage/example-assert.php b/example/PaymentPage/example-assert.php new file mode 100644 index 0000000..ba83ccd --- /dev/null +++ b/example/PaymentPage/example-assert.php @@ -0,0 +1,50 @@ +execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId()."\n"; + +// ----------------------------- +// Step 4: +// Capture the transaction to get the cash flowing. +// See ../Transaction/example-capture.php diff --git a/example/PaymentPage/example-initialize.php b/example/PaymentPage/example-initialize.php new file mode 100644 index 0000000..b5e2dce --- /dev/null +++ b/example/PaymentPage/example-initialize.php @@ -0,0 +1,79 @@ +setDescription('Order No. 12839'); + +$returnUrls = new Container\ReturnUrls( + 'http://www.mysite.ch/success?orderId=12839', + 'http://www.mysite.ch/fail' +); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$initializeRequest = new InitializeRequest( + $requestConfig, + $terminalId, + $payment, + $returnUrls +); + +// Note: More data can be provided to InitializeRequest with setters, +// for example: $initializeRequest->setPayer() +// See Saferpay documentation for available options. + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $initializeRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +// ----------------------------- +// Step 4: +// Save the response token, you will need it later to verify the payment (see step 7) +echo 'Payment token: ' . $response->getToken() . "
\n"; + +// ----------------------------- +// Step 5: +// Redirect to the payment page +echo 'Redirect to: ' . $response->getRedirectUrl() ."
\n"; + +// ----------------------------- +// Step 6: +// Fill in test payment page. For dummy credit card numbers see +// https://saferpay.github.io/sndbx/paymentmeans.html + +// ----------------------------- +// Step 7: +// On success page and notification url, assert that the payment has been successful. +// -> see example-assert.php diff --git a/example/SecureAliasStore/1-example-insert.php b/example/SecureAliasStore/1-example-insert.php deleted file mode 100644 index 486489d..0000000 --- a/example/SecureAliasStore/1-example-insert.php +++ /dev/null @@ -1,51 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$returnUrls = (new Container\ReturnUrls()) - ->setSuccess('http://www.mysite.ch/success') - ->setFail('http://www.mysite.ch/fail') - ->setAbort('http://www.mysite.ch/abort'); - -$response = (new InsertRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setRegisterAlias(new Container\RegisterAlias()) - ->setType('CARD') - ->setReturnUrls($returnUrls) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -// Step 3: -// Save the response token, you will need it later to verify the insert -echo 'Insert token: ' . $response->getToken() . "
\n"; - -// Step 4: -// Redirect to the payment page -echo 'Redirect to: ' . $response->getRedirectUrl() ."
\n"; - -// Step 5: -// Fill in test payment page. For dummy credit card numbers see -// https://saferpay.github.io/sndbx/paymentmeans.html - -// Step 6: -// On success page, assert the data has successfully been inserted -// -> see 2-example-assert.php diff --git a/example/SecureAliasStore/2-example-assert.php b/example/SecureAliasStore/2-example-assert.php deleted file mode 100644 index 872172c..0000000 --- a/example/SecureAliasStore/2-example-assert.php +++ /dev/null @@ -1,34 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$response = (new AssertInsertRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setToken($token) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -echo 'The insert has been successful! Insert alias: ' . $response->getAlias()->getId(); diff --git a/example/SecureAliasStore/3-example-insert-direct.php b/example/SecureAliasStore/3-example-insert-direct.php deleted file mode 100644 index 5b74b7c..0000000 --- a/example/SecureAliasStore/3-example-insert-direct.php +++ /dev/null @@ -1,43 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$card = (new Container\Card()) - ->setNumber('9030101052000008') - ->setExpYear(2025) - ->setExpMonth(10) - ->setHolderName('Johnny Cash'); - -$paymentMeans = (new Container\PaymentMeans()) - ->setCard($card); - -$response = (new InsertDirectRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setRegisterAlias(new Container\RegisterAlias()) - ->setPaymentMeans($paymentMeans) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -// Step 3: -// You are done! - -echo 'The insert has been successful! Insert alias: ' . $response->getAlias()->getId() . "
\n"; diff --git a/example/SecureAliasStore/4-example-delete.php b/example/SecureAliasStore/4-example-delete.php deleted file mode 100644 index f915ce3..0000000 --- a/example/SecureAliasStore/4-example-delete.php +++ /dev/null @@ -1,45 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$response = (new DeleteRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setAliasId($aliasId) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - - -// Step 3: -// You are done! - -echo 'The alias has successfully been deleted'; diff --git a/example/SecureCardData/example-alias-delete.php b/example/SecureCardData/example-alias-delete.php new file mode 100644 index 0000000..3523506 --- /dev/null +++ b/example/SecureCardData/example-alias-delete.php @@ -0,0 +1,48 @@ +execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo "The alias has successfully been deleted.
\n"; + +// Note that no error is returned if the provided alias id did not exist. +// This is by design by the Saferpay API. \ No newline at end of file diff --git a/example/SecureCardData/example-alias-insert-assert.php b/example/SecureCardData/example-alias-insert-assert.php new file mode 100644 index 0000000..7c729f8 --- /dev/null +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -0,0 +1,45 @@ +execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The insert has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/SecureCardData/example-alias-insert-direct.php b/example/SecureCardData/example-alias-insert-direct.php new file mode 100644 index 0000000..f54ddcf --- /dev/null +++ b/example/SecureCardData/example-alias-insert-direct.php @@ -0,0 +1,57 @@ +setNumber('9030003150000007') // Dummy from https://saferpay.github.io/sndbx/paymentmeans.html + ->setExpMonth(8) + ->setExpYear(2025) + ->setHolderName('Max Mustermann'); + +$paymentMeans = (new Container\PaymentMeans()) + ->setCard($card); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$insertRequest = new AliasInsertDirectRequest( + $requestConfig, + $registerAlias, + $paymentMeans +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $insertRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The insert has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; + diff --git a/example/SecureCardData/example-alias-insert.php b/example/SecureCardData/example-alias-insert.php new file mode 100644 index 0000000..87dfa12 --- /dev/null +++ b/example/SecureCardData/example-alias-insert.php @@ -0,0 +1,71 @@ +execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +// ----------------------------- +// Step 4: +// Save the response token, you will need it later to verify the payment (see step 7) +echo 'Payment token: ' . $response->getToken() . "
\n"; + +// ----------------------------- +// Step 5: +// Redirect to the payment page +echo 'Redirect to: ' . $response->getRedirect()->getRedirectUrl() ."
\n"; + +// ----------------------------- +// Step 6: +// Fill in test payment page. For dummy credit card numbers see +// https://saferpay.github.io/sndbx/paymentmeans.html + +// ----------------------------- +// Step 7: +// On success page and notification url, assert that the payment has been successful. +// -> see example-alias-insert-assert.php diff --git a/example/SecureCardData/example-alias-update.php b/example/SecureCardData/example-alias-update.php new file mode 100644 index 0000000..b2288c4 --- /dev/null +++ b/example/SecureCardData/example-alias-update.php @@ -0,0 +1,55 @@ +setExpMonth(6) + ->setExpYear(2028); + +$updatePaymentMeans = new Container\UpdatePaymentMeans($card); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$assertRequest = new AliasUpdateRequest( + $requestConfig, + $updateAlias, + $updatePaymentMeans +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $assertRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The update has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/Transaction/1-example-capture.php b/example/Transaction/1-example-capture.php deleted file mode 100644 index ca21098..0000000 --- a/example/Transaction/1-example-capture.php +++ /dev/null @@ -1,39 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$transactionReference = (new Container\TransactionReference()) - ->setTransactionId($transactionId); - -$response = (new CaptureRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -echo 'The transaction has successfully been captured! Transaction-ID: ' . $response->getTransactionId(); - -// You have now fully completed a successful payment :) \ No newline at end of file diff --git a/example/Transaction/2-example-cancel.php b/example/Transaction/2-example-cancel.php deleted file mode 100644 index acb2237..0000000 --- a/example/Transaction/2-example-cancel.php +++ /dev/null @@ -1,37 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$transactionReference = (new Container\TransactionReference()) - ->setTransactionId($transactionId); - -$response = (new CancelRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->execute(); - -// Step 2: -// Check for successful response - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -echo 'The transaction has successfully been canceled! Transaction-ID: ' . $response->getTransactionId(); diff --git a/example/Transaction/3-example-refund.php b/example/Transaction/3-example-refund.php deleted file mode 100644 index 579413a..0000000 --- a/example/Transaction/3-example-refund.php +++ /dev/null @@ -1,46 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$transactionReference = (new Container\TransactionReference()) - ->setTransactionId($transactionId); - -$amount = (new Container\Amount()) - ->setCurrencyCode('CHF') - ->setValue(5000); // amount in cents - -$refund = (new Container\Refund()) - ->setAmount($amount); - -$response = (new RefundRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->setRefund($refund) - ->execute(); - -// Step 2: -// Check for successful response - -/** @var \Ticketpark\SaferpayJson\Transaction\RefundResponse */ -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); -} - -echo 'The transaction has successfully been refunded! Transaction-ID: ' . $response->getTransaction()->getId(); diff --git a/example/Transaction/example-authorize-referenced.php b/example/Transaction/example-authorize-referenced.php new file mode 100644 index 0000000..4d882cf --- /dev/null +++ b/example/Transaction/example-authorize-referenced.php @@ -0,0 +1,67 @@ +setTransactionId($transactionId); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$authorizeReferencedRequest = new AuthorizeReferencedRequest( + $requestConfig, + $terminalId, + $payment, + $transactionReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { +$response = $authorizeReferencedRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +print sprintf( + "Transaction ID: %s, Status: %s, via %s (%s)", + $response->getTransaction()->getId(), + $response->getTransaction()->getStatus(), + $response->getPaymentMeans()->getBrand()->getName(), + $response->getPaymentMeans()->getDisplayText() +). "\n"; + +// Recurring payment transactions still need to be captured. +// see: example-capture.php diff --git a/example/Transaction/example-cancel.php b/example/Transaction/example-cancel.php new file mode 100644 index 0000000..89ac4a7 --- /dev/null +++ b/example/Transaction/example-cancel.php @@ -0,0 +1,49 @@ +setTransactionId($transactionId); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$cancelRequest = new CancelRequest( + $requestConfig, + $transactionReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $cancelRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The transaction has successfully been canceled! Transaction-ID: ' . $response->getTransactionId(); diff --git a/example/Transaction/example-capture.php b/example/Transaction/example-capture.php new file mode 100644 index 0000000..c73be6a --- /dev/null +++ b/example/Transaction/example-capture.php @@ -0,0 +1,51 @@ +setTransactionId($transactionId); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$captureRequest = new CaptureRequest( + $requestConfig, + $transactionReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $captureRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The transaction has successfully been captured! Capture-Id: ' . $response->getCaptureId()."\n"; + +// You have now fully completed a successful payment :) \ No newline at end of file diff --git a/example/Transaction/example-refund.php b/example/Transaction/example-refund.php new file mode 100644 index 0000000..9ec7f52 --- /dev/null +++ b/example/Transaction/example-refund.php @@ -0,0 +1,58 @@ +setCaptureId($captureId); + +$amount = new Container\Amount( + 2000, + 'CHF' +); + +$refund = new Container\Refund($amount); + +// ----------------------------- +// Step 2: +// Create the request with required data + +$refundRequest = new RefundRequest( + $requestConfig, + $refund, + $captureReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +try { + $response = $refundRequest->execute(); +} catch (SaferpayErrorException $e) { + die ($e->getErrorResponse()->getErrorMessage()); +} + +echo 'The transaction has successfully been refunded! Transaction-ID: ' . $response->getTransaction()->getId(); + diff --git a/example/credentials.dist.php b/example/credentials.dist.php new file mode 100644 index 0000000..18cd1ca --- /dev/null +++ b/example/credentials.dist.php @@ -0,0 +1,9 @@ +iban; - } - - public function setIban(string $iban): self - { - $this->iban = $iban; - return $this; - } - - public function getHolderName(): string - { - return $this->holderName; - } - - public function setHolderName(string $holderName): self - { - $this->holderName = $holderName; - - return $this; - } - - public function getBic(): string - { - return $this->bic; - } - - public function setBic(string $bic): self - { - $this->bic = $bic; - - return $this; - } - - public function getBankName(): string - { - return $this->bankName; - } - - public function setBankName(string $bankName): self - { - $this->bankName = $bankName; - - return $this; - } - - public function getCountryCode(): string - { - return $this->countryCode; - } - - public function setCountryCode(string $countryCode): self - { - $this->countryCode = $countryCode; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Card.php b/lib/SaferpayJson/Container/Card.php deleted file mode 100644 index 08945dd..0000000 --- a/lib/SaferpayJson/Container/Card.php +++ /dev/null @@ -1,142 +0,0 @@ -number; - } - - public function setNumber(string $number): self - { - $this->number = $number; - - return $this; - } - - public function getMaskedNumber(): string - { - return $this->maskedNumber; - } - - public function setMaskedNumber(string $maskedNumber): self - { - $this->maskedNumber = $maskedNumber; - - return $this; - } - - public function getExpYear(): int - { - return $this->expYear; - } - - public function setExpYear(int $expYear): self - { - $this->expYear = $expYear; - - return $this; - } - - public function getExpMonth(): int - { - return $this->expMonth; - } - - public function setExpMonth(int $expMonth): self - { - $this->expMonth = $expMonth; - - return $this; - } - - public function getHolderName(): string - { - return $this->holderName; - } - - public function setHolderName(string $holderName): self - { - $this->holderName = $holderName; - - return $this; - } - - public function getCountryCode(): string - { - return $this->countryCode; - } - - public function setCountryCode(string $countryCode): self - { - $this->countryCode = $countryCode; - - return $this; - } - - public function getHashValue(): string - { - return $this->hashValue; - } - - public function setHashValue(string $hashValue): self - { - $this->hashValue = $hashValue; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Check.php b/lib/SaferpayJson/Container/Check.php deleted file mode 100644 index 225932c..0000000 --- a/lib/SaferpayJson/Container/Check.php +++ /dev/null @@ -1,44 +0,0 @@ -type; - } - - public function setType(string $type): self - { - $this->type = $type; - - return $this; - } - - public function getTerminalId(): string - { - return $this->terminalId; - } - - public function setTerminalId(string $terminalId): self - { - $this->terminalId = $terminalId; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Dcc.php b/lib/SaferpayJson/Container/Dcc.php deleted file mode 100644 index 7fae153..0000000 --- a/lib/SaferpayJson/Container/Dcc.php +++ /dev/null @@ -1,28 +0,0 @@ -payerAmount; - } - - public function setPayerAmount(Amount $payerAmount): self - { - $this->payerAmount = $payerAmount; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Error.php b/lib/SaferpayJson/Container/Error.php deleted file mode 100644 index 920b40e..0000000 --- a/lib/SaferpayJson/Container/Error.php +++ /dev/null @@ -1,47 +0,0 @@ -errorName; - } - - public function setErrorName(string $errorName): self - { - $this->errorName = $errorName; - - return $this; - } - - public function getErrorMessage(): string - { - return $this->errorMessage; - } - - public function setErrorMessage(string $errorMessage): self - { - $this->errorMessage = $errorMessage; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Invoice.php b/lib/SaferpayJson/Container/Invoice.php deleted file mode 100644 index 3a8700c..0000000 --- a/lib/SaferpayJson/Container/Invoice.php +++ /dev/null @@ -1,67 +0,0 @@ -payee; - } - - public function setPayee(Payee $payee): self - { - $this->payee = $payee; - - return $this; - } - - public function getReasonForTransfer(): string - { - return $this->reasonForTransfer; - } - - public function setReasonForTransfer(string $reasonForTransfer): self - { - $this->reasonForTransfer = $reasonForTransfer; - - return $this; - } - - public function getDueDate(): string - { - return $this->dueDate; - } - - public function setDueDate(string $dueDate): self - { - $this->dueDate = $dueDate; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Payment.php b/lib/SaferpayJson/Container/Payment.php deleted file mode 100644 index c40bb8c..0000000 --- a/lib/SaferpayJson/Container/Payment.php +++ /dev/null @@ -1,98 +0,0 @@ -amount; - } - - public function setAmount(Amount $amount): self - { - $this->amount = $amount; - - return $this; - } - - public function getOrderId(): string - { - return $this->orderId; - } - - public function setOrderId(string $orderId): self - { - $this->orderId = $orderId; - - return $this; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): self - { - $this->description = $description; - - return $this; - } - - public function getPayerNote(): string - { - return $this->payerNote; - } - - public function setPayerNote(string $payerNote): self - { - $this->payerNote = $payerNote; - - return $this; - } - - public function getRecurring(): Recurring - { - return $this->recurring; - } - - public function setRecurring(Recurring $recurring): self - { - $this->recurring = $recurring; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/PaymentMeans.php b/lib/SaferpayJson/Container/PaymentMeans.php deleted file mode 100644 index 085d0a0..0000000 --- a/lib/SaferpayJson/Container/PaymentMeans.php +++ /dev/null @@ -1,126 +0,0 @@ -brand; - } - - public function setBrand(Brand $brand): self - { - $this->brand = $brand; - - return $this; - } - - public function getDisplayText(): string - { - return $this->displayText; - } - - public function setDisplayText(string $displayText): self - { - $this->displayText = $displayText; - - return $this; - } - - public function getWallet(): string - { - return $this->wallet; - } - - public function setWallet(string $wallet): self - { - $this->wallet = $wallet; - - return $this; - } - - public function getCard(): Card - { - return $this->card; - } - - public function setCard(Card $card): self - { - $this->card = $card; - - return $this; - } - - public function getBankAccount(): BankAccount - { - return $this->bankAccount; - } - - public function setBankAccount(BankAccount $bankAccount): self - { - $this->bankAccount = $bankAccount; - - return $this; - } - - public function getAlias(): Alias - { - return $this->alias; - } - - public function setAlias(Alias $alias): self - { - $this->alias = $alias; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Refund.php b/lib/SaferpayJson/Container/Refund.php deleted file mode 100644 index 2711f53..0000000 --- a/lib/SaferpayJson/Container/Refund.php +++ /dev/null @@ -1,66 +0,0 @@ -amount; - } - - public function setAmount(Amount $amount): self - { - $this->amount = $amount; - - return $this; - } - - public function getOrderId(): string - { - return $this->orderId; - } - - public function setOrderId(string $orderId): self - { - $this->orderId = $orderId; - - return $this; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): self - { - $this->description = $description; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/RegisterAlias.php b/lib/SaferpayJson/Container/RegisterAlias.php deleted file mode 100644 index 7c52abc..0000000 --- a/lib/SaferpayJson/Container/RegisterAlias.php +++ /dev/null @@ -1,80 +0,0 @@ -IdGenerator; - } - - /** - * @param string $idGenerator - * @return RegisterAlias - */ - public function setIdGenerator(string $idGenerator): self - { - $this->IdGenerator = $idGenerator; - - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $id - * @return RegisterAlias - */ - public function setId(string $id): self - { - $this->id = $id; - - return $this; - } - - public function getLifetime(): int - { - return $this->lifetime; - } - - public function setLifetime(int $lifetime): self - { - $this->lifetime = $lifetime; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/RegistrationResult.php b/lib/SaferpayJson/Container/RegistrationResult.php deleted file mode 100644 index 17cfe9c..0000000 --- a/lib/SaferpayJson/Container/RegistrationResult.php +++ /dev/null @@ -1,67 +0,0 @@ -success; - } - - public function setSuccess(bool $success): self - { - $this->success = $success; - return $this; - } - - public function getAlias(): Alias - { - return $this->alias; - } - - public function setAlias(Alias $alias): self - { - $this->alias = $alias; - - return $this; - } - - public function getError(): Error - { - return $this->error; - } - - public function setError(Error $error): self - { - $this->error = $error; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Styling.php b/lib/SaferpayJson/Container/Styling.php deleted file mode 100644 index 9493da2..0000000 --- a/lib/SaferpayJson/Container/Styling.php +++ /dev/null @@ -1,44 +0,0 @@ -cssUrl; - } - - public function setCssUrl(string $cssUrl): self - { - $this->cssUrl = $cssUrl; - - return $this; - } - - public function getTheme(): string - { - return $this->theme; - } - - public function setTheme(string $theme): self - { - $this->theme = $theme; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/ThreeDs.php b/lib/SaferpayJson/Container/ThreeDs.php deleted file mode 100644 index 4fadb81..0000000 --- a/lib/SaferpayJson/Container/ThreeDs.php +++ /dev/null @@ -1,86 +0,0 @@ -authenticated; - } - - public function setAuthenticated(bool $authenticated): self - { - $this->authenticated = $authenticated; - - return $this; - } - - public function isLiabilityShift(): bool - { - return $this->liabilityShift; - } - - public function setLiabilityShift(bool $liabilityShift): self - { - $this->liabilityShift = $liabilityShift; - - return $this; - } - - public function getXid(): string - { - return $this->xid; - } - - public function setXid(string $xid): self - { - $this->xid = $xid; - - return $this; - } - - public function getVerificationValue(): string - { - return $this->verificationValue; - } - - public function setVerificationValue(string $verificationValue): self - { - $this->verificationValue = $verificationValue; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Transaction.php b/lib/SaferpayJson/Container/Transaction.php deleted file mode 100644 index cd16b24..0000000 --- a/lib/SaferpayJson/Container/Transaction.php +++ /dev/null @@ -1,158 +0,0 @@ -type; - } - - public function setType(string $type): self - { - $this->type = $type; - return $this; - } - - public function getStatus(): string - { - return $this->status; - } - - public function setStatus(string $status): self - { - $this->status = $status; - return $this; - } - - public function getId(): string - { - return $this->id; - } - - public function setId(string $id): self - { - $this->id = $id; - return $this; - } - - public function getDate(): string - { - return $this->date; - } - - public function setDate(string $date): self - { - $this->date = $date; - - return $this; - } - - public function getAmount(): Amount - { - return $this->amount; - } - - public function setAmount(Amount $amount): self - { - $this->amount = $amount; - - return $this; - } - - public function getOrderId(): string - { - return $this->orderId; - } - - public function setOrderId(string $orderId): self - { - $this->orderId = $orderId; - - return $this; - } - - public function getAcquirerName(): string - { - return $this->acquirerName; - } - - public function setAcquirerName(string $acquirerName): self - { - $this->acquirerName = $acquirerName; - - return $this; - } - - public function getAcquirerReference(): string - { - return $this->acquirerReference; - } - - public function setAcquirerReference(string $acquirerReference): self - { - $this->acquirerReference = $acquirerReference; - - return $this; - } -} diff --git a/lib/SaferpayJson/Container/Address.php b/lib/SaferpayJson/Request/Container/Address.php similarity index 51% rename from lib/SaferpayJson/Container/Address.php rename to lib/SaferpayJson/Request/Container/Address.php index dafe535..c16f006 100644 --- a/lib/SaferpayJson/Container/Address.php +++ b/lib/SaferpayJson/Request/Container/Address.php @@ -1,274 +1,265 @@ firstName; } - public function setFirstName(string $firstName): self + public function setFirstName(?string $firstName): self { $this->firstName = $firstName; return $this; } - public function getLastName(): string + public function getLastName(): ?string { return $this->lastName; } - public function setLastName(string $lastName): self + public function setLastName(?string $lastName): self { $this->lastName = $lastName; return $this; } - public function getDateOfBirth(): \DateTime + public function getCompany(): ?string { - return $this->dateOfBirth; + return $this->company; } - public function setDateOfBirth(\DateTime $dateOfBirth): self + public function setCompany(?string $company): self { - $this->dateOfBirth = $dateOfBirth; + $this->company = $company; return $this; } - public function getCompany(): string + public function getGender(): ?string { - return $this->company; + return $this->gender; } - public function setCompany(string $company): self + public function setGender(?string $gender): self { - $this->company = $company; + $this->gender = $gender; return $this; } - public function getGender(): string + public function getStreet(): ?string { - return $this->gender; + return $this->street; } - public function setGender(string $gender): self + public function setStreet(?string $street): self { - $this->gender = $gender; + $this->street = $street; return $this; } - public function getLegalForm(): string + public function getZip(): ?string { - return $this->legalForm; + return $this->zip; } - public function setLegalForm(string $legalForm): self + public function setZip(?string $zip): self { - $this->legalForm = $legalForm; + $this->zip = $zip; return $this; } - public function getStreet(): string + public function getCity(): ?string { - return $this->street; + return $this->city; } - public function setStreet(string $street): self + public function setCity(?string $city): self { - $this->street = $street; + $this->city = $city; return $this; } - public function getStreet2(): string + public function getCountryCode(): ?string { - return $this->street2; + return $this->countryCode; } - public function setStreet2(string $street2): self + public function setCountryCode(?string $countryCode): self { - $this->street2 = $street2; + $this->countryCode = $countryCode; return $this; } - public function getZip(): string + public function getEmail(): ?string { - return $this->zip; + return $this->email; } - public function setZip(string $zip): self + public function setEmail(?string $email): self { - $this->zip = $zip; + $this->email = $email; return $this; } - public function getCity(): string + public function getDateOfBirth(): ?\DateTime { - return $this->city; + return $this->dateOfBirth; } - public function setCity(string $city): self + public function setDateOfBirth(?\DateTime $dateOfBirth): self { - $this->city = $city; + $this->dateOfBirth = $dateOfBirth; return $this; } - public function getCountrySubdivisionCode(): string + public function getLegalForm(): ?string { - return $this->countrySubdivisionCode; + return $this->legalForm; } - public function setCountrySubdivisionCode(string $countrySubdivisionCode): self + public function setLegalForm(?string $legalForm): self { - $this->countrySubdivisionCode = $countrySubdivisionCode; + $this->legalForm = $legalForm; return $this; } - public function getCountryCode(): string + public function getStreet2(): ?string { - return $this->countryCode; + return $this->street2; } - public function setCountryCode(string $countryCode): self + public function setStreet2(?string $street2): self { - $this->countryCode = $countryCode; + $this->street2 = $street2; return $this; } - public function getPhone(): string + public function getCountrySubdivisionCode(): ?string { - return $this->phone; + return $this->countrySubdivisionCode; } - public function setPhone(string $phone): self + public function setCountrySubdivisionCode(?string $countrySubdivisionCode): self { - $this->phone = $phone; + $this->countrySubdivisionCode = $countrySubdivisionCode; return $this; } - public function getEmail(): string + public function getPhone(): ?string { - return $this->email; + return $this->phone; } - public function setEmail(string $email): self + public function setPhone(?string $phone): self { - $this->email = $email; + $this->phone = $phone; return $this; } diff --git a/lib/SaferpayJson/Request/Container/AddressForm.php b/lib/SaferpayJson/Request/Container/AddressForm.php new file mode 100644 index 0000000..d6636ae --- /dev/null +++ b/lib/SaferpayJson/Request/Container/AddressForm.php @@ -0,0 +1,55 @@ +|null + * @SerializedName("MandatoryFields") + */ + private $mandatoryFields = []; + + public function __construct(bool $display) + { + $this->display = $display; + } + + public function isDisplay(): bool + { + return $this->display; + } + + public function getMandatoryFields(): ?array + { + return $this->mandatoryFields; + } + + public function setMandatoryFields(?array $mandatoryFields): self + { + $this->mandatoryFields = $mandatoryFields; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/Alias.php b/lib/SaferpayJson/Request/Container/Alias.php new file mode 100644 index 0000000..05556b2 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Alias.php @@ -0,0 +1,43 @@ +id = $id; + } + + public function getId(): string + { + return $this->id; + } + + public function getVerificationCode(): ?string + { + return $this->verificationCode; + } + + public function setVerificationCode(?string $verificationCode): self + { + $this->verificationCode = $verificationCode; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/Alipay.php b/lib/SaferpayJson/Request/Container/Alipay.php new file mode 100644 index 0000000..0841ff3 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Alipay.php @@ -0,0 +1,25 @@ +localWallet = $localWallet; + } + + public function getLocalWallet(): ?string + { + return $this->localWallet; + } +} diff --git a/lib/SaferpayJson/Container/Amount.php b/lib/SaferpayJson/Request/Container/Amount.php similarity index 64% rename from lib/SaferpayJson/Container/Amount.php rename to lib/SaferpayJson/Request/Container/Amount.php index f9e59c7..17ec234 100644 --- a/lib/SaferpayJson/Container/Amount.php +++ b/lib/SaferpayJson/Request/Container/Amount.php @@ -1,47 +1,38 @@ value; + $this->value = $value; + $this->currencyCode = $currencyCode; } - public function setValue(int $value): self + public function getValue(): int { - $this->value = $value; - - return $this; + return $this->value; } public function getCurrencyCode(): string { return $this->currencyCode; } - - public function setCurrencyCode(string $currencyCode): self - { - $this->currencyCode = $currencyCode; - - return $this; - } } diff --git a/lib/SaferpayJson/Request/Container/Authentication.php b/lib/SaferpayJson/Request/Container/Authentication.php new file mode 100644 index 0000000..0665fb1 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Authentication.php @@ -0,0 +1,52 @@ +exemption; + } + + public function setExemption(?string $exemption): self + { + $this->exemption = $exemption; + + return $this; + } + + public function getThreeDsChallenge(): ?string + { + return $this->threeDsChallenge; + } + + public function setThreeDsChallenge(?string $threeDsChallenge): self + { + $this->threeDsChallenge = $threeDsChallenge; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Payee.php b/lib/SaferpayJson/Request/Container/BankAccount.php similarity index 53% rename from lib/SaferpayJson/Container/Payee.php rename to lib/SaferpayJson/Request/Container/BankAccount.php index ffcf4b5..aabbf35 100644 --- a/lib/SaferpayJson/Container/Payee.php +++ b/lib/SaferpayJson/Request/Container/BankAccount.php @@ -1,83 +1,76 @@ iban; + $this->iban = $iban; } - public function setIban(string $iban): self + public function getIban(): string { - $this->iban = $iban; - - return $this; + return $this->iban; } - public function getHolderName(): string + public function getHolderName(): ?string { return $this->holderName; } - public function setHolderName(string $holderName): self + public function setHolderName(?string $holderName): self { $this->holderName = $holderName; return $this; } - public function getBic(): string + public function getBic(): ?string { return $this->bic; } - public function setBic(string $bic): self + public function setBic(?string $bic): self { $this->bic = $bic; return $this; } - public function getBankName(): string + public function getBankName(): ?string { return $this->bankName; } - public function setBankName(string $bankName): self + public function setBankName(?string $bankName): self { $this->bankName = $bankName; diff --git a/lib/SaferpayJson/Request/Container/Billpay.php b/lib/SaferpayJson/Request/Container/Billpay.php new file mode 100644 index 0000000..35f1fef --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Billpay.php @@ -0,0 +1,27 @@ +delayInDays; + } + + public function setDelayInDays(?int $delayInDays): self + { + $this->delayInDays = $delayInDays; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Brand.php b/lib/SaferpayJson/Request/Container/Brand.php similarity index 54% rename from lib/SaferpayJson/Container/Brand.php rename to lib/SaferpayJson/Request/Container/Brand.php index 4ce508b..a88f015 100644 --- a/lib/SaferpayJson/Container/Brand.php +++ b/lib/SaferpayJson/Request/Container/Brand.php @@ -1,44 +1,42 @@ paymentMethod; } - public function setPaymentMethod(string $paymentMethod): self + public function setPaymentMethod(?string $paymentMethod): self { $this->paymentMethod = $paymentMethod; return $this; } - public function getName(): string + public function getName(): ?string { return $this->name; } - public function setName(string $name): self + public function setName(?string $name): self { $this->name = $name; diff --git a/lib/SaferpayJson/Request/Container/CaptureReference.php b/lib/SaferpayJson/Request/Container/CaptureReference.php new file mode 100644 index 0000000..38af448 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/CaptureReference.php @@ -0,0 +1,80 @@ +captureId; + } + + public function setCaptureId(?string $captureId): self + { + $this->captureId = $captureId; + + return $this; + } + + public function getTransactionId(): ?string + { + return $this->transactionId; + } + + public function setTransactionId(?string $transactionId): self + { + $this->transactionId = $transactionId; + + return $this; + } + + public function getOrderId(): ?string + { + return $this->orderId; + } + + public function setOrderId(?string $orderId): self + { + $this->orderId = $orderId; + + return $this; + } + + public function getOrderPartId(): ?string + { + return $this->orderPartId; + } + + public function setOrderPartId(?string $orderPartId): self + { + $this->orderPartId = $orderPartId; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/Card.php b/lib/SaferpayJson/Request/Container/Card.php new file mode 100644 index 0000000..3ff9faa --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Card.php @@ -0,0 +1,101 @@ +number; + } + + public function setNumber(?string $number): self + { + $this->number = $number; + + return $this; + } + + public function getExpYear(): ?int + { + return $this->expYear; + } + + public function setExpYear(?int $expYear): self + { + $this->expYear = $expYear; + + return $this; + } + + public function getExpMonth(): ?int + { + return $this->expMonth; + } + + public function setExpMonth(?int $expMonth): self + { + $this->expMonth = $expMonth; + + return $this; + } + + public function getHolderName(): ?string + { + return $this->holderName; + } + + public function setHolderName(?string $holderName): self + { + $this->holderName = $holderName; + + return $this; + } + + public function getCountryCode(): ?string + { + return $this->countryCode; + } + + public function setCountryCode(?string $countryCode): self + { + $this->countryCode = $countryCode; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/CardForm.php b/lib/SaferpayJson/Request/Container/CardForm.php new file mode 100644 index 0000000..b3cbbb4 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/CardForm.php @@ -0,0 +1,30 @@ +holderName; + } + + public function setHolderName(string $holderName): self + { + $this->holderName = $holderName; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/Check.php b/lib/SaferpayJson/Request/Container/Check.php new file mode 100644 index 0000000..06464a7 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Check.php @@ -0,0 +1,47 @@ +type; + } + + public function setType(?string $type): self + { + $this->type = $type; + + return $this; + } + + public function getTerminalId(): ?string + { + return $this->terminalId; + } + + public function setTerminalId(?string $terminalId): self + { + $this->terminalId = $terminalId; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/ChosenPlan.php b/lib/SaferpayJson/Request/Container/ChosenPlan.php new file mode 100644 index 0000000..80ca408 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/ChosenPlan.php @@ -0,0 +1,138 @@ +numberOfInstallments = $numberOfInstallments; + } + + public function getNumberOfInstallments(): int + { + return $this->numberOfInstallments; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function setInterestRate(?string $interestRate): self + { + $this->interestRate = $interestRate; + + return $this; + } + + public function getInstallmentFee(): ?Amount + { + return $this->installmentFee; + } + + public function setInstallmentFee(?Amount $installmentFee): self + { + $this->installmentFee = $installmentFee; + + return $this; + } + + public function getAnnualPercentageRate(): ?string + { + return $this->annualPercentageRate; + } + + public function setAnnualPercentageRate(?string $annualPercentageRate): self + { + $this->annualPercentageRate = $annualPercentageRate; + + return $this; + } + + public function getFirstInstallmentAmount(): ?Amount + { + return $this->firstInstallmentAmount; + } + + public function setFirstInstallmentAmount(?Amount $firstInstallmentAmount): self + { + $this->firstInstallmentAmount = $firstInstallmentAmount; + + return $this; + } + + public function getSubsequentInstallmentAmount(): ?Amount + { + return $this->subsequentInstallmentAmount; + } + + public function setSubsequentInstallmentAmount(?Amount $subsequentInstallmentAmount): self + { + $this->subsequentInstallmentAmount = $subsequentInstallmentAmount; + + return $this; + } + + public function getTotalAmountDue(): ?Amount + { + return $this->totalAmountDue; + } + + public function setTotalAmountDue(?Amount $totalAmountDue): self + { + $this->totalAmountDue = $totalAmountDue; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/ClientInfo.php b/lib/SaferpayJson/Request/Container/ClientInfo.php new file mode 100644 index 0000000..a5072fd --- /dev/null +++ b/lib/SaferpayJson/Request/Container/ClientInfo.php @@ -0,0 +1,45 @@ +shopInfo; + } + + public function setShopInfo(?string $shopInfo): self + { + $this->shopInfo = $shopInfo; + + return $this; + } + + public function getOsInfo(): ?string + { + return $this->osInfo; + } + + public function setOsInfo(?string $osInfo): self + { + $this->osInfo = $osInfo; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/Ideal.php b/lib/SaferpayJson/Request/Container/Ideal.php new file mode 100644 index 0000000..f48ffc7 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Ideal.php @@ -0,0 +1,25 @@ +issuerId = $issuerId; + } + + public function getIssuerId(): string + { + return $this->issuerId; + } +} diff --git a/lib/SaferpayJson/Request/Container/Installment.php b/lib/SaferpayJson/Request/Container/Installment.php new file mode 100644 index 0000000..e3a054e --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Installment.php @@ -0,0 +1,24 @@ +initial = $initial; + } + + public function isInitial(): bool + { + return $this->initial; + } +} diff --git a/lib/SaferpayJson/Request/Container/Marketplace.php b/lib/SaferpayJson/Request/Container/Marketplace.php new file mode 100644 index 0000000..c9405d2 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Marketplace.php @@ -0,0 +1,60 @@ +submerchantId = $submerchantId; + } + + public function getSubmerchantId(): string + { + return $this->submerchantId; + } + + public function getFee(): ?Amount + { + return $this->fee; + } + + public function setFee(?Amount $fee): self + { + $this->fee = $fee; + + return $this; + } + + public function getFeeRefund(): ?Amount + { + return $this->feeRefund; + } + + public function setFeeRefund(?Amount $feeRefund): self + { + $this->feeRefund = $feeRefund; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Request/Container/MastercardIssuerInstallments.php new file mode 100644 index 0000000..b851e92 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/MastercardIssuerInstallments.php @@ -0,0 +1,28 @@ +chosenPlan; + } + + public function setChosenPlan(?ChosenPlan $chosenPlan): self + { + $this->chosenPlan = $chosenPlan; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Notification.php b/lib/SaferpayJson/Request/Container/Notification.php similarity index 51% rename from lib/SaferpayJson/Container/Notification.php rename to lib/SaferpayJson/Request/Container/Notification.php index e9a35dd..31492d8 100644 --- a/lib/SaferpayJson/Container/Notification.php +++ b/lib/SaferpayJson/Request/Container/Notification.php @@ -1,42 +1,42 @@ |null + * @SerializedName("MerchantEmails") */ - protected $merchantEmail; + private $merchantEmails = []; /** - * @var string + * @var string|null * @SerializedName("PayerEmail") */ - protected $payerEmail; + private $payerEmail; /** - * @var string + * @var string|null * @SerializedName("NotifyUrl") */ - protected $notifyUrl; + private $notifyUrl; - public function getMerchantEmail(): string + public function getMerchantEmails(): ?array { - return $this->merchantEmail; + return $this->merchantEmails; } - public function setMerchantEmail(string $merchantEmail): self + public function setMerchantEmails(?array $merchantEmails): self { - $this->merchantEmail = $merchantEmail; + $this->merchantEmails = $merchantEmails; return $this; } - public function getPayerEmail(): string + public function getPayerEmail(): ?string { return $this->payerEmail; } @@ -48,7 +48,7 @@ public function setPayerEmail(string $payerEmail): self return $this; } - public function getNotifyUrl(): string + public function getNotifyUrl(): ?string { return $this->notifyUrl; } diff --git a/lib/SaferpayJson/Request/Container/Options.php b/lib/SaferpayJson/Request/Container/Options.php new file mode 100644 index 0000000..887a465 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Options.php @@ -0,0 +1,27 @@ +preAuth; + } + + public function setPreAuth(?bool $preAuth): self + { + $this->preAuth = $preAuth; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Payer.php b/lib/SaferpayJson/Request/Container/Payer.php similarity index 50% rename from lib/SaferpayJson/Container/Payer.php rename to lib/SaferpayJson/Request/Container/Payer.php index e184a96..94cfd5f 100644 --- a/lib/SaferpayJson/Container/Payer.php +++ b/lib/SaferpayJson/Request/Container/Payer.php @@ -1,82 +1,79 @@ ipAddress; } - public function setIpAddress(string $ipAddress): self + public function setIpAddress(?string $ipAddress): self { $this->ipAddress = $ipAddress; return $this; } - public function getLanguageCode(): string + public function getLanguageCode(): ?string { return $this->languageCode; } - public function setLanguageCode(string $languageCode): self + public function setLanguageCode(?string $languageCode): self { $this->languageCode = $languageCode; return $this; } - public function getDeliveryAddress(): Address + public function getDeliveryAddress(): ?Address { return $this->deliveryAddress; } - public function setDeliveryAddress(Address $deliveryAddress): self + public function setDeliveryAddress(?Address $deliveryAddress): self { $this->deliveryAddress = $deliveryAddress; return $this; } - public function getBillingAddress(): Address + public function getBillingAddress(): ?Address { return $this->billingAddress; } - public function setBillingAddress(Address $billingAddress): self + public function setBillingAddress(?Address $billingAddress): self { $this->billingAddress = $billingAddress; diff --git a/lib/SaferpayJson/Request/Container/Payment.php b/lib/SaferpayJson/Request/Container/Payment.php new file mode 100644 index 0000000..7f3d0de --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Payment.php @@ -0,0 +1,157 @@ +amount = $amount; + } + + public function getAmount(): Amount + { + return $this->amount; + } + + public function setAmount(Amount $amount): self + { + $this->amount = $amount; + + return $this; + } + + public function getOrderId(): ?string + { + return $this->orderId; + } + + public function setOrderId(string $orderId): self + { + $this->orderId = $orderId; + + return $this; + } + + public function getPayerNote(): ?string + { + return $this->payerNote; + } + + public function setPayerNote(string $payerNote): self + { + $this->payerNote = $payerNote; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + } + + public function getMandateId(): ?string + { + return $this->mandateId; + } + + public function setMandateId(string $mandateId): self + { + $this->mandateId = $mandateId; + + return $this; + } + + public function getOptions(): ?Options + { + return $this->options; + } + + public function setOptions(Options $options): self + { + $this->options = $options; + + return $this; + } + + public function getRecurring(): ?Recurring + { + return $this->recurring; + } + + public function setRecurring(Recurring $recurring): self + { + $this->recurring = $recurring; + + return $this; + } + + public function getInstallment(): ?Installment + { + return $this->installment; + } + + public function setInstallment(Installment $installment): self + { + $this->installment = $installment; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/PaymentMeans.php b/lib/SaferpayJson/Request/Container/PaymentMeans.php new file mode 100644 index 0000000..8cd1bd0 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/PaymentMeans.php @@ -0,0 +1,162 @@ +brand; + } + + public function setBrand(?Brand $brand): self + { + $this->brand = $brand; + + return $this; + } + + public function getDisplayText(): ?string + { + return $this->displayText; + } + + public function setDisplayText(?string $displayText): self + { + $this->displayText = $displayText; + + return $this; + } + + public function getWallet(): ?string + { + return $this->wallet; + } + + public function setWallet(?string $wallet): self + { + $this->wallet = $wallet; + + return $this; + } + + public function getCard(): ?Card + { + return $this->card; + } + + public function setCard(?Card $card): self + { + $this->card = $card; + + return $this; + } + + public function getBankAccount(): ?BankAccount + { + return $this->bankAccount; + } + + public function setBankAccount(?BankAccount $bankAccount): self + { + $this->bankAccount = $bankAccount; + + return $this; + } + + public function getTwint(): ?Twint + { + return $this->twint; + } + + public function setTwint(?Twint $twint): self + { + $this->twint = $twint; + + return $this; + } + + public function getSaferpayFields(): ?SaferpayFields + { + return $this->saferpayFields; + } + + public function setSaferpayFields(?SaferpayFields $saferpayFields): self + { + $this->saferpayFields = $saferpayFields; + + return $this; + } + + public function getAlias(): ?Alias + { + return $this->alias; + } + + public function setAlias(?Alias $alias): self + { + $this->alias = $alias; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/PaymentMethodsOptions.php b/lib/SaferpayJson/Request/Container/PaymentMethodsOptions.php new file mode 100644 index 0000000..bbe6662 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/PaymentMethodsOptions.php @@ -0,0 +1,45 @@ +alipay; + } + + public function setAlipay(?Alipay $alipay): self + { + $this->alipay = $alipay; + + return $this; + } + + public function getIdeal(): ?Ideal + { + return $this->ideal; + } + + public function setIdeal(?Ideal $ideal): self + { + $this->ideal = $ideal; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/PendingNotification.php b/lib/SaferpayJson/Request/Container/PendingNotification.php new file mode 100644 index 0000000..7484c54 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/PendingNotification.php @@ -0,0 +1,44 @@ +|null + * @SerializedName("MerchantEmails") + */ + private $merchantEmails = []; + + /** + * @var string|null + * @SerializedName("NotifyUrl") + */ + private $notifyUrl; + + public function getMerchantEmails(): ?array + { + return $this->merchantEmails; + } + + public function setMerchantEmails(?array $merchantEmails): self + { + $this->merchantEmails = $merchantEmails; + + return $this; + } + + public function getNotifyUrl(): ?string + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Recurring.php b/lib/SaferpayJson/Request/Container/Recurring.php similarity index 61% rename from lib/SaferpayJson/Container/Recurring.php rename to lib/SaferpayJson/Request/Container/Recurring.php index 17df0a3..9c74b2f 100644 --- a/lib/SaferpayJson/Container/Recurring.php +++ b/lib/SaferpayJson/Request/Container/Recurring.php @@ -1,16 +1,16 @@ initial; } - - public function setInitial(bool $initial): self - { - $this->initial = $initial; - - return $this; - } } diff --git a/lib/SaferpayJson/Request/Container/Refund.php b/lib/SaferpayJson/Request/Container/Refund.php new file mode 100644 index 0000000..7354dbf --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Refund.php @@ -0,0 +1,69 @@ +amount = $amount; + } + + public function getAmount(): ?Amount + { + return $this->amount; + } + + public function setAmount(?Amount $amount): self + { + $this->amount = $amount; + + return $this; + } + + public function getOrderId(): ?string + { + return $this->orderId; + } + + public function setOrderId(?string $orderId): self + { + $this->orderId = $orderId; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/Container/RegisterAlias.php b/lib/SaferpayJson/Request/Container/RegisterAlias.php new file mode 100644 index 0000000..eb1cc71 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/RegisterAlias.php @@ -0,0 +1,66 @@ +idGenerator = $idGenerator; + } + + public function getIdGenerator(): string + { + return $this->idGenerator; + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + + return $this; + } + + public function getLifetime(): ?int + { + return $this->lifetime; + } + + public function setLifetime(?int $lifetime): self + { + $this->lifetime = $lifetime; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Request/Container/RequestHeader.php similarity index 53% rename from lib/SaferpayJson/Container/RequestHeader.php rename to lib/SaferpayJson/Request/Container/RequestHeader.php index 694762d..33a05fc 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Request/Container/RequestHeader.php @@ -1,79 +1,80 @@ specVersion; - } + /** + * @var ClientInfo|null + * @SerializedName("ClientInfo") + */ + private $clientInfo; - public function setSpecVersion(string $specVersion): self + public function __construct(string $customerId, string $requestId = null, int $retryIndicator = 0) { - $this->specVersion = $specVersion; + $this->customerId = $customerId; + $this->requestId = $requestId; + $this->retryIndicator = $retryIndicator; - return $this; + if (null === $requestId && 0 === $retryIndicator) { + $this->requestId = uniqid(); + } } - public function getCustomerId(): string + public function getSpecVersion(): string { - return $this->customerId; + return $this->specVersion; } - public function setCustomerId(string $customerId): self + public function getCustomerId(): string { - $this->customerId = $customerId; - - return $this; + return $this->customerId; } - public function getRequestId(): string + public function getRequestId(): ?string { return $this->requestId; } - public function setRequestId(string $requestId): self + public function getRetryIndicator(): int { - $this->requestId = $requestId; - - return $this; + return $this->retryIndicator; } - public function getRetryIndicator(): int + public function getClientInfo(): ?ClientInfo { - return $this->retryIndicator; + return $this->clientInfo; } - public function setRetryIndicator(int $retryIndicator): self + public function setClientInfo(?ClientInfo $clientInfo): self { - $this->retryIndicator = $retryIndicator; + $this->clientInfo = $clientInfo; return $this; } diff --git a/lib/SaferpayJson/Container/ReturnUrls.php b/lib/SaferpayJson/Request/Container/ReturnUrls.php similarity index 60% rename from lib/SaferpayJson/Container/ReturnUrls.php rename to lib/SaferpayJson/Request/Container/ReturnUrls.php index 913ce63..d71b2b6 100644 --- a/lib/SaferpayJson/Container/ReturnUrls.php +++ b/lib/SaferpayJson/Request/Container/ReturnUrls.php @@ -1,39 +1,39 @@ success; + $this->success = $success; + $this->fail = $fail; + $this->abort = $abort; } - public function setSuccess(string $success): self + public function getSuccess(): string { - $this->success = $success; - - return $this; + return $this->success; } public function getFail(): string @@ -41,19 +41,12 @@ public function getFail(): string return $this->fail; } - public function setFail(string $fail): self - { - $this->fail = $fail; - - return $this; - } - - public function getAbort(): string + public function getAbort(): ?string { return $this->abort; } - public function setAbort(string $abort): self + public function setAbort(?string $abort): self { $this->abort = $abort; diff --git a/lib/SaferpayJson/Request/Container/SaferpayFields.php b/lib/SaferpayJson/Request/Container/SaferpayFields.php new file mode 100644 index 0000000..6a3a6d2 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/SaferpayFields.php @@ -0,0 +1,25 @@ +token = $token; + } + + public function getToken(): ?string + { + return $this->token; + } +} diff --git a/lib/SaferpayJson/Request/Container/Styling.php b/lib/SaferpayJson/Request/Container/Styling.php new file mode 100644 index 0000000..63e9b50 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Styling.php @@ -0,0 +1,70 @@ +cssUrl; + } + + /** + * @deprecated This feature will be removed in one of the next versions of the Saferpay API + * Consider using payment page config (PPConfig) or Saferpay Fields instead. + */ + public function setCssUrl(?string $cssUrl): self + { + $this->cssUrl = $cssUrl; + + return $this; + } + + public function isContentSecurityEnabled(): ?bool + { + return $this->contentSecurityEnabled; + } + + public function setContentSecurityEnabled(?bool $contentSecurityEnabled): self + { + $this->contentSecurityEnabled = $contentSecurityEnabled; + + return $this; + } + + public function getTheme(): ?string + { + return $this->theme; + } + + public function setTheme(?string $theme): self + { + $this->theme = $theme; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/TransactionReference.php b/lib/SaferpayJson/Request/Container/TransactionReference.php similarity index 52% rename from lib/SaferpayJson/Container/TransactionReference.php rename to lib/SaferpayJson/Request/Container/TransactionReference.php index 880ff5f..b75338e 100644 --- a/lib/SaferpayJson/Container/TransactionReference.php +++ b/lib/SaferpayJson/Request/Container/TransactionReference.php @@ -1,41 +1,41 @@ transactionId; } - public function setTransactionId(string $transactionId): self + public function setTransactionId(?string $transactionId): self { $this->transactionId = $transactionId; return $this; } - public function getOrderId(): string + public function getOrderId(): ?string { return $this->orderId; } - public function setOrderId(string $orderId): self + public function setOrderId(?string $orderId): self { $this->orderId = $orderId; diff --git a/lib/SaferpayJson/Request/Container/Twint.php b/lib/SaferpayJson/Request/Container/Twint.php new file mode 100644 index 0000000..b2d0c09 --- /dev/null +++ b/lib/SaferpayJson/Request/Container/Twint.php @@ -0,0 +1,28 @@ +certificateExpirationDate; + } + + public function setCertificateExpirationDate(?\DateTime $certificateExpirationDate): self + { + $this->certificateExpirationDate = $certificateExpirationDate; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Alias.php b/lib/SaferpayJson/Request/Container/UpdateAlias.php similarity index 57% rename from lib/SaferpayJson/Container/Alias.php rename to lib/SaferpayJson/Request/Container/UpdateAlias.php index f673f9f..1e92479 100644 --- a/lib/SaferpayJson/Container/Alias.php +++ b/lib/SaferpayJson/Request/Container/UpdateAlias.php @@ -1,44 +1,41 @@ id; + $this->id = $id; } - public function setId(string $id): self + public function getId(): ?string { - $this->id = $id; - - return $this; + return $this->id; } - public function getLifetime(): int + public function getLifetime(): ?int { return $this->lifetime; } - public function setLifetime(int $lifetime): self + public function setLifetime(?int $lifetime): self { $this->lifetime = $lifetime; diff --git a/lib/SaferpayJson/Request/Container/UpdatePaymentMeans.php b/lib/SaferpayJson/Request/Container/UpdatePaymentMeans.php new file mode 100644 index 0000000..063debe --- /dev/null +++ b/lib/SaferpayJson/Request/Container/UpdatePaymentMeans.php @@ -0,0 +1,25 @@ +card = $card; + } + + public function getCard(): ?Card + { + return $this->card; + } +} diff --git a/lib/SaferpayJson/Exception/HttpRequestException.php b/lib/SaferpayJson/Request/Exception/HttpRequestException.php similarity index 61% rename from lib/SaferpayJson/Exception/HttpRequestException.php rename to lib/SaferpayJson/Request/Exception/HttpRequestException.php index 3e1cdee..f1d48ce 100644 --- a/lib/SaferpayJson/Exception/HttpRequestException.php +++ b/lib/SaferpayJson/Request/Exception/HttpRequestException.php @@ -1,6 +1,6 @@ errorResponse = $errorResponse; + + parent::__construct(); + } + + public function getErrorResponse(): ?ErrorResponse + { + return $this->errorResponse; + } +} diff --git a/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php b/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php index cd8b400..399e046 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php @@ -5,9 +5,10 @@ use JMS\Serializer\Annotation\SerializedName; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\PaymentPage\AssertResponse; -class AssertRequest extends Request +final class AssertRequest extends Request { const API_PATH = '/Payment/v1/PaymentPage/Assert'; const RESPONSE_CLASS = AssertResponse::class; @@ -18,7 +19,16 @@ class AssertRequest extends Request * @var string * @SerializedName("Token") */ - protected $token; + private $token; + + public function __construct( + RequestConfig $requestConfig, + string $token + ) { + $this->token = $token; + + parent::__construct($requestConfig); + } public function getToken(): string { @@ -31,4 +41,12 @@ public function setToken(string $token): self return $this; } + + public function execute(): AssertResponse + { + /** @var AssertResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php deleted file mode 100644 index cdef595..0000000 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ /dev/null @@ -1,72 +0,0 @@ -terminalId; - } - - public function setTerminalId(string $terminalId): self - { - $this->terminalId = $terminalId; - - return $this; - } - - public function getTransactionReference(): TransactionReference - { - return $this->transactionReference; - } - - public function setTransactionReference(TransactionReference $transactionReference): self - { - $this->transactionReference = $transactionReference; - - return $this; - } - - public function getPayment(): Payment - { - return $this->payment; - } - - public function setPayment(Payment $payment): self - { - $this->payment = $payment; - - return $this; - } -} diff --git a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php index e83d093..a95eb41 100644 --- a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php @@ -3,21 +3,27 @@ namespace Ticketpark\SaferpayJson\Request\PaymentPage; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\Notification; -use Ticketpark\SaferpayJson\Container\Payer; -use Ticketpark\SaferpayJson\Container\Payment; -use Ticketpark\SaferpayJson\Container\RegisterAlias; -use Ticketpark\SaferpayJson\Container\ReturnUrls; -use Ticketpark\SaferpayJson\Container\Styling; +use Ticketpark\SaferpayJson\Request\Container\AddressForm; +use Ticketpark\SaferpayJson\Request\Container\Authentication; +use Ticketpark\SaferpayJson\Request\Container\CardForm; +use Ticketpark\SaferpayJson\Request\Container\Notification; +use Ticketpark\SaferpayJson\Request\Container\Payer; +use Ticketpark\SaferpayJson\Request\Container\Payment; +use Ticketpark\SaferpayJson\Request\Container\PaymentMethodsOptions; +use Ticketpark\SaferpayJson\Request\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Request\Container\ReturnUrls; +use Ticketpark\SaferpayJson\Request\Container\Styling; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\PaymentPage\InitializeResponse; -class InitializeRequest extends Request +final class InitializeRequest extends Request { const API_PATH = '/Payment/v1/PaymentPage/Initialize'; const RESPONSE_CLASS = InitializeResponse::class; + const PAYMENT_METHOD_ALIPAY = "ALIPAY"; const PAYMENT_METHOD_AMEX = "AMEX"; const PAYMENT_METHOD_BANCONTACT = "BANCONTACT"; const PAYMENT_METHOD_BONUS = "BONUS"; @@ -33,84 +39,153 @@ class InitializeRequest extends Request const PAYMENT_METHOD_MASTERCARD = "MASTERCARD"; const PAYMENT_METHOD_MYONE = "MYONE"; const PAYMENT_METHOD_PAYPAL = "PAYPAL"; + const PAYMENT_METHOD_PAYDIREKT = "PAYDIREKT"; const PAYMENT_METHOD_POSTCARD = "POSTCARD"; const PAYMENT_METHOD_POSTFINANCE = "POSTFINANCE"; const PAYMENT_METHOD_SAFERPAYTEST = "SAFERPAYTEST"; const PAYMENT_METHOD_SOFORT = "SOFORT"; const PAYMENT_METHOD_TWINT = "TWINT"; + const PAYMENT_METHOD_UNIONPAY = "UNIONPAY"; const PAYMENT_METHOD_VISA = "VISA"; const PAYMENT_METHOD_VPAY = "VPAY"; + const WALLET_MASTERPASS = "MASTERPASS"; + const WALLET_APPLEPAY = "APPLEPAY"; + + const CONDITION_WITH_LIABILITY_SHIFT = 'WITH_LIABILITY_SHIFT'; + const CONDITION_IF_ALLOWED_BY_SCHEME = 'IF_ALLOWED_BY_SCHEME'; + use RequestCommonsTrait; + /** + * @var string + * @SerializedName("TerminalId") + */ + private $terminalId; + /** * @var Payment * @SerializedName("Payment") */ - protected $payment; + private $payment; + + /** + * @var ReturnUrls + * @SerializedName("ReturnUrls") + */ + private $returnUrls; /** - * @var Payer - * @SerializedName("Payer") + * @var string|null + * @SerializedName("ConfigSet") */ - protected $payer; + private $configSet; /** - * @var ReturnUrls - * @SerializedName("ReturnUrls") + * @var array|null + * @SerializedName("PaymentMethods") */ - protected $returnUrls; + private $paymentMethods; /** - * @var Notification - * @SerializedName("Notification") + * @var PaymentMethodsOptions|null + * @SerializedName("PaymentMethodsOptions") */ - protected $notification; + private $paymentMethodsOptions; /** - * @var string - * @SerializedName("TerminalId") + * @var Authentication|null + * @SerializedName("Authentication") */ - protected $terminalId; + private $authentication; /** - * @var array - * @SerializedName("PaymentMethods") + * @var array|null + * @SerializedName("Wallets") + */ + private $wallets; + + /** + * @var Payer|null + * @SerializedName("Payer") */ - protected $paymentMethods; + private $payer; /** * @var RegisterAlias|null * @SerializedName("RegisterAlias") */ - protected $registerAlias; + private $registerAlias; + + /** + * @var Notification|null + * @SerializedName("Notification") + */ + private $notification; /** * @var Styling|null * @SerializedName("Styling") */ - protected $styling; + private $styling; - public function getPayment(): Payment + /** + * @var AddressForm|null + * @SerializedName("BillingAddressForm") + */ + private $billingAddressForm; + + /** + * @var AddressForm|null + * @SerializedName("DeliveryAddressForm") + */ + private $deliveryAddressForm; + + /** + * @var CardForm|null + * @SerializedName("CardForm") + */ + private $cardForm; + + /** + * @var string|null + * @SerializedName("Condition") + */ + private $condition; + + public function __construct( + RequestConfig $requestConfig, + string $terminalId, + Payment $payment, + ReturnUrls $returnUrls + ) { + $this->terminalId = $terminalId; + $this->payment = $payment; + $this->returnUrls = $returnUrls; + + parent::__construct($requestConfig); + } + + public function getTerminalId(): string { - return $this->payment; + return $this->terminalId; } - public function setPayment(Payment $payment): self + public function setTerminalId(string $terminalId): self { - $this->payment = $payment; + $this->terminalId = $terminalId; return $this; } - public function getPayer(): Payer + public function getPayment(): Payment { - return $this->payer; + return $this->payment; } - public function setPayer(Payer $payer): self + public function setPayment(Payment $payment): self { - $this->payer = $payer; + $this->payment = $payment; return $this; } @@ -127,38 +202,74 @@ public function setReturnUrls(ReturnUrls $returnUrls): self return $this; } - public function getNotification(): Notification + public function getConfigSet(): ?string { - return $this->notification; + return $this->configSet; } - public function setNotification(Notification $notification): self + public function setConfigSet(?string $configSet): self { - $this->notification = $notification; + $this->configSet = $configSet; return $this; } - public function getTerminalId(): string + public function getPaymentMethods(): ?array { - return $this->terminalId; + return $this->paymentMethods; } - public function setTerminalId(string $terminalId): self + public function setPaymentMethods(?array $paymentMethods): self { - $this->terminalId = $terminalId; + $this->paymentMethods = $paymentMethods; return $this; } - public function getPaymentMethods(): array + public function getPaymentMethodsOptions(): ?PaymentMethodsOptions { - return $this->paymentMethods; + return $this->paymentMethodsOptions; } - public function setPaymentMethods(array $paymentMethods): self + public function setPaymentMethodsOptions(?PaymentMethodsOptions $paymentMethodsOptions): self { - $this->paymentMethods = $paymentMethods; + $this->paymentMethodsOptions = $paymentMethodsOptions; + + return $this; + } + + public function getAuthentication(): ?Authentication + { + return $this->authentication; + } + + public function setAuthentication(?Authentication $authentication): self + { + $this->authentication = $authentication; + + return $this; + } + + public function getWallets(): ?array + { + return $this->wallets; + } + + public function setWallets(?array $wallets): self + { + $this->wallets = $wallets; + + return $this; + } + + public function getPayer(): ?Payer + { + return $this->payer; + } + + public function setPayer(?Payer $payer): self + { + $this->payer = $payer; return $this; } @@ -168,22 +279,90 @@ public function getRegisterAlias(): ?RegisterAlias return $this->registerAlias; } - public function setRegisterAlias(RegisterAlias $registerAlias): self + public function setRegisterAlias(?RegisterAlias $registerAlias): self { $this->registerAlias = $registerAlias; return $this; } + public function getNotification(): ?Notification + { + return $this->notification; + } + + public function setNotification(?Notification $notification): self + { + $this->notification = $notification; + + return $this; + } + public function getStyling(): ?Styling { return $this->styling; } - public function setStyling(Styling $styling): self + public function setStyling(?Styling $styling): self { $this->styling = $styling; return $this; } + + public function getBillingAddressForm(): ?AddressForm + { + return $this->billingAddressForm; + } + + public function setBillingAddressForm(?AddressForm $billingAddressForm): self + { + $this->billingAddressForm = $billingAddressForm; + + return $this; + } + + public function getDeliveryAddressForm(): ?AddressForm + { + return $this->deliveryAddressForm; + } + + public function setDeliveryAddressForm(?AddressForm $deliveryAddressForm): self + { + $this->deliveryAddressForm = $deliveryAddressForm; + + return $this; + } + + public function getCardForm(): ?CardForm + { + return $this->cardForm; + } + + public function setCardForm(?CardForm $cardForm): self + { + $this->cardForm = $cardForm; + + return $this; + } + + public function getCondition(): ?string + { + return $this->condition; + } + + public function setCondition(?string $condition): self + { + $this->condition = $condition; + + return $this; + } + + public function execute(): InitializeResponse + { + /** @var InitializeResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index 72dcdda..6bfeb4d 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -3,140 +3,77 @@ namespace Ticketpark\SaferpayJson\Request; use Doctrine\Common\Annotations\AnnotationRegistry; -use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Psr7\Response as GuzzleResponse; use JMS\Serializer\Annotation\Exclude; use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\VirtualProperty; use JMS\Serializer\SerializerBuilder; use JMS\Serializer\SerializerInterface; -use Ticketpark\SaferpayJson\Exception\HttpRequestException; -use Ticketpark\SaferpayJson\Container\RequestHeader; +use Ticketpark\SaferpayJson\Request\Exception\HttpRequestException; +use Ticketpark\SaferpayJson\Request\Container\RequestHeader; +use Ticketpark\SaferpayJson\Request\Exception\SaferpayErrorException; use Ticketpark\SaferpayJson\Response\ErrorResponse; -use Ticketpark\SaferpayJson\Response\ResponseInterface; +use Ticketpark\SaferpayJson\Response\Response; abstract class Request { - const ROOT_URL = 'https://www.saferpay.com/api/'; - - const ROOT_URL_TEST = 'https://test.saferpay.com/api/'; - - const ERROR_RESPONSE_CLASS = ErrorResponse::class; + private const ROOT_URL = 'https://www.saferpay.com/api/'; + private const ROOT_URL_TEST = 'https://test.saferpay.com/api/'; + private const ERROR_RESPONSE_CLASS = ErrorResponse::class; /** - * @var string + * @var RequestConfig * @Exclude */ - protected $apiKey; + private $requestConfig; /** - * @var string - * @Exclude - */ - protected $apiSecret; - - /** - * @var bool - * @Exclude + * We want the implementation to define the exact return type hint of the response. + * In PHP 7.4 the return type hint here in the abstraction would therefore be Ticketpark\SaferpayJson\Response\Response, + * as all other responses inherit from that class. + * In PHP 7.3 this is not yet allowed. Therefore the return type is omitted and only provided as a PhpDoc in + * order to satisfy static code analysis by PhpStan. + * + * @link https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters + * @link https://stitcher.io/blog/new-in-php-74#improved-type-variance-rfc + * @return mixed */ - protected $test = false; - - /** - * @var \GuzzleHttp\Client - * @Exclude - */ - protected $client; - - /** - * @var RequestHeader - * @SerializedName("RequestHeader") - */ - protected $requestHeader; - - public function __construct( - string $apiKey, - string $apiSecret, - bool $test = true - ) { - $this->apiKey = $apiKey; - $this->apiSecret = $apiSecret; - $this->test = $test; - } + abstract public function execute(); abstract public function getApiPath(): string; abstract public function getResponseClass(): string; - public function getApiKey(): string - { - return $this->apiKey; - } - - public function setApiKey(string $apiKey): self + public function __construct(RequestConfig $requestConfig) { - $this->apiKey = $apiKey; - - return $this; - } - - public function getApiSecret(): string - { - return $this->apiSecret; - } - - public function setApiSecret(string $apiSecret): self - { - $this->apiSecret = $apiSecret; - - return $this; - } - - public function isTest(): bool - { - return $this->test; - } - - public function setTest(bool $test): self - { - $this->test = $test; - - return $this; + $this->requestConfig = $requestConfig; } + /** + * @SerializedName("RequestHeader") + * @VirtualProperty + */ public function getRequestHeader(): RequestHeader { - return $this->requestHeader; - } - - public function setRequestHeader(RequestHeader $requestHeader): self - { - $this->requestHeader = $requestHeader; - - return $this; - } - - public function setClient(Client $client): self - { - $this->client = $client; - - return $this; + return new RequestHeader( + $this->requestConfig->getCustomerId() + ); } - public function getClient(): Client + public function getRequestConfig(): RequestConfig { - if (null == $this->client) { - return new Client(); - } - - return $this->client; + return $this->requestConfig; } - public function execute(): ResponseInterface + protected function doExecute(): Response { try { - $response = $this->getClient()->post( + /** @var GuzzleResponse $response */ + $response = $this->requestConfig->getClient()->post( $this->getUrl(), [ 'headers' => $this->getHeaders(), - 'body' => $this->getContent(), + 'body' => $this->getContent() ] ); } catch (\Exception $e) { @@ -144,20 +81,22 @@ public function execute(): ResponseInterface throw new HttpRequestException($e->getMessage()); } + /** @var GuzzleResponse $response */ $response = $e->getResponse(); } $statusCode = $response->getStatusCode(); if ($statusCode >= 400 && $statusCode < 500) { - /** @var ResponseInterface $responseData */ - $responseData = $this->getSerializer()->deserialize( + + /** @var ErrorResponse $errorResponse */ + $errorResponse = $this->getSerializer()->deserialize( (string) $response->getBody(), self::ERROR_RESPONSE_CLASS, 'json' ); - return $responseData; + throw new SaferpayErrorException($errorResponse); } if (200 !== $statusCode) { @@ -167,42 +106,46 @@ public function execute(): ResponseInterface )); } - /** @var ResponseInterface $responseData */ - $responseData = $this->getSerializer()->deserialize( + /** @var Response $libraryResponse */ + $libraryResponse = $this->getSerializer()->deserialize( (string) $response->getBody(), $this->getResponseClass(), 'json' ); - return $responseData; + return $libraryResponse; } - protected function getUrl(): string + private function getUrl(): string { $rootUrl = self::ROOT_URL; - if ($this->isTest()) { + if ($this->requestConfig->isTest()) { $rootUrl = self::ROOT_URL_TEST; } return $rootUrl . $this->getApiPath(); } - protected function getHeaders(): array + private function getHeaders(): array { return [ 'Content-Type' => 'application/json; charset=utf-8', 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . base64_encode($this->apiKey.':'.$this->apiSecret) + 'Authorization' => 'Basic ' . base64_encode( + $this->requestConfig->getApiKey() + . ':' + . $this->requestConfig->getApiSecret() + ) ]; } - protected function getContent(): string + private function getContent(): string { return $this->getSerializer()->serialize($this, 'json'); } - protected function getSerializer(): SerializerInterface + private function getSerializer(): SerializerInterface { AnnotationRegistry::registerLoader('class_exists'); diff --git a/lib/SaferpayJson/Request/RequestConfig.php b/lib/SaferpayJson/Request/RequestConfig.php new file mode 100644 index 0000000..c0df074 --- /dev/null +++ b/lib/SaferpayJson/Request/RequestConfig.php @@ -0,0 +1,77 @@ +apiKey = $apiKey; + $this->apiSecret = $apiSecret; + $this->customerId = $customerId; + $this->test = $test; + } + + public function getApiKey(): string + { + return $this->apiKey; + } + + public function getApiSecret(): string + { + return $this->apiSecret; + } + + public function getCustomerId(): string + { + return $this->customerId; + } + + public function isTest(): bool + { + return $this->test; + } + + public function setClient(Client $client): self + { + $this->client = $client; + + return $this; + } + + public function getClient(): Client + { + if (null === $this->client) { + return new Client(); + } + + return $this->client; + } +} diff --git a/lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php b/lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php deleted file mode 100755 index 17c1f66..0000000 --- a/lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php +++ /dev/null @@ -1,34 +0,0 @@ -token; - } - - public function setToken(string $token): self - { - $this->token = $token; - - return $this; - } -} diff --git a/lib/SaferpayJson/Request/SecureAliasStore/DeleteRequest.php b/lib/SaferpayJson/Request/SecureAliasStore/DeleteRequest.php deleted file mode 100755 index 8c4ba64..0000000 --- a/lib/SaferpayJson/Request/SecureAliasStore/DeleteRequest.php +++ /dev/null @@ -1,34 +0,0 @@ -aliasId; - } - - public function setAliasId(string $aliasId): self - { - $this->aliasId = $aliasId; - - return $this; - } -} diff --git a/lib/SaferpayJson/Request/SecureAliasStore/InsertDirectRequest.php b/lib/SaferpayJson/Request/SecureAliasStore/InsertDirectRequest.php deleted file mode 100755 index f774813..0000000 --- a/lib/SaferpayJson/Request/SecureAliasStore/InsertDirectRequest.php +++ /dev/null @@ -1,55 +0,0 @@ -registerAlias; - } - - public function setRegisterAlias(RegisterAlias $registerAlias): self - { - $this->registerAlias = $registerAlias; - - return $this; - } - - public function getPaymentMeans(): PaymentMeans - { - return $this->paymentMeans; - } - - public function setPaymentMeans(PaymentMeans $paymentMeans): self - { - $this->paymentMeans = $paymentMeans; - return $this; - } -} diff --git a/lib/SaferpayJson/Request/SecureAliasStore/InsertRequest.php b/lib/SaferpayJson/Request/SecureAliasStore/InsertRequest.php deleted file mode 100755 index c94e756..0000000 --- a/lib/SaferpayJson/Request/SecureAliasStore/InsertRequest.php +++ /dev/null @@ -1,119 +0,0 @@ -registerAlias; - } - - public function setRegisterAlias(RegisterAlias $registerAlias): self - { - $this->registerAlias = $registerAlias; - - return $this; - } - - public function getType(): string - { - return $this->type; - } - - public function setType(string $type): self - { - $this->type = $type; - - return $this; - } - - public function getReturnUrls(): ReturnUrls - { - return $this->returnUrls; - } - - public function setReturnUrls(ReturnUrls $returnUrls): self - { - $this->returnUrls = $returnUrls; - - return $this; - } - - public function getStyling(): ?Styling - { - return $this->styling; - } - - public function setStyling(Styling $styling): self - { - $this->styling = $styling; - - return $this; - } - - public function getCheck(): ?Check - { - return $this->check; - } - - public function setCheck(Check $check): self - { - $this->check = $check; - - return $this; - } -} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php new file mode 100755 index 0000000..4a7c608 --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php @@ -0,0 +1,50 @@ +token = $token; + + parent::__construct($requestConfig); + } + + public function getToken(): string + { + return $this->token; + } + + public function setToken(string $token): self + { + $this->token = $token; + + return $this; + } + + public function execute(): AliasAssertInsertResponse + { + /** @var AliasAssertInsertResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php new file mode 100755 index 0000000..3f2df17 --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php @@ -0,0 +1,50 @@ +aliasId = $aliasId; + + parent::__construct($requestConfig); + } + + public function getAliasId(): string + { + return $this->aliasId; + } + + public function setAliasId(string $aliasId): self + { + $this->aliasId = $aliasId; + + return $this; + } + + public function execute(): AliasDeleteResponse + { + /** @var AliasDeleteResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php new file mode 100755 index 0000000..d3ad7c7 --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php @@ -0,0 +1,93 @@ +registerAlias = $registerAlias; + $this->paymentMeans = $paymentMeans; + + parent::__construct($requestConfig); + } + + public function getRegisterAlias(): RegisterAlias + { + return $this->registerAlias; + } + + public function setRegisterAlias(RegisterAlias $registerAlias): self + { + $this->registerAlias = $registerAlias; + + return $this; + } + + public function getPaymentMeans(): PaymentMeans + { + return $this->paymentMeans; + } + + public function setPaymentMeans(PaymentMeans $paymentMeans): self + { + $this->paymentMeans = $paymentMeans; + + return $this; + } + + public function getCheck(): ?Check + { + return $this->check; + } + + public function setCheck(?Check $check): self + { + $this->check = $check; + + return $this; + } + + public function execute(): AliasInsertDirectResponse + { + /** @var AliasInsertDirectResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php new file mode 100755 index 0000000..1f6c9ec --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -0,0 +1,228 @@ +|null + * @SerializedName("PaymentMethods") + */ + private $paymentMethods; + + /** + * @var CardForm|null + * @SerializedName("CardForm") + */ + private $cardForm; + + /** + * @var PaymentMeans|null + * @SerializedName("PaymentMeans") + */ + private $paymentMeans; + + public function __construct( + RequestConfig $requestConfig, + RegisterAlias $registerAlias, + string $type, + ReturnUrls $returnUrls + ) { + $this->registerAlias = $registerAlias; + $this->type = $type; + $this->returnUrls = $returnUrls; + + parent::__construct($requestConfig); + } + + public function getRegisterAlias(): RegisterAlias + { + return $this->registerAlias; + } + + public function setRegisterAlias(RegisterAlias $registerAlias): self + { + $this->registerAlias = $registerAlias; + + return $this; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): self + { + $this->type = $type; + + return $this; + } + + public function getReturnUrls(): ReturnUrls + { + return $this->returnUrls; + } + + public function setReturnUrls(ReturnUrls $returnUrls): self + { + $this->returnUrls = $returnUrls; + + return $this; + } + + public function getStyling(): ?Styling + { + return $this->styling; + } + + public function setStyling(?Styling $styling): self + { + $this->styling = $styling; + + return $this; + } + + public function getCheck(): ?Check + { + return $this->check; + } + + public function setCheck(?Check $check): self + { + $this->check = $check; + + return $this; + } + + public function getLanguageCode(): ?string + { + return $this->languageCode; + } + + public function setLanguageCode(?string $languageCode): self + { + $this->languageCode = $languageCode; + + return $this; + } + + public function getPaymentMethods(): ?array + { + return $this->paymentMethods; + } + + public function setPaymentMethods(?array $paymentMethods): self + { + $this->paymentMethods = $paymentMethods; + + return $this; + } + + public function getCardForm(): ?CardForm + { + return $this->cardForm; + } + + public function setCardForm(?CardForm $cardForm): self + { + $this->cardForm = $cardForm; + + return $this; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } + + public function setPaymentMeans(?PaymentMeans $paymentMeans): self + { + $this->paymentMeans = $paymentMeans; + + return $this; + } + + public function execute(): AliasInsertResponse + { + /** @var AliasInsertResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php new file mode 100755 index 0000000..ea2761d --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php @@ -0,0 +1,74 @@ +updateAlias = $updateAlias; + $this->updatePaymentMeans = $updatePaymentMeans; + + parent::__construct($requestConfig); + } + + public function getUpdateAlias(): ?UpdateAlias + { + return $this->updateAlias; + } + + public function setUpdateAlias(UpdateAlias $updateAlias): self + { + $this->updateAlias = $updateAlias; + + return $this; + } + + public function getUpdatePaymentMeans(): ?UpdatePaymentMeans + { + return $this->updatePaymentMeans; + } + + public function setUpdatePaymentMeans(UpdatePaymentMeans $updatePaymentMeans): self + { + $this->updatePaymentMeans = $updatePaymentMeans; + + return $this; + } + + public function execute(): AliasUpdateResponse + { + /** @var AliasUpdateResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php index 9bd3ea3..2edce3b 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -3,41 +3,84 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; +use Ticketpark\SaferpayJson\Request\Container\Authentication; +use Ticketpark\SaferpayJson\Request\Container\Payer; +use Ticketpark\SaferpayJson\Request\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\Request; -use Ticketpark\SaferpayJson\Container\Payment; -use Ticketpark\SaferpayJson\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Request\Container\Payment; +use Ticketpark\SaferpayJson\Request\Container\PaymentMeans; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\Transaction\AuthorizeDirectResponse; -/** - * Class AuthorizeDirectRequest - * @package Ticketpark\SaferpayJson\Transaction - */ -class AuthorizeDirectRequest extends Request +final class AuthorizeDirectRequest extends Request { const API_PATH = '/Payment/v1/Transaction/AuthorizeDirect'; const RESPONSE_CLASS = AuthorizeDirectResponse::class; use RequestCommonsTrait; + /** + * @var string + * @SerializedName("TerminalId") + */ + private $terminalId; + /** * @var Payment * @SerializedName("Payment") */ - protected $payment; + private $payment; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** - * @var string - * @SerializedName("TerminalId") + * @var Authentication|null + * @SerializedName("Authentication") */ - protected $terminalId; + private $authentication; + + /** + * @var RegisterAlias|null + * @SerializedName("RegisterAlias") + */ + private $registerAlias; + + /** + * @var Payer|null + * @SerializedName("Payer") + */ + private $payer; + + + public function __construct( + RequestConfig $requestConfig, + string $terminalId, + Payment $payment, + PaymentMeans $paymentMeans + ) { + $this->terminalId = $terminalId; + $this->payment = $payment; + $this->paymentMeans = $paymentMeans; + + parent::__construct($requestConfig); + } + + public function getTerminalId(): string + { + return $this->terminalId; + } + + public function setTerminalId(string $terminalId): self + { + $this->terminalId = $terminalId; + + return $this; + } public function getPayment(): Payment { @@ -63,15 +106,47 @@ public function setPaymentMeans(PaymentMeans $paymentMeans): self return $this; } - public function getTerminalId(): string + public function getAuthentication(): ?Authentication { - return $this->terminalId; + return $this->authentication; } - public function setTerminalId(string $terminalId): self + public function setAuthentication(?Authentication $authentication): self { - $this->terminalId = $terminalId; + $this->authentication = $authentication; + + return $this; + } + + public function getRegisterAlias(): ?RegisterAlias + { + return $this->registerAlias; + } + + public function setRegisterAlias(?RegisterAlias $registerAlias): self + { + $this->registerAlias = $registerAlias; + + return $this; + } + + public function getPayer(): ?Payer + { + return $this->payer; + } + + public function setPayer(?Payer $payer): self + { + $this->payer = $payer; return $this; } + + public function execute(): AuthorizeDirectResponse + { + /** @var AuthorizeDirectResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php new file mode 100644 index 0000000..c84e0d2 --- /dev/null +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php @@ -0,0 +1,131 @@ +terminalId = $terminalId; + $this->payment = $payment; + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } + + public function getTerminalId(): string + { + return $this->terminalId; + } + + public function setTerminalId(string $terminalId): self + { + $this->terminalId = $terminalId; + + return $this; + } + + public function getPayment(): Payment + { + return $this->payment; + } + + public function setPayment(Payment $payment): self + { + $this->payment = $payment; + + return $this; + } + + public function getTransactionReference(): TransactionReference + { + return $this->transactionReference; + } + + public function setTransactionReference(TransactionReference $transactionReference): self + { + $this->transactionReference = $transactionReference; + + return $this; + } + + public function getAuthentication(): ?Authentication + { + return $this->authentication; + } + + public function setAuthentication(?Authentication $authentication): self + { + $this->authentication = $authentication; + + return $this; + } + + public function isSuppressDcc(): ?bool + { + return $this->suppressDcc; + } + + public function setSuppressDcc(?bool $suppressDcc): self + { + $this->suppressDcc = $suppressDcc; + + return $this; + } + + public function execute(): AuthorizeReferencedResponse + { + /** @var AuthorizeReferencedResponse $response */ + $response = $this->doExecute(); + + return $response; + } +} diff --git a/lib/SaferpayJson/Request/Transaction/CancelRequest.php b/lib/SaferpayJson/Request/Transaction/CancelRequest.php index c0e481f..5d19989 100644 --- a/lib/SaferpayJson/Request/Transaction/CancelRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CancelRequest.php @@ -3,12 +3,13 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\TransactionReference; +use Ticketpark\SaferpayJson\Request\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\Transaction\CancelResponse; -class CancelRequest extends Request +final class CancelRequest extends Request { const API_PATH = '/Payment/v1/Transaction/Cancel'; const RESPONSE_CLASS = CancelResponse::class; @@ -19,7 +20,16 @@ class CancelRequest extends Request * @var TransactionReference * @SerializedName("TransactionReference") */ - protected $transactionReference; + private $transactionReference; + + public function __construct( + RequestConfig $requestConfig, + TransactionReference $transactionReference + ) { + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } public function getTransactionReference(): TransactionReference { @@ -32,4 +42,12 @@ public function setTransactionReference(TransactionReference $transactionReferen return $this; } + + public function execute(): CancelResponse + { + /** @var CancelResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php index 6bee783..d55a8c9 100644 --- a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php @@ -3,12 +3,18 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\TransactionReference; +use Ticketpark\SaferpayJson\Request\Container\Amount; +use Ticketpark\SaferpayJson\Request\Container\Billpay; +use Ticketpark\SaferpayJson\Request\Container\Marketplace; +use Ticketpark\SaferpayJson\Request\Container\MastercardIssuerInstallments; +use Ticketpark\SaferpayJson\Request\Container\PendingNotification; +use Ticketpark\SaferpayJson\Request\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\Transaction\CaptureResponse; -class CaptureRequest extends Request +final class CaptureRequest extends Request { const API_PATH = '/Payment/v1/Transaction/Capture'; const RESPONSE_CLASS = CaptureResponse::class; @@ -19,7 +25,46 @@ class CaptureRequest extends Request * @var TransactionReference * @SerializedName("TransactionReference") */ - protected $transactionReference; + private $transactionReference; + + /** + * @var Amount|null + * @SerializedName("Amount") + */ + private $amount; + + /** + * @var Billpay|null + * @SerializedName("Billpay") + */ + private $billpay; + + /** + * @var PendingNotification|null + * @SerializedName("PendingNotification") + */ + private $pendingNotification; + + /** + * @var Marketplace|null + * @SerializedName("Marketplace") + */ + private $marketplace; + + /** + * @var MastercardIssuerInstallments|null + * @SerializedName("MastercardIssuerInstallments") + */ + private $mastercardIssuerInstallments; + + public function __construct( + RequestConfig $requestConfig, + TransactionReference $transactionReference + ) { + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } public function getTransactionReference(): TransactionReference { @@ -32,4 +77,72 @@ public function setTransactionReference(TransactionReference $transactionReferen return $this; } + + public function getAmount(): ?Amount + { + return $this->amount; + } + + public function setAmount(?Amount $amount): self + { + $this->amount = $amount; + + return $this; + } + + public function getBillpay(): ?Billpay + { + return $this->billpay; + } + + public function setBillpay(?Billpay $billpay): self + { + $this->billpay = $billpay; + + return $this; + } + + public function getPendingNotification(): ?PendingNotification + { + return $this->pendingNotification; + } + + public function setPendingNotification(?PendingNotification $pendingNotification): self + { + $this->pendingNotification = $pendingNotification; + + return $this; + } + + public function getMarketplace(): ?Marketplace + { + return $this->marketplace; + } + + public function setMarketplace(?Marketplace $marketplace): self + { + $this->marketplace = $marketplace; + + return $this; + } + + public function getMastercardIssuerInstallments(): ?MastercardIssuerInstallments + { + return $this->mastercardIssuerInstallments; + } + + public function setMastercardIssuerInstallments(?MastercardIssuerInstallments $mastercardIssuerInstallments): self + { + $this->mastercardIssuerInstallments = $mastercardIssuerInstallments; + + return $this; + } + + public function execute(): CaptureResponse + { + /** @var CaptureResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Request/Transaction/RefundRequest.php b/lib/SaferpayJson/Request/Transaction/RefundRequest.php index 46f96dc..9fa2573 100644 --- a/lib/SaferpayJson/Request/Transaction/RefundRequest.php +++ b/lib/SaferpayJson/Request/Transaction/RefundRequest.php @@ -3,13 +3,16 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\Refund; -use Ticketpark\SaferpayJson\Container\TransactionReference; +use Ticketpark\SaferpayJson\Request\Container\CaptureReference; +use Ticketpark\SaferpayJson\Request\Container\PendingNotification; +use Ticketpark\SaferpayJson\Request\Container\Refund; +use Ticketpark\SaferpayJson\Request\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\Transaction\RefundResponse; -class RefundRequest extends Request +final class RefundRequest extends Request { const API_PATH = '/Payment/v1/Transaction/Refund'; const RESPONSE_CLASS = RefundResponse::class; @@ -20,15 +23,32 @@ class RefundRequest extends Request * @var Refund * @SerializedName("Refund") */ - protected $refund; + private $refund; /** - * @var TransactionReference - * @SerializedName("TransactionReference") + * @var CaptureReference + * @SerializedName("CaptureReference") */ - protected $transactionReference; + private $captureReference; - public function getRefund(): Refund + /** + * @var PendingNotification|null + * @SerializedName("PendingNotification") + */ + private $pendingNotification; + + public function __construct( + RequestConfig $requestConfig, + Refund $refund, + CaptureReference $captureReference + ) { + $this->refund = $refund; + $this->captureReference = $captureReference; + + parent::__construct($requestConfig); + } + + public function getRefund(): ?Refund { return $this->refund; } @@ -40,15 +60,35 @@ public function setRefund(Refund $refund): self return $this; } - public function getTransactionReference(): TransactionReference + public function getCaptureReference(): ?CaptureReference { - return $this->transactionReference; + return $this->captureReference; } - public function setTransactionReference(TransactionReference $transactionReference): self + public function setCaptureReference(CaptureReference $captureReference): self { - $this->transactionReference = $transactionReference; + $this->captureReference = $captureReference; return $this; } + + public function getPendingNotification(): ?PendingNotification + { + return $this->pendingNotification; + } + + public function setPendingNotification(?PendingNotification $pendingNotification): self + { + $this->pendingNotification = $pendingNotification; + + return $this; + } + + public function execute(): RefundResponse + { + /** @var RefundResponse $response */ + $response = $this->doExecute(); + + return $response; + } } diff --git a/lib/SaferpayJson/Response/Container/Address.php b/lib/SaferpayJson/Response/Container/Address.php new file mode 100644 index 0000000..db4e975 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Address.php @@ -0,0 +1,182 @@ +firstName; + } + + public function getLastName(): ?string + { + return $this->lastName; + } + + public function getCompany(): ?string + { + return $this->company; + } + + public function getGender(): ?string + { + return $this->gender; + } + + public function getStreet(): ?string + { + return $this->street; + } + + public function getZip(): ?string + { + return $this->zip; + } + + public function getCity(): ?string + { + return $this->city; + } + + public function getCountryCode(): ?string + { + return $this->countryCode; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function getDateOfBirth(): ?\DateTime + { + return $this->dateOfBirth; + } + + public function getLegalForm(): ?string + { + return $this->legalForm; + } + + public function getStreet2(): ?string + { + return $this->street2; + } + + public function getCountrySubdivisionCode(): ?string + { + return $this->countrySubdivisionCode; + } + + public function getPhone(): ?string + { + return $this->phone; + } +} diff --git a/lib/SaferpayJson/Response/Container/Alias.php b/lib/SaferpayJson/Response/Container/Alias.php new file mode 100644 index 0000000..43d2910 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Alias.php @@ -0,0 +1,33 @@ +id; + } + + public function getLifetime(): ?int + { + return $this->lifetime; + } +} diff --git a/lib/SaferpayJson/Response/Container/Amount.php b/lib/SaferpayJson/Response/Container/Amount.php new file mode 100644 index 0000000..f755c87 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Amount.php @@ -0,0 +1,33 @@ +value; + } + + public function getCurrencyCode(): string + { + return $this->currencyCode; + } +} diff --git a/lib/SaferpayJson/Response/Container/AuthenticationResult.php b/lib/SaferpayJson/Response/Container/AuthenticationResult.php new file mode 100644 index 0000000..424966e --- /dev/null +++ b/lib/SaferpayJson/Response/Container/AuthenticationResult.php @@ -0,0 +1,36 @@ +result; + } + + public function getMessage(): ?string + { + return $this->message; + } +} diff --git a/lib/SaferpayJson/Response/Container/BankAccount.php b/lib/SaferpayJson/Response/Container/BankAccount.php new file mode 100644 index 0000000..bc334b7 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/BankAccount.php @@ -0,0 +1,69 @@ +iban; + } + + public function getHolderName(): ?string + { + return $this->holderName; + } + + public function getBic(): ?string + { + return $this->bic; + } + + public function getBankName(): ?string + { + return $this->bankName; + } + + public function getCountryCode(): ?string + { + return $this->countryCode; + } +} diff --git a/lib/SaferpayJson/Response/Container/Brand.php b/lib/SaferpayJson/Response/Container/Brand.php new file mode 100644 index 0000000..5fb8ff5 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Brand.php @@ -0,0 +1,59 @@ +paymentMethod; + } + + public function getName(): ?string + { + return $this->name; + } +} diff --git a/lib/SaferpayJson/Response/Container/Card.php b/lib/SaferpayJson/Response/Container/Card.php new file mode 100644 index 0000000..309b24a --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Card.php @@ -0,0 +1,98 @@ +maskedNumber; + } + + public function getExpYear(): ?int + { + return $this->expYear; + } + + public function getExpMonth(): ?int + { + return $this->expMonth; + } + + public function getHolderName(): ?string + { + return $this->holderName; + } + + public function getHolderSegment(): ?string + { + return $this->holderSegment; + } + + public function getCountryCode(): ?string + { + return $this->countryCode; + } + + public function getHashValue(): ?string + { + return $this->hashValue; + } +} diff --git a/lib/SaferpayJson/Response/Container/CheckResult.php b/lib/SaferpayJson/Response/Container/CheckResult.php new file mode 100644 index 0000000..fe113a2 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/CheckResult.php @@ -0,0 +1,45 @@ +result; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function getAuthentication(): ?HolderAuthentication + { + return $this->authentication; + } +} diff --git a/lib/SaferpayJson/Response/Container/ChosenPlan.php b/lib/SaferpayJson/Response/Container/ChosenPlan.php new file mode 100644 index 0000000..365a689 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/ChosenPlan.php @@ -0,0 +1,93 @@ +numberOfInstallments; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function getInstallmentFee(): ?Amount + { + return $this->installmentFee; + } + + public function getAnnualPercentageRate(): ?string + { + return $this->annualPercentageRate; + } + + public function getFirstInstallmentAmount(): ?Amount + { + return $this->firstInstallmentAmount; + } + + public function getSubsequentInstallmentAmount(): ?Amount + { + return $this->subsequentInstallmentAmount; + } + + public function getTotalAmountDue(): ?Amount + { + return $this->totalAmountDue; + } +} diff --git a/lib/SaferpayJson/Response/Container/CustomPlan.php b/lib/SaferpayJson/Response/Container/CustomPlan.php new file mode 100644 index 0000000..f4bae1c --- /dev/null +++ b/lib/SaferpayJson/Response/Container/CustomPlan.php @@ -0,0 +1,81 @@ +minimumNumberOfInstallments; + } + + public function getMaximumNumberOfInstallments(): ?int + { + return $this->maximumNumberOfInstallments; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function getInstallmentFee(): ?Amount + { + return $this->installmentFee; + } + + public function getAnnualPercentageRate(): ?string + { + return $this->annualPercentageRate; + } + + public function getTotalAmountDue(): ?Amount + { + return $this->totalAmountDue; + } +} diff --git a/lib/SaferpayJson/Response/Container/Dcc.php b/lib/SaferpayJson/Response/Container/Dcc.php new file mode 100644 index 0000000..400c877 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Dcc.php @@ -0,0 +1,21 @@ +payerAmount; + } +} diff --git a/lib/SaferpayJson/Response/Container/DirectDebit.php b/lib/SaferpayJson/Response/Container/DirectDebit.php new file mode 100644 index 0000000..0274b90 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/DirectDebit.php @@ -0,0 +1,33 @@ +mandateId; + } + + public function getCreditorId(): ?string + { + return $this->creditorId; + } +} diff --git a/lib/SaferpayJson/Response/Container/Error.php b/lib/SaferpayJson/Response/Container/Error.php new file mode 100644 index 0000000..02edf3e --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Error.php @@ -0,0 +1,33 @@ +errorName; + } + + public function getErrorMessage(): ?string + { + return $this->errorMessage; + } +} diff --git a/lib/SaferpayJson/Response/Container/HolderAuthentication.php b/lib/SaferpayJson/Response/Container/HolderAuthentication.php new file mode 100644 index 0000000..61b8348 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/HolderAuthentication.php @@ -0,0 +1,48 @@ +result; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function getXid(): ?string + { + return $this->xid; + } +} diff --git a/lib/SaferpayJson/Response/Container/InstallmentPlan.php b/lib/SaferpayJson/Response/Container/InstallmentPlan.php new file mode 100644 index 0000000..0902a3f --- /dev/null +++ b/lib/SaferpayJson/Response/Container/InstallmentPlan.php @@ -0,0 +1,93 @@ +numberOfInstallments; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function getInstallmentFee(): ?Amount + { + return $this->installmentFee; + } + + public function getAnnualPercentageRate(): ?string + { + return $this->annualPercentageRate; + } + + public function getFirstInstallmentAmount(): ?Amount + { + return $this->firstInstallmentAmount; + } + + public function getSubsequentInstallmentAmount(): ?Amount + { + return $this->subsequentInstallmentAmount; + } + + public function getTotalAmountDue(): ?Amount + { + return $this->totalAmountDue; + } +} diff --git a/lib/SaferpayJson/Response/Container/Invoice.php b/lib/SaferpayJson/Response/Container/Invoice.php new file mode 100644 index 0000000..354a9e0 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Invoice.php @@ -0,0 +1,46 @@ +payee; + } + + public function getReasonForTransfer(): ?string + { + return $this->reasonForTransfer; + } + + public function getDueDate(): ?string + { + return $this->dueDate; + } +} diff --git a/lib/SaferpayJson/Response/Container/Liability.php b/lib/SaferpayJson/Response/Container/Liability.php new file mode 100644 index 0000000..4b2da74 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Liability.php @@ -0,0 +1,45 @@ +liabilityShift; + } + + public function getLiableEntity(): ?string + { + return $this->liableEntity; + } + + public function getThreeDs(): ?ThreeDs + { + return $this->threeDs; + } +} diff --git a/lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php new file mode 100644 index 0000000..8026931 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php @@ -0,0 +1,57 @@ +|null + * @SerializedName("InstallmentPlans") + * @Type("array") + */ + private $installmentPlans; + + /** + * @var CustomPlan|null + * @SerializedName("CustomPlan") + * @Type("Ticketpark\SaferpayJson\Response\Container\CustomPlan") + */ + private $customPlan; + + /** + * @var string|null + * @SerializedName("ReceiptFreeText") + * @Type("string") + */ + private $receiptFreeText; + + /** + * @var ChosenPlan|null + * @SerializedName("ChosenPlan") + * @Type("array") + */ + private $chosenPlan; + + public function getInstallmentPlans(): ?array + { + return $this->installmentPlans; + } + + public function getCustomPlan(): ?CustomPlan + { + return $this->customPlan; + } + + public function getReceiptFreeText(): ?string + { + return $this->receiptFreeText; + } + + public function getChosenPlan(): ?ChosenPlan + { + return $this->chosenPlan; + } +} diff --git a/lib/SaferpayJson/Response/Container/Payee.php b/lib/SaferpayJson/Response/Container/Payee.php new file mode 100644 index 0000000..0476f71 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Payee.php @@ -0,0 +1,57 @@ +iban; + } + + public function getHolderName(): ?string + { + return $this->holderName; + } + + public function getBic(): ?string + { + return $this->bic; + } + + public function getBankName(): ?string + { + return $this->bankName; + } +} diff --git a/lib/SaferpayJson/Response/Container/Payer.php b/lib/SaferpayJson/Response/Container/Payer.php new file mode 100644 index 0000000..c2c31f2 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Payer.php @@ -0,0 +1,57 @@ +ipAddress; + } + + public function getIpLocation(): ?string + { + return $this->ipLocation; + } + + public function getDeliveryAddress(): ?Address + { + return $this->deliveryAddress; + } + + public function getBillingAddress(): ?Address + { + return $this->billingAddress; + } +} diff --git a/lib/SaferpayJson/Response/Container/PaymentMeans.php b/lib/SaferpayJson/Response/Container/PaymentMeans.php new file mode 100644 index 0000000..3e17763 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/PaymentMeans.php @@ -0,0 +1,84 @@ +brand; + } + + public function getDisplayText(): ?string + { + return $this->displayText; + } + + public function getWallet(): ?string + { + return $this->wallet; + } + + public function getCard(): ?Card + { + return $this->card; + } + + public function getBankAccount(): ?BankAccount + { + return $this->bankAccount; + } + + public function getTwint(): ?Twint + { + return $this->twint; + } +} diff --git a/lib/SaferpayJson/Response/Container/Redirect.php b/lib/SaferpayJson/Response/Container/Redirect.php new file mode 100644 index 0000000..e62cd62 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Redirect.php @@ -0,0 +1,33 @@ +redirectUrl; + } + + public function isPaymentMeansRequired(): ?bool + { + return $this->paymentMeansRequired; + } +} diff --git a/lib/SaferpayJson/Response/Container/RegisterAlias.php b/lib/SaferpayJson/Response/Container/RegisterAlias.php new file mode 100644 index 0000000..ed951d1 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/RegisterAlias.php @@ -0,0 +1,33 @@ +id; + } + + public function getLifetime(): ?int + { + return $this->lifetime; + } +} diff --git a/lib/SaferpayJson/Response/Container/RegistrationResult.php b/lib/SaferpayJson/Response/Container/RegistrationResult.php new file mode 100644 index 0000000..68e954d --- /dev/null +++ b/lib/SaferpayJson/Response/Container/RegistrationResult.php @@ -0,0 +1,57 @@ +success; + } + + public function getAlias(): ?Alias + { + return $this->alias; + } + + public function getError(): ?Error + { + return $this->error; + } + + public function getAuthenticationResult(): ?AuthenticationResult + { + return $this->authenticationResult; + } +} diff --git a/lib/SaferpayJson/Container/ResponseHeader.php b/lib/SaferpayJson/Response/Container/ResponseHeader.php similarity index 55% rename from lib/SaferpayJson/Container/ResponseHeader.php rename to lib/SaferpayJson/Response/Container/ResponseHeader.php index 80ea9b2..96050c2 100644 --- a/lib/SaferpayJson/Container/ResponseHeader.php +++ b/lib/SaferpayJson/Response/Container/ResponseHeader.php @@ -1,47 +1,33 @@ specVersion; } - public function setSpecVersion(string $specVersion): self - { - $this->specVersion = $specVersion; - - return $this; - } - public function getRequestId(): string { return $this->requestId; } - - public function setRequestId(string $requestId): self - { - $this->requestId = $requestId; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/Container/SaferpayFields.php b/lib/SaferpayJson/Response/Container/SaferpayFields.php new file mode 100644 index 0000000..84560d5 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/SaferpayFields.php @@ -0,0 +1,20 @@ +token; + } +} diff --git a/lib/SaferpayJson/Response/Container/ThreeDs.php b/lib/SaferpayJson/Response/Container/ThreeDs.php new file mode 100644 index 0000000..f89a906 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/ThreeDs.php @@ -0,0 +1,57 @@ +authenticated; + } + + public function isLiabilityShift(): ?bool + { + return $this->liabilityShift; + } + + public function getXid(): ?string + { + return $this->xid; + } + + public function getVerificationValue(): ?string + { + return $this->verificationValue; + } +} diff --git a/lib/SaferpayJson/Response/Container/Transaction.php b/lib/SaferpayJson/Response/Container/Transaction.php new file mode 100644 index 0000000..7d7e8b6 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Transaction.php @@ -0,0 +1,172 @@ +type; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function getId(): ?string + { + return $this->id; + } + + public function getCaptureId(): ?string + { + return $this->captureId; + } + + public function getDate(): ?string + { + return $this->date; + } + + public function getAmount(): ?Amount + { + return $this->amount; + } + + public function getOrderId(): ?string + { + return $this->orderId; + } + + public function getAcquirerReference(): ?string + { + return $this->acquirerReference; + } + + public function getAcquirerName(): ?string + { + return $this->acquirerName; + } + + public function getSixTransactionReference(): ?string + { + return $this->sixTransactionReference; + } + + public function getApprovalCode(): ?string + { + return $this->approvalCode; + } + + public function getDirectDebit(): ?DirectDebit + { + return $this->directDebit; + } + + public function getInvoice(): ?Invoice + { + return $this->invoice; + } +} diff --git a/lib/SaferpayJson/Response/Container/Twint.php b/lib/SaferpayJson/Response/Container/Twint.php new file mode 100644 index 0000000..a801e61 --- /dev/null +++ b/lib/SaferpayJson/Response/Container/Twint.php @@ -0,0 +1,21 @@ +certificateExpirationDate; + } +} diff --git a/lib/SaferpayJson/Response/ErrorResponse.php b/lib/SaferpayJson/Response/ErrorResponse.php index b4cba7b..8c48e66 100644 --- a/lib/SaferpayJson/Response/ErrorResponse.php +++ b/lib/SaferpayJson/Response/ErrorResponse.php @@ -7,155 +7,104 @@ class ErrorResponse extends Response { + const BEHAVIOUR_ABORT = 'ABORT'; + const BEHAVIOUR_OTHER_MEANS = 'OTHER_MEANS'; + const BEHAVIOUR_RETRY = 'RETRY'; + const BEHAVIOUR_RETRY_LATER = 'RETRY_LATER'; + /** - * @var string + * @var string|null * @SerializedName("Behavior") * @Type("string") */ - protected $behaviour; + private $behaviour; /** - * @var string + * @var string|null * @SerializedName("ErrorName") * @Type("string") */ - protected $errorName; + private $errorName; /** - * @var string + * @var string|null * @SerializedName("ErrorMessage") * @Type("string") */ - protected $errorMessage; + private $errorMessage; /** * @var string|null * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** - * @var array + * @var array|null * @SerializedName("ErrorDetail") * @Type("array") */ - protected $errorDetail = []; + private $errorDetail = []; /** * @var string|null * @SerializedName("ProcessorName") * @Type("string") */ - protected $processorName; + private $processorName; /** * @var string|null * @SerializedName("ProcessorResult") * @Type("string") */ - protected $processorResult; + private $processorResult; /** - * @var string + * @var string|null * @SerializedName("ProcessorMessage") * @Type("string") */ - protected $processorMessage; + private $processorMessage; - public function getBehaviour(): string + public function getBehaviour(): ?string { return $this->behaviour; } - public function setBehaviour(string $behaviour): self - { - $this->behaviour = $behaviour; - - return $this; - } - - public function getErrorName(): string + public function getErrorName(): ?string { return $this->errorName; } - public function setErrorName(string $errorName): self - { - $this->errorName = $errorName; - - return $this; - } - - public function getErrorMessage(): string + public function getErrorMessage(): ?string { return $this->errorMessage; } - public function setErrorMessage(string $errorMessage): self - { - $this->errorMessage = $errorMessage; - - return $this; - } - public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): self - { - $this->transactionId = $transactionId; - - return $this; - } - - public function getErrorDetail(): array + public function getErrorDetail(): ?array { return $this->errorDetail; } - public function setErrorDetail(array $errorDetail): self - { - $this->errorDetail = $errorDetail; - - return $this; - } - public function getProcessorName(): ?string { return $this->processorName; } - public function setProcessorName(string $processorName): self - { - $this->processorName = $processorName; - - return $this; - } - public function getProcessorResult(): ?string { return $this->processorResult; } - public function setProcessorResult(string $processorResult): self - { - $this->processorResult = $processorResult; - - return $this; - } - public function getProcessorMessage(): ?string { return $this->processorMessage; } - - public function setProcessorMessage(string $processorMessage): self - { - $this->processorMessage = $processorMessage; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index 87bf696..6c56413 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -4,115 +4,98 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Dcc; -use Ticketpark\SaferpayJson\Container\Payer; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegistrationResult; -use Ticketpark\SaferpayJson\Container\ThreeDs; -use Ticketpark\SaferpayJson\Container\Transaction; +use Ticketpark\SaferpayJson\Response\Container\Dcc; +use Ticketpark\SaferpayJson\Response\Container\Liability; +use Ticketpark\SaferpayJson\Response\Container\MastercardIssuerInstallments; +use Ticketpark\SaferpayJson\Response\Container\Payer; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\RegistrationResult; +use Ticketpark\SaferpayJson\Response\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -class AssertResponse extends Response +final class AssertResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") - * @Type("Ticketpark\SaferpayJson\Container\Transaction") + * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ - protected $transaction; + private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** - * @var Payer + * @var Payer|null * @SerializedName("Payer") - * @Type("Ticketpark\SaferpayJson\Container\Payer") + * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ - protected $payer; + private $payer; /** - * @var RegistrationResult + * @var RegistrationResult|null * @SerializedName("RegistrationResult") - * @Type("Ticketpark\SaferpayJson\Container\RegistrationResult") + * @Type("Ticketpark\SaferpayJson\Response\Container\RegistrationResult") */ - protected $registrationResult; + private $registrationResult; /** - * @var ThreeDs - * @SerializedName("ThreeDs") - * @Type("Ticketpark\SaferpayJson\Container\ThreeDs") + * @var Liability|null + * @SerializedName("Liability") + * @Type("Ticketpark\SaferpayJson\Response\Container\Liability") */ - protected $threeDs; + private $liability; /** - * @var Dcc + * @var Dcc|null * @SerializedName("Dcc") - * @Type("Ticketpark\SaferpayJson\Container\Dcc") + * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ - protected $dcc; + private $dcc; - public function getTransaction(): Transaction - { - return $this->transaction; - } + /** + * @var MastercardIssuerInstallments|null + * @SerializedName("MastercardIssuerInstallments") + * @Type("Ticketpark\SaferpayJson\Response\Container\MastercardIssuerInstallments") + */ + private $mastercardIssuerInstallments; - public function setTransaction(Transaction $transaction): void + public function getTransaction(): ?Transaction { - $this->transaction = $transaction; + return $this->transaction; } - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } - - public function getPayer(): Payer + public function getPayer(): ?Payer { return $this->payer; } - public function setPayer(Payer $payer): void - { - $this->payer = $payer; - } - - public function getRegistrationResult(): RegistrationResult + public function getRegistrationResult(): ?RegistrationResult { return $this->registrationResult; } - public function setRegistrationResult(RegistrationResult $registrationResult): void - { - $this->registrationResult = $registrationResult; - } - - public function getThreeDs(): ThreeDs - { - return $this->threeDs; - } - - public function setThreeDs(ThreeDs $threeDs): void + public function getLiability(): ?Liability { - $this->threeDs = $threeDs; + return $this->liability; } - public function getDcc(): Dcc + public function getDcc(): ?Dcc { return $this->dcc; } - public function setDcc(Dcc $dcc): void + public function getMastercardIssuerInstallments(): ?MastercardIssuerInstallments { - $this->dcc = $dcc; + return $this->mastercardIssuerInstallments; } } diff --git a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php deleted file mode 100644 index 5b14022..0000000 --- a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php +++ /dev/null @@ -1,46 +0,0 @@ -transaction; - } - - public function setTransaction(Transaction $transaction): void - { - $this->transaction = $transaction; - } - - public function getPaymentMeans(): PaymentMeans - { - return $this->paymentMeans; - } - - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } -} diff --git a/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php b/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php index 2124ad2..f138d43 100644 --- a/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php @@ -6,62 +6,41 @@ use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Response\Response; -class InitializeResponse extends Response +final class InitializeResponse extends Response { /** - * @var string + * @var string|null * @SerializedName("Token") * @Type("string") */ - protected $token; + private $token; /** - * @var \DateTime + * @var \DateTime|null * @SerializedName("Expiration") * @Type("string") */ - protected $expiration; + private $expiration; /** - * @var string + * @var string|null * @SerializedName("RedirectUrl") * @Type("string") */ - protected $redirectUrl; + private $redirectUrl; - public function getToken(): string + public function getToken(): ?string { return $this->token; } - public function setToken(string $token): self - { - $this->token = $token; - - return $this; - } - - public function getExpiration(): \DateTime + public function getExpiration(): ?\DateTime { return $this->expiration; } - public function setExpiration(\DateTime $expiration): self - { - $this->expiration = $expiration; - - return $this; - } - - public function getRedirectUrl(): string + public function getRedirectUrl(): ?string { return $this->redirectUrl; } - - public function setRedirectUrl(string $redirectUrl): self - { - $this->redirectUrl = $redirectUrl; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/Response.php b/lib/SaferpayJson/Response/Response.php index 2220450..d7cfae0 100644 --- a/lib/SaferpayJson/Response/Response.php +++ b/lib/SaferpayJson/Response/Response.php @@ -4,14 +4,14 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\ResponseHeader; +use Ticketpark\SaferpayJson\Response\Container\ResponseHeader; -abstract class Response implements ResponseInterface +abstract class Response { /** * @var ResponseHeader * @SerializedName("ResponseHeader") - * @Type("Ticketpark\SaferpayJson\Container\ResponseHeader") + * @Type("Ticketpark\SaferpayJson\Response\Container\ResponseHeader") */ protected $responseHeader; @@ -20,7 +20,7 @@ public function getResponseHeader(): ResponseHeader return $this->responseHeader; } - public function setResponseHeader(ResponseHeader $responseHeader): ResponseInterface + public function setResponseHeader(ResponseHeader $responseHeader): self { $this->responseHeader = $responseHeader; diff --git a/lib/SaferpayJson/Response/ResponseInterface.php b/lib/SaferpayJson/Response/ResponseInterface.php deleted file mode 100644 index e2d8a19..0000000 --- a/lib/SaferpayJson/Response/ResponseInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -alias; - } - - public function setAlias(Alias $alias): void - { - $this->alias = $alias; - } - - public function getPaymentMeans(): PaymentMeans - { - return $this->paymentMeans; - } - - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } -} diff --git a/lib/SaferpayJson/Response/SecureAliasStore/DeleteResponse.php b/lib/SaferpayJson/Response/SecureAliasStore/DeleteResponse.php deleted file mode 100755 index 9e67a16..0000000 --- a/lib/SaferpayJson/Response/SecureAliasStore/DeleteResponse.php +++ /dev/null @@ -1,9 +0,0 @@ -alias; - } - - public function setAlias(Alias $alias): void - { - $this->alias = $alias; - } - - public function getPaymentMeans(): PaymentMeans - { - return $this->paymentMeans; - } - - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } -} diff --git a/lib/SaferpayJson/Response/SecureAliasStore/InsertResponse.php b/lib/SaferpayJson/Response/SecureAliasStore/InsertResponse.php deleted file mode 100755 index 6d90dcb..0000000 --- a/lib/SaferpayJson/Response/SecureAliasStore/InsertResponse.php +++ /dev/null @@ -1,61 +0,0 @@ -token; - } - - public function setToken(string $token): void - { - $this->token = $token; - } - - public function getExpiration(): \DateTime - { - return $this->expiration; - } - - public function setExpiration(\DateTime $expiration): void - { - $this->expiration = $expiration; - } - - public function getRedirectUrl(): string - { - return $this->redirectUrl; - } - - public function setRedirectUrl(string $redirectUrl): void - { - $this->redirectUrl = $redirectUrl; - } -} diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php new file mode 100755 index 0000000..b54648c --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php @@ -0,0 +1,49 @@ +alias; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } + + public function getCheckResult(): ?CheckResult + { + return $this->checkResult; + } +} diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php new file mode 100755 index 0000000..3f48f08 --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php @@ -0,0 +1,9 @@ +alias; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } + + public function getCheckResult(): ?CheckResult + { + return $this->checkResult; + } +} diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php new file mode 100755 index 0000000..c49d631 --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php @@ -0,0 +1,59 @@ +token; + } + + public function getExpiration(): ?\DateTime + { + return $this->expiration; + } + + public function isRedirectRequired(): ?bool + { + return $this->redirectRequired; + } + + public function getRedirect(): ?Redirect + { + return $this->redirect; + } +} diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php new file mode 100755 index 0000000..b19473b --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php @@ -0,0 +1,36 @@ +alias; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } +} diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index eabb1c6..f463d69 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -4,47 +4,59 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\Transaction; +use Ticketpark\SaferpayJson\Response\Container\Payer; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Response\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -/** - * Class AuthorizeDirectResponse - * @package Ticketpark\SaferpayJson\Transaction - */ -class AuthorizeDirectResponse extends Response +final class AuthorizeDirectResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") - * @Type("Ticketpark\SaferpayJson\Container\Transaction") + * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ - protected $transaction; + private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; - public function getTransaction(): Transaction + /** + * @var RegisterAlias|null + * @SerializedName("RegisterAlias") + * @Type("Ticketpark\SaferpayJson\Response\Container\RegisterAlias") + */ + private $registerAlias; + + /** + * @var Payer|null + * @SerializedName("Payer") + * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") + */ + private $payer; + + public function getTransaction(): ?Transaction { return $this->transaction; } - public function setTransaction(Transaction $transaction): void + public function getPaymentMeans(): ?PaymentMeans { - $this->transaction = $transaction; + return $this->paymentMeans; } - public function getPaymentMeans(): PaymentMeans + public function getRegisterAlias(): ?RegisterAlias { - return $this->paymentMeans; + return $this->registerAlias; } - public function setPaymentMeans(PaymentMeans $paymentMeans): void + public function getPayer(): ?Payer { - $this->paymentMeans = $paymentMeans; + return $this->payer; } } diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php new file mode 100644 index 0000000..ec5024c --- /dev/null +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php @@ -0,0 +1,62 @@ +transaction; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } + + public function getPayer(): ?Payer + { + return $this->payer; + } + + public function getDcc(): ?Dcc + { + return $this->dcc; + } +} diff --git a/lib/SaferpayJson/Response/Transaction/CancelResponse.php b/lib/SaferpayJson/Response/Transaction/CancelResponse.php index 3b0ec69..34c804c 100644 --- a/lib/SaferpayJson/Response/Transaction/CancelResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CancelResponse.php @@ -6,56 +6,41 @@ use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Response\Response; -class CancelResponse extends Response +final class CancelResponse extends Response { /** - * @var string + * @var string|null * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** - * @var string + * @var string|null * @SerializedName("OrderId") * @Type("string") */ - protected $orderId; + private $orderId; /** - * @var string + * @var string|null * @SerializedName("Date") * @Type("string") */ - protected $date; + private $date; - public function getTransactionId(): string + public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): void - { - $this->transactionId = $transactionId; - } - - public function getOrderId(): string + public function getOrderId(): ?string { return $this->orderId; } - public function setOrderId(string $orderId): void - { - $this->orderId = $orderId; - } - - public function getDate(): string + public function getDate(): ?string { return $this->date; } - - public function setDate(string $date): void - { - $this->date = $date; - } } diff --git a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php index 3d52eec..0ddac48 100644 --- a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php @@ -4,76 +4,71 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Invoice; +use Ticketpark\SaferpayJson\Response\Container\Invoice; use Ticketpark\SaferpayJson\Response\Response; -class CaptureResponse extends Response +final class CaptureResponse extends Response { + const STATUS_PENDING = 'PENDING'; + const STATUS_CAPTURED = 'CAPTURED'; + /** - * @var string + * @var string|null * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** - * @var string - * @SerializedName("OrderId") + * @var string|null + * @SerializedName("CaptureId") * @Type("string") */ - protected $orderId; + private $captureId; /** - * @var string + * @var string|null + * @SerializedName("Status") + * @Type("string") + */ + private $status; + + /** + * @var string|null * @SerializedName("Date") * @Type("string") */ - protected $date; + private $date; /** - * @var Invoice + * @var Invoice|null * @SerializedName("Invoice") - * @Type("Ticketpark\SaferpayJson\Container\Invoice") + * @Type("Ticketpark\SaferpayJson\Response\Container\Invoice") */ - protected $invoice; + private $invoice; - public function getTransactionId(): string + public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): void - { - $this->transactionId = $transactionId; - } - - public function getOrderId(): string + public function getCaptureId(): ?string { - return $this->orderId; + return $this->captureId; } - public function setOrderId(string $orderId): void + public function getStatus(): ?string { - $this->orderId = $orderId; + return $this->status; } - public function getDate(): string + public function getDate(): ?string { return $this->date; } - public function setDate(string $date): void - { - $this->date = $date; - } - - public function getInvoice(): Invoice + public function getInvoice(): ?Invoice { return $this->invoice; } - - public function setInvoice(Invoice $invoice): void - { - $this->invoice = $invoice; - } } diff --git a/lib/SaferpayJson/Response/Transaction/RefundResponse.php b/lib/SaferpayJson/Response/Transaction/RefundResponse.php index 5bae5e6..6bd6249 100644 --- a/lib/SaferpayJson/Response/Transaction/RefundResponse.php +++ b/lib/SaferpayJson/Response/Transaction/RefundResponse.php @@ -4,61 +4,46 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Dcc; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\Transaction; +use Ticketpark\SaferpayJson\Response\Container\Dcc; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -class RefundResponse extends Response +final class RefundResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") - * @Type("Ticketpark\SaferpayJson\Container\Transaction") + * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ - protected $transaction; + private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** - * @var Dcc + * @var Dcc|null * @SerializedName("Dcc") - * @Type("Ticketpark\SaferpayJson\Container\Dcc") + * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ - protected $dcc; + private $dcc; - public function getTransaction(): Transaction + public function getTransaction(): ?Transaction { return $this->transaction; } - public function setTransaction(Transaction $transaction): void - { - $this->transaction = $transaction; - } - - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } - - public function getDcc(): Dcc + public function getDcc(): ?Dcc { return $this->dcc; } - - public function setDcc(Dcc $dcc): void - { - $this->dcc = $dcc; - } } diff --git a/phpstan.neon b/phpstan.neon index aed940e..42df7f8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 7 + level: 8 paths: - - lib/ + - lib checkMissingIterableValueType: false diff --git a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php index 797f2cc..5a2f699 100644 --- a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php @@ -4,12 +4,14 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use GuzzleHttp\Client; -use GuzzleHttp\Psr7\Response; +use GuzzleHttp\Psr7\Response as GuzzleResponse; use JMS\Serializer\SerializerBuilder; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Ticketpark\SaferpayJson\Request\Exception\SaferpayErrorException; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\ErrorResponse; -use Ticketpark\SaferpayJson\Response\ResponseInterface; +use Ticketpark\SaferpayJson\Response\Response; abstract class CommonRequestTest extends TestCase { @@ -19,28 +21,41 @@ abstract class CommonRequestTest extends TestCase /** @var ?string */ private $successfulResponseClass; - public function doTestErrorResponse(string $requestClass): void + abstract protected function getInstance(); + + public function testErrorResponse(): void { - $this->successful = false; - $this->successfulResponseClass = null; - $response = $this->executeRequest($requestClass); + $this->expectException(SaferpayErrorException::class); - $this->assertInstanceOf(ErrorResponse::class, $response); + $this->successful = false; + $this->executeRequest(); } - public function doTestSuccessfulResponse(string $requestClass, string $responseClass): void + public function doTestSuccessfulResponse(string $responseClass): void { $this->successful = true; $this->successfulResponseClass = $responseClass; - $response = $this->executeRequest($requestClass); + $response = $this->executeRequest(); $this->assertInstanceOf($responseClass, $response); } - private function executeRequest(string $requestClass): ResponseInterface + protected function getRequestConfig(): RequestConfig + { + $requestConfig = new RequestConfig( + 'apiKey', + 'apiSecret', + 'customerId' + ); + + $requestConfig->setClient($this->getClientMock()); + + return $requestConfig; + } + + private function executeRequest(): Response { - $initializer = new $requestClass('key', 'secret'); - $initializer->setClient($this->getClientMock()); + $initializer = $this->getInstance(); return $initializer->execute(); } @@ -61,7 +76,7 @@ private function getClientMock(): MockObject private function getResponseMock(): MockObject { - $response = $this->getMockBuilder(Response::class) + $response = $this->getMockBuilder(GuzzleResponse::class) ->disableOriginalConstructor() ->onlyMethods([ 'getStatusCode', diff --git a/tests/SaferpayJson/Tests/Request/PaymentPage/AssertRequestTest.php b/tests/SaferpayJson/Tests/Request/PaymentPage/AssertRequestTest.php index 4334683..20705fd 100644 --- a/tests/SaferpayJson/Tests/Request/PaymentPage/AssertRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/PaymentPage/AssertRequestTest.php @@ -8,16 +8,18 @@ class AssertRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(AssertRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - AssertRequest::class, AssertResponse::class ); } + + protected function getInstance() + { + return new AssertRequest( + $this->getRequestConfig(), + 'someTokenId' + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/PaymentPage/AuthorizeReferencedRequestTest.php b/tests/SaferpayJson/Tests/Request/PaymentPage/AuthorizeReferencedRequestTest.php deleted file mode 100644 index c8a9fdd..0000000 --- a/tests/SaferpayJson/Tests/Request/PaymentPage/AuthorizeReferencedRequestTest.php +++ /dev/null @@ -1,23 +0,0 @@ -getRequestConfig(), + 'someTerminalId', + new Payment( + new Amount(5000, 'CHF') + ), + new ReturnUrls('success-url', 'fail-url') + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php deleted file mode 100755 index f647fc8..0000000 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php +++ /dev/null @@ -1,23 +0,0 @@ -getRequestConfig(), + 'someToken' + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php new file mode 100755 index 0000000..69f7f55 --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php @@ -0,0 +1,25 @@ +getRequestConfig(), + 'someAliasId' + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php new file mode 100755 index 0000000..d6f6a0e --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php @@ -0,0 +1,21 @@ +getRequestConfig(), + new RegisterAlias(RegisterAlias::ID_GENERATOR_RANDOM), + new PaymentMeans() + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php new file mode 100755 index 0000000..f2dc74d --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php @@ -0,0 +1,29 @@ +getRequestConfig(), + new RegisterAlias(RegisterAlias::ID_GENERATOR_RANDOM), + AliasInsertRequest::TYPE_CARD, + new ReturnUrls('success-url', 'fail-url') + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php new file mode 100755 index 0000000..dd4f522 --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php @@ -0,0 +1,31 @@ +getRequestConfig(), + new UpdateAlias('some-id'), + new UpdatePaymentMeans( + new Card() + ) + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php index d812d0b..c0f23e9 100644 --- a/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php @@ -1,22 +1,31 @@ getRequestConfig(), + 'someTerminalId', + new Payment( + new Amount(5000, 'CHF') + ), + new PaymentMeans() + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeReferencedRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeReferencedRequestTest.php new file mode 100644 index 0000000..376d030 --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeReferencedRequestTest.php @@ -0,0 +1,32 @@ +getRequestConfig(), + 'someTerminalId', + new Payment( + new Amount(5000, 'CHF') + ), + new TransactionReference() + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/Transaction/CancelRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/CancelRequestTest.php index 23b464b..90c5350 100644 --- a/tests/SaferpayJson/Tests/Request/Transaction/CancelRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/Transaction/CancelRequestTest.php @@ -2,22 +2,25 @@ namespace Ticketpark\SaferpayJson\Tests\Transaction; +use Ticketpark\SaferpayJson\Request\Container\TransactionReference; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; use Ticketpark\SaferpayJson\Request\Transaction\CancelRequest; use Ticketpark\SaferpayJson\Response\Transaction\CancelResponse; class CancelRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(CancelRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - CancelRequest::class, CancelResponse::class ); } + + public function getInstance() + { + return new CancelRequest( + $this->getRequestConfig(), + new TransactionReference() + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/Transaction/CaptureRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/CaptureRequestTest.php index 8bef85e..e158428 100644 --- a/tests/SaferpayJson/Tests/Request/Transaction/CaptureRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/Transaction/CaptureRequestTest.php @@ -2,22 +2,25 @@ namespace Ticketpark\SaferpayJson\Tests\Transaction; +use Ticketpark\SaferpayJson\Request\Container\TransactionReference; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; use Ticketpark\SaferpayJson\Request\Transaction\CaptureRequest; use Ticketpark\SaferpayJson\Response\Transaction\CaptureResponse; class CaptureRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(CaptureRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - CaptureRequest::class, CaptureResponse::class ); } + + public function getInstance() + { + return new CaptureRequest( + $this->getRequestConfig(), + new TransactionReference() + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/Transaction/RefundRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/RefundRequestTest.php index 89d786c..9f81140 100644 --- a/tests/SaferpayJson/Tests/Request/Transaction/RefundRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/Transaction/RefundRequestTest.php @@ -2,22 +2,30 @@ namespace Ticketpark\SaferpayJson\Tests\Transaction; +use Ticketpark\SaferpayJson\Request\Container\Amount; +use Ticketpark\SaferpayJson\Request\Container\CaptureReference; +use Ticketpark\SaferpayJson\Request\Container\Refund; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; use Ticketpark\SaferpayJson\Request\Transaction\RefundRequest; use Ticketpark\SaferpayJson\Response\Transaction\RefundResponse; class RefundRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(RefundRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - RefundRequest::class, RefundResponse::class ); } + + public function getInstance() + { + return new RefundRequest( + $this->getRequestConfig(), + new Refund( + new Amount(5000, 'CHF') + ), + new CaptureReference() + ); + } }