From bc8e7debbc8915e2da7bf33ba4777a832e69bf0e Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 10:28:52 +0200 Subject: [PATCH 01/34] Add ClientInfo container --- lib/SaferpayJson/Container/ClientInfo.php | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/SaferpayJson/Container/ClientInfo.php diff --git a/lib/SaferpayJson/Container/ClientInfo.php b/lib/SaferpayJson/Container/ClientInfo.php new file mode 100644 index 0000000..d01242c --- /dev/null +++ b/lib/SaferpayJson/Container/ClientInfo.php @@ -0,0 +1,47 @@ +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; + } +} From 85746becac70940a53922485380191e7c68399c4 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 10:29:23 +0200 Subject: [PATCH 02/34] Update RequestHeader to specs of 1.17 --- lib/SaferpayJson/Container/RequestHeader.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Container/RequestHeader.php index 694762d..b34b7e3 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Container/RequestHeader.php @@ -10,7 +10,7 @@ class RequestHeader * @var string * @SerializedName("SpecVersion") */ - protected $specVersion = '1.2'; + protected $specVersion = '1.17'; /** * @var string @@ -30,6 +30,12 @@ class RequestHeader */ protected $retryIndicator = 0; + /** + * @var ClientInfo + * @SerializedName("ClientInfo") + */ + protected $clientInfo; + public function getSpecVersion(): string { return $this->specVersion; @@ -77,4 +83,16 @@ public function setRetryIndicator(int $retryIndicator): self return $this; } + + public function getClientInfo(): ?ClientInfo + { + return $this->clientInfo; + } + + public function setClientInfo(ClientInfo $clientInfo): self + { + $this->clientInfo = $clientInfo; + + return $this; + } } From 34c807f82c9f2b7fd0a428c60d706ddc716fa481 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 12:21:44 +0200 Subject: [PATCH 03/34] Adjust PaymentPage\InitializeRequest to work for spec 1.16 --- example/PaymentPage/1-example-initialize.php | 94 ++++--- example/credentials.dist.php | 9 + example/credentials.php | 9 - lib/SaferpayJson/Container/Address.php | 146 +++++------ lib/SaferpayJson/Container/AddressForm.php | 62 +++++ lib/SaferpayJson/Container/Alipay.php | 33 +++ lib/SaferpayJson/Container/Amount.php | 6 + lib/SaferpayJson/Container/Authentication.php | 53 ++++ lib/SaferpayJson/Container/CardForm.php | 35 +++ lib/SaferpayJson/Container/Ideal.php | 33 +++ lib/SaferpayJson/Container/Installment.php | 31 +++ lib/SaferpayJson/Container/Notification.php | 20 +- lib/SaferpayJson/Container/Options.php | 27 ++ lib/SaferpayJson/Container/Payment.php | 80 +++++- .../Container/PaymentMethodsOptions.php | 45 ++++ lib/SaferpayJson/Container/RegisterAlias.php | 29 +-- lib/SaferpayJson/Container/RequestHeader.php | 13 +- lib/SaferpayJson/Container/ResponseHeader.php | 2 +- lib/SaferpayJson/Container/ReturnUrls.php | 13 +- lib/SaferpayJson/Container/Styling.php | 12 +- .../Request/PaymentPage/InitializeRequest.php | 232 +++++++++++++++--- lib/SaferpayJson/Request/Request.php | 109 +++----- lib/SaferpayJson/Request/RequestConfig.php | 77 ++++++ 23 files changed, 883 insertions(+), 287 deletions(-) create mode 100644 example/credentials.dist.php delete mode 100644 example/credentials.php create mode 100644 lib/SaferpayJson/Container/AddressForm.php create mode 100644 lib/SaferpayJson/Container/Alipay.php create mode 100644 lib/SaferpayJson/Container/Authentication.php create mode 100644 lib/SaferpayJson/Container/CardForm.php create mode 100644 lib/SaferpayJson/Container/Ideal.php create mode 100644 lib/SaferpayJson/Container/Installment.php create mode 100644 lib/SaferpayJson/Container/Options.php create mode 100644 lib/SaferpayJson/Container/PaymentMethodsOptions.php create mode 100644 lib/SaferpayJson/Request/RequestConfig.php diff --git a/example/PaymentPage/1-example-initialize.php b/example/PaymentPage/1-example-initialize.php index 646a703..4f618f6 100644 --- a/example/PaymentPage/1-example-initialize.php +++ b/example/PaymentPage/1-example-initialize.php @@ -1,75 +1,71 @@ 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(); +// See https://saferpay.github.io/jsonapi/#Payment_v1_PaymentPage_Initialize + +$requestConfig = new RequestConfig( + $apiKey, + $apiSecret, + $customerId, + true +); + +$amount = new Container\Amount( + 5000, // amount in cents + 'CHF' +); + +$payment = new Container\Payment( + $amount, + 'Order No. 12839' +); + +$returnUrls = new Container\ReturnUrls( + 'http://www.mysite.ch/success?orderId=12839', + 'http://www.mysite.ch/fail', + 'http://www.mysite.ch/abort' +); // Step 2: +// Execute the request + +$initializeRequest = new InitializeRequest( + $requestConfig, + $terminalId, + $payment, + $returnUrls +); + +$response = $initializeRequest->execute(); + +// Step 3: // Check for successful response if ($response instanceof ErrorResponse) { die($response->getErrorMessage()); } -// Step 3: +// Step 4: // Save the response token, you will need it later to verify the payment echo 'Payment token: ' . $response->getToken() . "
\n"; -// Step 4: +// Step 5: // Redirect to the payment page echo 'Redirect to: ' . $response->getRedirectUrl() ."
\n"; -// Step 5: +// Step 6: // Fill in test payment page. For dummy credit card numbers see // https://saferpay.github.io/sndbx/paymentmeans.html -// Step 6: +// Step 7: // On success page and notification url, assert the payment has been successful. // -> see 2-example-assert.php 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 @@ +dateOfBirth; - } - - public function setDateOfBirth(\DateTime $dateOfBirth): self - { - $this->dateOfBirth = $dateOfBirth; - - return $this; - } - public function getCompany(): string { return $this->company; @@ -165,110 +153,122 @@ public function setGender(string $gender): self return $this; } - public function getLegalForm(): string + public function getStreet(): string { - return $this->legalForm; + return $this->street; } - public function setLegalForm(string $legalForm): self + public function setStreet(string $street): self { - $this->legalForm = $legalForm; + $this->street = $street; return $this; } - public function getStreet(): string + public function getZip(): string { - return $this->street; + return $this->zip; } - public function setStreet(string $street): self + public function setZip(string $zip): self { - $this->street = $street; + $this->zip = $zip; return $this; } - public function getStreet2(): string + public function getCity(): string { - return $this->street2; + return $this->city; } - public function setStreet2(string $street2): self + public function setCity(string $city): self { - $this->street2 = $street2; + $this->city = $city; return $this; } - public function getZip(): string + public function getCountryCode(): string { - return $this->zip; + return $this->countryCode; } - public function setZip(string $zip): self + public function setCountryCode(string $countryCode): self { - $this->zip = $zip; + $this->countryCode = $countryCode; return $this; } - public function getCity(): string + public function getEmail(): string { - return $this->city; + return $this->email; } - public function setCity(string $city): self + public function setEmail(string $email): self { - $this->city = $city; + $this->email = $email; return $this; } - public function getCountrySubdivisionCode(): string + public function getDateOfBirth(): \DateTime { - return $this->countrySubdivisionCode; + return $this->dateOfBirth; } - public function setCountrySubdivisionCode(string $countrySubdivisionCode): self + public function setDateOfBirth(\DateTime $dateOfBirth): self { - $this->countrySubdivisionCode = $countrySubdivisionCode; + $this->dateOfBirth = $dateOfBirth; return $this; } - public function getCountryCode(): string + public function getLegalForm(): string { - return $this->countryCode; + return $this->legalForm; } - public function setCountryCode(string $countryCode): self + public function setLegalForm(string $legalForm): self { - $this->countryCode = $countryCode; + $this->legalForm = $legalForm; return $this; } - public function getPhone(): string + public function getStreet2(): string { - return $this->phone; + return $this->street2; } - public function setPhone(string $phone): self + public function setStreet2(string $street2): self { - $this->phone = $phone; + $this->street2 = $street2; return $this; } - public function getEmail(): string + public function getCountrySubdivisionCode(): string { - return $this->email; + return $this->countrySubdivisionCode; } - public function setEmail(string $email): self + public function setCountrySubdivisionCode(string $countrySubdivisionCode): self { - $this->email = $email; + $this->countrySubdivisionCode = $countrySubdivisionCode; + + return $this; + } + + public function getPhone(): string + { + return $this->phone; + } + + public function setPhone(string $phone): self + { + $this->phone = $phone; return $this; } diff --git a/lib/SaferpayJson/Container/AddressForm.php b/lib/SaferpayJson/Container/AddressForm.php new file mode 100644 index 0000000..2c72bad --- /dev/null +++ b/lib/SaferpayJson/Container/AddressForm.php @@ -0,0 +1,62 @@ + + * @SerializedName("MandatoryFields") + */ + protected $mandatoryFields = []; + + public function __construct(bool $display = true) + { + $this->display = $display; + } + + public function isDisplay(): bool + { + return $this->display; + } + + public function setDisplay(bool $display): self + { + $this->display = $display; + + return $this; + } + + public function getMandatoryFields(): array + { + return $this->mandatoryFields; + } + + public function setMandatoryFields(array $mandatoryFields): self + { + $this->mandatoryFields = $mandatoryFields; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Alipay.php b/lib/SaferpayJson/Container/Alipay.php new file mode 100644 index 0000000..3bc43dc --- /dev/null +++ b/lib/SaferpayJson/Container/Alipay.php @@ -0,0 +1,33 @@ +localWallet = $localWallet; + } + + public function getLocalWallet(): ?string + { + return $this->localWallet; + } + + public function setLocalWallet(string $localWallet): self + { + $this->localWallet = $localWallet; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Amount.php b/lib/SaferpayJson/Container/Amount.php index f9e59c7..2bbecc3 100644 --- a/lib/SaferpayJson/Container/Amount.php +++ b/lib/SaferpayJson/Container/Amount.php @@ -21,6 +21,12 @@ class Amount */ protected $currencyCode; + public function __construct(int $value, string $currencyCode) + { + $this->value = $value; + $this->currencyCode = $currencyCode; + } + public function getValue(): int { return $this->value; diff --git a/lib/SaferpayJson/Container/Authentication.php b/lib/SaferpayJson/Container/Authentication.php new file mode 100644 index 0000000..c4da7c2 --- /dev/null +++ b/lib/SaferpayJson/Container/Authentication.php @@ -0,0 +1,53 @@ +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/CardForm.php b/lib/SaferpayJson/Container/CardForm.php new file mode 100644 index 0000000..70b0eb0 --- /dev/null +++ b/lib/SaferpayJson/Container/CardForm.php @@ -0,0 +1,35 @@ +holderName = $holderName; + } + + public function getHolderName(): string + { + return $this->holderName; + } + + public function setHolderName(string $holderName): self + { + $this->holderName = $holderName; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Ideal.php b/lib/SaferpayJson/Container/Ideal.php new file mode 100644 index 0000000..fad7933 --- /dev/null +++ b/lib/SaferpayJson/Container/Ideal.php @@ -0,0 +1,33 @@ +issuerId = $issuerId; + } + + public function getIssuerId(): ?string + { + return $this->issuerId; + } + + public function setIssuerId(string $issuerId): self + { + $this->issuerId = $issuerId; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Installment.php b/lib/SaferpayJson/Container/Installment.php new file mode 100644 index 0000000..f089d62 --- /dev/null +++ b/lib/SaferpayJson/Container/Installment.php @@ -0,0 +1,31 @@ +initial = $initial; + } + + public function isInitial(): bool + { + return $this->initial; + } + + public function setInitial(bool $initial): self + { + $this->initial = $initial; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Notification.php b/lib/SaferpayJson/Container/Notification.php index e9a35dd..ef77efd 100644 --- a/lib/SaferpayJson/Container/Notification.php +++ b/lib/SaferpayJson/Container/Notification.php @@ -7,36 +7,36 @@ class Notification { /** - * @var string - * @SerializedName("MerchantEmail") + * @var array + * @SerializedName("MerchantEmails") */ - protected $merchantEmail; + protected $merchantEmails = []; /** - * @var string + * @var string|null * @SerializedName("PayerEmail") */ protected $payerEmail; /** - * @var string + * @var string|null * @SerializedName("NotifyUrl") */ protected $notifyUrl; - public function getMerchantEmail(): string + public function getMerchantEmails(): array { return $this->merchantEmail; } - 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/Container/Options.php b/lib/SaferpayJson/Container/Options.php new file mode 100644 index 0000000..1bc2826 --- /dev/null +++ b/lib/SaferpayJson/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/Payment.php b/lib/SaferpayJson/Container/Payment.php index c40bb8c..b71ddc8 100644 --- a/lib/SaferpayJson/Container/Payment.php +++ b/lib/SaferpayJson/Container/Payment.php @@ -13,11 +13,17 @@ class Payment protected $amount; /** - * @var string + * @var string|null * @SerializedName("OrderId") */ protected $orderId; + /** + * @var string|null + * @SerializedName("PayerNote") + */ + protected $payerNote; + /** * @var string * @SerializedName("Description") @@ -25,17 +31,35 @@ class Payment protected $description; /** - * @var string - * @SerializedName("PayerNote") + * @var string|null + * @SerializedName("MandateId") */ - protected $payerNote; + protected $mandateId; + + /** + * @var Options|null + * @SerializedName("Options") + */ + protected $options; /** - * @var Recurring + * @var Recurring|null * @SerializedName("Recurring") */ protected $recurring; + /** + * @var Installment|null + * @SerializedName("Installment") + */ + protected $installment; + + public function __construct(Amount $amount, string $description) + { + $this->amount = $amount; + $this->description = $description; + } + public function getAmount(): Amount { return $this->amount; @@ -48,7 +72,7 @@ public function setAmount(Amount $amount): self return $this; } - public function getOrderId(): string + public function getOrderId(): ?string { return $this->orderId; } @@ -60,6 +84,18 @@ public function setOrderId(string $orderId): self 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; @@ -72,14 +108,26 @@ public function setDescription(string $description): self return $this; } - public function getPayerNote(): string + public function getMandateId(): ?string { - return $this->payerNote; + return $this->mandateId; } - public function setPayerNote(string $payerNote): self + public function setMandateId(string $mandateId): self { - $this->payerNote = $payerNote; + $this->mandateId = $mandateId; + + return $this; + } + + public function getOptions(): ?Options + { + return $this->options; + } + + public function setOptions(Options $options): self + { + $this->options = $options; return $this; } @@ -95,4 +143,16 @@ public function setRecurring(Recurring $recurring): self 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/Container/PaymentMethodsOptions.php b/lib/SaferpayJson/Container/PaymentMethodsOptions.php new file mode 100644 index 0000000..6759d94 --- /dev/null +++ b/lib/SaferpayJson/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/Container/RegisterAlias.php b/lib/SaferpayJson/Container/RegisterAlias.php index 7c52abc..b228de0 100644 --- a/lib/SaferpayJson/Container/RegisterAlias.php +++ b/lib/SaferpayJson/Container/RegisterAlias.php @@ -7,12 +7,16 @@ class RegisterAlias { + const ID_GENERATOR_MANUAL = 'MANUAL'; + const ID_GENERATOR_RANDOM = 'RANDOM'; + const ID_GENERATOR_RANDOM_UNIQUE = 'RANDOM_UNIQUE'; + /** * @var string * @SerializedName("IdGenerator") * @Type("string") */ - protected $IdGenerator="RANDOM"; + protected $idGenerator; /** * @var string @@ -28,37 +32,28 @@ class RegisterAlias */ protected $lifetime; - /** - * @return string - */ + public function __construct(string $idGenerator = self::ID_GENERATOR_RANDOM) + { + $this->idGenerator = $idGenerator; + } + public function getIdGenerator(): string { - return $this->IdGenerator; + return $this->idGenerator; } - /** - * @param string $idGenerator - * @return RegisterAlias - */ public function setIdGenerator(string $idGenerator): self { - $this->IdGenerator = $idGenerator; + $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; diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Container/RequestHeader.php index b34b7e3..e46eed6 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Container/RequestHeader.php @@ -10,7 +10,7 @@ class RequestHeader * @var string * @SerializedName("SpecVersion") */ - protected $specVersion = '1.17'; + protected $specVersion = '1.16'; /** * @var string @@ -36,6 +36,17 @@ class RequestHeader */ protected $clientInfo; + public function __construct(string $customerId, string $requestId = null, int $retryIndicator = 0) + { + $this->customerId = $customerId; + $this->requestId = $requestId; + $this->retryIndicator = $retryIndicator; + + if (null === $requestId && 0 === $retryIndicator) { + $this->requestId = uniqid(); + } + } + public function getSpecVersion(): string { return $this->specVersion; diff --git a/lib/SaferpayJson/Container/ResponseHeader.php b/lib/SaferpayJson/Container/ResponseHeader.php index 80ea9b2..f485e48 100644 --- a/lib/SaferpayJson/Container/ResponseHeader.php +++ b/lib/SaferpayJson/Container/ResponseHeader.php @@ -12,7 +12,7 @@ class ResponseHeader * @SerializedName("SpecVersion") * @Type("string") */ - protected $specVersion = '1.2'; + protected $specVersion; /** * @var string diff --git a/lib/SaferpayJson/Container/ReturnUrls.php b/lib/SaferpayJson/Container/ReturnUrls.php index 913ce63..1e94470 100644 --- a/lib/SaferpayJson/Container/ReturnUrls.php +++ b/lib/SaferpayJson/Container/ReturnUrls.php @@ -19,11 +19,18 @@ class ReturnUrls protected $fail; /** - * @var string + * @var string|null * @SerializedName("Abort") */ protected $abort; + public function __construct(string $success, string $fail, string $abort = null) + { + $this->success = $success; + $this->fail = $fail; + $this->abort = $abort; + } + public function getSuccess(): string { return $this->success; @@ -48,12 +55,12 @@ public function setFail(string $fail): self 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/Container/Styling.php b/lib/SaferpayJson/Container/Styling.php index 9493da2..090f9ae 100644 --- a/lib/SaferpayJson/Container/Styling.php +++ b/lib/SaferpayJson/Container/Styling.php @@ -6,19 +6,23 @@ class Styling { + const THEME_DEFAULT = 'DEFAULT'; + const THEME_SIX = 'SIX'; + const THEME_NONE = 'NONE'; + /** - * @var string + * @var string|null * @SerializedName("CssUrl") */ protected $cssUrl; /** - * @var string + * @var string|null * @SerializedName("Theme") */ protected $theme; - public function getCssUrl(): string + public function getCssUrl(): ?string { return $this->cssUrl; } @@ -30,7 +34,7 @@ public function setCssUrl(string $cssUrl): self return $this; } - public function getTheme(): string + public function getTheme(): ?string { return $this->theme; } diff --git a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php index e83d093..50b87f5 100644 --- a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php @@ -3,14 +3,19 @@ namespace Ticketpark\SaferpayJson\Request\PaymentPage; use JMS\Serializer\Annotation\SerializedName; +use Ticketpark\SaferpayJson\Container\AddressForm; +use Ticketpark\SaferpayJson\Container\Authentication; +use Ticketpark\SaferpayJson\Container\CardForm; use Ticketpark\SaferpayJson\Container\Notification; use Ticketpark\SaferpayJson\Container\Payer; use Ticketpark\SaferpayJson\Container\Payment; +use Ticketpark\SaferpayJson\Container\PaymentMethodsOptions; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Container\ReturnUrls; use Ticketpark\SaferpayJson\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 @@ -18,6 +23,7 @@ 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,16 +39,36 @@ 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|null + * @SerializedName("ConfigSet") + */ + protected $configSet; + + /** + * @var string + * @SerializedName("TerminalId") + */ + protected $terminalId; + /** * @var Payment * @SerializedName("Payment") @@ -50,11 +76,41 @@ class InitializeRequest extends Request protected $payment; /** - * @var Payer + * @var array|null + * @SerializedName("PaymentMethods") + */ + protected $paymentMethods; + + /** + * @var PaymentMethodsOptions|null + * @SerializedName("PaymentMethodsOptions") + */ + protected $paymentMethodsOptions; + + /** + * @var Authentication|null + * @SerializedName("Authentication") + */ + protected $authentication; + + /** + * @var array|null + * @SerializedName("Wallets") + */ + protected $wallets; + + /** + * @var Payer|null * @SerializedName("Payer") */ protected $payer; + /** + * @var RegisterAlias|null + * @SerializedName("RegisterAlias") + */ + protected $registerAlias; + /** * @var ReturnUrls * @SerializedName("ReturnUrls") @@ -62,34 +118,78 @@ class InitializeRequest extends Request protected $returnUrls; /** - * @var Notification + * @var Notification|null * @SerializedName("Notification") */ protected $notification; /** - * @var string - * @SerializedName("TerminalId") + * @var Styling|null + * @SerializedName("Styling") */ - protected $terminalId; + protected $styling; /** - * @var array - * @SerializedName("PaymentMethods") + * @var AddressForm|null + * @SerializedName("BillingAddressForm") */ - protected $paymentMethods; + protected $billingAddressForm; /** - * @var RegisterAlias|null - * @SerializedName("RegisterAlias") + * @var AddressForm|null + * @SerializedName("DeliveryAddressForm") */ - protected $registerAlias; + protected $deliveryAddressForm; /** - * @var Styling|null - * @SerializedName("Styling") + * @var CardForm|null + * @SerializedName("CardForm") */ - protected $styling; + protected $cardForm; + + /** + * @var string + * @SerializedName("Condition") + */ + protected $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 getConfigSet(): ?string + { + return $this->configSet; + } + + public function setConfigSet(string $configSet): self + { + $this->configSet = $configSet; + + return $this; + } + + public function getTerminalId(): string + { + return $this->terminalId; + } + + public function setTerminalId(string $terminalId): self + { + $this->terminalId = $terminalId; + + return $this; + } public function getPayment(): Payment { @@ -103,6 +203,54 @@ public function setPayment(Payment $payment): self return $this; } + public function getPaymentMethods(): array + { + return $this->paymentMethods; + } + + public function setPaymentMethods(array $paymentMethods): self + { + $this->paymentMethods = $paymentMethods; + + return $this; + } + + public function getPaymentMethodsOptions(): ?PaymentMethodsOptions + { + return $this->paymentMethodsOptions; + } + + public function setPaymentMethodsOptions(PaymentMethodsOptions $paymentMethodsOptions): self + { + $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; @@ -115,6 +263,18 @@ public function setPayer(Payer $payer): self return $this; } + public function getRegisterAlias(): ?RegisterAlias + { + return $this->registerAlias; + } + + public function setRegisterAlias(RegisterAlias $registerAlias): self + { + $this->registerAlias = $registerAlias; + + return $this; + } + public function getReturnUrls(): ReturnUrls { return $this->returnUrls; @@ -139,50 +299,62 @@ public function setNotification(Notification $notification): self return $this; } - public function getTerminalId(): string + public function getStyling(): ?Styling { - return $this->terminalId; + return $this->styling; } - public function setTerminalId(string $terminalId): self + public function setStyling(Styling $styling): self { - $this->terminalId = $terminalId; + $this->styling = $styling; return $this; } - public function getPaymentMethods(): array + public function getBillingAddressForm(): ?AddressForm { - return $this->paymentMethods; + return $this->billingAddressForm; } - public function setPaymentMethods(array $paymentMethods): self + public function setBillingAddressForm(AddressForm $billingAddressForm): self { - $this->paymentMethods = $paymentMethods; + $this->billingAddressForm = $billingAddressForm; return $this; } - public function getRegisterAlias(): ?RegisterAlias + public function getDeliveryAddressForm(): ?AddressForm { - return $this->registerAlias; + return $this->deliveryAddressForm; } - public function setRegisterAlias(RegisterAlias $registerAlias): self + public function setDeliveryAddressForm(AddressForm $deliveryAddressForm): self { - $this->registerAlias = $registerAlias; + $this->deliveryAddressForm = $deliveryAddressForm; return $this; } - public function getStyling(): ?Styling + public function getCardForm(): ?CardForm { - return $this->styling; + return $this->cardForm; } - public function setStyling(Styling $styling): self + public function setCardForm(CardForm $cardForm): self { - $this->styling = $styling; + $this->cardForm = $cardForm; + + return $this; + } + + public function getCondition(): ?string + { + return $this->condition; + } + + public function setCondition(string $condition): self + { + $this->condition = $condition; return $this; } diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index d080479..d04d61e 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -3,8 +3,8 @@ namespace Ticketpark\SaferpayJson\Request; use Doctrine\Common\Annotations\AnnotationRegistry; -use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Exclude; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\SerializerBuilder; @@ -23,86 +23,46 @@ abstract class Request const ERROR_RESPONSE_CLASS = ErrorResponse::class; /** - * @var string + * @var RequestConfig * @Exclude */ - protected $apiKey; - - /** - * @var string - * @Exclude - */ - protected $apiSecret; - - /** - * @var bool - * @Exclude - */ - protected $test = false; - - /** - * @var \GuzzleHttp\Client - * @Exclude - */ - protected $client; + private $requestConfig; /** * @var RequestHeader * @SerializedName("RequestHeader") + * @Accessor(getter="getRequestHeader") */ - protected $requestHeader; - - public function __construct( - string $apiKey, - string $apiSecret, - bool $test = true - ) { - $this->apiKey = $apiKey; - $this->apiSecret = $apiSecret; - $this->test = $test; - } + private $requestHeader; 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; + $this->requestConfig = $requestConfig; } - public function getApiSecret(): string + public function getRequestConfig(): RequestConfig { - return $this->apiSecret; + return $this->requestConfig; } - public function setApiSecret(string $apiSecret): self + public function setRequestConfig(RequestConfig $requestConfig): self { - $this->apiSecret = $apiSecret; - - return $this; - } - - public function isTest(): bool - { - return $this->test; - } - - public function setTest(bool $test): self - { - $this->test = $test; + $this->requestConfig = $requestConfig; return $this; } public function getRequestHeader(): RequestHeader { + if (null === $this->requestHeader) { + return new RequestHeader( + $this->requestConfig->getCustomerId() + ); + } + return $this->requestHeader; } @@ -113,26 +73,10 @@ public function setRequestHeader(RequestHeader $requestHeader): self return $this; } - 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; - } - public function execute(): ResponseInterface { try { - $response = $this->getClient()->post( + $response = $this->requestConfig->getClient()->post( $this->getUrl(), [ 'headers' => $this->getHeaders(), @@ -150,6 +94,7 @@ public function execute(): ResponseInterface $statusCode = $response->getStatusCode(); if ($statusCode >= 400 && $statusCode < 500) { + print (string) $response->getBody(); exit; return $this->getSerializer()->deserialize( (string) $response->getBody(), self::ERROR_RESPONSE_CLASS, @@ -171,32 +116,36 @@ public function execute(): ResponseInterface ); } - 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..36c5f43 --- /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; + } +} \ No newline at end of file From 04c020a958577550e6bac91a21dec645c9e1db0c Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 12:28:11 +0200 Subject: [PATCH 04/34] Remove debug code --- lib/SaferpayJson/Request/Request.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index d04d61e..73a0e6f 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -94,7 +94,6 @@ public function execute(): ResponseInterface $statusCode = $response->getStatusCode(); if ($statusCode >= 400 && $statusCode < 500) { - print (string) $response->getBody(); exit; return $this->getSerializer()->deserialize( (string) $response->getBody(), self::ERROR_RESPONSE_CLASS, From 2a91242d5fca9e693b9dd760b7a9b2f472586097 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 12:30:52 +0200 Subject: [PATCH 05/34] Fix codestyle --- lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php | 3 +-- lib/SaferpayJson/Request/RequestConfig.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php index 50b87f5..2a9d0ab 100644 --- a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php @@ -158,8 +158,7 @@ public function __construct( string $terminalId, Payment $payment, ReturnUrls $returnUrls - ) - { + ) { $this->terminalId = $terminalId; $this->payment = $payment; $this->returnUrls = $returnUrls; diff --git a/lib/SaferpayJson/Request/RequestConfig.php b/lib/SaferpayJson/Request/RequestConfig.php index 36c5f43..3456124 100644 --- a/lib/SaferpayJson/Request/RequestConfig.php +++ b/lib/SaferpayJson/Request/RequestConfig.php @@ -74,4 +74,4 @@ public function getClient(): Client return $this->client; } -} \ No newline at end of file +} From 3724cb9a8cebd321a784497bc9446d06bb34e075 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 13:53:04 +0200 Subject: [PATCH 06/34] Fix container properties and constants --- lib/SaferpayJson/Container/Authentication.php | 2 +- lib/SaferpayJson/Container/Notification.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/SaferpayJson/Container/Authentication.php b/lib/SaferpayJson/Container/Authentication.php index c4da7c2..d72de13 100644 --- a/lib/SaferpayJson/Container/Authentication.php +++ b/lib/SaferpayJson/Container/Authentication.php @@ -11,7 +11,7 @@ class Authentication const EXEMPTION_TRANSACTION_RISK_ANALYSIS = 'TRANSACTION_RISK_ANALYSIS'; const EXEMPTION_THREEDSCHALLENGE_AVOID = 'AVOID'; - const EXEMPTION_THREEDSCHALLENGE_AVOID = 'FORCE'; + const EXEMPTION_THREEDSCHALLENGE_FORCE = 'FORCE'; /** * @var string diff --git a/lib/SaferpayJson/Container/Notification.php b/lib/SaferpayJson/Container/Notification.php index ef77efd..7f428da 100644 --- a/lib/SaferpayJson/Container/Notification.php +++ b/lib/SaferpayJson/Container/Notification.php @@ -26,7 +26,7 @@ class Notification public function getMerchantEmails(): array { - return $this->merchantEmail; + return $this->merchantEmails; } public function setMerchantEmails(array $merchantEmails): self From 4a800544d0a7181f107f5bb86874c4cc596aaccf Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 30 Apr 2020 14:00:26 +0200 Subject: [PATCH 07/34] Improve descriptions in 1-example-initialize --- example/PaymentPage/1-example-initialize.php | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/example/PaymentPage/1-example-initialize.php b/example/PaymentPage/1-example-initialize.php index 4f618f6..559e33a 100644 --- a/example/PaymentPage/1-example-initialize.php +++ b/example/PaymentPage/1-example-initialize.php @@ -9,8 +9,9 @@ require_once __DIR__ . '/../credentials.php'; +// ----------------------------- // Step 1: -// Initialize the payment page +// Initialize the required payment page data // See https://saferpay.github.io/jsonapi/#Payment_v1_PaymentPage_Initialize $requestConfig = new RequestConfig( @@ -32,12 +33,12 @@ $returnUrls = new Container\ReturnUrls( 'http://www.mysite.ch/success?orderId=12839', - 'http://www.mysite.ch/fail', - 'http://www.mysite.ch/abort' + 'http://www.mysite.ch/fail' ); +// ----------------------------- // Step 2: -// Execute the request +// Create the request with required data $initializeRequest = new InitializeRequest( $requestConfig, @@ -46,26 +47,36 @@ $returnUrls ); -$response = $initializeRequest->execute(); +// Note: More data can be provided to InitializeRequest with setters, +// for example: $initializeRequest->setPayer() +// See Saferpay documentation for available options. +// ----------------------------- // Step 3: -// Check for successful response +// Execute and check for successful response + +$response = $initializeRequest->execute(); + if ($response instanceof ErrorResponse) { die($response->getErrorMessage()); } +// ----------------------------- // Step 4: -// Save the response token, you will need it later to verify the payment +// 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 the payment has been successful. +// On success page and notification url, assert that the payment has been successful. // -> see 2-example-assert.php From febcdf91ebd73b4cf76865758beaebccfa2cfeb4 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Fri, 1 May 2020 11:43:05 +0200 Subject: [PATCH 08/34] Adjust PaymentPage\AssertRequest to work for spec 1.16 --- example/PaymentPage/1-example-initialize.php | 1 - example/PaymentPage/2-example-assert.php | 40 +++-- .../Container/AuthenticationResult.php | 50 ++++++ lib/SaferpayJson/Container/CustomPlan.php | 123 +++++++++++++++ lib/SaferpayJson/Container/DirectDebit.php | 47 ++++++ .../Container/InstallmentPlan.php | 142 ++++++++++++++++++ lib/SaferpayJson/Container/Liability.php | 66 ++++++++ .../MastercardIssuerInstallments.php | 66 ++++++++ lib/SaferpayJson/Container/Payer.php | 19 +++ lib/SaferpayJson/Container/PaymentMeans.php | 16 +- .../Container/RegistrationResult.php | 8 + lib/SaferpayJson/Container/ThreeDs.php | 1 - lib/SaferpayJson/Container/Transaction.php | 96 ++++++++++++ lib/SaferpayJson/Container/Twint.php | 28 ++++ .../Request/PaymentPage/AssertRequest.php | 10 ++ .../Response/PaymentPage/AssertResponse.php | 25 ++- 16 files changed, 700 insertions(+), 38 deletions(-) create mode 100644 lib/SaferpayJson/Container/AuthenticationResult.php create mode 100644 lib/SaferpayJson/Container/CustomPlan.php create mode 100644 lib/SaferpayJson/Container/DirectDebit.php create mode 100644 lib/SaferpayJson/Container/InstallmentPlan.php create mode 100644 lib/SaferpayJson/Container/Liability.php create mode 100644 lib/SaferpayJson/Container/MastercardIssuerInstallments.php create mode 100644 lib/SaferpayJson/Container/Twint.php diff --git a/example/PaymentPage/1-example-initialize.php b/example/PaymentPage/1-example-initialize.php index 559e33a..27cd8ef 100644 --- a/example/PaymentPage/1-example-initialize.php +++ b/example/PaymentPage/1-example-initialize.php @@ -8,7 +8,6 @@ require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; - // ----------------------------- // Step 1: // Initialize the required payment page data diff --git a/example/PaymentPage/2-example-assert.php b/example/PaymentPage/2-example-assert.php index 899c0f9..ded82f1 100644 --- a/example/PaymentPage/2-example-assert.php +++ b/example/PaymentPage/2-example-assert.php @@ -1,8 +1,8 @@ setCustomerId($customerId) - ->setRequestId(uniqid()); - -$response = (new AssertRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setToken($token) - ->execute(); +$requestConfig = new RequestConfig( + $apiKey, + $apiSecret, + $customerId, + true +); +// ----------------------------- // Step 2: -// Check for successful response +// Create the request with required data + +$assertRequest = new AssertRequest( + $requestConfig, + $token, +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +$response = $assertRequest->execute(); if ($response instanceof ErrorResponse) { die($response->getErrorMessage()); @@ -33,6 +44,7 @@ echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId(); -// Step 3: +// ----------------------------- +// Step 4: // Capture the transaction to get the cash flowing. // See ../Transaction/1-example-capture.php diff --git a/lib/SaferpayJson/Container/AuthenticationResult.php b/lib/SaferpayJson/Container/AuthenticationResult.php new file mode 100644 index 0000000..dac342c --- /dev/null +++ b/lib/SaferpayJson/Container/AuthenticationResult.php @@ -0,0 +1,50 @@ +result; + } + + public function setResult(string $result): self + { + $this->result = $result; + + return $this; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function setMessage(string $message): self + { + $this->message = $message; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/CustomPlan.php b/lib/SaferpayJson/Container/CustomPlan.php new file mode 100644 index 0000000..9fdbc31 --- /dev/null +++ b/lib/SaferpayJson/Container/CustomPlan.php @@ -0,0 +1,123 @@ +minimumNumberOfInstallments; + } + + public function setMinimumNumberOfInstallments(int $minimumNumberOfInstallments): self + { + $this->minimumNumberOfInstallments = $minimumNumberOfInstallments; + + return $this; + } + + public function getMaximumNumberOfInstallments(): ?int + { + return $this->maximumNumberOfInstallments; + } + + public function setMaximumNumberOfInstallments(int $maximumNumberOfInstallments): self + { + $this->maximumNumberOfInstallments = $maximumNumberOfInstallments; + + return $this; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function setInterestRate(string $interestRate): self + { + $this->interestRate = $interestRate; + + return $this; + } + + public function getInstallmentFee(): ?InstallmentFee + { + return $this->InstallmentFee; + } + + public function setInstallmentFee(InstallmentFee $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 getTotalAmountDue(): ?Amount + { + return $this->totalAmountDue; + } + + public function setTotalAmountDue(Amount $totalAmountDue): self + { + $this->totalAmountDue = $totalAmountDue; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/DirectDebit.php b/lib/SaferpayJson/Container/DirectDebit.php new file mode 100644 index 0000000..73278bb --- /dev/null +++ b/lib/SaferpayJson/Container/DirectDebit.php @@ -0,0 +1,47 @@ +mandateId; + } + + public function setMandateId(string $mandateId): self + { + $this->mandateId = $mandateId; + + return $this; + } + + public function getCreditorId(): ?string + { + return $this->creditorId; + } + + public function setCreditorId(string $creditorId): self + { + $this->creditorId = $creditorId; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/InstallmentPlan.php b/lib/SaferpayJson/Container/InstallmentPlan.php new file mode 100644 index 0000000..dd0ce54 --- /dev/null +++ b/lib/SaferpayJson/Container/InstallmentPlan.php @@ -0,0 +1,142 @@ +numberOfInstallments; + } + + public function setNumberOfInstallments(int $numberOfInstallments): self + { + $this->numberOfInstallments = $numberOfInstallments; + + return $this; + } + + public function getInterestRate(): ?string + { + return $this->interestRate; + } + + public function setInterestRate(string $interestRate): self + { + $this->interestRate = $interestRate; + + return $this; + } + + public function getInstallmentFee(): ?InstallmentFee + { + return $this->InstallmentFee; + } + + public function setInstallmentFee(InstallmentFee $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/Container/Liability.php b/lib/SaferpayJson/Container/Liability.php new file mode 100644 index 0000000..168dcc7 --- /dev/null +++ b/lib/SaferpayJson/Container/Liability.php @@ -0,0 +1,66 @@ +liabilityShift; + } + + public function setLiabilityShift(bool $liabilityShift): self + { + $this->liabilityShift = $liabilityShift; + + return $this; + } + + public function getLiableEntity(): ?string + { + return $this->liableEntity; + } + + public function setLiableEntity(string $liableEntity): self + { + $this->liableEntity = $liableEntity; + + return $this; + } + + public function getThreeDs(): ?ThreeDs + { + return $this->threeDs; + } + + public function setThreeDs(ThreeDs $threeDs): self + { + $this->threeDs = $threeDs; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php new file mode 100644 index 0000000..bba4c06 --- /dev/null +++ b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php @@ -0,0 +1,66 @@ + + * @SerializedName("InstallmentPlans") + * @Type("array") + */ + protected $installmentPlans; + + /** + * @var CustomPlan + * @SerializedName("CustomPlan") + * @Type("Ticketpark\SaferpayJson\Container\CustomPlan") + */ + protected $customPlan; + + /** + * @var string + * @SerializedName("ReceiptFreeText") + * @Type("string") + */ + protected $receiptFreeText; + + public function getInstallmentPlans(): ?array + { + return $this->installmentPlans; + } + + public function setInstallmentPlans(array $installmentPlans): self + { + $this->installmentPlans = $installmentPlans; + + return $this; + } + + public function getCustomPlan(): ?CustomPlan + { + return $this->customPlan; + } + + public function setCustomPlan(CustomPlan $customPlan): self + { + $this->customPlan = $customPlan; + + return $this; + } + + public function getReceiptFreeText(): ?string + { + return $this->receiptFreeText; + } + + public function setReceiptFreeText(string $receiptFreeText): self + { + $this->receiptFreeText = $receiptFreeText; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/Payer.php b/lib/SaferpayJson/Container/Payer.php index e184a96..b3a3c3f 100644 --- a/lib/SaferpayJson/Container/Payer.php +++ b/lib/SaferpayJson/Container/Payer.php @@ -14,6 +14,13 @@ class Payer */ protected $ipAddress; + /** + * @var string + * @SerializedName("IpLocation") + * @Type("string") + */ + protected $ipLocation; + /** * @var string * @SerializedName("LanguageCode") @@ -47,6 +54,18 @@ public function setIpAddress(string $ipAddress): self return $this; } + public function getIpLocation(): ?string + { + return $this->ipLocation; + } + + public function setIpLocation(string $ipLocation): self + { + $this->ipLocation = $ipLocation; + + return $this; + } + public function getLanguageCode(): string { return $this->languageCode; diff --git a/lib/SaferpayJson/Container/PaymentMeans.php b/lib/SaferpayJson/Container/PaymentMeans.php index 085d0a0..4aede5b 100644 --- a/lib/SaferpayJson/Container/PaymentMeans.php +++ b/lib/SaferpayJson/Container/PaymentMeans.php @@ -46,11 +46,11 @@ class PaymentMeans protected $bankAccount; /** - * @var Alias - * @SerializedName("Alias") - * @Type("Ticketpark\SaferpayJson\Container\Alias") + * @var Twint + * @SerializedName("Twint") + * @Type("Ticketpark\SaferpayJson\Container\Twint") */ - protected $alias; + protected $twint; public function getBrand(): Brand { @@ -112,14 +112,14 @@ public function setBankAccount(BankAccount $bankAccount): self return $this; } - public function getAlias(): Alias + public function getTwint(): ?Twint { - return $this->alias; + return $this->twint; } - public function setAlias(Alias $alias): self + public function setTwint(Twint $twint): self { - $this->alias = $alias; + $this->twint = $twint; return $this; } diff --git a/lib/SaferpayJson/Container/RegistrationResult.php b/lib/SaferpayJson/Container/RegistrationResult.php index 17cfe9c..3731804 100644 --- a/lib/SaferpayJson/Container/RegistrationResult.php +++ b/lib/SaferpayJson/Container/RegistrationResult.php @@ -6,6 +6,7 @@ use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\Alias; use Ticketpark\SaferpayJson\Container\Error; +use Ticketpark\SaferpayJson\Container\Error; class RegistrationResult { @@ -30,6 +31,13 @@ class RegistrationResult */ protected $error; + /** + * @var AuthenticationResult + * @SerializedName("AuthenticationResult") + * @Type("Ticketpark\SaferpayJson\Container\AuthenticationResult") + */ + protected $authenticationResult; + public function isSuccess(): bool { return $this->success; diff --git a/lib/SaferpayJson/Container/ThreeDs.php b/lib/SaferpayJson/Container/ThreeDs.php index 4fadb81..c363ae2 100644 --- a/lib/SaferpayJson/Container/ThreeDs.php +++ b/lib/SaferpayJson/Container/ThreeDs.php @@ -28,7 +28,6 @@ class ThreeDs */ protected $xid; - /** * @var string * @SerializedName("VerificationValue") diff --git a/lib/SaferpayJson/Container/Transaction.php b/lib/SaferpayJson/Container/Transaction.php index cd16b24..f6ac676 100644 --- a/lib/SaferpayJson/Container/Transaction.php +++ b/lib/SaferpayJson/Container/Transaction.php @@ -28,6 +28,13 @@ class Transaction */ protected $id; + /** + * @var string + * @SerializedName("CaptureId") + * @Type("string") + */ + protected $captureId; + /** * @var string * @SerializedName("Date") @@ -56,6 +63,13 @@ class Transaction */ protected $acquirerName; + /** + * @var string + * @SerializedName("SixTransactionReference") + * @Type("string") + */ + protected $sixTransactionReference; + /** * @var string * @SerializedName("AcquirerReference") @@ -63,6 +77,28 @@ class Transaction */ protected $acquirerReference; + /** + * @var string + * @SerializedName("ApprovalCode") + * @Type("string") + */ + protected $approvalCode; + + /** + * @var DirectDebit + * @SerializedName("DirectDebit") + * @Type("Ticketpark\SaferpayJson\Container\DirectDebit") + */ + protected $directDebit; + + /** + * @var Invoice + * @SerializedName("Invoice") + * @Type("Ticketpark\SaferpayJson\Container\Invoice") + */ + protected $invoice; + + public function getType(): string { return $this->type; @@ -96,6 +132,18 @@ public function setId(string $id): self return $this; } + public function getCaptureId(): ?string + { + return $this->captureId; + } + + public function setCaptureId(string $captureId): self + { + $this->captureId = $captureId; + + return $this; + } + public function getDate(): string { return $this->date; @@ -155,4 +203,52 @@ public function setAcquirerReference(string $acquirerReference): self return $this; } + + public function getSixTransactionReference(): ?string + { + return $this->sixTransactionReference; + } + + public function setSixTransactionReference(string $sixTransactionReference): self + { + $this->sixTransactionReference = $sixTransactionReference; + + return $this; + } + + public function getApprovalCode(): ?string + { + return $this->approvalCode; + } + + public function setApprovalCode(string $approvalCode): self + { + $this->approvalCode = $approvalCode; + + return $this; + } + + public function getDirectDebit(): ?DirectDebit + { + return $this->directDebit; + } + + public function setDirectDebit(DirectDebit $directDebit): self + { + $this->directDebit = $directDebit; + + return $this; + } + + public function getInvoice(): ?Invoice + { + return $this->invoice; + } + + public function setInvoice(Invoice $invoice): self + { + $this->invoice = $invoice; + + return $this; + } } diff --git a/lib/SaferpayJson/Container/Twint.php b/lib/SaferpayJson/Container/Twint.php new file mode 100644 index 0000000..77ee963 --- /dev/null +++ b/lib/SaferpayJson/Container/Twint.php @@ -0,0 +1,28 @@ +certificateExpirationDate; + } + + public function setCertificateExpirationDate(\DateTime $certificateExpirationDate): self + { + $this->certificateExpirationDate = $certificateExpirationDate; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php b/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php index cd8b400..3efd197 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php @@ -5,6 +5,7 @@ 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 @@ -20,6 +21,15 @@ class AssertRequest extends Request */ protected $token; + public function __construct( + RequestConfig $requestConfig, + string $token + ) { + $this->token = $token; + + parent::__construct($requestConfig); + } + public function getToken(): string { return $this->token; diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index 87bf696..2570910 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -43,11 +43,11 @@ class AssertResponse extends Response protected $registrationResult; /** - * @var ThreeDs - * @SerializedName("ThreeDs") - * @Type("Ticketpark\SaferpayJson\Container\ThreeDs") + * @var Liability + * @SerializedName("Liability") + * @Type("Ticketpark\SaferpayJson\Container\Liability") */ - protected $threeDs; + protected $liability; /** * @var Dcc @@ -56,6 +56,13 @@ class AssertResponse extends Response */ protected $dcc; + /** + * @var MastercardIssuerInstallments + * @SerializedName("MastercardIssuerInstallments") + * @Type("Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments") + */ + protected $mastercardIssuerInstallments; + public function getTransaction(): Transaction { return $this->transaction; @@ -96,16 +103,6 @@ public function setRegistrationResult(RegistrationResult $registrationResult): v $this->registrationResult = $registrationResult; } - public function getThreeDs(): ThreeDs - { - return $this->threeDs; - } - - public function setThreeDs(ThreeDs $threeDs): void - { - $this->threeDs = $threeDs; - } - public function getDcc(): Dcc { return $this->dcc; From ff151471e92da294c1ba5ccc5736910429851ac9 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Fri, 1 May 2020 12:07:06 +0200 Subject: [PATCH 09/34] Adjust Transaction\CaptureRequest to work for spec 1.16 --- example/PaymentPage/3-example-recurring.php | 50 --------- example/Transaction/1-example-capture.php | 40 ++++--- lib/SaferpayJson/Container/Billpay.php | 27 +++++ lib/SaferpayJson/Container/ChosenPlan.php | 11 ++ .../Container/InstallmentPlan.php | 8 +- lib/SaferpayJson/Container/Marketplace.php | 62 +++++++++++ .../MastercardIssuerInstallments.php | 21 +++- .../Container/PendingNotification.php | 44 ++++++++ .../Request/Transaction/CaptureRequest.php | 105 ++++++++++++++++++ .../Response/Transaction/CaptureResponse.php | 54 +++++++-- 10 files changed, 341 insertions(+), 81 deletions(-) delete mode 100644 example/PaymentPage/3-example-recurring.php create mode 100644 lib/SaferpayJson/Container/Billpay.php create mode 100644 lib/SaferpayJson/Container/ChosenPlan.php create mode 100644 lib/SaferpayJson/Container/Marketplace.php create mode 100644 lib/SaferpayJson/Container/PendingNotification.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/Transaction/1-example-capture.php b/example/Transaction/1-example-capture.php index ca21098..d6e145c 100644 --- a/example/Transaction/1-example-capture.php +++ b/example/Transaction/1-example-capture.php @@ -1,39 +1,51 @@ setCustomerId($customerId) - ->setRequestId(uniqid()); +$requestConfig = new RequestConfig( + $apiKey, + $apiSecret, + $customerId, + true +); $transactionReference = (new Container\TransactionReference()) ->setTransactionId($transactionId); -$response = (new CaptureRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->execute(); - +// ----------------------------- // Step 2: -// Check for successful response +// Create the request with required data + +$captureRequest = new CaptureRequest( + $requestConfig, + $transactionReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +$response = $captureRequest->execute(); if ($response instanceof ErrorResponse) { die($response->getErrorMessage()); } -echo 'The transaction has successfully been captured! Transaction-ID: ' . $response->getTransactionId(); +echo 'The transaction has successfully been captured! Capture-Status: ' . $response->getStatus(); // You have now fully completed a successful payment :) \ No newline at end of file diff --git a/lib/SaferpayJson/Container/Billpay.php b/lib/SaferpayJson/Container/Billpay.php new file mode 100644 index 0000000..3a49cf2 --- /dev/null +++ b/lib/SaferpayJson/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/ChosenPlan.php b/lib/SaferpayJson/Container/ChosenPlan.php new file mode 100644 index 0000000..263f0f1 --- /dev/null +++ b/lib/SaferpayJson/Container/ChosenPlan.php @@ -0,0 +1,11 @@ +InstallmentFee; + return $this->installmentFee; } - public function setInstallmentFee(InstallmentFee $InstallmentFee): self + public function setInstallmentFee(InstallmentFee $installmentFee): self { - $this->InstallmentFee = $InstallmentFee; + $this->installmentFee = $installmentFee; return $this; } diff --git a/lib/SaferpayJson/Container/Marketplace.php b/lib/SaferpayJson/Container/Marketplace.php new file mode 100644 index 0000000..51fd9df --- /dev/null +++ b/lib/SaferpayJson/Container/Marketplace.php @@ -0,0 +1,62 @@ +submerchantId; + } + + public function setSubmerchantId(string $submerchantId): self + { + $this->submerchantId = $submerchantId; + + return $this; + } + + 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/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php index bba4c06..532af57 100644 --- a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php +++ b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php @@ -8,7 +8,7 @@ class MastercardIssuerInstallments { /** - * @var array + * @var array * @SerializedName("InstallmentPlans") * @Type("array") */ @@ -28,6 +28,13 @@ class MastercardIssuerInstallments */ protected $receiptFreeText; + /** + * @var ChosenPlan + * @SerializedName("ChosenPlan") + * @Type("array") + */ + protected $chosenPlan; + public function getInstallmentPlans(): ?array { return $this->installmentPlans; @@ -63,4 +70,16 @@ public function setReceiptFreeText(string $receiptFreeText): self return $this; } + + public function getChosenPlan(): ?ChosenPlan + { + return $this->chosenPlan; + } + + public function setChosenPlan(ChosenPlan $chosenPlan): self + { + $this->chosenPlan = $chosenPlan; + + return $this; + } } diff --git a/lib/SaferpayJson/Container/PendingNotification.php b/lib/SaferpayJson/Container/PendingNotification.php new file mode 100644 index 0000000..10e3001 --- /dev/null +++ b/lib/SaferpayJson/Container/PendingNotification.php @@ -0,0 +1,44 @@ + + * @SerializedName("MerchantEmails") + */ + protected $merchantEmails = []; + + /** + * @var string|null + * @SerializedName("NotifyUrl") + */ + protected $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/Request/Transaction/CaptureRequest.php b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php index 6bee783..3e47ddc 100644 --- a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php @@ -3,9 +3,15 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; +use Ticketpark\SaferpayJson\Container\Amount; +use Ticketpark\SaferpayJson\Container\Billpay; +use Ticketpark\SaferpayJson\Container\Marketplace; +use Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments; +use Ticketpark\SaferpayJson\Container\PendingNotification; use Ticketpark\SaferpayJson\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 @@ -21,6 +27,45 @@ class CaptureRequest extends Request */ protected $transactionReference; + /** + * @var Amount + * @SerializedName("Amount") + */ + protected $amount; + + /** + * @var Billpay + * @SerializedName("Billpay") + */ + protected $billpay; + + /** + * @var PendingNotification + * @SerializedName("PendingNotification") + */ + protected $pendingNotification; + + /** + * @var Marketplace + * @SerializedName("Marketplace") + */ + protected $marketplace; + + /** + * @var MastercardIssuerInstallments + * @SerializedName("MastercardIssuerInstallments") + */ + protected $mastercardIssuerInstallments; + + public function __construct( + RequestConfig $requestConfig, + TransactionReference $transactionReference + ) { + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } + public function getTransactionReference(): TransactionReference { return $this->transactionReference; @@ -32,4 +77,64 @@ 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; + } } diff --git a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php index 3d52eec..2f378bc 100644 --- a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php @@ -9,6 +9,9 @@ class CaptureResponse extends Response { + const STATUS_PENDING = 'PENDING'; + const STATUS_CAPTURED = 'CAPTURED'; + /** * @var string * @SerializedName("TransactionId") @@ -18,10 +21,17 @@ class CaptureResponse extends Response /** * @var string - * @SerializedName("OrderId") + * @SerializedName("CaptureId") * @Type("string") */ - protected $orderId; + protected $captureId; + + /** + * @var string + * @SerializedName("Statis") + * @Type("string") + */ + protected $status; /** * @var string @@ -37,43 +47,63 @@ class CaptureResponse extends Response */ protected $invoice; - public function getTransactionId(): string + public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): void + public function setTransactionId(string $transactionId): self { $this->transactionId = $transactionId; + + return $this; } - public function getOrderId(): string + public function getCaptureId(): ?string { - return $this->orderId; + return $this->captureId; } - public function setOrderId(string $orderId): void + public function setCaptureId(string $captureId): self { - $this->orderId = $orderId; + $this->captureId = $captureId; + + return $this; } - public function getDate(): string + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(string $status): self + { + $this->status = $status; + + return $this; + } + + public function getDate(): ?string { return $this->date; } - public function setDate(string $date): void + public function setDate(string $date): self { $this->date = $date; + + return $this; } - public function getInvoice(): Invoice + public function getInvoice(): ?Invoice { return $this->invoice; } - public function setInvoice(Invoice $invoice): void + public function setInvoice(Invoice $invoice): self { $this->invoice = $invoice; + + return $this; } } From d789202bf093c242a71b4e9c8f13947d0a97a1ea Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Fri, 1 May 2020 16:04:52 +0200 Subject: [PATCH 10/34] Adjust Transaction\RefundRequest to work for spec 1.16 --- example/Transaction/3-example-refund.php | 60 ++++++++------ .../Container/CaptureReference.php | 80 +++++++++++++++++++ lib/SaferpayJson/Container/Refund.php | 5 ++ .../Request/Transaction/RefundRequest.php | 48 +++++++++-- 4 files changed, 161 insertions(+), 32 deletions(-) create mode 100644 lib/SaferpayJson/Container/CaptureReference.php diff --git a/example/Transaction/3-example-refund.php b/example/Transaction/3-example-refund.php index 579413a..5123400 100644 --- a/example/Transaction/3-example-refund.php +++ b/example/Transaction/3-example-refund.php @@ -1,46 +1,58 @@ setCustomerId($customerId) - ->setRequestId(uniqid()); +$requestConfig = new RequestConfig( + $apiKey, + $apiSecret, + $customerId, + true +); -$transactionReference = (new Container\TransactionReference()) - ->setTransactionId($transactionId); +$captureReference = (new Container\CaptureReference()) + ->setCaptureId($captureId); -$amount = (new Container\Amount()) - ->setCurrencyCode('CHF') - ->setValue(5000); // amount in cents +$amount = new Container\Amount( + 2000, + 'CHF' +); -$refund = (new Container\Refund()) - ->setAmount($amount); - -$response = (new RefundRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->setRefund($refund) - ->execute(); +$refund = new Container\Refund($amount); +// ----------------------------- // Step 2: -// Check for successful response +// Create the request with required data + +$refundRequest = new RefundRequest( + $requestConfig, + $refund, + $captureReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +$response = $refundRequest->execute(); -/** @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/lib/SaferpayJson/Container/CaptureReference.php b/lib/SaferpayJson/Container/CaptureReference.php new file mode 100644 index 0000000..8d5c0fd --- /dev/null +++ b/lib/SaferpayJson/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/Container/Refund.php b/lib/SaferpayJson/Container/Refund.php index 2711f53..478065a 100644 --- a/lib/SaferpayJson/Container/Refund.php +++ b/lib/SaferpayJson/Container/Refund.php @@ -28,6 +28,11 @@ class Refund */ protected $description; + public function __construct(Amount $amount) + { + $this->amount = $amount; + } + public function getAmount(): Amount { return $this->amount; diff --git a/lib/SaferpayJson/Request/Transaction/RefundRequest.php b/lib/SaferpayJson/Request/Transaction/RefundRequest.php index 46f96dc..cf1eb87 100644 --- a/lib/SaferpayJson/Request/Transaction/RefundRequest.php +++ b/lib/SaferpayJson/Request/Transaction/RefundRequest.php @@ -3,10 +3,13 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; +use Ticketpark\SaferpayJson\Container\CaptureReference; +use Ticketpark\SaferpayJson\Container\PendingNotification; use Ticketpark\SaferpayJson\Container\Refund; use Ticketpark\SaferpayJson\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 @@ -23,12 +26,29 @@ class RefundRequest extends Request protected $refund; /** - * @var TransactionReference - * @SerializedName("TransactionReference") + * @var CaptureReference + * @SerializedName("CaptureReference") */ - protected $transactionReference; + protected $captureReference; - public function getRefund(): Refund + /** + * @var PendingNotification + * @SerializedName("PendingNotification") + */ + protected $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,14 +60,26 @@ public function setRefund(Refund $refund): self return $this; } - public function getTransactionReference(): TransactionReference + public function getCaptureReference(): ?CaptureReference + { + return $this->captureReference; + } + + public function setCaptureReference(CaptureReference $captureReference): self + { + $this->captureReference = $captureReference; + + return $this; + } + + public function getPendingNotification(): ?PendingNotification { - return $this->transactionReference; + return $this->pendingNotification; } - public function setTransactionReference(TransactionReference $transactionReference): self + public function setPendingNotification(PendingNotification $pendingNotification): self { - $this->transactionReference = $transactionReference; + $this->pendingNotification = $pendingNotification; return $this; } From 7aa76dd517f0a17b970d8587eb6b9faf06feaf9f Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Fri, 1 May 2020 16:05:03 +0200 Subject: [PATCH 11/34] Adjust Transaction\CancelRequest to work for spec 1.16 --- example/Transaction/1-example-capture.php | 4 +-- example/Transaction/2-example-cancel.php | 33 ++++++++++++------- .../Request/Transaction/CancelRequest.php | 10 ++++++ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/example/Transaction/1-example-capture.php b/example/Transaction/1-example-capture.php index d6e145c..d696a1a 100644 --- a/example/Transaction/1-example-capture.php +++ b/example/Transaction/1-example-capture.php @@ -10,7 +10,7 @@ // A transaction id you received with a successful assert request (see ../PaymentPage/2-example-assert.php) -$transactionId = 'Y4EMlvbGhK3YUAS7l7fObQn8YKAb'; +$transactionId = 'xxx'; // ----------------------------- // Step 1: @@ -46,6 +46,6 @@ die($response->getErrorMessage()); } -echo 'The transaction has successfully been captured! Capture-Status: ' . $response->getStatus(); +echo 'The transaction has successfully been captured! Capture-Id: ' . $response->getCaptureId(); // 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 index acb2237..c213b33 100644 --- a/example/Transaction/2-example-cancel.php +++ b/example/Transaction/2-example-cancel.php @@ -11,24 +11,35 @@ $transactionId = 'xxx'; +// ----------------------------- // Step 1: -// Prepare the cancel request -// https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Transaction_Cancel +// Prepare the capture request +// https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Transaction_Capture -$requestHeader = (new Container\RequestHeader()) - ->setCustomerId($customerId) - ->setRequestId(uniqid()); +$requestConfig = new RequestConfig( + $apiKey, + $apiSecret, + $customerId, + true +); $transactionReference = (new Container\TransactionReference()) ->setTransactionId($transactionId); -$response = (new CancelRequest($apiKey, $apiSecret)) - ->setRequestHeader($requestHeader) - ->setTransactionReference($transactionReference) - ->execute(); - +// ----------------------------- // Step 2: -// Check for successful response +// Create the request with required data + +$cancelRequest = new CancelRequest( + $requestConfig, + $transactionReference +); + +// ----------------------------- +// Step 3: +// Execute and check for successful response + +$response = $cancelRequest->execute(); if ($response instanceof ErrorResponse) { die($response->getErrorMessage()); diff --git a/lib/SaferpayJson/Request/Transaction/CancelRequest.php b/lib/SaferpayJson/Request/Transaction/CancelRequest.php index c0e481f..0840f3c 100644 --- a/lib/SaferpayJson/Request/Transaction/CancelRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CancelRequest.php @@ -6,6 +6,7 @@ use Ticketpark\SaferpayJson\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 @@ -21,6 +22,15 @@ class CancelRequest extends Request */ protected $transactionReference; + public function __construct( + RequestConfig $requestConfig, + TransactionReference $transactionReference + ) { + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } + public function getTransactionReference(): TransactionReference { return $this->transactionReference; From 5925b92e5f6425f5690df9691910e85aa299f53d Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 12:50:34 +0200 Subject: [PATCH 12/34] Adjust Transaction\AuthorizeReferencedRequest to work for spec 1.16 --- ...-example-assert.php => example-assert.php} | 6 +- ...-initialize.php => example-initialize.php} | 8 +-- .../example-authorize-referenced.php | 67 +++++++++++++++++++ ...-example-cancel.php => example-cancel.php} | 2 +- ...xample-capture.php => example-capture.php} | 6 +- ...-example-refund.php => example-refund.php} | 2 +- lib/SaferpayJson/Container/Payment.php | 3 +- .../AuthorizeReferencedRequest.php | 52 ++++++++++++++ .../Transaction/AuthorizeDirectRequest.php | 48 ++++++++++++- .../AuthorizeReferencedResponse.php | 40 +++++++++++ .../Transaction/AuthorizeDirectResponse.php | 39 +++++++++++ 11 files changed, 258 insertions(+), 15 deletions(-) rename example/PaymentPage/{2-example-assert.php => example-assert.php} (86%) rename example/PaymentPage/{1-example-initialize.php => example-initialize.php} (94%) create mode 100644 example/Transaction/example-authorize-referenced.php rename example/Transaction/{2-example-cancel.php => example-cancel.php} (96%) rename example/Transaction/{1-example-capture.php => example-capture.php} (88%) rename example/Transaction/{3-example-refund.php => example-refund.php} (97%) diff --git a/example/PaymentPage/2-example-assert.php b/example/PaymentPage/example-assert.php similarity index 86% rename from example/PaymentPage/2-example-assert.php rename to example/PaymentPage/example-assert.php index ded82f1..0cc23e2 100644 --- a/example/PaymentPage/2-example-assert.php +++ b/example/PaymentPage/example-assert.php @@ -7,7 +7,7 @@ require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; -// A token you received after initializing a payment page (see 1-example-assert.php) +// A token you received after initializing a payment page (see example-assert.php) $token = 'xxx'; @@ -42,9 +42,9 @@ die($response->getErrorMessage()); } -echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId(); +echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId()."\n"; // ----------------------------- // Step 4: // Capture the transaction to get the cash flowing. -// See ../Transaction/1-example-capture.php +// See ../Transaction/example-capture.php diff --git a/example/PaymentPage/1-example-initialize.php b/example/PaymentPage/example-initialize.php similarity index 94% rename from example/PaymentPage/1-example-initialize.php rename to example/PaymentPage/example-initialize.php index 27cd8ef..d99162f 100644 --- a/example/PaymentPage/1-example-initialize.php +++ b/example/PaymentPage/example-initialize.php @@ -25,10 +25,8 @@ 'CHF' ); -$payment = new Container\Payment( - $amount, - 'Order No. 12839' -); +$payment = new Container\Payment($amount); +$payment->setDescription('Order No. 12839'); $returnUrls = new Container\ReturnUrls( 'http://www.mysite.ch/success?orderId=12839', @@ -78,4 +76,4 @@ // ----------------------------- // Step 7: // On success page and notification url, assert that the payment has been successful. -// -> see 2-example-assert.php +// -> see example-assert.php diff --git a/example/Transaction/example-authorize-referenced.php b/example/Transaction/example-authorize-referenced.php new file mode 100644 index 0000000..89f9f94 --- /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 + +$response = $authorizeReferencedRequest->execute(); + +if ($response instanceof ErrorResponse) { + die($response->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/2-example-cancel.php b/example/Transaction/example-cancel.php similarity index 96% rename from example/Transaction/2-example-cancel.php rename to example/Transaction/example-cancel.php index c213b33..b25db6c 100644 --- a/example/Transaction/2-example-cancel.php +++ b/example/Transaction/example-cancel.php @@ -7,7 +7,7 @@ require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; -// A transaction id you received with a successful assert request (see ../PaymentPage/2-example-assert.php) +// A transaction id you received with a successful assert request (see ../PaymentPage/example-assert.php) $transactionId = 'xxx'; diff --git a/example/Transaction/1-example-capture.php b/example/Transaction/example-capture.php similarity index 88% rename from example/Transaction/1-example-capture.php rename to example/Transaction/example-capture.php index d696a1a..660657f 100644 --- a/example/Transaction/1-example-capture.php +++ b/example/Transaction/example-capture.php @@ -8,7 +8,7 @@ require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; -// A transaction id you received with a successful assert request (see ../PaymentPage/2-example-assert.php) +// A transaction id you received with a successful assert request (see ../PaymentPage/example-assert.php) $transactionId = 'xxx'; @@ -43,9 +43,11 @@ $response = $captureRequest->execute(); if ($response instanceof ErrorResponse) { + var_dump($response); exit; + die($response->getErrorMessage()); } -echo 'The transaction has successfully been captured! Capture-Id: ' . $response->getCaptureId(); +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/3-example-refund.php b/example/Transaction/example-refund.php similarity index 97% rename from example/Transaction/3-example-refund.php rename to example/Transaction/example-refund.php index 5123400..f77441f 100644 --- a/example/Transaction/3-example-refund.php +++ b/example/Transaction/example-refund.php @@ -8,7 +8,7 @@ require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; -// A capture id you receive with a successful capture request (see ../PaymentPage/3-example-capture.php) +// A capture id you receive with a successful capture request (see ../PaymentPage/example-capture.php) $captureId = 'xxx'; diff --git a/lib/SaferpayJson/Container/Payment.php b/lib/SaferpayJson/Container/Payment.php index b71ddc8..c9c3ea1 100644 --- a/lib/SaferpayJson/Container/Payment.php +++ b/lib/SaferpayJson/Container/Payment.php @@ -54,10 +54,9 @@ class Payment */ protected $installment; - public function __construct(Amount $amount, string $description) + public function __construct(Amount $amount) { $this->amount = $amount; - $this->description = $description; } public function getAmount(): Amount diff --git a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php index cdef595..c4f9ee7 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php @@ -3,10 +3,12 @@ namespace Ticketpark\SaferpayJson\Request\PaymentPage; use JMS\Serializer\Annotation\SerializedName; +use Ticketpark\SaferpayJson\Container\Authentication; use Ticketpark\SaferpayJson\Container\Payment; use Ticketpark\SaferpayJson\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\PaymentPage\AuthorizeReferencedResponse; class AuthorizeReferencedRequest extends Request @@ -34,6 +36,32 @@ class AuthorizeReferencedRequest extends Request */ protected $transactionReference; + /** + * @var Authentication + * @SerializedName("Authentication") + */ + protected $authentication; + + /** + * @var bool + * @SerializedName("SuppressDcc") + */ + protected $suppressDcc; + + public function __construct( + RequestConfig $requestConfig, + string $terminalId, + Payment $payment, + TransactionReference $transactionReference + ) + { + $this->terminalId = $terminalId; + $this->payment = $payment; + $this->transactionReference = $transactionReference; + + parent::__construct($requestConfig); + } + public function getTerminalId(): string { return $this->terminalId; @@ -69,4 +97,28 @@ public function setPayment(Payment $payment): self 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; + } } diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php index 9bd3ea3..2bdaf85 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -3,10 +3,12 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; +use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Container\Payment; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\Transaction\AuthorizeDirectResponse; /** @@ -29,16 +31,36 @@ class AuthorizeDirectRequest extends Request /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ protected $paymentMeans; + /** + * @var RegisterAlias + * @SerializedName("RegisterAlias") + */ + protected $registerAlias; + + /** + * @var Payer + * @SerializedName("Payer") + */ + protected $payer; + /** * @var string * @SerializedName("TerminalId") */ protected $terminalId; + 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 getPayment(): Payment { return $this->payment; @@ -74,4 +96,28 @@ public function setTerminalId(string $terminalId): self 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; + } } diff --git a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php index 5b14022..4a62b35 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php @@ -4,6 +4,8 @@ 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\Transaction; use Ticketpark\SaferpayJson\Response\Response; @@ -24,6 +26,20 @@ class AuthorizeReferencedResponse extends Response */ protected $paymentMeans; + /** + * @var Payer + * @SerializedName("Payer") + * @Type("Ticketpark\SaferpayJson\Container\Payer") + */ + protected $payer; + + /** + * @var Dcc + * @SerializedName("Dcc") + * @Type("Ticketpark\SaferpayJson\Container\Dcc") + */ + protected $dcc; + public function getTransaction(): Transaction { return $this->transaction; @@ -43,4 +59,28 @@ public function setPaymentMeans(PaymentMeans $paymentMeans): void { $this->paymentMeans = $paymentMeans; } + + public function getPayer(): ?Payer + { + return $this->payer; + } + + public function setPayer(Payer $payer): self + { + $this->payer = $payer; + + return $this; + } + + public function getDcc(): ?Dcc + { + return $this->dcc; + } + + public function setDcc(Dcc $dcc): self + { + $this->dcc = $dcc; + + return $this; + } } diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index eabb1c6..f3d42e7 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -5,6 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; @@ -28,6 +29,20 @@ class AuthorizeDirectResponse extends Response */ protected $paymentMeans; + /** + * @var RegisterAlias + * @SerializedName("RegisterAlias") + * @Type("Ticketpark\SaferpayJson\Container\RegisterAlias") + */ + protected $registerAlias; + + /** + * @var Payer + * @SerializedName("Payer") + * @Type("Ticketpark\SaferpayJson\Container\Payer") + */ + protected $payer; + public function getTransaction(): Transaction { return $this->transaction; @@ -47,4 +62,28 @@ public function setPaymentMeans(PaymentMeans $paymentMeans): void { $this->paymentMeans = $paymentMeans; } + + 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; + } } From 029fda9983468555e27ecc655679dcce6eb8dfc5 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 13:23:25 +0200 Subject: [PATCH 13/34] Bump version of Saferpay API to 1.17 --- lib/SaferpayJson/Container/RequestHeader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Container/RequestHeader.php index e46eed6..f45fae1 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Container/RequestHeader.php @@ -10,7 +10,7 @@ class RequestHeader * @var string * @SerializedName("SpecVersion") */ - protected $specVersion = '1.16'; + protected $specVersion = '1.17'; /** * @var string From c2e79484b3c1fe2f39fad0526e99afece5cfa36a Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 13:23:47 +0200 Subject: [PATCH 14/34] Adjust SecureCardData\AliasInsertRequest to work for spec 1.16 --- example/SecureAliasStore/1-example-insert.php | 51 ---- .../SecureCardData/example-alias-insert.php | 71 ++++++ .../example-assert.php} | 2 +- .../example-delete.php} | 2 +- .../example-insert-direct.php} | 2 +- lib/SaferpayJson/Container/Redirect.php | 47 ++++ .../SecureAliasStore/InsertRequest.php | 119 ---------- .../SecureCardData/AliasInsertRequest.php | 221 ++++++++++++++++++ .../AssertInsertRequest.php | 4 +- .../DeleteRequest.php | 4 +- .../InsertDirectRequest.php | 4 +- .../SecureAliasStore/InsertResponse.php | 61 ----- .../SecureCardData/AliasInsertResponse.php | 83 +++++++ .../AssertInsertResponse.php | 2 +- .../DeleteResponse.php | 2 +- .../InsertDirectResponse.php | 2 +- .../AssertInsertRequestTest.php | 4 +- .../SecureAliasStore/DeleteRequestTest.php | 4 +- .../InsertDirectRequestTest.php | 4 +- .../SecureAliasStore/InsertRequestTest.php | 10 +- 20 files changed, 445 insertions(+), 254 deletions(-) delete mode 100644 example/SecureAliasStore/1-example-insert.php create mode 100644 example/SecureCardData/example-alias-insert.php rename example/{SecureAliasStore/2-example-assert.php => SecureCardData/example-assert.php} (92%) rename example/{SecureAliasStore/4-example-delete.php => SecureCardData/example-delete.php} (93%) rename example/{SecureAliasStore/3-example-insert-direct.php => SecureCardData/example-insert-direct.php} (93%) create mode 100644 lib/SaferpayJson/Container/Redirect.php delete mode 100755 lib/SaferpayJson/Request/SecureAliasStore/InsertRequest.php create mode 100755 lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php rename lib/SaferpayJson/Request/{SecureAliasStore => SecureCardData}/AssertInsertRequest.php (82%) rename lib/SaferpayJson/Request/{SecureAliasStore => SecureCardData}/DeleteRequest.php (83%) rename lib/SaferpayJson/Request/{SecureAliasStore => SecureCardData}/InsertDirectRequest.php (90%) delete mode 100755 lib/SaferpayJson/Response/SecureAliasStore/InsertResponse.php create mode 100755 lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php rename lib/SaferpayJson/Response/{SecureAliasStore => SecureCardData}/AssertInsertResponse.php (94%) rename lib/SaferpayJson/Response/{SecureAliasStore => SecureCardData}/DeleteResponse.php (66%) rename lib/SaferpayJson/Response/{SecureAliasStore => SecureCardData}/InsertDirectResponse.php (94%) 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/SecureCardData/example-alias-insert.php b/example/SecureCardData/example-alias-insert.php new file mode 100644 index 0000000..200753e --- /dev/null +++ b/example/SecureCardData/example-alias-insert.php @@ -0,0 +1,71 @@ +execute(); + +if ($response instanceof ErrorResponse) { + die($response->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-assert.php diff --git a/example/SecureAliasStore/2-example-assert.php b/example/SecureCardData/example-assert.php similarity index 92% rename from example/SecureAliasStore/2-example-assert.php rename to example/SecureCardData/example-assert.php index 872172c..4b9b914 100644 --- a/example/SecureAliasStore/2-example-assert.php +++ b/example/SecureCardData/example-assert.php @@ -1,7 +1,7 @@ redirectUrl; + } + + public function setRedirectUrl(string $redirectUrl): self + { + $this->redirectUrl = $redirectUrl; + + return $this; + } + + public function isPaymentMeansRequired(): ?bool + { + return $this->paymentMeansRequired; + } + + public function setPaymentMeansRequired(bool $paymentMeansRequired): self + { + $this->paymentMeansRequired = $paymentMeansRequired; + + 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/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php new file mode 100755 index 0000000..9958ed1 --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -0,0 +1,221 @@ + + * @SerializedName("PaymentMethods") + */ + protected $paymentMethods; + + /** + * @var CardForm + * @SerializedName("CardForm") + */ + protected $cardForm; + + /** + * @var PaymentMeans + * @SerializedName("PaymentMeans") + */ + protected $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; + } +} diff --git a/lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php similarity index 82% rename from lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php rename to lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php index 17c1f66..d45e1c5 100755 --- a/lib/SaferpayJson/Request/SecureAliasStore/AssertInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php @@ -1,11 +1,11 @@ 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/AliasInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php new file mode 100755 index 0000000..85e0814 --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php @@ -0,0 +1,83 @@ +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 isRedirectRequired(): ?bool + { + return $this->redirectRequired; + } + + public function setRedirectRequired(bool $redirectRequired): self + { + $this->redirectRequired = $redirectRequired; + + return $this; + } + + public function getRedirect(): ?Redirect + { + return $this->redirect; + } + + public function setRedirect(Redirect $redirect): self + { + $this->redirect = $redirect; + + return $this; + } +} diff --git a/lib/SaferpayJson/Response/SecureAliasStore/AssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php similarity index 94% rename from lib/SaferpayJson/Response/SecureAliasStore/AssertInsertResponse.php rename to lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php index 1eca3a0..81264d2 100755 --- a/lib/SaferpayJson/Response/SecureAliasStore/AssertInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php @@ -1,6 +1,6 @@ Date: Sun, 3 May 2020 13:38:49 +0200 Subject: [PATCH 15/34] Adjust SecureCardData\AliasInsertAssertRequest to work for spec 1.17 --- .../example-alias-insert-assert.php | 45 ++++++++++++ .../SecureCardData/example-alias-insert.php | 2 +- example/SecureCardData/example-assert.php | 34 --------- lib/SaferpayJson/Container/Authentication.php | 53 -------------- lib/SaferpayJson/Container/Check.php | 44 ------------ lib/SaferpayJson/Container/CheckResult.php | 66 ++++++++++++++++++ .../Container/HolderAuthentication.php | 69 +++++++++++++++++++ .../AuthorizeReferencedRequest.php | 8 +-- .../Request/PaymentPage/InitializeRequest.php | 8 +-- ...quest.php => AliasAssertInsertRequest.php} | 14 +++- .../SecureCardData/AliasInsertRequest.php | 8 +-- ...onse.php => AliasAssertInsertResponse.php} | 9 ++- .../AssertInsertRequestTest.php | 10 +-- 13 files changed, 217 insertions(+), 153 deletions(-) create mode 100644 example/SecureCardData/example-alias-insert-assert.php delete mode 100644 example/SecureCardData/example-assert.php delete mode 100644 lib/SaferpayJson/Container/Authentication.php delete mode 100644 lib/SaferpayJson/Container/Check.php create mode 100644 lib/SaferpayJson/Container/CheckResult.php create mode 100644 lib/SaferpayJson/Container/HolderAuthentication.php rename lib/SaferpayJson/Request/SecureCardData/{AssertInsertRequest.php => AliasAssertInsertRequest.php} (60%) rename lib/SaferpayJson/Response/SecureCardData/{AssertInsertResponse.php => AliasAssertInsertResponse.php} (82%) diff --git a/example/SecureCardData/example-alias-insert-assert.php b/example/SecureCardData/example-alias-insert-assert.php new file mode 100644 index 0000000..890ed34 --- /dev/null +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -0,0 +1,45 @@ +execute(); + +if ($response instanceof ErrorResponse) { + die($response->getErrorMessage()); +} + +echo 'The insert has been successful! Insert alias: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/SecureCardData/example-alias-insert.php b/example/SecureCardData/example-alias-insert.php index 200753e..d87e776 100644 --- a/example/SecureCardData/example-alias-insert.php +++ b/example/SecureCardData/example-alias-insert.php @@ -68,4 +68,4 @@ // ----------------------------- // Step 7: // On success page and notification url, assert that the payment has been successful. -// -> see example-alias-assert.php +// -> see example-alias-insert-assert.php diff --git a/example/SecureCardData/example-assert.php b/example/SecureCardData/example-assert.php deleted file mode 100644 index 4b9b914..0000000 --- a/example/SecureCardData/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/lib/SaferpayJson/Container/Authentication.php b/lib/SaferpayJson/Container/Authentication.php deleted file mode 100644 index d72de13..0000000 --- a/lib/SaferpayJson/Container/Authentication.php +++ /dev/null @@ -1,53 +0,0 @@ -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/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/CheckResult.php b/lib/SaferpayJson/Container/CheckResult.php new file mode 100644 index 0000000..0032a83 --- /dev/null +++ b/lib/SaferpayJson/Container/CheckResult.php @@ -0,0 +1,66 @@ +result; + } + + public function setResult(string $result): self + { + $this->result = $result; + + return $this; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function setMessage(string $message): self + { + $this->message = $message; + + return $this; + } + + public function getAuthentication(): ?HolderAuthentication + { + return $this->authentication; + } + + public function setAuthentication(HolderAuthentication $authentication): self + { + $this->authentication = $authentication; + + return $this; + } +} diff --git a/lib/SaferpayJson/Container/HolderAuthentication.php b/lib/SaferpayJson/Container/HolderAuthentication.php new file mode 100644 index 0000000..c897138 --- /dev/null +++ b/lib/SaferpayJson/Container/HolderAuthentication.php @@ -0,0 +1,69 @@ +result; + } + + public function setResult(string $result): self + { + $this->result = $result; + + return $this; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function setMessage(string $message): self + { + $this->message = $message; + + return $this; + } + + public function getXid(): ?string + { + return $this->xid; + } + + public function setXid(string $xid): self + { + $this->xid = $xid; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php index c4f9ee7..fd6f762 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php @@ -3,7 +3,7 @@ namespace Ticketpark\SaferpayJson\Request\PaymentPage; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\Authentication; +use Ticketpark\SaferpayJson\Container\HolderAuthentication; use Ticketpark\SaferpayJson\Container\Payment; use Ticketpark\SaferpayJson\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\Request; @@ -37,7 +37,7 @@ class AuthorizeReferencedRequest extends Request protected $transactionReference; /** - * @var Authentication + * @var HolderAuthentication * @SerializedName("Authentication") */ protected $authentication; @@ -98,12 +98,12 @@ public function setPayment(Payment $payment): self return $this; } - public function getAuthentication(): ?Authentication + public function getAuthentication(): ?HolderAuthentication { return $this->authentication; } - public function setAuthentication(Authentication $authentication): self + public function setAuthentication(HolderAuthentication $authentication): self { $this->authentication = $authentication; diff --git a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php index 2a9d0ab..b952a7f 100644 --- a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php @@ -4,7 +4,7 @@ use JMS\Serializer\Annotation\SerializedName; use Ticketpark\SaferpayJson\Container\AddressForm; -use Ticketpark\SaferpayJson\Container\Authentication; +use Ticketpark\SaferpayJson\Container\HolderAuthentication; use Ticketpark\SaferpayJson\Container\CardForm; use Ticketpark\SaferpayJson\Container\Notification; use Ticketpark\SaferpayJson\Container\Payer; @@ -88,7 +88,7 @@ class InitializeRequest extends Request protected $paymentMethodsOptions; /** - * @var Authentication|null + * @var HolderAuthentication|null * @SerializedName("Authentication") */ protected $authentication; @@ -226,12 +226,12 @@ public function setPaymentMethodsOptions(PaymentMethodsOptions $paymentMethodsOp return $this; } - public function getAuthentication(): ?Authentication + public function getAuthentication(): ?HolderAuthentication { return $this->authentication; } - public function setAuthentication(Authentication $authentication): self + public function setAuthentication(HolderAuthentication $authentication): self { $this->authentication = $authentication; diff --git a/lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php similarity index 60% rename from lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php rename to lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php index d45e1c5..fa501cf 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AssertInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php @@ -5,12 +5,13 @@ use JMS\Serializer\Annotation\SerializedName; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; -use Ticketpark\SaferpayJson\Response\SecureCardData\AssertInsertResponse; +use Ticketpark\SaferpayJson\Request\RequestConfig; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasAssertInsertResponse; -class AssertInsertRequest extends Request +class AliasAssertInsertRequest extends Request { const API_PATH = '/Payment/v1/Alias/AssertInsert'; - const RESPONSE_CLASS = AssertInsertResponse::class; + const RESPONSE_CLASS = AliasAssertInsertResponse::class; use RequestCommonsTrait; @@ -20,6 +21,13 @@ class AssertInsertRequest extends Request */ protected $token; + public function __construct(RequestConfig $requestConfig, string $token) + { + $this->token = $token; + + parent::__construct($requestConfig); + } + public function getToken(): string { return $this->token; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php index 9958ed1..99193d7 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -5,7 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\CardForm; -use Ticketpark\SaferpayJson\Container\Check; +use Ticketpark\SaferpayJson\Container\CheckResult; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Container\ReturnUrls; @@ -74,7 +74,7 @@ class AliasInsertRequest extends Request protected $languageCode; /** - * @var Check + * @var CheckResult * @SerializedName("Check") */ protected $check; @@ -159,12 +159,12 @@ public function setStyling(Styling $styling): self return $this; } - public function getCheck(): ?Check + public function getCheck(): ?CheckResult { return $this->check; } - public function setCheck(Check $check): self + public function setCheck(CheckResult $check): self { $this->check = $check; diff --git a/lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php similarity index 82% rename from lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php rename to lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php index 81264d2..fec27bb 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AssertInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php @@ -8,7 +8,7 @@ use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; -class AssertInsertResponse extends Response +class AliasAssertInsertResponse extends Response { /** * @var Alias @@ -24,6 +24,13 @@ class AssertInsertResponse extends Response */ protected $paymentMeans; + /** + * @var CheckResult + * @SerializedName("CheckResult") + * @Type("Ticketpark\SaferpayJson\Container\CheckResult") + */ + protected $checkResult; + public function getAlias(): Alias { return $this->alias; diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php index a379628..5078faa 100755 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureAliasStore/AssertInsertRequestTest.php @@ -2,22 +2,22 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Request\SecureCardData\AssertInsertRequest; -use Ticketpark\SaferpayJson\Response\SecureCardData\AssertInsertResponse; +use Ticketpark\SaferpayJson\Request\SecureCardData\AliasAssertInsertRequest; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasAssertInsertResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; class AssertInsertRequestTest extends CommonRequestTest { public function testErrorResponse(): void { - parent::doTestErrorResponse(AssertInsertRequest::class); + parent::doTestErrorResponse(AliasAssertInsertRequest::class); } public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - AssertInsertRequest::class, - AssertInsertResponse::class + AliasAssertInsertRequest::class, + AliasAssertInsertResponse::class ); } } From 28185ecb784d0812300c930412c8b51a46de6ccc Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 13:54:48 +0200 Subject: [PATCH 16/34] Add SecureCardData/AliasUpdateResponse --- .../example-alias-insert-assert.php | 2 +- .../SecureCardData/example-alias-update.php | 55 +++++++++++++++ example/SecureCardData/example-delete.php | 4 +- lib/SaferpayJson/Container/UpdateAlias.php | 51 ++++++++++++++ .../Container/UpdatePaymentMeans.php | 32 +++++++++ ...leteRequest.php => AliasDeleteRequest.php} | 6 +- .../SecureCardData/AliasUpdateRequest.php | 67 +++++++++++++++++++ ...teResponse.php => AliasDeleteResponse.php} | 2 +- .../SecureCardData/AliasUpdateResponse.php | 50 ++++++++++++++ .../SecureAliasStore/DeleteRequestTest.php | 10 +-- 10 files changed, 267 insertions(+), 12 deletions(-) create mode 100644 example/SecureCardData/example-alias-update.php create mode 100644 lib/SaferpayJson/Container/UpdateAlias.php create mode 100644 lib/SaferpayJson/Container/UpdatePaymentMeans.php rename lib/SaferpayJson/Request/SecureCardData/{DeleteRequest.php => AliasDeleteRequest.php} (78%) create mode 100755 lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php rename lib/SaferpayJson/Response/SecureCardData/{DeleteResponse.php => AliasDeleteResponse.php} (77%) create mode 100755 lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php diff --git a/example/SecureCardData/example-alias-insert-assert.php b/example/SecureCardData/example-alias-insert-assert.php index 890ed34..ad877ca 100644 --- a/example/SecureCardData/example-alias-insert-assert.php +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -42,4 +42,4 @@ die($response->getErrorMessage()); } -echo 'The insert has been successful! Insert alias: ' . $response->getAlias()->getId()."
\n"; +echo 'The insert has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/SecureCardData/example-alias-update.php b/example/SecureCardData/example-alias-update.php new file mode 100644 index 0000000..d7337b7 --- /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 + +$response = $assertRequest->execute(); + +if ($response instanceof ErrorResponse) { + die($response->getErrorMessage()); +} + +echo 'The update has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/SecureCardData/example-delete.php b/example/SecureCardData/example-delete.php index e1e6fdd..622b6d0 100644 --- a/example/SecureCardData/example-delete.php +++ b/example/SecureCardData/example-delete.php @@ -1,7 +1,7 @@ setCustomerId($customerId) ->setRequestId(uniqid()); -$response = (new DeleteRequest($apiKey, $apiSecret)) +$response = (new AliasDeleteRequest($apiKey, $apiSecret)) ->setRequestHeader($requestHeader) ->setAliasId($aliasId) ->execute(); diff --git a/lib/SaferpayJson/Container/UpdateAlias.php b/lib/SaferpayJson/Container/UpdateAlias.php new file mode 100644 index 0000000..595545c --- /dev/null +++ b/lib/SaferpayJson/Container/UpdateAlias.php @@ -0,0 +1,51 @@ +id = $id; + } + + 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/UpdatePaymentMeans.php b/lib/SaferpayJson/Container/UpdatePaymentMeans.php new file mode 100644 index 0000000..8aae071 --- /dev/null +++ b/lib/SaferpayJson/Container/UpdatePaymentMeans.php @@ -0,0 +1,32 @@ +card = $card; + } + + public function getCard(): ?Card + { + return $this->card; + } + + public function setCard(Card $card): self + { + $this->card = $card; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/DeleteRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php similarity index 78% rename from lib/SaferpayJson/Request/SecureCardData/DeleteRequest.php rename to lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php index fbcdf5d..02f64b7 100755 --- a/lib/SaferpayJson/Request/SecureCardData/DeleteRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php @@ -5,12 +5,12 @@ use JMS\Serializer\Annotation\SerializedName; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; -use Ticketpark\SaferpayJson\Response\SecureCardData\DeleteResponse; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasDeleteResponse; -class DeleteRequest extends Request +class AliasDeleteRequest extends Request { const API_PATH = '/Payment/v1/Alias/Delete'; - const RESPONSE_CLASS = DeleteResponse::class; + const RESPONSE_CLASS = AliasDeleteResponse::class; use RequestCommonsTrait; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php new file mode 100755 index 0000000..b29a074 --- /dev/null +++ b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php @@ -0,0 +1,67 @@ +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; + } +} diff --git a/lib/SaferpayJson/Response/SecureCardData/DeleteResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php similarity index 77% rename from lib/SaferpayJson/Response/SecureCardData/DeleteResponse.php rename to lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php index 2a816c0..5cbaeff 100755 --- a/lib/SaferpayJson/Response/SecureCardData/DeleteResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php @@ -4,6 +4,6 @@ use Ticketpark\SaferpayJson\Response\Response; -class DeleteResponse extends Response +class AliasDeleteResponse extends Response { } diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php new file mode 100755 index 0000000..c957282 --- /dev/null +++ b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php @@ -0,0 +1,50 @@ +alias; + } + + public function setAlias(Alias $alias): self + { + $this->alias = $alias; + + return $this; + } + + public function getPaymentMeans(): ?PaymentMeans + { + return $this->paymentMeans; + } + + public function setPaymentMeans(PaymentMeans $paymentMeans): self + { + $this->paymentMeans = $paymentMeans; + + return $this; + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php index 916d7c4..b0b0272 100755 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php @@ -2,22 +2,22 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Request\SecureCardData\DeleteRequest; -use Ticketpark\SaferpayJson\Response\SecureCardData\DeleteResponse; +use Ticketpark\SaferpayJson\Request\SecureCardData\AliasDeleteRequest; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasDeleteResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; class DeleteRequestTest extends CommonRequestTest { public function testErrorResponse(): void { - parent::doTestErrorResponse(DeleteRequest::class); + parent::doTestErrorResponse(AliasDeleteRequest::class); } public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - DeleteRequest::class, - DeleteResponse::class + AliasDeleteRequest::class, + AliasDeleteResponse::class ); } } From ec338a80d5fc46de079c84cbee372f2340c9f3bf Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 14:12:02 +0200 Subject: [PATCH 17/34] Adjust SecureCardData\AliasInsertDirectRequest to work for spec 1.17 --- .../SecureCardData/example-alias-delete.php | 48 ++++++++++++++++ .../example-alias-insert-assert.php | 2 +- .../example-alias-insert-direct.php | 57 +++++++++++++++++++ example/SecureCardData/example-delete.php | 45 --------------- .../SecureCardData/example-insert-direct.php | 43 -------------- lib/SaferpayJson/Container/Alias.php | 19 +++++++ lib/SaferpayJson/Container/BankAccount.php | 5 ++ lib/SaferpayJson/Container/Check.php | 47 +++++++++++++++ lib/SaferpayJson/Container/PaymentMeans.php | 38 +++++++++++++ lib/SaferpayJson/Container/SaferpayFields.php | 32 +++++++++++ .../SecureCardData/AliasDeleteRequest.php | 8 +++ ...quest.php => AliasInsertDirectRequest.php} | 40 +++++++++++-- .../SecureCardData/AliasInsertRequest.php | 8 +-- ...onse.php => AliasInsertDirectResponse.php} | 10 +++- .../InsertDirectRequestTest.php | 10 ++-- 15 files changed, 308 insertions(+), 104 deletions(-) create mode 100644 example/SecureCardData/example-alias-delete.php create mode 100644 example/SecureCardData/example-alias-insert-direct.php delete mode 100644 example/SecureCardData/example-delete.php delete mode 100644 example/SecureCardData/example-insert-direct.php create mode 100644 lib/SaferpayJson/Container/Check.php create mode 100644 lib/SaferpayJson/Container/SaferpayFields.php rename lib/SaferpayJson/Request/SecureCardData/{InsertDirectRequest.php => AliasInsertDirectRequest.php} (53%) rename lib/SaferpayJson/Response/SecureCardData/{InsertDirectResponse.php => AliasInsertDirectResponse.php} (79%) diff --git a/example/SecureCardData/example-alias-delete.php b/example/SecureCardData/example-alias-delete.php new file mode 100644 index 0000000..babca7f --- /dev/null +++ b/example/SecureCardData/example-alias-delete.php @@ -0,0 +1,48 @@ +execute(); + +if ($response instanceof ErrorResponse) { + die($response->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 index ad877ca..9435405 100644 --- a/example/SecureCardData/example-alias-insert-assert.php +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -9,7 +9,7 @@ // A token you received after initializing an insert (see example-alias-insert.php) -$token = '2kt8aodsr4c3spuy6rsqilwk3'; +$token = 'xxx'; // ----------------------------- // Step 1: diff --git a/example/SecureCardData/example-alias-insert-direct.php b/example/SecureCardData/example-alias-insert-direct.php new file mode 100644 index 0000000..c6c46a1 --- /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 + +$response = $insertRequest->execute(); + +if ($response instanceof ErrorResponse) { + die($response->getErrorMessage()); +} + +echo 'The insert has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; + diff --git a/example/SecureCardData/example-delete.php b/example/SecureCardData/example-delete.php deleted file mode 100644 index 622b6d0..0000000 --- a/example/SecureCardData/example-delete.php +++ /dev/null @@ -1,45 +0,0 @@ -setCustomerId($customerId) - ->setRequestId(uniqid()); - -$response = (new AliasDeleteRequest($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-insert-direct.php b/example/SecureCardData/example-insert-direct.php deleted file mode 100644 index 9283af0..0000000 --- a/example/SecureCardData/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/lib/SaferpayJson/Container/Alias.php b/lib/SaferpayJson/Container/Alias.php index f673f9f..465bcbc 100644 --- a/lib/SaferpayJson/Container/Alias.php +++ b/lib/SaferpayJson/Container/Alias.php @@ -21,6 +21,13 @@ class Alias */ protected $lifetime; + /** + * @var string + * @SerializedName("VerificationCode") + * @Type("string") + */ + protected $verificationCode; + public function getId(): string { return $this->id; @@ -44,4 +51,16 @@ public function setLifetime(int $lifetime): self return $this; } + + public function getVerificationCode(): ?string + { + return $this->verificationCode; + } + + public function setVerificationCode(string $verificationCode): self + { + $this->verificationCode = $verificationCode; + + return $this; + } } diff --git a/lib/SaferpayJson/Container/BankAccount.php b/lib/SaferpayJson/Container/BankAccount.php index af7eaf3..393febc 100644 --- a/lib/SaferpayJson/Container/BankAccount.php +++ b/lib/SaferpayJson/Container/BankAccount.php @@ -42,6 +42,11 @@ class BankAccount */ protected $countryCode; + public function __construct(string $iban) + { + $this->iban = $iban; + } + public function getIban(): string { return $this->iban; diff --git a/lib/SaferpayJson/Container/Check.php b/lib/SaferpayJson/Container/Check.php new file mode 100644 index 0000000..d5a3753 --- /dev/null +++ b/lib/SaferpayJson/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/Container/PaymentMeans.php b/lib/SaferpayJson/Container/PaymentMeans.php index 4aede5b..6594b78 100644 --- a/lib/SaferpayJson/Container/PaymentMeans.php +++ b/lib/SaferpayJson/Container/PaymentMeans.php @@ -52,6 +52,20 @@ class PaymentMeans */ protected $twint; + /** + * @var SaferpayFields + * @SerializedName("SaferpayFields") + * @Type("Ticketpark\SaferpayJson\Container\SaferpayFields") + */ + protected $saferpayFields; + + /** + * @var Alias + * @SerializedName("Alias") + * @Type("Ticketpark\SaferpayJson\Container\Alias") + */ + protected $alias; + public function getBrand(): Brand { return $this->brand; @@ -123,4 +137,28 @@ public function setTwint(Twint $twint): self 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/Container/SaferpayFields.php b/lib/SaferpayJson/Container/SaferpayFields.php new file mode 100644 index 0000000..0db357b --- /dev/null +++ b/lib/SaferpayJson/Container/SaferpayFields.php @@ -0,0 +1,32 @@ +token = $token; + } + + public function getToken(): ?string + { + return $this->token; + } + + public function setToken(string $token): self + { + $this->token = $token; + + return $this; + } +} diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php index 02f64b7..ce28aeb 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php @@ -5,6 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasDeleteResponse; class AliasDeleteRequest extends Request @@ -20,6 +21,13 @@ class AliasDeleteRequest extends Request */ protected $aliasId; + public function __construct(RequestConfig $requestConfig, string $aliasId) + { + $this->aliasId = $aliasId; + + parent::__construct($requestConfig); + } + public function getAliasId(): string { return $this->aliasId; diff --git a/lib/SaferpayJson/Request/SecureCardData/InsertDirectRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php similarity index 53% rename from lib/SaferpayJson/Request/SecureCardData/InsertDirectRequest.php rename to lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php index dbecb7e..2d828eb 100755 --- a/lib/SaferpayJson/Request/SecureCardData/InsertDirectRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php @@ -4,16 +4,18 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; +use Ticketpark\SaferpayJson\Container\Check; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; -use Ticketpark\SaferpayJson\Response\SecureCardData\InsertDirectResponse; +use Ticketpark\SaferpayJson\Request\RequestConfig; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertDirectResponse; -class InsertDirectRequest extends Request +class AliasInsertDirectRequest extends Request { const API_PATH = '/Payment/v1/Alias/InsertDirect'; - const RESPONSE_CLASS = InsertDirectResponse::class; + const RESPONSE_CLASS = AliasInsertDirectResponse::class; use RequestCommonsTrait; @@ -30,7 +32,22 @@ class InsertDirectRequest extends Request */ protected $paymentMeans; - public function getRegisterAlias(): RegisterAlias + /** + * @var Check + * @SerializedName("Check") + * @Type("Ticketpark\SaferpayJson\Container\Check") + */ + protected $check; + + public function __construct(RequestConfig $requestConfig, RegisterAlias $registerAlias, PaymentMeans $paymentMeans) + { + $this->registerAlias = $registerAlias; + $this->paymentMeans = $paymentMeans; + + parent::__construct($requestConfig); + } + + public function getRegisterAlias(): ?RegisterAlias { return $this->registerAlias; } @@ -42,7 +59,7 @@ public function setRegisterAlias(RegisterAlias $registerAlias): self return $this; } - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } @@ -50,6 +67,19 @@ public function getPaymentMeans(): 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; } } diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php index 99193d7..9958ed1 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -5,7 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\CardForm; -use Ticketpark\SaferpayJson\Container\CheckResult; +use Ticketpark\SaferpayJson\Container\Check; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Container\ReturnUrls; @@ -74,7 +74,7 @@ class AliasInsertRequest extends Request protected $languageCode; /** - * @var CheckResult + * @var Check * @SerializedName("Check") */ protected $check; @@ -159,12 +159,12 @@ public function setStyling(Styling $styling): self return $this; } - public function getCheck(): ?CheckResult + public function getCheck(): ?Check { return $this->check; } - public function setCheck(CheckResult $check): self + public function setCheck(Check $check): self { $this->check = $check; diff --git a/lib/SaferpayJson/Response/SecureCardData/InsertDirectResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php similarity index 79% rename from lib/SaferpayJson/Response/SecureCardData/InsertDirectResponse.php rename to lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php index 8a0cb83..47a9e8e 100755 --- a/lib/SaferpayJson/Response/SecureCardData/InsertDirectResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php @@ -5,10 +5,11 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\Alias; +use Ticketpark\SaferpayJson\Container\CheckResult; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; -class InsertDirectResponse extends Response +class AliasInsertDirectResponse extends Response { /** * @var Alias @@ -24,6 +25,13 @@ class InsertDirectResponse extends Response */ protected $paymentMeans; + /** + * @var CheckResult + * @SerializedName("CheckResult") + * @Type("Ticketpark\SaferpayJson\Container\CheckResult") + */ + protected $checkResult; + public function getAlias(): Alias { return $this->alias; diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php index 5eae3d9..e804af5 100755 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php @@ -2,22 +2,22 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Request\SecureCardData\InsertDirectRequest; -use Ticketpark\SaferpayJson\Response\SecureCardData\InsertDirectResponse; +use Ticketpark\SaferpayJson\Request\SecureCardData\AliasInsertDirectRequest; +use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertDirectResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; class InsertDirectRequestTest extends CommonRequestTest { public function testErrorResponse(): void { - parent::doTestErrorResponse(InsertDirectRequest::class); + parent::doTestErrorResponse(AliasInsertDirectRequest::class); } public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - InsertDirectRequest::class, - InsertDirectResponse::class + AliasInsertDirectRequest::class, + AliasInsertDirectResponse::class ); } } From 942bcaa6d57c345d8fff83b904a13f94f5a7985c Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 14:12:22 +0200 Subject: [PATCH 18/34] Fix codestyle --- .../Request/PaymentPage/AuthorizeReferencedRequest.php | 3 +-- lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php | 3 +-- lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php index fd6f762..250c695 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php @@ -53,8 +53,7 @@ public function __construct( string $terminalId, Payment $payment, TransactionReference $transactionReference - ) - { + ) { $this->terminalId = $terminalId; $this->payment = $payment; $this->transactionReference = $transactionReference; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php index 9958ed1..c212a00 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -102,8 +102,7 @@ public function __construct( RegisterAlias $registerAlias, string $type, ReturnUrls $returnUrls - ) - { + ) { $this->registerAlias = $registerAlias; $this->type = $type; $this->returnUrls = $returnUrls; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php index b29a074..fd94ab7 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php @@ -33,8 +33,7 @@ public function __construct( RequestConfig $requestConfig, UpdateAlias $updateAlias, UpdatePaymentMeans $updatePaymentMeans - ) - { + ) { $this->updateAlias = $updateAlias; $this->updatePaymentMeans = $updatePaymentMeans; From 18e0e43f30877113c2a70076c49bad4da410218f Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 19:21:59 +0200 Subject: [PATCH 19/34] Fix tests --- lib/SaferpayJson/Container/CustomPlan.php | 14 ++++----- .../Container/InstallmentPlan.php | 8 ++--- .../Container/RegistrationResult.php | 15 +++++++-- .../Transaction/AuthorizeDirectRequest.php | 9 ++++-- .../Response/PaymentPage/AssertResponse.php | 2 ++ .../AliasAssertInsertResponse.php | 1 + .../Transaction/AuthorizeDirectResponse.php | 1 + .../Tests/Request/CommonRequestTest.php | 30 +++++++++++++----- .../Request/PaymentPage/AssertRequestTest.php | 14 +++++---- .../AuthorizeReferencedRequestTest.php | 21 +++++++++---- .../PaymentPage/InitializeRequestTest.php | 21 +++++++++---- .../InsertDirectRequestTest.php | 23 -------------- .../AliasAssertInsertRequestTest.php} | 16 +++++----- .../AliasDeleteRequestTest.php} | 16 +++++----- .../AliasInsertDirectRequestTest.php | 21 +++++++++++++ .../AliasInsertRequestTest.php} | 20 +++++++----- .../SecureCardData/AliasUpdateRequestTest.php | 31 +++++++++++++++++++ .../AuthorizeDirectRequestTest.php | 21 +++++++++---- .../Request/Transaction/CancelRequestTest.php | 15 +++++---- .../Transaction/CaptureRequestTest.php | 15 +++++---- .../Request/Transaction/RefundRequestTest.php | 20 ++++++++---- 21 files changed, 224 insertions(+), 110 deletions(-) delete mode 100755 tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php rename tests/SaferpayJson/Tests/Request/{SecureAliasStore/AssertInsertRequestTest.php => SecureCardData/AliasAssertInsertRequestTest.php} (69%) rename tests/SaferpayJson/Tests/Request/{SecureAliasStore/DeleteRequestTest.php => SecureCardData/AliasDeleteRequestTest.php} (69%) create mode 100755 tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php rename tests/SaferpayJson/Tests/Request/{SecureAliasStore/InsertRequestTest.php => SecureCardData/AliasInsertRequestTest.php} (53%) create mode 100755 tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php diff --git a/lib/SaferpayJson/Container/CustomPlan.php b/lib/SaferpayJson/Container/CustomPlan.php index 9fdbc31..e01114e 100644 --- a/lib/SaferpayJson/Container/CustomPlan.php +++ b/lib/SaferpayJson/Container/CustomPlan.php @@ -29,11 +29,11 @@ class CustomPlan protected $interestRate; /** - * @var InstallmentFee + * @var Amount * @SerializedName("InstallmentFee") - * @Type("Ticketpark\SaferpayJson\Container\InstallmentFee") + * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $InstallmentFee; + protected $installmentFee; /** * @var string @@ -85,14 +85,14 @@ public function setInterestRate(string $interestRate): self return $this; } - public function getInstallmentFee(): ?InstallmentFee + public function getInstallmentFee(): ?Amount { - return $this->InstallmentFee; + return $this->installmentFee; } - public function setInstallmentFee(InstallmentFee $InstallmentFee): self + public function setInstallmentFee(Amount $installmentFee): self { - $this->InstallmentFee = $InstallmentFee; + $this->installmentFee = $installmentFee; return $this; } diff --git a/lib/SaferpayJson/Container/InstallmentPlan.php b/lib/SaferpayJson/Container/InstallmentPlan.php index 9f1b5cc..efeaef0 100644 --- a/lib/SaferpayJson/Container/InstallmentPlan.php +++ b/lib/SaferpayJson/Container/InstallmentPlan.php @@ -22,9 +22,9 @@ class InstallmentPlan protected $interestRate; /** - * @var InstallmentFee + * @var Amount * @SerializedName("InstallmentFee") - * @Type("Ticketpark\SaferpayJson\Container\InstallmentFee") + * @Type("Ticketpark\SaferpayJson\Container\Amount") */ protected $installmentFee; @@ -80,12 +80,12 @@ public function setInterestRate(string $interestRate): self return $this; } - public function getInstallmentFee(): ?InstallmentFee + public function getInstallmentFee(): ?Amount { return $this->installmentFee; } - public function setInstallmentFee(InstallmentFee $installmentFee): self + public function setInstallmentFee(Amount $installmentFee): self { $this->installmentFee = $installmentFee; diff --git a/lib/SaferpayJson/Container/RegistrationResult.php b/lib/SaferpayJson/Container/RegistrationResult.php index 3731804..336b4bd 100644 --- a/lib/SaferpayJson/Container/RegistrationResult.php +++ b/lib/SaferpayJson/Container/RegistrationResult.php @@ -4,9 +4,6 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Alias; -use Ticketpark\SaferpayJson\Container\Error; -use Ticketpark\SaferpayJson\Container\Error; class RegistrationResult { @@ -72,4 +69,16 @@ public function setError(Error $error): self return $this; } + + public function getAuthenticationResult(): ?AuthenticationResult + { + return $this->authenticationResult; + } + + public function setAuthenticationResult(AuthenticationResult $authenticationResult): self + { + $this->authenticationResult = $authenticationResult; + + return $this; + } } diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php index 2bdaf85..8f6745a 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -3,6 +3,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; +use Ticketpark\SaferpayJson\Container\Payer; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Container\Payment; @@ -52,8 +53,12 @@ class AuthorizeDirectRequest extends Request */ protected $terminalId; - public function __construct(RequestConfig $requestConfig, string $terminalId, Payment $payment, PaymentMeans $paymentMeans) - { + public function __construct( + RequestConfig $requestConfig, + string $terminalId, + Payment $payment, + PaymentMeans $paymentMeans + ) { $this->terminalId = $terminalId; $this->payment = $payment; $this->paymentMeans = $paymentMeans; diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index 2570910..0aed76f 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -5,6 +5,8 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\Dcc; +use Ticketpark\SaferpayJson\Container\Liability; +use Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments; use Ticketpark\SaferpayJson\Container\Payer; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Container\RegistrationResult; diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php index fec27bb..423bbe6 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php @@ -5,6 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\Alias; +use Ticketpark\SaferpayJson\Container\CheckResult; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index f3d42e7..c978e92 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -4,6 +4,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; +use Ticketpark\SaferpayJson\Container\Payer; use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Container\RegisterAlias; use Ticketpark\SaferpayJson\Container\Transaction; diff --git a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php index 797f2cc..44df602 100644 --- a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php @@ -8,6 +8,7 @@ use JMS\Serializer\SerializerBuilder; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\ErrorResponse; use Ticketpark\SaferpayJson\Response\ResponseInterface; @@ -19,28 +20,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); + $response = $this->executeRequest(); $this->assertInstanceOf(ErrorResponse::class, $response); } - 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(): ResponseInterface { - $initializer = new $requestClass('key', 'secret'); - $initializer->setClient($this->getClientMock()); + $initializer = $this->getInstance(); return $initializer->execute(); } 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 index c8a9fdd..79bc2ed 100644 --- a/tests/SaferpayJson/Tests/Request/PaymentPage/AuthorizeReferencedRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/PaymentPage/AuthorizeReferencedRequestTest.php @@ -2,22 +2,31 @@ namespace Ticketpark\SaferpayJson\Tests\PaymentPage; +use Ticketpark\SaferpayJson\Container\Amount; +use Ticketpark\SaferpayJson\Container\Payment; +use Ticketpark\SaferpayJson\Container\TransactionReference; use Ticketpark\SaferpayJson\Request\PaymentPage\AuthorizeReferencedRequest; use Ticketpark\SaferpayJson\Response\PaymentPage\AuthorizeReferencedResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; class AuthorizeReferencedRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(AuthorizeReferencedRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - AuthorizeReferencedRequest::class, AuthorizeReferencedResponse::class ); } + + protected function getInstance() + { + return new AuthorizeReferencedRequest( + $this->getRequestConfig(), + 'someTerminalId', + new Payment( + new Amount(5000, 'CHF') + ), + new TransactionReference() + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php b/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php index 5c2fec9..11302c6 100644 --- a/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php @@ -2,22 +2,31 @@ namespace Ticketpark\SaferpayJson\Tests\PaymentPage; +use Ticketpark\SaferpayJson\Container\Amount; +use Ticketpark\SaferpayJson\Container\Payment; +use Ticketpark\SaferpayJson\Container\ReturnUrls; use Ticketpark\SaferpayJson\Request\PaymentPage\InitializeRequest; use Ticketpark\SaferpayJson\Response\PaymentPage\InitializeResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; class InitializeRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(InitializeRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - InitializeRequest::class, InitializeResponse::class ); } + + protected function getInstance() + { + return new InitializeRequest( + $this->getRequestConfig(), + 'someTerminalId', + new Payment( + new Amount(5000, 'CHF') + ), + new ReturnUrls('success-url', 'fail-url') + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php deleted file mode 100755 index e804af5..0000000 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertDirectRequestTest.php +++ /dev/null @@ -1,23 +0,0 @@ -getRequestConfig(), + 'someToken' + ); + } } diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php similarity index 69% rename from tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php rename to tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php index b0b0272..69f7f55 100755 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/DeleteRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasDeleteRequestTest.php @@ -6,18 +6,20 @@ use Ticketpark\SaferpayJson\Response\SecureCardData\AliasDeleteResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; -class DeleteRequestTest extends CommonRequestTest +class AliasDeleteRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(AliasDeleteRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - AliasDeleteRequest::class, AliasDeleteResponse::class ); } + + public function getInstance() + { + return new AliasDeleteRequest( + $this->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..881e42f --- /dev/null +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php @@ -0,0 +1,21 @@ +getRequestConfig(), + new RegisterAlias(), + new PaymentMeans() + ); + } +} diff --git a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php similarity index 53% rename from tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertRequestTest.php rename to tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php index 76feeda..015b698 100755 --- a/tests/SaferpayJson/Tests/Request/SecureAliasStore/InsertRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php @@ -2,22 +2,28 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; +use Ticketpark\SaferpayJson\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Container\ReturnUrls; use Ticketpark\SaferpayJson\Request\SecureCardData\AliasInsertRequest; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; -class InsertRequestTest extends CommonRequestTest +class AliasInsertRequestTest extends CommonRequestTest { - public function testErrorResponse(): void - { - parent::doTestErrorResponse(AliasInsertRequest::class); - } - public function testSuccessfulResponse(): void { parent::doTestSuccessfulResponse( - AliasInsertRequest::class, AliasInsertResponse::class ); } + + public function getInstance() + { + return new AliasInsertRequest( + $this->getRequestConfig(), + new RegisterAlias(), + 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..1ce6257 --- /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..9bf24cc 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/CancelRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/CancelRequestTest.php index 23b464b..3d5937e 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\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..6dde2db 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\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..b92b169 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\Container\Amount; +use Ticketpark\SaferpayJson\Container\CaptureReference; +use Ticketpark\SaferpayJson\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() + ); + } } From cf98136e3f2f47228213752604fb728998e80f2e Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 22:18:00 +0200 Subject: [PATCH 20/34] Improve structure of requests and responses --- example/PaymentPage/example-assert.php | 10 +- example/PaymentPage/example-initialize.php | 10 +- .../SecureCardData/example-alias-delete.php | 10 +- .../example-alias-insert-assert.php | 8 +- .../example-alias-insert-direct.php | 10 +- .../SecureCardData/example-alias-insert.php | 10 +- .../SecureCardData/example-alias-update.php | 10 +- .../example-authorize-referenced.php | 8 +- example/Transaction/example-cancel.php | 10 +- example/Transaction/example-capture.php | 12 +- example/Transaction/example-refund.php | 10 +- lib/SaferpayJson/Container/Payment.php | 2 +- lib/SaferpayJson/Container/RequestHeader.php | 36 +---- .../SaferpayErrorResponseException.php | 23 +++ .../Request/PaymentPage/AssertRequest.php | 12 +- .../AuthorizeReferencedRequest.php | 44 +++--- .../Request/PaymentPage/InitializeRequest.php | 142 +++++++++--------- lib/SaferpayJson/Request/Request.php | 51 +++---- lib/SaferpayJson/Request/RequestConfig.php | 2 +- .../AliasAssertInsertRequest.php | 12 +- .../SecureCardData/AliasDeleteRequest.php | 12 +- .../AliasInsertDirectRequest.php | 24 ++- .../SecureCardData/AliasInsertRequest.php | 52 ++++--- .../SecureCardData/AliasUpdateRequest.php | 14 +- .../Transaction/AuthorizeDirectRequest.php | 61 ++++---- .../Request/Transaction/CancelRequest.php | 12 +- .../Request/Transaction/CaptureRequest.php | 42 +++--- .../Request/Transaction/RefundRequest.php | 20 ++- lib/SaferpayJson/Response/ErrorResponse.php | 72 +-------- .../Response/PaymentPage/AssertResponse.php | 52 ++----- .../AuthorizeReferencedResponse.php | 34 +---- .../PaymentPage/InitializeResponse.php | 35 +---- lib/SaferpayJson/Response/Response.php | 4 +- .../Response/ResponseInterface.php | 11 -- .../AliasAssertInsertResponse.php | 18 +-- .../SecureCardData/AliasDeleteResponse.php | 2 +- .../AliasInsertDirectResponse.php | 22 +-- .../SecureCardData/AliasInsertResponse.php | 38 +---- .../SecureCardData/AliasUpdateResponse.php | 20 +-- .../Transaction/AuthorizeDirectResponse.php | 42 +----- .../Response/Transaction/CancelResponse.php | 29 +--- .../Response/Transaction/CaptureResponse.php | 47 +----- .../Response/Transaction/RefundResponse.php | 29 +--- phpstan.neon | 2 +- .../Tests/Request/CommonRequestTest.php | 15 +- 45 files changed, 468 insertions(+), 673 deletions(-) create mode 100644 lib/SaferpayJson/Exception/SaferpayErrorResponseException.php delete mode 100644 lib/SaferpayJson/Response/ResponseInterface.php diff --git a/example/PaymentPage/example-assert.php b/example/PaymentPage/example-assert.php index 0cc23e2..31f9804 100644 --- a/example/PaymentPage/example-assert.php +++ b/example/PaymentPage/example-assert.php @@ -1,8 +1,8 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $assertRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } echo 'The transaction has been successful! Transaction id: ' . $response->getTransaction()->getId()."\n"; diff --git a/example/PaymentPage/example-initialize.php b/example/PaymentPage/example-initialize.php index d99162f..0dfe424 100644 --- a/example/PaymentPage/example-initialize.php +++ b/example/PaymentPage/example-initialize.php @@ -1,9 +1,9 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $initializeRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } // ----------------------------- diff --git a/example/SecureCardData/example-alias-delete.php b/example/SecureCardData/example-alias-delete.php index babca7f..016521e 100644 --- a/example/SecureCardData/example-alias-delete.php +++ b/example/SecureCardData/example-alias-delete.php @@ -1,8 +1,8 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $assertRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } echo "The alias has successfully been deleted.
\n"; diff --git a/example/SecureCardData/example-alias-insert-assert.php b/example/SecureCardData/example-alias-insert-assert.php index 9435405..e036bf4 100644 --- a/example/SecureCardData/example-alias-insert-assert.php +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -1,8 +1,8 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +} catch (SaferpayErrorResponseException $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 index c6c46a1..152d0f6 100644 --- a/example/SecureCardData/example-alias-insert-direct.php +++ b/example/SecureCardData/example-alias-insert-direct.php @@ -1,9 +1,9 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $insertRequest->execute(); +} catch (SaferpayErrorResponseException $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 index d87e776..ef5d164 100644 --- a/example/SecureCardData/example-alias-insert.php +++ b/example/SecureCardData/example-alias-insert.php @@ -1,9 +1,9 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $insertRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } // ----------------------------- diff --git a/example/SecureCardData/example-alias-update.php b/example/SecureCardData/example-alias-update.php index d7337b7..90e57c8 100644 --- a/example/SecureCardData/example-alias-update.php +++ b/example/SecureCardData/example-alias-update.php @@ -1,9 +1,9 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $assertRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } echo 'The update has been successful! Alias id: ' . $response->getAlias()->getId()."
\n"; diff --git a/example/Transaction/example-authorize-referenced.php b/example/Transaction/example-authorize-referenced.php index 89f9f94..eb7984b 100644 --- a/example/Transaction/example-authorize-referenced.php +++ b/example/Transaction/example-authorize-referenced.php @@ -1,7 +1,7 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } print sprintf( diff --git a/example/Transaction/example-cancel.php b/example/Transaction/example-cancel.php index b25db6c..7e1be7e 100644 --- a/example/Transaction/example-cancel.php +++ b/example/Transaction/example-cancel.php @@ -1,7 +1,7 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $cancelRequest->execute(); +} catch (SaferpayErrorResponseException $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 index 660657f..112dbe2 100644 --- a/example/Transaction/example-capture.php +++ b/example/Transaction/example-capture.php @@ -1,9 +1,9 @@ execute(); - -if ($response instanceof ErrorResponse) { - var_dump($response); exit; - - die($response->getErrorMessage()); +try { + $response = $captureRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } echo 'The transaction has successfully been captured! Capture-Id: ' . $response->getCaptureId()."\n"; diff --git a/example/Transaction/example-refund.php b/example/Transaction/example-refund.php index f77441f..de6a622 100644 --- a/example/Transaction/example-refund.php +++ b/example/Transaction/example-refund.php @@ -1,7 +1,7 @@ execute(); - -if ($response instanceof ErrorResponse) { - die($response->getErrorMessage()); +try { + $response = $refundRequest->execute(); +} catch (SaferpayErrorResponseException $e) { + die ($e->getErrorResponse()->getErrorMessage()); } echo 'The transaction has successfully been refunded! Transaction-ID: ' . $response->getTransaction()->getId(); diff --git a/lib/SaferpayJson/Container/Payment.php b/lib/SaferpayJson/Container/Payment.php index c9c3ea1..1c38950 100644 --- a/lib/SaferpayJson/Container/Payment.php +++ b/lib/SaferpayJson/Container/Payment.php @@ -131,7 +131,7 @@ public function setOptions(Options $options): self return $this; } - public function getRecurring(): Recurring + public function getRecurring(): ?Recurring { return $this->recurring; } diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Container/RequestHeader.php index f45fae1..58cbc89 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Container/RequestHeader.php @@ -19,7 +19,7 @@ class RequestHeader protected $customerId; /** - * @var string + * @var string|null * @SerializedName("RequestId") */ protected $requestId; @@ -31,7 +31,7 @@ class RequestHeader protected $retryIndicator = 0; /** - * @var ClientInfo + * @var ClientInfo|null * @SerializedName("ClientInfo") */ protected $clientInfo; @@ -52,55 +52,27 @@ public function getSpecVersion(): string return $this->specVersion; } - public function setSpecVersion(string $specVersion): self - { - $this->specVersion = $specVersion; - - return $this; - } - public function getCustomerId(): string { return $this->customerId; } - public function setCustomerId(string $customerId): self - { - $this->customerId = $customerId; - - return $this; - } - - public function getRequestId(): string + public function getRequestId(): ?string { return $this->requestId; } - public function setRequestId(string $requestId): self - { - $this->requestId = $requestId; - - return $this; - } - public function getRetryIndicator(): int { return $this->retryIndicator; } - public function setRetryIndicator(int $retryIndicator): self - { - $this->retryIndicator = $retryIndicator; - - return $this; - } - public function getClientInfo(): ?ClientInfo { return $this->clientInfo; } - public function setClientInfo(ClientInfo $clientInfo): self + public function setClientInfo(?ClientInfo $clientInfo): self { $this->clientInfo = $clientInfo; diff --git a/lib/SaferpayJson/Exception/SaferpayErrorResponseException.php b/lib/SaferpayJson/Exception/SaferpayErrorResponseException.php new file mode 100644 index 0000000..e13e965 --- /dev/null +++ b/lib/SaferpayJson/Exception/SaferpayErrorResponseException.php @@ -0,0 +1,23 @@ +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 3efd197..399e046 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AssertRequest.php @@ -8,7 +8,7 @@ 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; @@ -19,7 +19,7 @@ class AssertRequest extends Request * @var string * @SerializedName("Token") */ - protected $token; + private $token; public function __construct( RequestConfig $requestConfig, @@ -41,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 index 250c695..f106d96 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php @@ -11,7 +11,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\PaymentPage\AuthorizeReferencedResponse; -class AuthorizeReferencedRequest extends Request +final class AuthorizeReferencedRequest extends Request { const API_PATH = '/Payment/v1/Transaction/AuthorizeReferenced'; const RESPONSE_CLASS = AuthorizeReferencedResponse::class; @@ -22,31 +22,31 @@ class AuthorizeReferencedRequest extends Request * @var string * @SerializedName("TerminalId") */ - protected $terminalId; + private $terminalId; /** * @var Payment * @SerializedName("Payment") */ - protected $payment; + private $payment; /** * @var TransactionReference * @SerializedName("TransactionReference") */ - protected $transactionReference; + private $transactionReference; /** - * @var HolderAuthentication + * @var HolderAuthentication|null * @SerializedName("Authentication") */ - protected $authentication; + private $authentication; /** - * @var bool + * @var bool|null * @SerializedName("SuppressDcc") */ - protected $suppressDcc; + private $suppressDcc; public function __construct( RequestConfig $requestConfig, @@ -73,26 +73,26 @@ public function setTerminalId(string $terminalId): self return $this; } - public function getTransactionReference(): TransactionReference + public function getPayment(): Payment { - return $this->transactionReference; + return $this->payment; } - public function setTransactionReference(TransactionReference $transactionReference): self + public function setPayment(Payment $payment): self { - $this->transactionReference = $transactionReference; + $this->payment = $payment; return $this; } - public function getPayment(): Payment + public function getTransactionReference(): TransactionReference { - return $this->payment; + return $this->transactionReference; } - public function setPayment(Payment $payment): self + public function setTransactionReference(TransactionReference $transactionReference): self { - $this->payment = $payment; + $this->transactionReference = $transactionReference; return $this; } @@ -102,7 +102,7 @@ public function getAuthentication(): ?HolderAuthentication return $this->authentication; } - public function setAuthentication(HolderAuthentication $authentication): self + public function setAuthentication(?HolderAuthentication $authentication): self { $this->authentication = $authentication; @@ -114,10 +114,18 @@ public function isSuppressDcc(): ?bool return $this->suppressDcc; } - public function setSuppressDcc(bool $suppressDcc): self + 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/PaymentPage/InitializeRequest.php b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php index b952a7f..959511a 100644 --- a/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php +++ b/lib/SaferpayJson/Request/PaymentPage/InitializeRequest.php @@ -18,7 +18,7 @@ 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; @@ -57,101 +57,101 @@ class InitializeRequest extends Request use RequestCommonsTrait; - /** - * @var string|null - * @SerializedName("ConfigSet") - */ - protected $configSet; - /** * @var string * @SerializedName("TerminalId") */ - protected $terminalId; + private $terminalId; /** * @var Payment * @SerializedName("Payment") */ - protected $payment; + private $payment; + + /** + * @var ReturnUrls + * @SerializedName("ReturnUrls") + */ + private $returnUrls; + + /** + * @var string|null + * @SerializedName("ConfigSet") + */ + private $configSet; /** * @var array|null * @SerializedName("PaymentMethods") */ - protected $paymentMethods; + private $paymentMethods; /** * @var PaymentMethodsOptions|null * @SerializedName("PaymentMethodsOptions") */ - protected $paymentMethodsOptions; + private $paymentMethodsOptions; /** * @var HolderAuthentication|null * @SerializedName("Authentication") */ - protected $authentication; + private $authentication; /** * @var array|null * @SerializedName("Wallets") */ - protected $wallets; + private $wallets; /** * @var Payer|null * @SerializedName("Payer") */ - protected $payer; + private $payer; /** * @var RegisterAlias|null * @SerializedName("RegisterAlias") */ - protected $registerAlias; - - /** - * @var ReturnUrls - * @SerializedName("ReturnUrls") - */ - protected $returnUrls; + private $registerAlias; /** * @var Notification|null * @SerializedName("Notification") */ - protected $notification; + private $notification; /** * @var Styling|null * @SerializedName("Styling") */ - protected $styling; + private $styling; /** * @var AddressForm|null * @SerializedName("BillingAddressForm") */ - protected $billingAddressForm; + private $billingAddressForm; /** * @var AddressForm|null * @SerializedName("DeliveryAddressForm") */ - protected $deliveryAddressForm; + private $deliveryAddressForm; /** * @var CardForm|null * @SerializedName("CardForm") */ - protected $cardForm; + private $cardForm; /** - * @var string + * @var string|null * @SerializedName("Condition") */ - protected $condition; + private $condition; public function __construct( RequestConfig $requestConfig, @@ -166,18 +166,6 @@ public function __construct( parent::__construct($requestConfig); } - public function getConfigSet(): ?string - { - return $this->configSet; - } - - public function setConfigSet(string $configSet): self - { - $this->configSet = $configSet; - - return $this; - } - public function getTerminalId(): string { return $this->terminalId; @@ -202,12 +190,36 @@ public function setPayment(Payment $payment): self return $this; } - public function getPaymentMethods(): array + public function getReturnUrls(): ReturnUrls + { + return $this->returnUrls; + } + + public function setReturnUrls(ReturnUrls $returnUrls): self + { + $this->returnUrls = $returnUrls; + + return $this; + } + + public function getConfigSet(): ?string + { + return $this->configSet; + } + + public function setConfigSet(?string $configSet): self + { + $this->configSet = $configSet; + + return $this; + } + + public function getPaymentMethods(): ?array { return $this->paymentMethods; } - public function setPaymentMethods(array $paymentMethods): self + public function setPaymentMethods(?array $paymentMethods): self { $this->paymentMethods = $paymentMethods; @@ -219,7 +231,7 @@ public function getPaymentMethodsOptions(): ?PaymentMethodsOptions return $this->paymentMethodsOptions; } - public function setPaymentMethodsOptions(PaymentMethodsOptions $paymentMethodsOptions): self + public function setPaymentMethodsOptions(?PaymentMethodsOptions $paymentMethodsOptions): self { $this->paymentMethodsOptions = $paymentMethodsOptions; @@ -231,7 +243,7 @@ public function getAuthentication(): ?HolderAuthentication return $this->authentication; } - public function setAuthentication(HolderAuthentication $authentication): self + public function setAuthentication(?HolderAuthentication $authentication): self { $this->authentication = $authentication; @@ -243,19 +255,19 @@ public function getWallets(): ?array return $this->wallets; } - public function setWallets(array $wallets): self + public function setWallets(?array $wallets): self { $this->wallets = $wallets; return $this; } - public function getPayer(): Payer + public function getPayer(): ?Payer { return $this->payer; } - public function setPayer(Payer $payer): self + public function setPayer(?Payer $payer): self { $this->payer = $payer; @@ -267,31 +279,19 @@ 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 getReturnUrls(): ReturnUrls - { - return $this->returnUrls; - } - - public function setReturnUrls(ReturnUrls $returnUrls): self - { - $this->returnUrls = $returnUrls; - - return $this; - } - - public function getNotification(): Notification + public function getNotification(): ?Notification { return $this->notification; } - public function setNotification(Notification $notification): self + public function setNotification(?Notification $notification): self { $this->notification = $notification; @@ -303,7 +303,7 @@ public function getStyling(): ?Styling return $this->styling; } - public function setStyling(Styling $styling): self + public function setStyling(?Styling $styling): self { $this->styling = $styling; @@ -315,7 +315,7 @@ public function getBillingAddressForm(): ?AddressForm return $this->billingAddressForm; } - public function setBillingAddressForm(AddressForm $billingAddressForm): self + public function setBillingAddressForm(?AddressForm $billingAddressForm): self { $this->billingAddressForm = $billingAddressForm; @@ -327,7 +327,7 @@ public function getDeliveryAddressForm(): ?AddressForm return $this->deliveryAddressForm; } - public function setDeliveryAddressForm(AddressForm $deliveryAddressForm): self + public function setDeliveryAddressForm(?AddressForm $deliveryAddressForm): self { $this->deliveryAddressForm = $deliveryAddressForm; @@ -339,7 +339,7 @@ public function getCardForm(): ?CardForm return $this->cardForm; } - public function setCardForm(CardForm $cardForm): self + public function setCardForm(?CardForm $cardForm): self { $this->cardForm = $cardForm; @@ -351,10 +351,18 @@ public function getCondition(): ?string return $this->condition; } - public function setCondition(string $condition): self + 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 73a0e6f..5c3b829 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -4,6 +4,7 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Psr7\Response as GuzzleResponse; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Exclude; use JMS\Serializer\Annotation\SerializedName; @@ -11,16 +12,16 @@ use JMS\Serializer\SerializerInterface; use Ticketpark\SaferpayJson\Exception\HttpRequestException; use Ticketpark\SaferpayJson\Container\RequestHeader; +use Ticketpark\SaferpayJson\Exception\SaferpayErrorResponseException; 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/'; + private const ROOT_URL = 'https://www.saferpay.com/api/'; + private const ROOT_URL_TEST = 'https://test.saferpay.com/api/'; - const ROOT_URL_TEST = 'https://test.saferpay.com/api/'; - - const ERROR_RESPONSE_CLASS = ErrorResponse::class; + private const ERROR_RESPONSE_CLASS = ErrorResponse::class; /** * @var RequestConfig @@ -37,6 +38,7 @@ abstract class Request abstract public function getApiPath(): string; abstract public function getResponseClass(): string; + abstract public function execute(): Response; public function __construct(RequestConfig $requestConfig) { @@ -48,34 +50,17 @@ public function getRequestConfig(): RequestConfig return $this->requestConfig; } - public function setRequestConfig(RequestConfig $requestConfig): self - { - $this->requestConfig = $requestConfig; - - return $this; - } - public function getRequestHeader(): RequestHeader { - if (null === $this->requestHeader) { - return new RequestHeader( - $this->requestConfig->getCustomerId() - ); - } - - return $this->requestHeader; - } - - public function setRequestHeader(RequestHeader $requestHeader): self - { - $this->requestHeader = $requestHeader; - - return $this; + return new RequestHeader( + $this->requestConfig->getCustomerId() + ); } - public function execute(): ResponseInterface + protected function doExecute(): Response { try { + /** @var GuzzleResponse $response */ $response = $this->requestConfig->getClient()->post( $this->getUrl(), [ @@ -85,6 +70,7 @@ public function execute(): ResponseInterface ); } catch (\Exception $e) { if ($e instanceof ClientException) { + /** @var GuzzleResponse $response */ $response = $e->getResponse(); } else { throw new HttpRequestException($e->getMessage()); @@ -94,11 +80,15 @@ public function execute(): ResponseInterface $statusCode = $response->getStatusCode(); if ($statusCode >= 400 && $statusCode < 500) { - return $this->getSerializer()->deserialize( + + /** @var ErrorResponse $errorResponse */ + $errorResponse = $this->getSerializer()->deserialize( (string) $response->getBody(), self::ERROR_RESPONSE_CLASS, 'json' ); + + throw new SaferpayErrorResponseException($errorResponse); } if (200 !== $statusCode) { @@ -108,11 +98,14 @@ public function execute(): ResponseInterface )); } - return $this->getSerializer()->deserialize( + /** @var Response $response */ + $response = $this->getSerializer()->deserialize( (string) $response->getBody(), $this->getResponseClass(), 'json' ); + + return $response; } private function getUrl(): string diff --git a/lib/SaferpayJson/Request/RequestConfig.php b/lib/SaferpayJson/Request/RequestConfig.php index 3456124..c0df074 100644 --- a/lib/SaferpayJson/Request/RequestConfig.php +++ b/lib/SaferpayJson/Request/RequestConfig.php @@ -4,7 +4,7 @@ use GuzzleHttp\Client; -class RequestConfig +final class RequestConfig { /** * @var string diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php index fa501cf..4a7c608 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasAssertInsertRequest.php @@ -8,7 +8,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasAssertInsertResponse; -class AliasAssertInsertRequest extends Request +final class AliasAssertInsertRequest extends Request { const API_PATH = '/Payment/v1/Alias/AssertInsert'; const RESPONSE_CLASS = AliasAssertInsertResponse::class; @@ -19,7 +19,7 @@ class AliasAssertInsertRequest extends Request * @var string * @SerializedName("Token") */ - protected $token; + private $token; public function __construct(RequestConfig $requestConfig, string $token) { @@ -39,4 +39,12 @@ public function setToken(string $token): self 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 index ce28aeb..3f2df17 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasDeleteRequest.php @@ -8,7 +8,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasDeleteResponse; -class AliasDeleteRequest extends Request +final class AliasDeleteRequest extends Request { const API_PATH = '/Payment/v1/Alias/Delete'; const RESPONSE_CLASS = AliasDeleteResponse::class; @@ -19,7 +19,7 @@ class AliasDeleteRequest extends Request * @var string * @SerializedName("AliasId") */ - protected $aliasId; + private $aliasId; public function __construct(RequestConfig $requestConfig, string $aliasId) { @@ -39,4 +39,12 @@ public function setAliasId(string $aliasId): self 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 index 2d828eb..80f4782 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php @@ -12,7 +12,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertDirectResponse; -class AliasInsertDirectRequest extends Request +final class AliasInsertDirectRequest extends Request { const API_PATH = '/Payment/v1/Alias/InsertDirect'; const RESPONSE_CLASS = AliasInsertDirectResponse::class; @@ -23,21 +23,21 @@ class AliasInsertDirectRequest extends Request * @var RegisterAlias * @SerializedName("RegisterAlias") */ - protected $registerAlias; + private $registerAlias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** - * @var Check + * @var Check|null * @SerializedName("Check") * @Type("Ticketpark\SaferpayJson\Container\Check") */ - protected $check; + private $check; public function __construct(RequestConfig $requestConfig, RegisterAlias $registerAlias, PaymentMeans $paymentMeans) { @@ -47,7 +47,7 @@ public function __construct(RequestConfig $requestConfig, RegisterAlias $registe parent::__construct($requestConfig); } - public function getRegisterAlias(): ?RegisterAlias + public function getRegisterAlias(): RegisterAlias { return $this->registerAlias; } @@ -59,7 +59,7 @@ public function setRegisterAlias(RegisterAlias $registerAlias): self return $this; } - public function getPaymentMeans(): ?PaymentMeans + public function getPaymentMeans(): PaymentMeans { return $this->paymentMeans; } @@ -76,10 +76,18 @@ public function getCheck(): ?Check return $this->check; } - public function setCheck(Check $check): self + 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 index c212a00..bde5bf4 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -15,7 +15,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertResponse; -class AliasInsertRequest extends Request +final class AliasInsertRequest extends Request { const API_PATH = '/Payment/v1/Alias/Insert'; const RESPONSE_CLASS = AliasInsertResponse::class; @@ -45,57 +45,57 @@ class AliasInsertRequest extends Request * @var RegisterAlias * @SerializedName("RegisterAlias") */ - protected $registerAlias; + private $registerAlias; /** * @var string * @SerializedName("Type") * @Type("string") */ - protected $type; + private $type; /** * @var ReturnUrls * @SerializedName("ReturnUrls") */ - protected $returnUrls; + private $returnUrls; /** - * @var Styling + * @var Styling|null * @SerializedName("Styling") */ - protected $styling; + private $styling; /** - * @var string + * @var string|null * @SerializedName("LanguageCode") * @Type("string") */ - protected $languageCode; + private $languageCode; /** - * @var Check + * @var Check|null * @SerializedName("Check") */ - protected $check; + private $check; /** - * @var array + * @var array|null * @SerializedName("PaymentMethods") */ - protected $paymentMethods; + private $paymentMethods; /** - * @var CardForm + * @var CardForm|null * @SerializedName("CardForm") */ - protected $cardForm; + private $cardForm; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; public function __construct( RequestConfig $requestConfig, @@ -151,7 +151,7 @@ public function getStyling(): ?Styling return $this->styling; } - public function setStyling(Styling $styling): self + public function setStyling(?Styling $styling): self { $this->styling = $styling; @@ -163,7 +163,7 @@ public function getCheck(): ?Check return $this->check; } - public function setCheck(Check $check): self + public function setCheck(?Check $check): self { $this->check = $check; @@ -175,7 +175,7 @@ public function getLanguageCode(): ?string return $this->languageCode; } - public function setLanguageCode(string $languageCode): self + public function setLanguageCode(?string $languageCode): self { $this->languageCode = $languageCode; @@ -187,7 +187,7 @@ public function getPaymentMethods(): ?array return $this->paymentMethods; } - public function setPaymentMethods(array $paymentMethods): self + public function setPaymentMethods(?array $paymentMethods): self { $this->paymentMethods = $paymentMethods; @@ -199,7 +199,7 @@ public function getCardForm(): ?CardForm return $this->cardForm; } - public function setCardForm(CardForm $cardForm): self + public function setCardForm(?CardForm $cardForm): self { $this->cardForm = $cardForm; @@ -211,10 +211,18 @@ public function getPaymentMeans(): ?PaymentMeans return $this->paymentMeans; } - public function setPaymentMeans(PaymentMeans $paymentMeans): self + 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 index fd94ab7..7ae5e80 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php @@ -10,7 +10,7 @@ use Ticketpark\SaferpayJson\Request\RequestConfig; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasUpdateResponse; -class AliasUpdateRequest extends Request +final class AliasUpdateRequest extends Request { const API_PATH = '/Payment/v1/Alias/Update'; const RESPONSE_CLASS = AliasUpdateResponse::class; @@ -21,13 +21,13 @@ class AliasUpdateRequest extends Request * @var UpdateAlias * @SerializedName("UpdateAlias") */ - protected $updateAlias; + private $updateAlias; /** * @var UpdatePaymentMeans * @SerializedName("UpdatePaymentMeans") */ - protected $updatePaymentMeans; + private $updatePaymentMeans; public function __construct( RequestConfig $requestConfig, @@ -63,4 +63,12 @@ public function setUpdatePaymentMeans(UpdatePaymentMeans $updatePaymentMeans): s 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 8f6745a..b9d18b1 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -16,42 +16,43 @@ * 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") */ - protected $paymentMeans; + private $paymentMeans; /** - * @var RegisterAlias + * @var RegisterAlias|null * @SerializedName("RegisterAlias") */ - protected $registerAlias; + private $registerAlias; /** - * @var Payer + * @var Payer|null * @SerializedName("Payer") */ - protected $payer; + private $payer; - /** - * @var string - * @SerializedName("TerminalId") - */ - protected $terminalId; public function __construct( RequestConfig $requestConfig, @@ -66,38 +67,38 @@ public function __construct( parent::__construct($requestConfig); } - public function getPayment(): Payment + 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 getPaymentMeans(): PaymentMeans + public function getPayment(): Payment { - return $this->paymentMeans; + return $this->payment; } - public function setPaymentMeans(PaymentMeans $paymentMeans): self + public function setPayment(Payment $payment): self { - $this->paymentMeans = $paymentMeans; + $this->payment = $payment; return $this; } - public function getTerminalId(): string + public function getPaymentMeans(): PaymentMeans { - return $this->terminalId; + return $this->paymentMeans; } - public function setTerminalId(string $terminalId): self + public function setPaymentMeans(PaymentMeans $paymentMeans): self { - $this->terminalId = $terminalId; + $this->paymentMeans = $paymentMeans; return $this; } @@ -107,7 +108,7 @@ public function getRegisterAlias(): ?RegisterAlias return $this->registerAlias; } - public function setRegisterAlias(RegisterAlias $registerAlias): self + public function setRegisterAlias(?RegisterAlias $registerAlias): self { $this->registerAlias = $registerAlias; @@ -119,10 +120,18 @@ public function getPayer(): ?Payer return $this->payer; } - public function setPayer(Payer $payer): self + 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/CancelRequest.php b/lib/SaferpayJson/Request/Transaction/CancelRequest.php index 0840f3c..f54914d 100644 --- a/lib/SaferpayJson/Request/Transaction/CancelRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CancelRequest.php @@ -9,7 +9,7 @@ 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; @@ -20,7 +20,7 @@ class CancelRequest extends Request * @var TransactionReference * @SerializedName("TransactionReference") */ - protected $transactionReference; + private $transactionReference; public function __construct( RequestConfig $requestConfig, @@ -42,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 3e47ddc..7db07bb 100644 --- a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php @@ -14,7 +14,7 @@ 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; @@ -25,37 +25,37 @@ class CaptureRequest extends Request * @var TransactionReference * @SerializedName("TransactionReference") */ - protected $transactionReference; + private $transactionReference; /** - * @var Amount + * @var Amount|null * @SerializedName("Amount") */ - protected $amount; + private $amount; /** - * @var Billpay + * @var Billpay|null * @SerializedName("Billpay") */ - protected $billpay; + private $billpay; /** - * @var PendingNotification + * @var PendingNotification|null * @SerializedName("PendingNotification") */ - protected $pendingNotification; + private $pendingNotification; /** - * @var Marketplace + * @var Marketplace|null * @SerializedName("Marketplace") */ - protected $marketplace; + private $marketplace; /** - * @var MastercardIssuerInstallments + * @var MastercardIssuerInstallments|null * @SerializedName("MastercardIssuerInstallments") */ - protected $mastercardIssuerInstallments; + private $mastercardIssuerInstallments; public function __construct( RequestConfig $requestConfig, @@ -83,7 +83,7 @@ public function getAmount(): ?Amount return $this->amount; } - public function setAmount(Amount $amount): self + public function setAmount(?Amount $amount): self { $this->amount = $amount; @@ -95,7 +95,7 @@ public function getBillpay(): ?Billpay return $this->billpay; } - public function setBillpay(Billpay $billpay): self + public function setBillpay(?Billpay $billpay): self { $this->billpay = $billpay; @@ -107,7 +107,7 @@ public function getPendingNotification(): ?PendingNotification return $this->pendingNotification; } - public function setPendingNotification(PendingNotification $pendingNotification): self + public function setPendingNotification(?PendingNotification $pendingNotification): self { $this->pendingNotification = $pendingNotification; @@ -119,7 +119,7 @@ public function getMarketplace(): ?Marketplace return $this->marketplace; } - public function setMarketplace(Marketplace $marketplace): self + public function setMarketplace(?Marketplace $marketplace): self { $this->marketplace = $marketplace; @@ -131,10 +131,18 @@ public function getMastercardIssuerInstallments(): ?MastercardIssuerInstallments return $this->mastercardIssuerInstallments; } - public function setMastercardIssuerInstallments(MastercardIssuerInstallments $mastercardIssuerInstallments): self + 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 cf1eb87..f89b5af 100644 --- a/lib/SaferpayJson/Request/Transaction/RefundRequest.php +++ b/lib/SaferpayJson/Request/Transaction/RefundRequest.php @@ -12,7 +12,7 @@ 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; @@ -23,19 +23,19 @@ class RefundRequest extends Request * @var Refund * @SerializedName("Refund") */ - protected $refund; + private $refund; /** * @var CaptureReference * @SerializedName("CaptureReference") */ - protected $captureReference; + private $captureReference; /** - * @var PendingNotification + * @var PendingNotification|null * @SerializedName("PendingNotification") */ - protected $pendingNotification; + private $pendingNotification; public function __construct( RequestConfig $requestConfig, @@ -77,10 +77,18 @@ public function getPendingNotification(): ?PendingNotification return $this->pendingNotification; } - public function setPendingNotification(PendingNotification $pendingNotification): self + 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/ErrorResponse.php b/lib/SaferpayJson/Response/ErrorResponse.php index b4cba7b..9ac1a48 100644 --- a/lib/SaferpayJson/Response/ErrorResponse.php +++ b/lib/SaferpayJson/Response/ErrorResponse.php @@ -12,150 +12,94 @@ class ErrorResponse extends Response * @SerializedName("Behavior") * @Type("string") */ - protected $behaviour; + private $behaviour; /** * @var string * @SerializedName("ErrorName") * @Type("string") */ - protected $errorName; + private $errorName; /** * @var string * @SerializedName("ErrorMessage") * @Type("string") */ - protected $errorMessage; + private $errorMessage; /** * @var string|null * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** * @var array * @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 * @SerializedName("ProcessorMessage") * @Type("string") */ - protected $processorMessage; + private $processorMessage; public function getBehaviour(): string { return $this->behaviour; } - public function setBehaviour(string $behaviour): self - { - $this->behaviour = $behaviour; - - return $this; - } - public function getErrorName(): string { return $this->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; - } - public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): self - { - $this->transactionId = $transactionId; - - return $this; - } - 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 0aed76f..273fcb4 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -10,108 +10,82 @@ 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\Response; -class AssertResponse extends Response +final class AssertResponse extends Response { /** * @var Transaction * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Container\Transaction") */ - protected $transaction; + private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** * @var Payer * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Container\Payer") */ - protected $payer; + private $payer; /** * @var RegistrationResult * @SerializedName("RegistrationResult") * @Type("Ticketpark\SaferpayJson\Container\RegistrationResult") */ - protected $registrationResult; + private $registrationResult; /** * @var Liability * @SerializedName("Liability") * @Type("Ticketpark\SaferpayJson\Container\Liability") */ - protected $liability; + private $liability; /** * @var Dcc * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\Container\Dcc") */ - protected $dcc; + private $dcc; /** * @var MastercardIssuerInstallments * @SerializedName("MastercardIssuerInstallments") * @Type("Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments") */ - protected $mastercardIssuerInstallments; + private $mastercardIssuerInstallments; - 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 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 getDcc(): Dcc + public function getDcc(): ?Dcc { return $this->dcc; } - - public function setDcc(Dcc $dcc): void - { - $this->dcc = $dcc; - } } diff --git a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php index 4a62b35..a90d8d5 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php @@ -10,77 +10,53 @@ use Ticketpark\SaferpayJson\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -class AuthorizeReferencedResponse extends Response +final class AuthorizeReferencedResponse extends Response { /** * @var Transaction * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Container\Transaction") */ - protected $transaction; + private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** * @var Payer * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Container\Payer") */ - protected $payer; + private $payer; /** * @var Dcc * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\Container\Dcc") */ - protected $dcc; + private $dcc; public function getTransaction(): Transaction { return $this->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; - } - public function getPayer(): ?Payer { return $this->payer; } - public function setPayer(Payer $payer): self - { - $this->payer = $payer; - - return $this; - } - public function getDcc(): ?Dcc { return $this->dcc; } - - public function setDcc(Dcc $dcc): self - { - $this->dcc = $dcc; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php b/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php index 2124ad2..4d8fe0b 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 * @SerializedName("Token") * @Type("string") */ - protected $token; + private $token; /** * @var \DateTime * @SerializedName("Expiration") * @Type("string") */ - protected $expiration; + private $expiration; /** * @var string * @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..d710611 100644 --- a/lib/SaferpayJson/Response/Response.php +++ b/lib/SaferpayJson/Response/Response.php @@ -6,7 +6,7 @@ use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\ResponseHeader; -abstract class Response implements ResponseInterface +abstract class Response { /** * @var 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/SecureCardData/AliasDeleteResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php index 5cbaeff..3f48f08 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasDeleteResponse.php @@ -4,6 +4,6 @@ use Ticketpark\SaferpayJson\Response\Response; -class AliasDeleteResponse extends Response +final class AliasDeleteResponse extends Response { } diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php index 47a9e8e..635675c 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php @@ -9,46 +9,36 @@ use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; -class AliasInsertDirectResponse extends Response +final class AliasInsertDirectResponse extends Response { /** * @var Alias * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Container\Alias") */ - protected $alias; + private $alias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** * @var CheckResult * @SerializedName("CheckResult") * @Type("Ticketpark\SaferpayJson\Container\CheckResult") */ - protected $checkResult; + private $checkResult; - public function getAlias(): Alias + public function getAlias(): ?Alias { return $this->alias; } - public function setAlias(Alias $alias): void - { - $this->alias = $alias; - } - - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } - - public function setPaymentMeans(PaymentMeans $paymentMeans): void - { - $this->paymentMeans = $paymentMeans; - } } diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php index 85e0814..3affd05 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php @@ -7,77 +7,53 @@ use Ticketpark\SaferpayJson\Container\Redirect; use Ticketpark\SaferpayJson\Response\Response; -class AliasInsertResponse extends Response +final class AliasInsertResponse extends Response { /** * @var string * @SerializedName("Token") * @Type("string") */ - protected $token; + private $token; /** * @var \DateTime * @SerializedName("Expiration") * @Type("string") */ - protected $expiration; + private $expiration; /** * @var bool * @SerializedName("RedirectRequired") * @Type("bool") */ - protected $redirectRequired; + private $redirectRequired; /** * @var Redirect * @SerializedName("Redirect") * @Type("Ticketpark\SaferpayJson\Container\Redirect") */ - protected $redirect; + private $redirect; - public function getToken(): string + public function getToken(): ?string { return $this->token; } - public function setToken(string $token): void - { - $this->token = $token; - } - - public function getExpiration(): \DateTime + public function getExpiration(): ?\DateTime { return $this->expiration; } - public function setExpiration(\DateTime $expiration): void - { - $this->expiration = $expiration; - } - public function isRedirectRequired(): ?bool { return $this->redirectRequired; } - public function setRedirectRequired(bool $redirectRequired): self - { - $this->redirectRequired = $redirectRequired; - - return $this; - } - public function getRedirect(): ?Redirect { return $this->redirect; } - - public function setRedirect(Redirect $redirect): self - { - $this->redirect = $redirect; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php index c957282..ce497d8 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php @@ -8,43 +8,29 @@ use Ticketpark\SaferpayJson\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; -class AliasUpdateResponse extends Response +final class AliasUpdateResponse extends Response { /** * @var Alias * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Container\Alias") */ - protected $alias; + private $alias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; public function getAlias(): ?Alias { return $this->alias; } - public function setAlias(Alias $alias): self - { - $this->alias = $alias; - - 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/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index c978e92..c768b65 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -10,81 +10,53 @@ use Ticketpark\SaferpayJson\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -/** - * Class AuthorizeDirectResponse - * @package Ticketpark\SaferpayJson\Transaction - */ -class AuthorizeDirectResponse extends Response +final class AuthorizeDirectResponse extends Response { /** * @var Transaction * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Container\Transaction") */ - protected $transaction; + private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** * @var RegisterAlias * @SerializedName("RegisterAlias") * @Type("Ticketpark\SaferpayJson\Container\RegisterAlias") */ - protected $registerAlias; + private $registerAlias; /** * @var Payer * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Container\Payer") */ - protected $payer; + private $payer; - 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 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; - } } diff --git a/lib/SaferpayJson/Response/Transaction/CancelResponse.php b/lib/SaferpayJson/Response/Transaction/CancelResponse.php index 3b0ec69..45b3a48 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 * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** * @var string * @SerializedName("OrderId") * @Type("string") */ - protected $orderId; + private $orderId; /** * @var string * @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 2f378bc..870dbec 100644 --- a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php @@ -7,7 +7,7 @@ use Ticketpark\SaferpayJson\Container\Invoice; use Ticketpark\SaferpayJson\Response\Response; -class CaptureResponse extends Response +final class CaptureResponse extends Response { const STATUS_PENDING = 'PENDING'; const STATUS_CAPTURED = 'CAPTURED'; @@ -17,93 +17,58 @@ class CaptureResponse extends Response * @SerializedName("TransactionId") * @Type("string") */ - protected $transactionId; + private $transactionId; /** * @var string * @SerializedName("CaptureId") * @Type("string") */ - protected $captureId; + private $captureId; /** * @var string * @SerializedName("Statis") * @Type("string") */ - protected $status; + private $status; /** * @var string * @SerializedName("Date") * @Type("string") */ - protected $date; + private $date; /** * @var Invoice * @SerializedName("Invoice") * @Type("Ticketpark\SaferpayJson\Container\Invoice") */ - protected $invoice; + private $invoice; public function getTransactionId(): ?string { return $this->transactionId; } - public function setTransactionId(string $transactionId): self - { - $this->transactionId = $transactionId; - - return $this; - } - public function getCaptureId(): ?string { return $this->captureId; } - public function setCaptureId(string $captureId): self - { - $this->captureId = $captureId; - - return $this; - } - public function getStatus(): ?string { return $this->status; } - public function setStatus(string $status): self - { - $this->status = $status; - - return $this; - } - public function getDate(): ?string { return $this->date; } - public function setDate(string $date): self - { - $this->date = $date; - - return $this; - } - public function getInvoice(): ?Invoice { return $this->invoice; } - - public function setInvoice(Invoice $invoice): self - { - $this->invoice = $invoice; - - return $this; - } } diff --git a/lib/SaferpayJson/Response/Transaction/RefundResponse.php b/lib/SaferpayJson/Response/Transaction/RefundResponse.php index 5bae5e6..63741fd 100644 --- a/lib/SaferpayJson/Response/Transaction/RefundResponse.php +++ b/lib/SaferpayJson/Response/Transaction/RefundResponse.php @@ -9,56 +9,41 @@ use Ticketpark\SaferpayJson\Container\Transaction; use Ticketpark\SaferpayJson\Response\Response; -class RefundResponse extends Response +final class RefundResponse extends Response { /** * @var Transaction * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Container\Transaction") */ - protected $transaction; + private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") */ - protected $paymentMeans; + private $paymentMeans; /** * @var Dcc * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\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 9235569..42df7f8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 5 + level: 8 paths: - lib checkMissingIterableValueType: false diff --git a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php index 44df602..ceb9e0c 100644 --- a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php @@ -4,13 +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\Exception\SaferpayErrorResponseException; 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 { @@ -24,10 +25,10 @@ abstract protected function getInstance(); public function testErrorResponse(): void { - $this->successful = false; - $response = $this->executeRequest(); + $this->expectException(SaferpayErrorResponseException::class); - $this->assertInstanceOf(ErrorResponse::class, $response); + $this->successful = false; + $this->executeRequest(); } public function doTestSuccessfulResponse(string $responseClass): void @@ -52,7 +53,7 @@ protected function getRequestConfig(): RequestConfig return $requestConfig; } - private function executeRequest(): ResponseInterface + private function executeRequest(): Response { $initializer = $this->getInstance(); @@ -75,7 +76,7 @@ private function getClientMock(): MockObject private function getResponseMock(): MockObject { - $response = $this->getMockBuilder(Response::class) + $response = $this->getMockBuilder(GuzzleResponse::class) ->disableOriginalConstructor() ->onlyMethods([ 'getStatusCode', From 29358e7968c69c36dcd409ee78ef86b6be7a8fab Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Sun, 3 May 2020 22:49:43 +0200 Subject: [PATCH 21/34] Improve structure of containers --- lib/SaferpayJson/Container/Address.php | 114 +++++++-------- lib/SaferpayJson/Container/AddressForm.php | 19 +-- lib/SaferpayJson/Container/Alias.php | 24 ++-- lib/SaferpayJson/Container/Alipay.php | 11 +- lib/SaferpayJson/Container/Amount.php | 20 +-- .../Container/AuthenticationResult.php | 14 +- lib/SaferpayJson/Container/BankAccount.php | 44 +++--- lib/SaferpayJson/Container/Billpay.php | 6 +- lib/SaferpayJson/Container/Brand.php | 18 +-- .../Container/CaptureReference.php | 26 ++-- lib/SaferpayJson/Container/Card.php | 58 ++++---- lib/SaferpayJson/Container/CardForm.php | 11 +- lib/SaferpayJson/Container/Check.php | 14 +- lib/SaferpayJson/Container/CheckResult.php | 20 +-- lib/SaferpayJson/Container/ChosenPlan.php | 135 +++++++++++++++++- lib/SaferpayJson/Container/ClientInfo.php | 14 +- lib/SaferpayJson/Container/CustomPlan.php | 38 ++--- lib/SaferpayJson/Container/Dcc.php | 8 +- lib/SaferpayJson/Container/DirectDebit.php | 14 +- lib/SaferpayJson/Container/Error.php | 18 +-- .../Container/HolderAuthentication.php | 20 +-- lib/SaferpayJson/Container/Ideal.php | 13 +- lib/SaferpayJson/Container/Installment.php | 11 +- .../Container/InstallmentPlan.php | 44 +++--- lib/SaferpayJson/Container/Invoice.php | 26 ++-- lib/SaferpayJson/Container/Liability.php | 20 +-- lib/SaferpayJson/Container/Marketplace.php | 20 +-- .../MastercardIssuerInstallments.php | 26 ++-- lib/SaferpayJson/Container/Notification.php | 14 +- lib/SaferpayJson/Container/Options.php | 8 +- lib/SaferpayJson/Container/Payee.php | 35 +++-- lib/SaferpayJson/Container/Payer.php | 40 +++--- lib/SaferpayJson/Container/Payment.php | 24 ++-- lib/SaferpayJson/Container/PaymentMeans.php | 60 ++++---- .../Container/PaymentMethodsOptions.php | 14 +- .../Container/PendingNotification.php | 14 +- lib/SaferpayJson/Container/Recurring.php | 11 +- lib/SaferpayJson/Container/Redirect.php | 14 +- lib/SaferpayJson/Container/Refund.php | 28 ++-- lib/SaferpayJson/Container/RegisterAlias.php | 29 ++-- .../Container/RegistrationResult.php | 32 ++--- lib/SaferpayJson/Container/RequestHeader.php | 12 +- lib/SaferpayJson/Container/ResponseHeader.php | 20 +-- lib/SaferpayJson/Container/ReturnUrls.php | 22 +-- lib/SaferpayJson/Container/SaferpayFields.php | 11 +- lib/SaferpayJson/Container/Styling.php | 10 +- lib/SaferpayJson/Container/ThreeDs.php | 34 ++--- lib/SaferpayJson/Container/Transaction.php | 97 +++++++------ .../Container/TransactionReference.php | 18 +-- lib/SaferpayJson/Container/Twint.php | 8 +- lib/SaferpayJson/Container/UpdateAlias.php | 17 +-- .../Container/UpdatePaymentMeans.php | 11 +- .../AliasInsertDirectRequestTest.php | 2 +- .../SecureCardData/AliasInsertRequestTest.php | 2 +- 54 files changed, 705 insertions(+), 688 deletions(-) diff --git a/lib/SaferpayJson/Container/Address.php b/lib/SaferpayJson/Container/Address.php index 10928b7..7705cce 100644 --- a/lib/SaferpayJson/Container/Address.php +++ b/lib/SaferpayJson/Container/Address.php @@ -5,268 +5,268 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Address +final class Address { /** - * @var string + * @var string|null * @SerializedName("FirstName") * @Type("string") */ - protected $firstName; + private $firstName; /** - * @var string + * @var string|null * @SerializedName("LastName") * @Type("string") */ - protected $lastName; + private $lastName; /** - * @var string + * @var string|null * @SerializedName("Company") * @Type("string") */ - protected $company; + private $company; /** - * @var string + * @var string|null * @SerializedName("Gender") * @Type("string") */ - protected $gender; + private $gender; /** - * @var string + * @var string|null * @SerializedName("Street") * @Type("string") */ - protected $street; + private $street; /** - * @var string + * @var string|null * @SerializedName("Zip") * @Type("string") */ - protected $zip; + private $zip; /** - * @var string + * @var string|null * @SerializedName("City") * @Type("string") */ - protected $city; + private $city; /** - * @var string + * @var string|null * @SerializedName("CountryCode") * @Type("string") */ - protected $countryCode; + private $countryCode; /** - * @var string + * @var string|null * @SerializedName("Email") * @Type("string") */ - protected $email; + private $email; /** - * @var \DateTime + * @var \DateTime|null * @SerializedName("DateOfBirth") * @Type("string") */ - protected $dateOfBirth; + private $dateOfBirth; /** - * @var string + * @var string|null * @SerializedName("LegalForm") * @Type("string") */ - protected $legalForm; + private $legalForm; /** - * @var string + * @var string|null * @SerializedName("Street2") * @Type("string") */ - protected $street2; + private $street2; /** - * @var string + * @var string|null * @SerializedName("CountrySubdivisionCode") * @Type("string") */ - protected $countrySubdivisionCode; + private $countrySubdivisionCode; /** - * @var string + * @var string|null * @SerializedName("Phone") * @Type("string") */ - protected $phone; + private $phone; - public function getFirstName(): string + public function getFirstName(): ?string { return $this->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 getCompany(): string + public function getCompany(): ?string { return $this->company; } - public function setCompany(string $company): self + public function setCompany(?string $company): self { $this->company = $company; return $this; } - public function getGender(): string + public function getGender(): ?string { return $this->gender; } - public function setGender(string $gender): self + public function setGender(?string $gender): self { $this->gender = $gender; return $this; } - public function getStreet(): string + public function getStreet(): ?string { return $this->street; } - public function setStreet(string $street): self + public function setStreet(?string $street): self { $this->street = $street; return $this; } - public function getZip(): string + public function getZip(): ?string { return $this->zip; } - public function setZip(string $zip): self + public function setZip(?string $zip): self { $this->zip = $zip; return $this; } - public function getCity(): string + public function getCity(): ?string { return $this->city; } - public function setCity(string $city): self + public function setCity(?string $city): self { $this->city = $city; return $this; } - public function getCountryCode(): string + public function getCountryCode(): ?string { return $this->countryCode; } - public function setCountryCode(string $countryCode): self + public function setCountryCode(?string $countryCode): self { $this->countryCode = $countryCode; return $this; } - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } - public function setEmail(string $email): self + public function setEmail(?string $email): self { $this->email = $email; return $this; } - public function getDateOfBirth(): \DateTime + public function getDateOfBirth(): ?\DateTime { return $this->dateOfBirth; } - public function setDateOfBirth(\DateTime $dateOfBirth): self + public function setDateOfBirth(?\DateTime $dateOfBirth): self { $this->dateOfBirth = $dateOfBirth; return $this; } - public function getLegalForm(): string + public function getLegalForm(): ?string { return $this->legalForm; } - public function setLegalForm(string $legalForm): self + public function setLegalForm(?string $legalForm): self { $this->legalForm = $legalForm; return $this; } - public function getStreet2(): string + public function getStreet2(): ?string { return $this->street2; } - public function setStreet2(string $street2): self + public function setStreet2(?string $street2): self { $this->street2 = $street2; return $this; } - public function getCountrySubdivisionCode(): string + public function getCountrySubdivisionCode(): ?string { return $this->countrySubdivisionCode; } - public function setCountrySubdivisionCode(string $countrySubdivisionCode): self + public function setCountrySubdivisionCode(?string $countrySubdivisionCode): self { $this->countrySubdivisionCode = $countrySubdivisionCode; return $this; } - public function getPhone(): string + public function getPhone(): ?string { return $this->phone; } - public function setPhone(string $phone): self + public function setPhone(?string $phone): self { $this->phone = $phone; diff --git a/lib/SaferpayJson/Container/AddressForm.php b/lib/SaferpayJson/Container/AddressForm.php index 2c72bad..76386a3 100644 --- a/lib/SaferpayJson/Container/AddressForm.php +++ b/lib/SaferpayJson/Container/AddressForm.php @@ -5,7 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class AddressForm +final class AddressForm { const MANDATORY_FIELD_CITY = 'CITY'; const MANDATORY_FIELD_COMPANY = 'COMPANY'; @@ -23,13 +23,13 @@ class AddressForm * @var bool * @SerializedName("Display") */ - protected $display; + private $display; /** - * @var array + * @var array|null * @SerializedName("MandatoryFields") */ - protected $mandatoryFields = []; + private $mandatoryFields = []; public function __construct(bool $display = true) { @@ -41,19 +41,12 @@ public function isDisplay(): bool return $this->display; } - public function setDisplay(bool $display): self - { - $this->display = $display; - - return $this; - } - - public function getMandatoryFields(): array + public function getMandatoryFields(): ?array { return $this->mandatoryFields; } - public function setMandatoryFields(array $mandatoryFields): self + public function setMandatoryFields(?array $mandatoryFields): self { $this->mandatoryFields = $mandatoryFields; diff --git a/lib/SaferpayJson/Container/Alias.php b/lib/SaferpayJson/Container/Alias.php index 465bcbc..a0ee679 100644 --- a/lib/SaferpayJson/Container/Alias.php +++ b/lib/SaferpayJson/Container/Alias.php @@ -5,47 +5,47 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Alias +final class Alias { /** - * @var string + * @var string|null * @SerializedName("Id") * @Type("string") */ - protected $id; + private $id; /** - * @var int + * @var int|null * @SerializedName("Lifetime") * @Type("integer") */ - protected $lifetime; + private $lifetime; /** - * @var string + * @var string|null * @SerializedName("VerificationCode") * @Type("string") */ - protected $verificationCode; + private $verificationCode; - public function getId(): string + public function getId(): ?string { return $this->id; } - public function setId(string $id): self + public function setId(?string $id): self { $this->id = $id; return $this; } - 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; @@ -57,7 +57,7 @@ public function getVerificationCode(): ?string return $this->verificationCode; } - public function setVerificationCode(string $verificationCode): self + public function setVerificationCode(?string $verificationCode): self { $this->verificationCode = $verificationCode; diff --git a/lib/SaferpayJson/Container/Alipay.php b/lib/SaferpayJson/Container/Alipay.php index 3bc43dc..e782852 100644 --- a/lib/SaferpayJson/Container/Alipay.php +++ b/lib/SaferpayJson/Container/Alipay.php @@ -5,14 +5,14 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Alipay +final class Alipay { /** * @var string * @SerializedName("LocalWallet") * @Type("string") */ - protected $localWallet; + private $localWallet; public function __construct(string $localWallet) { @@ -23,11 +23,4 @@ public function getLocalWallet(): ?string { return $this->localWallet; } - - public function setLocalWallet(string $localWallet): self - { - $this->localWallet = $localWallet; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Amount.php b/lib/SaferpayJson/Container/Amount.php index 2bbecc3..89200e4 100644 --- a/lib/SaferpayJson/Container/Amount.php +++ b/lib/SaferpayJson/Container/Amount.php @@ -5,21 +5,21 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Amount +final class Amount { /** * @var int * @SerializedName("Value") * @Type("integer") */ - protected $value; + private $value; /** * @var string * @SerializedName("CurrencyCode") * @Type("string") */ - protected $currencyCode; + private $currencyCode; public function __construct(int $value, string $currencyCode) { @@ -32,22 +32,8 @@ public function getValue(): int return $this->value; } - public function setValue(int $value): self - { - $this->value = $value; - - return $this; - } - public function getCurrencyCode(): string { return $this->currencyCode; } - - public function setCurrencyCode(string $currencyCode): self - { - $this->currencyCode = $currencyCode; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/AuthenticationResult.php b/lib/SaferpayJson/Container/AuthenticationResult.php index dac342c..d8f9a9a 100644 --- a/lib/SaferpayJson/Container/AuthenticationResult.php +++ b/lib/SaferpayJson/Container/AuthenticationResult.php @@ -5,31 +5,31 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class AuthenticationResult +final class AuthenticationResult { const RESULT_OK = 'OK'; const RESULT_NOT_SUPPORTED = 'NOT_SUPPORTED'; /** - * @var string + * @var string|null * @SerializedName("Result") * @Type("string") */ - protected $result; + private $result; /** - * @var string + * @var string|null * @SerializedName("Message") * @Type("string") */ - protected $message; + private $message; public function getResult(): ?string { return $this->result; } - public function setResult(string $result): self + public function setResult(?string $result): self { $this->result = $result; @@ -41,7 +41,7 @@ public function getMessage(): ?string return $this->message; } - public function setMessage(string $message): self + public function setMessage(?string $message): self { $this->message = $message; diff --git a/lib/SaferpayJson/Container/BankAccount.php b/lib/SaferpayJson/Container/BankAccount.php index 393febc..461dac9 100644 --- a/lib/SaferpayJson/Container/BankAccount.php +++ b/lib/SaferpayJson/Container/BankAccount.php @@ -5,101 +5,101 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class BankAccount +final class BankAccount { /** - * @var string + * @var string|null * @SerializedName("Iban") * @Type("string") */ - protected $iban; + private $iban; /** - * @var string + * @var string|null * @SerializedName("HolderName") * @Type("string") */ - protected $holderName; + private $holderName; /** - * @var string + * @var string|null * @SerializedName("BIC") * @Type("string") */ - protected $bic; + private $bic; /** - * @var string + * @var string|null * @SerializedName("BankName") * @Type("string") */ - protected $bankName; + private $bankName; /** - * @var string + * @var string|null * @SerializedName("CountryCode") * @Type("string") */ - protected $countryCode; + private $countryCode; - public function __construct(string $iban) + public function __construct(?string $iban) { $this->iban = $iban; } - public function getIban(): string + public function getIban(): ?string { return $this->iban; } - public function setIban(string $iban): self + public function setIban(?string $iban): self { $this->iban = $iban; return $this; } - 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; return $this; } - public function getCountryCode(): string + public function getCountryCode(): ?string { return $this->countryCode; } - public function setCountryCode(string $countryCode): self + public function setCountryCode(?string $countryCode): self { $this->countryCode = $countryCode; diff --git a/lib/SaferpayJson/Container/Billpay.php b/lib/SaferpayJson/Container/Billpay.php index 3a49cf2..64cd0e3 100644 --- a/lib/SaferpayJson/Container/Billpay.php +++ b/lib/SaferpayJson/Container/Billpay.php @@ -5,10 +5,10 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Billpay +final class Billpay { /** - * @var int + * @var int|null * @SerializedName("DelayInDays") */ private $delayInDays; @@ -18,7 +18,7 @@ public function getDelayInDays(): ?int return $this->delayInDays; } - public function setDelayInDays(int $delayInDays): self + public function setDelayInDays(?int $delayInDays): self { $this->delayInDays = $delayInDays; diff --git a/lib/SaferpayJson/Container/Brand.php b/lib/SaferpayJson/Container/Brand.php index 4ce508b..204288b 100644 --- a/lib/SaferpayJson/Container/Brand.php +++ b/lib/SaferpayJson/Container/Brand.php @@ -5,40 +5,40 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Brand +final class Brand { /** - * @var string + * @var string|null * @SerializedName("PaymentMethod") * @Type("string") */ - protected $paymentMethod; + private $paymentMethod; /** - * @var string + * @var string|null * @SerializedName("Name") * @Type("string") */ - protected $name; + private $name; - public function getPaymentMethod(): string + public function getPaymentMethod(): ?string { return $this->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/Container/CaptureReference.php b/lib/SaferpayJson/Container/CaptureReference.php index 8d5c0fd..18ccb48 100644 --- a/lib/SaferpayJson/Container/CaptureReference.php +++ b/lib/SaferpayJson/Container/CaptureReference.php @@ -4,38 +4,38 @@ use JMS\Serializer\Annotation\SerializedName; -class CaptureReference +final class CaptureReference { /** - * @var string + * @var string|null * @SerializedName("CaptureId") */ - protected $captureId; + private $captureId; /** - * @var string + * @var string|null * @SerializedName("TransactionId") */ - protected $transactionId; + private $transactionId; /** - * @var string + * @var string|null * @SerializedName("OrderId") */ - protected $orderId; + private $orderId; /** - * @var string + * @var string|null * @SerializedName("OrderPartId") */ - protected $orderPartId; + private $orderPartId; public function getCaptureId(): ?string { return $this->captureId; } - public function setCaptureId(string $captureId): self + public function setCaptureId(?string $captureId): self { $this->captureId = $captureId; @@ -47,7 +47,7 @@ public function getTransactionId(): ?string return $this->transactionId; } - public function setTransactionId(string $transactionId): self + public function setTransactionId(?string $transactionId): self { $this->transactionId = $transactionId; @@ -59,7 +59,7 @@ public function getOrderId(): ?string return $this->orderId; } - public function setOrderId(string $orderId): self + public function setOrderId(?string $orderId): self { $this->orderId = $orderId; @@ -71,7 +71,7 @@ public function getOrderPartId(): ?string return $this->orderPartId; } - public function setOrderPartId(string $orderPartId): self + public function setOrderPartId(?string $orderPartId): self { $this->orderPartId = $orderPartId; diff --git a/lib/SaferpayJson/Container/Card.php b/lib/SaferpayJson/Container/Card.php index 08945dd..820c319 100644 --- a/lib/SaferpayJson/Container/Card.php +++ b/lib/SaferpayJson/Container/Card.php @@ -5,135 +5,135 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Card +final class Card { /** - * @var string + * @var string|null * @SerializedName("Number") * @Type("string") */ - protected $number; + private $number; /** - * @var string + * @var string|null * @SerializedName("MaskedNumber") * @Type("string") */ - protected $maskedNumber; + private $maskedNumber; /** - * @var int + * @var int|null * @SerializedName("ExpYear") * @Type("integer") */ - protected $expYear; + private $expYear; /** - * @var int + * @var int|null * @SerializedName("ExpMonth") * @Type("integer") */ - protected $expMonth; + private $expMonth; /** - * @var string + * @var string|null * @SerializedName("HolderName") * @Type("string") */ - protected $holderName; + private $holderName; /** - * @var string + * @var string|null * @SerializedName("CountryCode") * @Type("string") */ - protected $countryCode; + private $countryCode; /** - * @var string + * @var string|null * @SerializedName("HashValue") * @Type("string") */ - protected $hashValue; + private $hashValue; - public function getNumber(): string + public function getNumber(): ?string { return $this->number; } - public function setNumber(string $number): self + public function setNumber(?string $number): self { $this->number = $number; return $this; } - public function getMaskedNumber(): string + public function getMaskedNumber(): ?string { return $this->maskedNumber; } - public function setMaskedNumber(string $maskedNumber): self + public function setMaskedNumber(?string $maskedNumber): self { $this->maskedNumber = $maskedNumber; return $this; } - public function getExpYear(): int + public function getExpYear(): ?int { return $this->expYear; } - public function setExpYear(int $expYear): self + public function setExpYear(?int $expYear): self { $this->expYear = $expYear; return $this; } - public function getExpMonth(): int + public function getExpMonth(): ?int { return $this->expMonth; } - public function setExpMonth(int $expMonth): self + public function setExpMonth(?int $expMonth): self { $this->expMonth = $expMonth; return $this; } - 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 getCountryCode(): string + public function getCountryCode(): ?string { return $this->countryCode; } - public function setCountryCode(string $countryCode): self + public function setCountryCode(?string $countryCode): self { $this->countryCode = $countryCode; return $this; } - public function getHashValue(): string + public function getHashValue(): ?string { return $this->hashValue; } - public function setHashValue(string $hashValue): self + public function setHashValue(?string $hashValue): self { $this->hashValue = $hashValue; diff --git a/lib/SaferpayJson/Container/CardForm.php b/lib/SaferpayJson/Container/CardForm.php index 70b0eb0..a29b4c1 100644 --- a/lib/SaferpayJson/Container/CardForm.php +++ b/lib/SaferpayJson/Container/CardForm.php @@ -5,7 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class CardForm +final class CardForm { const HOLDER_NAME_NONE = 'NONE'; const HOLDER_NAME_MANDATORY = 'MANDATORY'; @@ -14,7 +14,7 @@ class CardForm * @var string * @SerializedName("HolderName") */ - protected $holderName; + private $holderName; public function __construct(string $holderName) { @@ -25,11 +25,4 @@ public function getHolderName(): string { return $this->holderName; } - - public function setHolderName(string $holderName): self - { - $this->holderName = $holderName; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Check.php b/lib/SaferpayJson/Container/Check.php index d5a3753..4ca5fa2 100644 --- a/lib/SaferpayJson/Container/Check.php +++ b/lib/SaferpayJson/Container/Check.php @@ -4,29 +4,29 @@ use JMS\Serializer\Annotation\SerializedName; -class Check +final class Check { const TYPE_ONLINE = 'ONLINE'; const TYPE_ONLINE_STRONG = 'ONLINE_STRONG'; /** - * @var string + * @var string|null * @SerializedName("Type") */ - protected $type; + private $type; /** - * @var string + * @var string|null * @SerializedName("TerminalId") */ - protected $terminalId; + private $terminalId; public function getType(): ?string { return $this->type; } - public function setType(string $type): self + public function setType(?string $type): self { $this->type = $type; @@ -38,7 +38,7 @@ public function getTerminalId(): ?string return $this->terminalId; } - public function setTerminalId(string $terminalId): self + public function setTerminalId(?string $terminalId): self { $this->terminalId = $terminalId; diff --git a/lib/SaferpayJson/Container/CheckResult.php b/lib/SaferpayJson/Container/CheckResult.php index 0032a83..5602c5b 100644 --- a/lib/SaferpayJson/Container/CheckResult.php +++ b/lib/SaferpayJson/Container/CheckResult.php @@ -5,35 +5,35 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class CheckResult +final class CheckResult { /** - * @var string + * @var string|null * @SerializedName("Result") * @Type("string") */ - protected $result; + private $result; /** - * @var string + * @var string|null * @SerializedName("Message") * @Type("string") */ - protected $message; + private $message; /** - * @var HolderAuthentication + * @var HolderAuthentication|null * @SerializedName("Authentication") * @Type("Ticketpark\SaferpayJson\Container\HolderAuthentication") */ - protected $authentication; + private $authentication; public function getResult(): ?string { return $this->result; } - public function setResult(string $result): self + public function setResult(?string $result): self { $this->result = $result; @@ -45,7 +45,7 @@ public function getMessage(): ?string return $this->message; } - public function setMessage(string $message): self + public function setMessage(?string $message): self { $this->message = $message; @@ -57,7 +57,7 @@ public function getAuthentication(): ?HolderAuthentication return $this->authentication; } - public function setAuthentication(HolderAuthentication $authentication): self + public function setAuthentication(?HolderAuthentication $authentication): self { $this->authentication = $authentication; diff --git a/lib/SaferpayJson/Container/ChosenPlan.php b/lib/SaferpayJson/Container/ChosenPlan.php index 263f0f1..2094a2a 100644 --- a/lib/SaferpayJson/Container/ChosenPlan.php +++ b/lib/SaferpayJson/Container/ChosenPlan.php @@ -5,7 +5,138 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class ChosenPlan extends InstallmentPlan +final class ChosenPlan { - // same code, different name + /** + * @var int|null + * @SerializedName("NumberOfInstallments") + * @Type("int") + */ + private $numberOfInstallments; + + /** + * @var string|null + * @SerializedName("InterestRate") + * @Type("string") + */ + private $interestRate; + + /** + * @var Amount|null + * @SerializedName("InstallmentFee") + * @Type("Ticketpark\SaferpayJson\Container\Amount") + */ + private $installmentFee; + + /** + * @var string|null + * @SerializedName("AnnualPercentageRate") + * @Type("string") + */ + private $annualPercentageRate; + + /** + * @var Amount|null + * @SerializedName("FirstInstallmentAmount") + * @Type("Ticketpark\SaferpayJson\Container\Amount") + */ + private $firstInstallmentAmount; + + /** + * @var Amount|null + * @SerializedName("SubsequentInstallmentAmount") + * @Type("Ticketpark\SaferpayJson\Container\Amount") + */ + private $subsequentInstallmentAmount; + + /** + * @var Amount|null + * @SerializedName("TotalAmountDue") + * @Type("Ticketpark\SaferpayJson\Container\Amount") + */ + private $totalAmountDue; + + public function getNumberOfInstallments(): ?int + { + return $this->numberOfInstallments; + } + + public function setNumberOfInstallments(?int $numberOfInstallments): self + { + $this->numberOfInstallments = $numberOfInstallments; + + return $this; + } + + 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/Container/ClientInfo.php b/lib/SaferpayJson/Container/ClientInfo.php index d01242c..9d05148 100644 --- a/lib/SaferpayJson/Container/ClientInfo.php +++ b/lib/SaferpayJson/Container/ClientInfo.php @@ -5,28 +5,28 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class ClientInfo +final class ClientInfo { /** - * @var string + * @var string|null * @SerializedName("ShopInfo") * @Type("string") */ - protected $shopInfo; + private $shopInfo; /** - * @var string + * @var string|null * @SerializedName("OsInfo") * @Type("string") */ - protected $osInfo; + private $osInfo; public function getShopInfo(): ?string { return $this->shopInfo; } - public function setShopInfo(string $shopInfo): self + public function setShopInfo(?string $shopInfo): self { $this->shopInfo = $shopInfo; @@ -38,7 +38,7 @@ public function getOsInfo(): ?string return $this->osInfo; } - public function setOsInfo(string $osInfo): self + public function setOsInfo(?string $osInfo): self { $this->osInfo = $osInfo; diff --git a/lib/SaferpayJson/Container/CustomPlan.php b/lib/SaferpayJson/Container/CustomPlan.php index e01114e..6232460 100644 --- a/lib/SaferpayJson/Container/CustomPlan.php +++ b/lib/SaferpayJson/Container/CustomPlan.php @@ -5,56 +5,56 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class CustomPlan +final class CustomPlan { /** - * @var int + * @var int|null * @SerializedName("MinimumNumberOfInstallments") * @Type("int") */ - protected $minimumNumberOfInstallments; + private $minimumNumberOfInstallments; /** - * @var int + * @var int|null * @SerializedName("MaximumNumberOfInstallments") * @Type("int") */ - protected $maximumNumberOfInstallments; + private $maximumNumberOfInstallments; /** - * @var string + * @var string|null * @SerializedName("InterestRate") * @Type("string") */ - protected $interestRate; + private $interestRate; /** - * @var Amount + * @var Amount|null * @SerializedName("InstallmentFee") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $installmentFee; + private $installmentFee; /** - * @var string + * @var string|null * @SerializedName("AnnualPercentageRate") * @Type("string") */ - protected $annualPercentageRate; + private $annualPercentageRate; /** - * @var Amount + * @var Amount|null * @SerializedName("TotalAmountDue") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $totalAmountDue; + private $totalAmountDue; public function getMinimumNumberOfInstallments(): ?int { return $this->minimumNumberOfInstallments; } - public function setMinimumNumberOfInstallments(int $minimumNumberOfInstallments): self + public function setMinimumNumberOfInstallments(?int $minimumNumberOfInstallments): self { $this->minimumNumberOfInstallments = $minimumNumberOfInstallments; @@ -66,7 +66,7 @@ public function getMaximumNumberOfInstallments(): ?int return $this->maximumNumberOfInstallments; } - public function setMaximumNumberOfInstallments(int $maximumNumberOfInstallments): self + public function setMaximumNumberOfInstallments(?int $maximumNumberOfInstallments): self { $this->maximumNumberOfInstallments = $maximumNumberOfInstallments; @@ -78,7 +78,7 @@ public function getInterestRate(): ?string return $this->interestRate; } - public function setInterestRate(string $interestRate): self + public function setInterestRate(?string $interestRate): self { $this->interestRate = $interestRate; @@ -90,7 +90,7 @@ public function getInstallmentFee(): ?Amount return $this->installmentFee; } - public function setInstallmentFee(Amount $installmentFee): self + public function setInstallmentFee(?Amount $installmentFee): self { $this->installmentFee = $installmentFee; @@ -102,7 +102,7 @@ public function getAnnualPercentageRate(): ?string return $this->annualPercentageRate; } - public function setAnnualPercentageRate(string $annualPercentageRate): self + public function setAnnualPercentageRate(?string $annualPercentageRate): self { $this->annualPercentageRate = $annualPercentageRate; @@ -114,7 +114,7 @@ public function getTotalAmountDue(): ?Amount return $this->totalAmountDue; } - public function setTotalAmountDue(Amount $totalAmountDue): self + public function setTotalAmountDue(?Amount $totalAmountDue): self { $this->totalAmountDue = $totalAmountDue; diff --git a/lib/SaferpayJson/Container/Dcc.php b/lib/SaferpayJson/Container/Dcc.php index 7fae153..715d81f 100644 --- a/lib/SaferpayJson/Container/Dcc.php +++ b/lib/SaferpayJson/Container/Dcc.php @@ -5,21 +5,21 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Dcc +final class Dcc { /** - * @var Amount + * @var Amount|null * @SerializedName("PayerAmount") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ private $payerAmount; - public function getPayerAmount(): Amount + public function getPayerAmount(): ?Amount { return $this->payerAmount; } - public function setPayerAmount(Amount $payerAmount): self + public function setPayerAmount(?Amount $payerAmount): self { $this->payerAmount = $payerAmount; diff --git a/lib/SaferpayJson/Container/DirectDebit.php b/lib/SaferpayJson/Container/DirectDebit.php index 73278bb..9d165f9 100644 --- a/lib/SaferpayJson/Container/DirectDebit.php +++ b/lib/SaferpayJson/Container/DirectDebit.php @@ -5,28 +5,28 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class DirectDebit +final class DirectDebit { /** - * @var string + * @var string|null * @SerializedName("MandateId") * @Type("string") */ - protected $mandateId; + private $mandateId; /** - * @var string + * @var string|null * @SerializedName("CreditorId") * @Type("string") */ - protected $creditorId; + private $creditorId; public function getMandateId(): ?string { return $this->mandateId; } - public function setMandateId(string $mandateId): self + public function setMandateId(?string $mandateId): self { $this->mandateId = $mandateId; @@ -38,7 +38,7 @@ public function getCreditorId(): ?string return $this->creditorId; } - public function setCreditorId(string $creditorId): self + public function setCreditorId(?string $creditorId): self { $this->creditorId = $creditorId; diff --git a/lib/SaferpayJson/Container/Error.php b/lib/SaferpayJson/Container/Error.php index 920b40e..033b3f0 100644 --- a/lib/SaferpayJson/Container/Error.php +++ b/lib/SaferpayJson/Container/Error.php @@ -5,40 +5,40 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Error +final class Error { /** - * @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; - public function getErrorName(): string + public function getErrorName(): ?string { return $this->errorName; } - public function setErrorName(string $errorName): self + 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 + public function setErrorMessage(?string $errorMessage): self { $this->errorMessage = $errorMessage; diff --git a/lib/SaferpayJson/Container/HolderAuthentication.php b/lib/SaferpayJson/Container/HolderAuthentication.php index c897138..4f99e51 100644 --- a/lib/SaferpayJson/Container/HolderAuthentication.php +++ b/lib/SaferpayJson/Container/HolderAuthentication.php @@ -5,38 +5,38 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class HolderAuthentication +final class HolderAuthentication { const RESULT_OK = 'OK'; const RESULT_NOT_SUPPORTED = 'NOT_SUPPORTED'; /** - * @var string + * @var string|null * @SerializedName("Result") * @Type("string") */ - protected $result; + private $result; /** - * @var string + * @var string|null * @SerializedName("Message") * @Type("string") */ - protected $message; + private $message; /** - * @var string + * @var string|null * @SerializedName("Xid") * @Type("string") */ - protected $xid; + private $xid; public function getResult(): ?string { return $this->result; } - public function setResult(string $result): self + public function setResult(?string $result): self { $this->result = $result; @@ -48,7 +48,7 @@ public function getMessage(): ?string return $this->message; } - public function setMessage(string $message): self + public function setMessage(?string $message): self { $this->message = $message; @@ -60,7 +60,7 @@ public function getXid(): ?string return $this->xid; } - public function setXid(string $xid): self + public function setXid(?string $xid): self { $this->xid = $xid; diff --git a/lib/SaferpayJson/Container/Ideal.php b/lib/SaferpayJson/Container/Ideal.php index fad7933..ad84f82 100644 --- a/lib/SaferpayJson/Container/Ideal.php +++ b/lib/SaferpayJson/Container/Ideal.php @@ -5,29 +5,22 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Ideal +final class Ideal { /** * @var string * @SerializedName("IssuerId") * @Type("string") */ - protected $issuerId; + private $issuerId; public function __construct(string $issuerId) { $this->issuerId = $issuerId; } - public function getIssuerId(): ?string + public function getIssuerId(): string { return $this->issuerId; } - - public function setIssuerId(string $issuerId): self - { - $this->issuerId = $issuerId; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Installment.php b/lib/SaferpayJson/Container/Installment.php index f089d62..22754f8 100644 --- a/lib/SaferpayJson/Container/Installment.php +++ b/lib/SaferpayJson/Container/Installment.php @@ -4,13 +4,13 @@ use JMS\Serializer\Annotation\SerializedName; -class Installment +final class Installment { /** * @var bool * @SerializedName("Initial") */ - protected $initial; + private $initial; public function __construct(bool $initial = true) { @@ -21,11 +21,4 @@ public function isInitial(): bool { return $this->initial; } - - public function setInitial(bool $initial): self - { - $this->initial = $initial; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/InstallmentPlan.php b/lib/SaferpayJson/Container/InstallmentPlan.php index efeaef0..26df0e0 100644 --- a/lib/SaferpayJson/Container/InstallmentPlan.php +++ b/lib/SaferpayJson/Container/InstallmentPlan.php @@ -5,63 +5,63 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class InstallmentPlan +final class InstallmentPlan { /** - * @var int + * @var int|null * @SerializedName("NumberOfInstallments") * @Type("int") */ - protected $numberOfInstallments; + private $numberOfInstallments; /** - * @var string + * @var string|null * @SerializedName("InterestRate") * @Type("string") */ - protected $interestRate; + private $interestRate; /** - * @var Amount + * @var Amount|null * @SerializedName("InstallmentFee") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $installmentFee; + private $installmentFee; /** - * @var string + * @var string|null * @SerializedName("AnnualPercentageRate") * @Type("string") */ - protected $annualPercentageRate; + private $annualPercentageRate; /** - * @var Amount + * @var Amount|null * @SerializedName("FirstInstallmentAmount") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $firstInstallmentAmount; + private $firstInstallmentAmount; /** - * @var Amount + * @var Amount|null * @SerializedName("SubsequentInstallmentAmount") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $subsequentInstallmentAmount; + private $subsequentInstallmentAmount; /** - * @var Amount + * @var Amount|null * @SerializedName("TotalAmountDue") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $totalAmountDue; + private $totalAmountDue; public function getNumberOfInstallments(): ?int { return $this->numberOfInstallments; } - public function setNumberOfInstallments(int $numberOfInstallments): self + public function setNumberOfInstallments(?int $numberOfInstallments): self { $this->numberOfInstallments = $numberOfInstallments; @@ -73,7 +73,7 @@ public function getInterestRate(): ?string return $this->interestRate; } - public function setInterestRate(string $interestRate): self + public function setInterestRate(?string $interestRate): self { $this->interestRate = $interestRate; @@ -85,7 +85,7 @@ public function getInstallmentFee(): ?Amount return $this->installmentFee; } - public function setInstallmentFee(Amount $installmentFee): self + public function setInstallmentFee(?Amount $installmentFee): self { $this->installmentFee = $installmentFee; @@ -97,7 +97,7 @@ public function getAnnualPercentageRate(): ?string return $this->annualPercentageRate; } - public function setAnnualPercentageRate(string $annualPercentageRate): self + public function setAnnualPercentageRate(?string $annualPercentageRate): self { $this->annualPercentageRate = $annualPercentageRate; @@ -109,7 +109,7 @@ public function getFirstInstallmentAmount(): ?Amount return $this->firstInstallmentAmount; } - public function setFirstInstallmentAmount(Amount $firstInstallmentAmount): self + public function setFirstInstallmentAmount(?Amount $firstInstallmentAmount): self { $this->firstInstallmentAmount = $firstInstallmentAmount; @@ -121,7 +121,7 @@ public function getSubsequentInstallmentAmount(): ?Amount return $this->subsequentInstallmentAmount; } - public function setSubsequentInstallmentAmount(Amount $subsequentInstallmentAmount): self + public function setSubsequentInstallmentAmount(?Amount $subsequentInstallmentAmount): self { $this->subsequentInstallmentAmount = $subsequentInstallmentAmount; @@ -133,7 +133,7 @@ public function getTotalAmountDue(): ?Amount return $this->totalAmountDue; } - public function setTotalAmountDue(Amount $totalAmountDue): self + public function setTotalAmountDue(?Amount $totalAmountDue): self { $this->totalAmountDue = $totalAmountDue; diff --git a/lib/SaferpayJson/Container/Invoice.php b/lib/SaferpayJson/Container/Invoice.php index 3a8700c..500d023 100644 --- a/lib/SaferpayJson/Container/Invoice.php +++ b/lib/SaferpayJson/Container/Invoice.php @@ -6,59 +6,59 @@ use JMS\Serializer\Annotation\Type; use Ticketpark\SaferpayJson\Container\Payee; -class Invoice +final class Invoice { /** - * @var Payee + * @var Payee|null * @SerializedName("Payee") * @Type("Ticketpark\SaferpayJson\Container\Payee") */ - protected $payee; + private $payee; /** - * @var string + * @var string|null * @SerializedName("ReasonForTransfer") * @Type("string") */ - protected $reasonForTransfer; + private $reasonForTransfer; /** - * @var string + * @var string|null * @SerializedName("DueDate") * @Type("string") */ - protected $dueDate; + private $dueDate; - public function getPayee(): Payee + public function getPayee(): ?Payee { return $this->payee; } - public function setPayee(Payee $payee): self + public function setPayee(?Payee $payee): self { $this->payee = $payee; return $this; } - public function getReasonForTransfer(): string + public function getReasonForTransfer(): ?string { return $this->reasonForTransfer; } - public function setReasonForTransfer(string $reasonForTransfer): self + public function setReasonForTransfer(?string $reasonForTransfer): self { $this->reasonForTransfer = $reasonForTransfer; return $this; } - public function getDueDate(): string + public function getDueDate(): ?string { return $this->dueDate; } - public function setDueDate(string $dueDate): self + public function setDueDate(?string $dueDate): self { $this->dueDate = $dueDate; diff --git a/lib/SaferpayJson/Container/Liability.php b/lib/SaferpayJson/Container/Liability.php index 168dcc7..46c3c50 100644 --- a/lib/SaferpayJson/Container/Liability.php +++ b/lib/SaferpayJson/Container/Liability.php @@ -5,35 +5,35 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Liability +final class Liability { /** - * @var bool + * @var bool|null * @SerializedName("LiabilityShift") * @Type("boolean") */ - protected $liabilityShift; + private $liabilityShift; /** - * @var string + * @var string|null * @SerializedName("LiableEntity") * @Type("string") */ - protected $liableEntity; + private $liableEntity; /** - * @var ThreeDs + * @var ThreeDs|null * @SerializedName("ThreeDs") * @Type("Ticketpark\SaferpayJson\Container\ThreeDs") */ - protected $threeDs; + private $threeDs; public function isLiabilityShift(): ?bool { return $this->liabilityShift; } - public function setLiabilityShift(bool $liabilityShift): self + public function setLiabilityShift(?bool $liabilityShift): self { $this->liabilityShift = $liabilityShift; @@ -45,7 +45,7 @@ public function getLiableEntity(): ?string return $this->liableEntity; } - public function setLiableEntity(string $liableEntity): self + public function setLiableEntity(?string $liableEntity): self { $this->liableEntity = $liableEntity; @@ -57,7 +57,7 @@ public function getThreeDs(): ?ThreeDs return $this->threeDs; } - public function setThreeDs(ThreeDs $threeDs): self + public function setThreeDs(?ThreeDs $threeDs): self { $this->threeDs = $threeDs; diff --git a/lib/SaferpayJson/Container/Marketplace.php b/lib/SaferpayJson/Container/Marketplace.php index 51fd9df..51d0a8f 100644 --- a/lib/SaferpayJson/Container/Marketplace.php +++ b/lib/SaferpayJson/Container/Marketplace.php @@ -4,32 +4,32 @@ use JMS\Serializer\Annotation\SerializedName; -class Marketplace +final class Marketplace { /** - * @var string + * @var string|null * @SerializedName("SubmerchantId") */ - protected $submerchantId; + private $submerchantId; /** - * @var Amount + * @var Amount|null * @SerializedName("Fee") */ - protected $fee; + private $fee; /** - * @var Amount + * @var Amount|null * @SerializedName("FeeRefund") */ - protected $feeRefund; + private $feeRefund; public function getSubmerchantId(): ?string { return $this->submerchantId; } - public function setSubmerchantId(string $submerchantId): self + public function setSubmerchantId(?string $submerchantId): self { $this->submerchantId = $submerchantId; @@ -41,7 +41,7 @@ public function getFee(): ?Amount return $this->fee; } - public function setFee(Amount $fee): self + public function setFee(?Amount $fee): self { $this->fee = $fee; @@ -53,7 +53,7 @@ public function getFeeRefund(): ?Amount return $this->feeRefund; } - public function setFeeRefund(Amount $feeRefund): self + public function setFeeRefund(?Amount $feeRefund): self { $this->feeRefund = $feeRefund; diff --git a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php index 532af57..3ccb901 100644 --- a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php +++ b/lib/SaferpayJson/Container/MastercardIssuerInstallments.php @@ -5,42 +5,42 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class MastercardIssuerInstallments +final class MastercardIssuerInstallments { /** - * @var array + * @var array|null * @SerializedName("InstallmentPlans") * @Type("array") */ - protected $installmentPlans; + private $installmentPlans; /** - * @var CustomPlan + * @var CustomPlan|null * @SerializedName("CustomPlan") * @Type("Ticketpark\SaferpayJson\Container\CustomPlan") */ - protected $customPlan; + private $customPlan; /** - * @var string + * @var string|null * @SerializedName("ReceiptFreeText") * @Type("string") */ - protected $receiptFreeText; + private $receiptFreeText; /** - * @var ChosenPlan + * @var ChosenPlan|null * @SerializedName("ChosenPlan") * @Type("array") */ - protected $chosenPlan; + private $chosenPlan; public function getInstallmentPlans(): ?array { return $this->installmentPlans; } - public function setInstallmentPlans(array $installmentPlans): self + public function setInstallmentPlans(?array $installmentPlans): self { $this->installmentPlans = $installmentPlans; @@ -52,7 +52,7 @@ public function getCustomPlan(): ?CustomPlan return $this->customPlan; } - public function setCustomPlan(CustomPlan $customPlan): self + public function setCustomPlan(?CustomPlan $customPlan): self { $this->customPlan = $customPlan; @@ -64,7 +64,7 @@ public function getReceiptFreeText(): ?string return $this->receiptFreeText; } - public function setReceiptFreeText(string $receiptFreeText): self + public function setReceiptFreeText(?string $receiptFreeText): self { $this->receiptFreeText = $receiptFreeText; @@ -76,7 +76,7 @@ public function getChosenPlan(): ?ChosenPlan return $this->chosenPlan; } - public function setChosenPlan(ChosenPlan $chosenPlan): self + public function setChosenPlan(?ChosenPlan $chosenPlan): self { $this->chosenPlan = $chosenPlan; diff --git a/lib/SaferpayJson/Container/Notification.php b/lib/SaferpayJson/Container/Notification.php index 7f428da..851762f 100644 --- a/lib/SaferpayJson/Container/Notification.php +++ b/lib/SaferpayJson/Container/Notification.php @@ -4,32 +4,32 @@ use JMS\Serializer\Annotation\SerializedName; -class Notification +final class Notification { /** - * @var array + * @var array|null * @SerializedName("MerchantEmails") */ - protected $merchantEmails = []; + private $merchantEmails = []; /** * @var string|null * @SerializedName("PayerEmail") */ - protected $payerEmail; + private $payerEmail; /** * @var string|null * @SerializedName("NotifyUrl") */ - protected $notifyUrl; + private $notifyUrl; - public function getMerchantEmails(): array + public function getMerchantEmails(): ?array { return $this->merchantEmails; } - public function setMerchantEmails(array $merchantEmails): self + public function setMerchantEmails(?array $merchantEmails): self { $this->merchantEmails = $merchantEmails; diff --git a/lib/SaferpayJson/Container/Options.php b/lib/SaferpayJson/Container/Options.php index 1bc2826..14fbc85 100644 --- a/lib/SaferpayJson/Container/Options.php +++ b/lib/SaferpayJson/Container/Options.php @@ -5,20 +5,20 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Options +final class Options { /** - * @var bool + * @var bool|null * @SerializedName("PreAuth") */ - protected $preAuth; + private $preAuth; public function isPreAuth(): ?bool { return $this->preAuth; } - public function setPreAuth(bool $preAuth): self + public function setPreAuth(?bool $preAuth): self { $this->preAuth = $preAuth; diff --git a/lib/SaferpayJson/Container/Payee.php b/lib/SaferpayJson/Container/Payee.php index ffcf4b5..e337f92 100644 --- a/lib/SaferpayJson/Container/Payee.php +++ b/lib/SaferpayJson/Container/Payee.php @@ -5,79 +5,78 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Payee +final class Payee { /** - * @var string + * @var string|null * @SerializedName("Iban") * @Type("string") */ - protected $iban; + private $iban; /** - * @var string + * @var string|null * @SerializedName("HolderName") * @Type("string") */ - protected $holderName; + private $holderName; /** - * @var string + * @var string|null * @SerializedName("Bic") * @Type("string") */ - protected $bic; - + private $bic; /** - * @var string + * @var string|null * @SerializedName("BankName") * @Type("string") */ - protected $bankName; + private $bankName; - public function getIban(): string + public function getIban(): ?string { return $this->iban; } - public function setIban(string $iban): self + public function setIban(?string $iban): self { $this->iban = $iban; return $this; } - 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/Container/Payer.php b/lib/SaferpayJson/Container/Payer.php index b3a3c3f..0f58c9f 100644 --- a/lib/SaferpayJson/Container/Payer.php +++ b/lib/SaferpayJson/Container/Payer.php @@ -5,49 +5,49 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Payer +final class Payer { /** - * @var string + * @var string|null * @SerializedName("IpAddress") * @Type("string") */ - protected $ipAddress; + private $ipAddress; /** - * @var string + * @var string|null * @SerializedName("IpLocation") * @Type("string") */ - protected $ipLocation; + private $ipLocation; /** - * @var string + * @var string|null * @SerializedName("LanguageCode") * @Type("string") */ - protected $languageCode; + private $languageCode; /** - * @var Address + * @var Address|null * @SerializedName("DeliveryAddress") * @Type("Ticketpark\SaferpayJson\Container\Address") */ - protected $deliveryAddress; + private $deliveryAddress; /** - * @var Address + * @var Address|null * @SerializedName("BillingAddress") * @Type("Ticketpark\SaferpayJson\Container\Address") */ - protected $billingAddress; + private $billingAddress; - public function getIpAddress(): string + public function getIpAddress(): ?string { return $this->ipAddress; } - public function setIpAddress(string $ipAddress): self + public function setIpAddress(?string $ipAddress): self { $this->ipAddress = $ipAddress; @@ -59,43 +59,43 @@ public function getIpLocation(): ?string return $this->ipLocation; } - public function setIpLocation(string $ipLocation): self + public function setIpLocation(?string $ipLocation): self { $this->ipLocation = $ipLocation; 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/Container/Payment.php b/lib/SaferpayJson/Container/Payment.php index 1c38950..773ca66 100644 --- a/lib/SaferpayJson/Container/Payment.php +++ b/lib/SaferpayJson/Container/Payment.php @@ -4,55 +4,55 @@ use JMS\Serializer\Annotation\SerializedName; -class Payment +final class Payment { /** * @var Amount * @SerializedName("Amount") */ - protected $amount; + private $amount; /** * @var string|null * @SerializedName("OrderId") */ - protected $orderId; + private $orderId; /** * @var string|null * @SerializedName("PayerNote") */ - protected $payerNote; + private $payerNote; /** - * @var string + * @var string|null * @SerializedName("Description") */ - protected $description; + private $description; /** * @var string|null * @SerializedName("MandateId") */ - protected $mandateId; + private $mandateId; /** * @var Options|null * @SerializedName("Options") */ - protected $options; + private $options; /** * @var Recurring|null * @SerializedName("Recurring") */ - protected $recurring; + private $recurring; /** * @var Installment|null * @SerializedName("Installment") */ - protected $installment; + private $installment; public function __construct(Amount $amount) { @@ -95,12 +95,12 @@ public function setPayerNote(string $payerNote): self return $this; } - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } - public function setDescription(string $description): self + public function setDescription(?string $description): self { $this->description = $description; diff --git a/lib/SaferpayJson/Container/PaymentMeans.php b/lib/SaferpayJson/Container/PaymentMeans.php index 6594b78..9d9e3b1 100644 --- a/lib/SaferpayJson/Container/PaymentMeans.php +++ b/lib/SaferpayJson/Container/PaymentMeans.php @@ -8,118 +8,118 @@ use Ticketpark\SaferpayJson\Container\Brand; use Ticketpark\SaferpayJson\Container\Card; -class PaymentMeans +final class PaymentMeans { /** - * @var Brand + * @var Brand|null * @SerializedName("Brand") * @Type("Ticketpark\SaferpayJson\Container\Brand") */ - protected $brand; + private $brand; /** - * @var string + * @var string|null * @SerializedName("DisplayText") * @Type("string") */ - protected $displayText; + private $displayText; /** - * @var string + * @var string|null * @SerializedName("Wallet") * @Type("string") */ - protected $wallet; + private $wallet; /** - * @var Card + * @var Card|null * @SerializedName("Card") * @Type("Ticketpark\SaferpayJson\Container\Card") */ - protected $card; + private $card; /** - * @var BankAccount + * @var BankAccount|null * @SerializedName("BankAccount") * @Type("Ticketpark\SaferpayJson\Container\BankAccount") */ - protected $bankAccount; + private $bankAccount; /** - * @var Twint + * @var Twint|null * @SerializedName("Twint") * @Type("Ticketpark\SaferpayJson\Container\Twint") */ - protected $twint; + private $twint; /** - * @var SaferpayFields + * @var SaferpayFields|null * @SerializedName("SaferpayFields") * @Type("Ticketpark\SaferpayJson\Container\SaferpayFields") */ - protected $saferpayFields; + private $saferpayFields; /** - * @var Alias + * @var Alias|null * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Container\Alias") */ - protected $alias; + private $alias; - public function getBrand(): Brand + public function getBrand(): ?Brand { return $this->brand; } - public function setBrand(Brand $brand): self + public function setBrand(?Brand $brand): self { $this->brand = $brand; return $this; } - public function getDisplayText(): string + public function getDisplayText(): ?string { return $this->displayText; } - public function setDisplayText(string $displayText): self + public function setDisplayText(?string $displayText): self { $this->displayText = $displayText; return $this; } - public function getWallet(): string + public function getWallet(): ?string { return $this->wallet; } - public function setWallet(string $wallet): self + public function setWallet(?string $wallet): self { $this->wallet = $wallet; return $this; } - public function getCard(): Card + public function getCard(): ?Card { return $this->card; } - public function setCard(Card $card): self + public function setCard(?Card $card): self { $this->card = $card; return $this; } - public function getBankAccount(): BankAccount + public function getBankAccount(): ?BankAccount { return $this->bankAccount; } - public function setBankAccount(BankAccount $bankAccount): self + public function setBankAccount(?BankAccount $bankAccount): self { $this->bankAccount = $bankAccount; @@ -131,7 +131,7 @@ public function getTwint(): ?Twint return $this->twint; } - public function setTwint(Twint $twint): self + public function setTwint(?Twint $twint): self { $this->twint = $twint; @@ -143,7 +143,7 @@ public function getSaferpayFields(): ?SaferpayFields return $this->saferpayFields; } - public function setSaferpayFields(SaferpayFields $saferpayFields): self + public function setSaferpayFields(?SaferpayFields $saferpayFields): self { $this->saferpayFields = $saferpayFields; @@ -155,7 +155,7 @@ public function getAlias(): ?Alias return $this->alias; } - public function setAlias(Alias $alias): self + public function setAlias(?Alias $alias): self { $this->alias = $alias; diff --git a/lib/SaferpayJson/Container/PaymentMethodsOptions.php b/lib/SaferpayJson/Container/PaymentMethodsOptions.php index 6759d94..be5b0ac 100644 --- a/lib/SaferpayJson/Container/PaymentMethodsOptions.php +++ b/lib/SaferpayJson/Container/PaymentMethodsOptions.php @@ -5,26 +5,26 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class PaymentMethodsOptions +final class PaymentMethodsOptions { /** - * @var Alipay + * @var Alipay|null * @SerializedName("Alipay") */ - protected $alipay; + private $alipay; /** - * @var Ideal + * @var Ideal|null * @SerializedName("Ideal") */ - protected $ideal; + private $ideal; public function getAlipay(): ?Alipay { return $this->alipay; } - public function setAlipay(Alipay $alipay): self + public function setAlipay(?Alipay $alipay): self { $this->alipay = $alipay; @@ -36,7 +36,7 @@ public function getIdeal(): ?Ideal return $this->ideal; } - public function setIdeal(Ideal $ideal): self + public function setIdeal(?Ideal $ideal): self { $this->ideal = $ideal; diff --git a/lib/SaferpayJson/Container/PendingNotification.php b/lib/SaferpayJson/Container/PendingNotification.php index 10e3001..fe94c26 100644 --- a/lib/SaferpayJson/Container/PendingNotification.php +++ b/lib/SaferpayJson/Container/PendingNotification.php @@ -4,26 +4,26 @@ use JMS\Serializer\Annotation\SerializedName; -class PendingNotification +final class PendingNotification { /** - * @var array + * @var array|null * @SerializedName("MerchantEmails") */ - protected $merchantEmails = []; + private $merchantEmails = []; /** * @var string|null * @SerializedName("NotifyUrl") */ - protected $notifyUrl; + private $notifyUrl; - public function getMerchantEmails(): array + public function getMerchantEmails(): ?array { return $this->merchantEmails; } - public function setMerchantEmails(array $merchantEmails): self + public function setMerchantEmails(?array $merchantEmails): self { $this->merchantEmails = $merchantEmails; @@ -35,7 +35,7 @@ public function getNotifyUrl(): ?string return $this->notifyUrl; } - public function setNotifyUrl(string $notifyUrl): self + public function setNotifyUrl(?string $notifyUrl): self { $this->notifyUrl = $notifyUrl; diff --git a/lib/SaferpayJson/Container/Recurring.php b/lib/SaferpayJson/Container/Recurring.php index 17df0a3..1923a8a 100644 --- a/lib/SaferpayJson/Container/Recurring.php +++ b/lib/SaferpayJson/Container/Recurring.php @@ -4,13 +4,13 @@ use JMS\Serializer\Annotation\SerializedName; -class Recurring +final class Recurring { /** * @var bool * @SerializedName("Initial") */ - protected $initial; + private $initial; public function __construct(bool $initial = true) { @@ -21,11 +21,4 @@ public function isInitial(): bool { return $this->initial; } - - public function setInitial(bool $initial): self - { - $this->initial = $initial; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Redirect.php b/lib/SaferpayJson/Container/Redirect.php index 3adb75d..1b8d69c 100644 --- a/lib/SaferpayJson/Container/Redirect.php +++ b/lib/SaferpayJson/Container/Redirect.php @@ -5,28 +5,28 @@ use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\SerializedName; -class Redirect +final class Redirect { /** - * @var string + * @var string|null * @SerializedName("RedirectUrl") * @Type("string") */ - protected $redirectUrl; + private $redirectUrl; /** - * @var bool + * @var bool|null * @SerializedName("PaymentMeansRequired") * @Type("bool") */ - protected $paymentMeansRequired; + private $paymentMeansRequired; public function getRedirectUrl(): ?string { return $this->redirectUrl; } - public function setRedirectUrl(string $redirectUrl): self + public function setRedirectUrl(?string $redirectUrl): self { $this->redirectUrl = $redirectUrl; @@ -38,7 +38,7 @@ public function isPaymentMeansRequired(): ?bool return $this->paymentMeansRequired; } - public function setPaymentMeansRequired(bool $paymentMeansRequired): self + public function setPaymentMeansRequired(?bool $paymentMeansRequired): self { $this->paymentMeansRequired = $paymentMeansRequired; diff --git a/lib/SaferpayJson/Container/Refund.php b/lib/SaferpayJson/Container/Refund.php index 478065a..d432368 100644 --- a/lib/SaferpayJson/Container/Refund.php +++ b/lib/SaferpayJson/Container/Refund.php @@ -5,64 +5,64 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Refund +final class Refund { /** - * @var Amount + * @var Amount|null * @SerializedName("Amount") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $amount; + private $amount; /** - * @var string + * @var string|null * @SerializedName("OrderId") * @Type("string") */ - protected $orderId; + private $orderId; /** - * @var string + * @var string|null * @SerializedName("Description") * @Type("string") */ - protected $description; + private $description; - public function __construct(Amount $amount) + public function __construct(?Amount $amount) { $this->amount = $amount; } - public function getAmount(): Amount + public function getAmount(): ?Amount { return $this->amount; } - public function setAmount(Amount $amount): self + public function setAmount(?Amount $amount): self { $this->amount = $amount; 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; return $this; } - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } - public function setDescription(string $description): self + public function setDescription(?string $description): self { $this->description = $description; diff --git a/lib/SaferpayJson/Container/RegisterAlias.php b/lib/SaferpayJson/Container/RegisterAlias.php index b228de0..6e12c61 100644 --- a/lib/SaferpayJson/Container/RegisterAlias.php +++ b/lib/SaferpayJson/Container/RegisterAlias.php @@ -5,7 +5,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class RegisterAlias +final class RegisterAlias { const ID_GENERATOR_MANUAL = 'MANUAL'; const ID_GENERATOR_RANDOM = 'RANDOM'; @@ -16,23 +16,23 @@ class RegisterAlias * @SerializedName("IdGenerator") * @Type("string") */ - protected $idGenerator; + private $idGenerator; /** - * @var string + * @var string|null * @SerializedName("Id") * @Type("string") */ - protected $id; + private $id; /** - * @var int + * @var int|null * @SerializedName("Lifetime") * @Type("integer") */ - protected $lifetime; + private $lifetime; - public function __construct(string $idGenerator = self::ID_GENERATOR_RANDOM) + public function __construct(string $idGenerator) { $this->idGenerator = $idGenerator; } @@ -42,31 +42,24 @@ public function getIdGenerator(): string return $this->idGenerator; } - public function setIdGenerator(string $idGenerator): self - { - $this->idGenerator = $idGenerator; - - return $this; - } - - public function getId(): string + public function getId(): ?string { return $this->id; } - public function setId(string $id): self + public function setId(?string $id): self { $this->id = $id; return $this; } - 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/Container/RegistrationResult.php b/lib/SaferpayJson/Container/RegistrationResult.php index 336b4bd..0e90725 100644 --- a/lib/SaferpayJson/Container/RegistrationResult.php +++ b/lib/SaferpayJson/Container/RegistrationResult.php @@ -5,65 +5,65 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class RegistrationResult +final class RegistrationResult { /** - * @var bool + * @var bool|null * @SerializedName("Success") * @Type("boolean") */ - protected $success; + private $success; /** - * @var Alias + * @var Alias|null * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Container\Alias") */ - protected $alias; + private $alias; /** - * @var Error + * @var Error|null * @SerializedName("Error") * @Type("Ticketpark\SaferpayJson\Container\Error") */ - protected $error; + private $error; /** - * @var AuthenticationResult + * @var AuthenticationResult|null * @SerializedName("AuthenticationResult") * @Type("Ticketpark\SaferpayJson\Container\AuthenticationResult") */ - protected $authenticationResult; + private $authenticationResult; - public function isSuccess(): bool + public function isSuccess(): ?bool { return $this->success; } - public function setSuccess(bool $success): self + public function setSuccess(?bool $success): self { $this->success = $success; return $this; } - public function getAlias(): Alias + public function getAlias(): ?Alias { return $this->alias; } - public function setAlias(Alias $alias): self + public function setAlias(?Alias $alias): self { $this->alias = $alias; return $this; } - public function getError(): Error + public function getError(): ?Error { return $this->error; } - public function setError(Error $error): self + public function setError(?Error $error): self { $this->error = $error; @@ -75,7 +75,7 @@ public function getAuthenticationResult(): ?AuthenticationResult return $this->authenticationResult; } - public function setAuthenticationResult(AuthenticationResult $authenticationResult): self + public function setAuthenticationResult(?AuthenticationResult $authenticationResult): self { $this->authenticationResult = $authenticationResult; diff --git a/lib/SaferpayJson/Container/RequestHeader.php b/lib/SaferpayJson/Container/RequestHeader.php index 58cbc89..c0f21b2 100644 --- a/lib/SaferpayJson/Container/RequestHeader.php +++ b/lib/SaferpayJson/Container/RequestHeader.php @@ -4,37 +4,37 @@ use JMS\Serializer\Annotation\SerializedName; -class RequestHeader +final class RequestHeader { /** * @var string * @SerializedName("SpecVersion") */ - protected $specVersion = '1.17'; + private $specVersion = '1.17'; /** * @var string * @SerializedName("CustomerId") */ - protected $customerId; + private $customerId; /** * @var string|null * @SerializedName("RequestId") */ - protected $requestId; + private $requestId; /** * @var int * @SerializedName("RetryIndicator") */ - protected $retryIndicator = 0; + private $retryIndicator = 0; /** * @var ClientInfo|null * @SerializedName("ClientInfo") */ - protected $clientInfo; + private $clientInfo; public function __construct(string $customerId, string $requestId = null, int $retryIndicator = 0) { diff --git a/lib/SaferpayJson/Container/ResponseHeader.php b/lib/SaferpayJson/Container/ResponseHeader.php index f485e48..2f32b98 100644 --- a/lib/SaferpayJson/Container/ResponseHeader.php +++ b/lib/SaferpayJson/Container/ResponseHeader.php @@ -5,43 +5,29 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class ResponseHeader +final class ResponseHeader { /** * @var string * @SerializedName("SpecVersion") * @Type("string") */ - protected $specVersion; + private $specVersion; /** * @var string * @SerializedName("RequestId") * @Type("string") */ - protected $requestId; + private $requestId; public function getSpecVersion(): string { return $this->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/Container/ReturnUrls.php b/lib/SaferpayJson/Container/ReturnUrls.php index 1e94470..055762f 100644 --- a/lib/SaferpayJson/Container/ReturnUrls.php +++ b/lib/SaferpayJson/Container/ReturnUrls.php @@ -4,25 +4,25 @@ use JMS\Serializer\Annotation\SerializedName; -class ReturnUrls +final class ReturnUrls { /** * @var string * @SerializedName("Success") */ - protected $success; + private $success; /** * @var string * @SerializedName("Fail") */ - protected $fail; + private $fail; /** * @var string|null * @SerializedName("Abort") */ - protected $abort; + private $abort; public function __construct(string $success, string $fail, string $abort = null) { @@ -36,25 +36,11 @@ public function getSuccess(): string return $this->success; } - public function setSuccess(string $success): self - { - $this->success = $success; - - return $this; - } - public function getFail(): string { return $this->fail; } - public function setFail(string $fail): self - { - $this->fail = $fail; - - return $this; - } - public function getAbort(): ?string { return $this->abort; diff --git a/lib/SaferpayJson/Container/SaferpayFields.php b/lib/SaferpayJson/Container/SaferpayFields.php index 0db357b..63581dd 100644 --- a/lib/SaferpayJson/Container/SaferpayFields.php +++ b/lib/SaferpayJson/Container/SaferpayFields.php @@ -5,13 +5,13 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class SaferpayFields +final class SaferpayFields { /** * @var string * @SerializedName("Token") */ - protected $token; + private $token; public function __construct(string $token) { @@ -22,11 +22,4 @@ public function getToken(): ?string { return $this->token; } - - public function setToken(string $token): self - { - $this->token = $token; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Styling.php b/lib/SaferpayJson/Container/Styling.php index 090f9ae..0742aaf 100644 --- a/lib/SaferpayJson/Container/Styling.php +++ b/lib/SaferpayJson/Container/Styling.php @@ -4,7 +4,7 @@ use JMS\Serializer\Annotation\SerializedName; -class Styling +final class Styling { const THEME_DEFAULT = 'DEFAULT'; const THEME_SIX = 'SIX'; @@ -14,20 +14,20 @@ class Styling * @var string|null * @SerializedName("CssUrl") */ - protected $cssUrl; + private $cssUrl; /** * @var string|null * @SerializedName("Theme") */ - protected $theme; + private $theme; public function getCssUrl(): ?string { return $this->cssUrl; } - public function setCssUrl(string $cssUrl): self + public function setCssUrl(?string $cssUrl): self { $this->cssUrl = $cssUrl; @@ -39,7 +39,7 @@ public function getTheme(): ?string return $this->theme; } - public function setTheme(string $theme): self + public function setTheme(?string $theme): self { $this->theme = $theme; diff --git a/lib/SaferpayJson/Container/ThreeDs.php b/lib/SaferpayJson/Container/ThreeDs.php index c363ae2..60b39a2 100644 --- a/lib/SaferpayJson/Container/ThreeDs.php +++ b/lib/SaferpayJson/Container/ThreeDs.php @@ -5,78 +5,78 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class ThreeDs +final class ThreeDs { /** - * @var bool + * @var bool|null * @SerializedName("Authenticated") * @Type("boolean") */ - protected $authenticated; + private $authenticated; /** - * @var bool + * @var bool|null * @SerializedName("LiabilityShift") * @Type("boolean") */ - protected $liabilityShift; + private $liabilityShift; /** - * @var string + * @var string|null * @SerializedName("Xid") * @Type("string") */ - protected $xid; + private $xid; /** - * @var string + * @var string|null * @SerializedName("VerificationValue") * @Type("string") */ - protected $verificationValue; + private $verificationValue; - public function isAuthenticated(): bool + public function isAuthenticated(): ?bool { return $this->authenticated; } - public function setAuthenticated(bool $authenticated): self + public function setAuthenticated(?bool $authenticated): self { $this->authenticated = $authenticated; return $this; } - public function isLiabilityShift(): bool + public function isLiabilityShift(): ?bool { return $this->liabilityShift; } - public function setLiabilityShift(bool $liabilityShift): self + public function setLiabilityShift(?bool $liabilityShift): self { $this->liabilityShift = $liabilityShift; return $this; } - public function getXid(): string + public function getXid(): ?string { return $this->xid; } - public function setXid(string $xid): self + public function setXid(?string $xid): self { $this->xid = $xid; return $this; } - public function getVerificationValue(): string + public function getVerificationValue(): ?string { return $this->verificationValue; } - public function setVerificationValue(string $verificationValue): self + public function setVerificationValue(?string $verificationValue): self { $this->verificationValue = $verificationValue; diff --git a/lib/SaferpayJson/Container/Transaction.php b/lib/SaferpayJson/Container/Transaction.php index f6ac676..d85ff38 100644 --- a/lib/SaferpayJson/Container/Transaction.php +++ b/lib/SaferpayJson/Container/Transaction.php @@ -5,128 +5,127 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Transaction +final class Transaction { /** - * @var string + * @var string|null * @SerializedName("Type") * @Type("string") */ - protected $type; + private $type; /** - * @var string + * @var string|null * @SerializedName("Status") * @Type("string") */ - protected $status; + private $status; /** - * @var string + * @var string|null * @SerializedName("Id") * @Type("string") */ - protected $id; + private $id; /** - * @var string + * @var string|null * @SerializedName("CaptureId") * @Type("string") */ - protected $captureId; + private $captureId; /** - * @var string + * @var string|null * @SerializedName("Date") * @Type("string") */ - protected $date; + private $date; /** - * @var Amount + * @var Amount|null * @SerializedName("Amount") * @Type("Ticketpark\SaferpayJson\Container\Amount") */ - protected $amount; + private $amount; /** - * @var string + * @var string|null * @SerializedName("OrderId") * @Type("string") */ - protected $orderId; + private $orderId; /** - * @var string + * @var string|null * @SerializedName("AcquirerName") * @Type("string") */ - protected $acquirerName; + private $acquirerName; /** - * @var string + * @var string|null * @SerializedName("SixTransactionReference") * @Type("string") */ - protected $sixTransactionReference; + private $sixTransactionReference; /** - * @var string + * @var string|null * @SerializedName("AcquirerReference") * @Type("string") */ - protected $acquirerReference; + private $acquirerReference; /** - * @var string + * @var string|null * @SerializedName("ApprovalCode") * @Type("string") */ - protected $approvalCode; + private $approvalCode; /** - * @var DirectDebit + * @var DirectDebit|null * @SerializedName("DirectDebit") * @Type("Ticketpark\SaferpayJson\Container\DirectDebit") */ - protected $directDebit; + private $directDebit; /** - * @var Invoice + * @var Invoice|null * @SerializedName("Invoice") * @Type("Ticketpark\SaferpayJson\Container\Invoice") */ - protected $invoice; + private $invoice; - - public function getType(): string + public function getType(): ?string { return $this->type; } - public function setType(string $type): self + public function setType(?string $type): self { $this->type = $type; return $this; } - public function getStatus(): string + public function getStatus(): ?string { return $this->status; } - public function setStatus(string $status): self + public function setStatus(?string $status): self { $this->status = $status; return $this; } - public function getId(): string + public function getId(): ?string { return $this->id; } - public function setId(string $id): self + public function setId(?string $id): self { $this->id = $id; return $this; @@ -137,67 +136,67 @@ public function getCaptureId(): ?string return $this->captureId; } - public function setCaptureId(string $captureId): self + public function setCaptureId(?string $captureId): self { $this->captureId = $captureId; return $this; } - public function getDate(): string + public function getDate(): ?string { return $this->date; } - public function setDate(string $date): self + public function setDate(?string $date): self { $this->date = $date; return $this; } - public function getAmount(): Amount + public function getAmount(): ?Amount { return $this->amount; } - public function setAmount(Amount $amount): self + public function setAmount(?Amount $amount): self { $this->amount = $amount; 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; return $this; } - public function getAcquirerName(): string + public function getAcquirerName(): ?string { return $this->acquirerName; } - public function setAcquirerName(string $acquirerName): self + public function setAcquirerName(?string $acquirerName): self { $this->acquirerName = $acquirerName; return $this; } - public function getAcquirerReference(): string + public function getAcquirerReference(): ?string { return $this->acquirerReference; } - public function setAcquirerReference(string $acquirerReference): self + public function setAcquirerReference(?string $acquirerReference): self { $this->acquirerReference = $acquirerReference; @@ -209,7 +208,7 @@ public function getSixTransactionReference(): ?string return $this->sixTransactionReference; } - public function setSixTransactionReference(string $sixTransactionReference): self + public function setSixTransactionReference(?string $sixTransactionReference): self { $this->sixTransactionReference = $sixTransactionReference; @@ -221,7 +220,7 @@ public function getApprovalCode(): ?string return $this->approvalCode; } - public function setApprovalCode(string $approvalCode): self + public function setApprovalCode(?string $approvalCode): self { $this->approvalCode = $approvalCode; @@ -233,7 +232,7 @@ public function getDirectDebit(): ?DirectDebit return $this->directDebit; } - public function setDirectDebit(DirectDebit $directDebit): self + public function setDirectDebit(?DirectDebit $directDebit): self { $this->directDebit = $directDebit; @@ -245,7 +244,7 @@ public function getInvoice(): ?Invoice return $this->invoice; } - public function setInvoice(Invoice $invoice): self + public function setInvoice(?Invoice $invoice): self { $this->invoice = $invoice; diff --git a/lib/SaferpayJson/Container/TransactionReference.php b/lib/SaferpayJson/Container/TransactionReference.php index 880ff5f..3d7c853 100644 --- a/lib/SaferpayJson/Container/TransactionReference.php +++ b/lib/SaferpayJson/Container/TransactionReference.php @@ -4,38 +4,38 @@ use JMS\Serializer\Annotation\SerializedName; -class TransactionReference +final class TransactionReference { /** - * @var string + * @var string|null * @SerializedName("TransactionId") */ - protected $transactionId; + private $transactionId; /** - * @var string + * @var string|null * @SerializedName("OrderId") */ - protected $orderId; + private $orderId; - public function getTransactionId(): string + public function getTransactionId(): ?string { return $this->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/Container/Twint.php b/lib/SaferpayJson/Container/Twint.php index 77ee963..f197e26 100644 --- a/lib/SaferpayJson/Container/Twint.php +++ b/lib/SaferpayJson/Container/Twint.php @@ -5,21 +5,21 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class Twint +final class Twint { /** - * @var \DateTime + * @var \DateTime|null * @SerializedName("CertificateExpirationDate") * @Type("DateTime") */ - protected $certificateExpirationDate; + private $certificateExpirationDate; public function getCertificateExpirationDate(): ?\DateTime { return $this->certificateExpirationDate; } - public function setCertificateExpirationDate(\DateTime $certificateExpirationDate): self + public function setCertificateExpirationDate(?\DateTime $certificateExpirationDate): self { $this->certificateExpirationDate = $certificateExpirationDate; diff --git a/lib/SaferpayJson/Container/UpdateAlias.php b/lib/SaferpayJson/Container/UpdateAlias.php index 595545c..f0ca1bb 100644 --- a/lib/SaferpayJson/Container/UpdateAlias.php +++ b/lib/SaferpayJson/Container/UpdateAlias.php @@ -5,20 +5,20 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class UpdateAlias +final class UpdateAlias { /** * @var string * @SerializedName("Id") */ - protected $id; + private $id; /** - * @var int + * @var int|null * @SerializedName("Lifetime") * @Type("integer") */ - protected $lifetime; + private $lifetime; public function __construct(string $id) { @@ -30,19 +30,12 @@ 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 + public function setLifetime(?int $lifetime): self { $this->lifetime = $lifetime; diff --git a/lib/SaferpayJson/Container/UpdatePaymentMeans.php b/lib/SaferpayJson/Container/UpdatePaymentMeans.php index 8aae071..e3455bd 100644 --- a/lib/SaferpayJson/Container/UpdatePaymentMeans.php +++ b/lib/SaferpayJson/Container/UpdatePaymentMeans.php @@ -5,13 +5,13 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -class UpdatePaymentMeans +final class UpdatePaymentMeans { /** * @var Card * @SerializedName("Card") */ - protected $card; + private $card; public function __construct(Card $card) { @@ -22,11 +22,4 @@ public function getCard(): ?Card { return $this->card; } - - public function setCard(Card $card): self - { - $this->card = $card; - - return $this; - } } diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php index 881e42f..ccd3817 100755 --- a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php @@ -14,7 +14,7 @@ public function getInstance() { return new AliasInsertDirectRequest( $this->getRequestConfig(), - new RegisterAlias(), + 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 index 015b698..5361061 100755 --- a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php @@ -21,7 +21,7 @@ public function getInstance() { return new AliasInsertRequest( $this->getRequestConfig(), - new RegisterAlias(), + new RegisterAlias(RegisterAlias::ID_GENERATOR_RANDOM), AliasInsertRequest::TYPE_CARD, new ReturnUrls('success-url', 'fail-url') ); From 654e5f090df04251f842bb321223488566d056e9 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 09:58:10 +0200 Subject: [PATCH 22/34] Fix return type hinting for PHP 7.3 --- lib/SaferpayJson/Request/Request.php | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index 5c3b829..6b3572d 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -5,9 +5,9 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Psr7\Response as GuzzleResponse; -use JMS\Serializer\Annotation\Accessor; 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; @@ -20,7 +20,6 @@ abstract class Request { 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; /** @@ -30,26 +29,30 @@ abstract class Request private $requestConfig; /** - * @var RequestHeader - * @SerializedName("RequestHeader") - * @Accessor(getter="getRequestHeader") + * 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 */ - private $requestHeader; + abstract public function execute(); abstract public function getApiPath(): string; abstract public function getResponseClass(): string; - abstract public function execute(): Response; public function __construct(RequestConfig $requestConfig) { $this->requestConfig = $requestConfig; } - public function getRequestConfig(): RequestConfig - { - return $this->requestConfig; - } - + /** + * @SerializedName("RequestHeader") + * @VirtualProperty + */ public function getRequestHeader(): RequestHeader { return new RequestHeader( @@ -57,6 +60,11 @@ public function getRequestHeader(): RequestHeader ); } + public function getRequestConfig(): RequestConfig + { + return $this->requestConfig; + } + protected function doExecute(): Response { try { From 4f17f640525e0f08e9efd98335e5295f03a59ac8 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 10:00:55 +0200 Subject: [PATCH 23/34] Fix comment urls in examples --- example/Transaction/example-cancel.php | 2 +- example/Transaction/example-capture.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/Transaction/example-cancel.php b/example/Transaction/example-cancel.php index 7e1be7e..ba4cee2 100644 --- a/example/Transaction/example-cancel.php +++ b/example/Transaction/example-cancel.php @@ -14,7 +14,7 @@ // ----------------------------- // Step 1: // Prepare the capture request -// https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Transaction_Capture +// https://saferpay.github.io/jsonapi/#Payment_v1_Transaction_Cancel $requestConfig = new RequestConfig( $apiKey, diff --git a/example/Transaction/example-capture.php b/example/Transaction/example-capture.php index 112dbe2..d3729b0 100644 --- a/example/Transaction/example-capture.php +++ b/example/Transaction/example-capture.php @@ -15,7 +15,7 @@ // ----------------------------- // Step 1: // Prepare the capture request -// https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Transaction_Capture +// https://saferpay.github.io/jsonapi/#Payment_v1_Transaction_Capture $requestConfig = new RequestConfig( $apiKey, From e169c32960007eea3182d3426bf0e635bd61c792 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 10:08:03 +0200 Subject: [PATCH 24/34] Update README for v3 --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0fd1542..be61a97 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,21 @@ 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 perform 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. @@ -35,7 +36,9 @@ You are welcome to contribute to this repo. * 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 Saferpay API 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 \ No newline at end of file From 56b01061947104c4c4580b0da1ab8f8496983e61 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 10:15:47 +0200 Subject: [PATCH 25/34] Improve README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 47d45bf..92114f9 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ composer require ticketpark/saferpay-json-api ``` ## Usage -In order to perform a payment as you would typically do it in an online shop, you need to perform the following steps: +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. +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)) @@ -40,7 +40,7 @@ You are welcome to contribute to this repo. ## History -* v3 added more major refactoring and based on Saferpay API v1.17 +* 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 From a88c9820f49e8c677daf60169ac07fcd4cabb61b Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 14:15:58 +0200 Subject: [PATCH 26/34] Seperate containers by response and request --- example/PaymentPage/example-assert.php | 4 +- example/PaymentPage/example-initialize.php | 6 +- .../SecureCardData/example-alias-delete.php | 4 +- .../example-alias-insert-assert.php | 4 +- .../example-alias-insert-direct.php | 6 +- .../SecureCardData/example-alias-insert.php | 6 +- .../SecureCardData/example-alias-update.php | 6 +- .../example-authorize-referenced.php | 6 +- example/Transaction/example-cancel.php | 6 +- example/Transaction/example-capture.php | 6 +- example/Transaction/example-refund.php | 6 +- .../{ => Request}/Container/Address.php | 21 +- .../{ => Request}/Container/AddressForm.php | 2 +- .../{ => Request}/Container/Alias.php | 33 +--- .../{ => Request}/Container/Alipay.php | 3 +- .../{ => Request}/Container/Amount.php | 3 +- .../Request/Container/Authentication.php | 50 +++++ .../Container/BankAccount.php} | 16 +- .../{ => Request}/Container/Billpay.php | 2 +- .../{ => Request}/Container/Brand.php | 4 +- .../Container/CaptureReference.php | 2 +- .../{ => Request}/Container/Card.php | 43 +---- .../{ => Request}/Container/CardForm.php | 14 +- .../{ => Request}/Container/Check.php | 2 +- .../{ => Request}/Container/ChosenPlan.php | 24 +-- .../{ => Request}/Container/ClientInfo.php | 4 +- .../{ => Request}/Container/Ideal.php | 3 +- .../{ => Request}/Container/Installment.php | 4 +- .../{ => Request}/Container/Marketplace.php | 14 +- .../MastercardIssuerInstallments.php | 28 +++ .../{ => Request}/Container/Notification.php | 2 +- .../{ => Request}/Container/Options.php | 2 +- .../{ => Request}/Container/Payer.php | 28 +-- .../{ => Request}/Container/Payment.php | 2 +- .../{ => Request}/Container/PaymentMeans.php | 22 +-- .../Container/PaymentMethodsOptions.php | 2 +- .../Container/PendingNotification.php | 2 +- .../{ => Request}/Container/Recurring.php | 2 +- .../{ => Request}/Container/Refund.php | 6 +- .../{ => Request}/Container/RegisterAlias.php | 4 +- .../{ => Request}/Container/RequestHeader.php | 2 +- .../{ => Request}/Container/ReturnUrls.php | 2 +- .../Container/SaferpayFields.php | 2 +- .../{ => Request}/Container/Styling.php | 24 ++- .../Container/TransactionReference.php | 2 +- .../{ => Request}/Container/Twint.php | 2 +- .../{ => Request}/Container/UpdateAlias.php | 2 +- .../Container/UpdatePaymentMeans.php | 2 +- .../Exception/HttpRequestException.php | 2 +- .../Exception/SaferpayErrorException.php} | 4 +- .../Request/PaymentPage/InitializeRequest.php | 26 +-- lib/SaferpayJson/Request/Request.php | 8 +- .../AliasInsertDirectRequest.php | 10 +- .../SecureCardData/AliasInsertRequest.php | 12 +- .../SecureCardData/AliasUpdateRequest.php | 4 +- .../Transaction/AuthorizeDirectRequest.php | 19 +- .../AuthorizeReferencedRequest.php | 16 +- .../Request/Transaction/CancelRequest.php | 2 +- .../Request/Transaction/CaptureRequest.php | 12 +- .../Request/Transaction/RefundRequest.php | 8 +- .../Response/Container/Address.php | 182 ++++++++++++++++++ lib/SaferpayJson/Response/Container/Alias.php | 33 ++++ .../Response/Container/Amount.php | 33 ++++ .../Container/AuthenticationResult.php | 16 +- .../{ => Response}/Container/BankAccount.php | 41 +--- lib/SaferpayJson/Response/Container/Brand.php | 59 ++++++ lib/SaferpayJson/Response/Container/Card.php | 98 ++++++++++ .../{ => Response}/Container/CheckResult.php | 23 +-- .../Response/Container/ChosenPlan.php | 93 +++++++++ .../{ => Response}/Container/CustomPlan.php | 48 +---- .../{ => Response}/Container/Dcc.php | 11 +- .../{ => Response}/Container/DirectDebit.php | 16 +- .../{ => Response}/Container/Error.php | 16 +- .../Container/HolderAuthentication.php | 23 +-- .../Container/InstallmentPlan.php | 59 +----- .../{ => Response}/Container/Invoice.php | 27 +-- .../{ => Response}/Container/Liability.php | 25 +-- .../MastercardIssuerInstallments.php | 32 +-- lib/SaferpayJson/Response/Container/Payee.php | 57 ++++++ lib/SaferpayJson/Response/Container/Payer.php | 57 ++++++ .../Response/Container/PaymentMeans.php | 84 ++++++++ .../{ => Response}/Container/Redirect.php | 16 +- .../Response/Container/RegisterAlias.php | 33 ++++ .../Container/RegistrationResult.php | 35 +--- .../Container/ResponseHeader.php | 2 +- .../Response/Container/SaferpayFields.php | 20 ++ .../{ => Response}/Container/ThreeDs.php | 30 +-- .../{ => Response}/Container/Transaction.php | 115 ++--------- lib/SaferpayJson/Response/Container/Twint.php | 21 ++ lib/SaferpayJson/Response/ErrorResponse.php | 23 ++- .../Response/PaymentPage/AssertResponse.php | 28 +-- lib/SaferpayJson/Response/Response.php | 4 +- .../AliasAssertInsertResponse.php | 12 +- .../AliasInsertDirectResponse.php | 12 +- .../SecureCardData/AliasInsertResponse.php | 4 +- .../SecureCardData/AliasUpdateResponse.php | 8 +- .../Transaction/AuthorizeDirectResponse.php | 16 +- .../AuthorizeReferencedResponse.php | 18 +- .../Response/Transaction/CaptureResponse.php | 4 +- .../Response/Transaction/RefundResponse.php | 12 +- .../Tests/Request/CommonRequestTest.php | 4 +- .../PaymentPage/InitializeRequestTest.php | 6 +- .../AliasInsertDirectRequestTest.php | 4 +- .../SecureCardData/AliasInsertRequestTest.php | 4 +- .../SecureCardData/AliasUpdateRequestTest.php | 6 +- .../AuthorizeDirectRequestTest.php | 6 +- .../AuthorizeReferencedRequestTest.php | 12 +- .../Request/Transaction/CancelRequestTest.php | 2 +- .../Transaction/CaptureRequestTest.php | 2 +- .../Request/Transaction/RefundRequestTest.php | 6 +- 110 files changed, 1194 insertions(+), 869 deletions(-) rename lib/SaferpayJson/{ => Request}/Container/Address.php (92%) rename lib/SaferpayJson/{ => Request}/Container/AddressForm.php (96%) rename lib/SaferpayJson/{ => Request}/Container/Alias.php (54%) rename lib/SaferpayJson/{ => Request}/Container/Alipay.php (86%) rename lib/SaferpayJson/{ => Request}/Container/Amount.php (90%) create mode 100644 lib/SaferpayJson/Request/Container/Authentication.php rename lib/SaferpayJson/{Container/Payee.php => Request/Container/BankAccount.php} (86%) rename lib/SaferpayJson/{ => Request}/Container/Billpay.php (89%) rename lib/SaferpayJson/{ => Request}/Container/Brand.php (89%) rename lib/SaferpayJson/{ => Request}/Container/CaptureReference.php (96%) rename lib/SaferpayJson/{ => Request}/Container/Card.php (67%) rename lib/SaferpayJson/{ => Request}/Container/CardForm.php (66%) rename lib/SaferpayJson/{ => Request}/Container/Check.php (93%) rename lib/SaferpayJson/{ => Request}/Container/ChosenPlan.php (84%) rename lib/SaferpayJson/{ => Request}/Container/ClientInfo.php (89%) rename lib/SaferpayJson/{ => Request}/Container/Ideal.php (86%) rename lib/SaferpayJson/{ => Request}/Container/Installment.php (76%) rename lib/SaferpayJson/{ => Request}/Container/Marketplace.php (81%) create mode 100644 lib/SaferpayJson/Request/Container/MastercardIssuerInstallments.php rename lib/SaferpayJson/{ => Request}/Container/Notification.php (95%) rename lib/SaferpayJson/{ => Request}/Container/Options.php (89%) rename lib/SaferpayJson/{ => Request}/Container/Payer.php (73%) rename lib/SaferpayJson/{ => Request}/Container/Payment.php (98%) rename lib/SaferpayJson/{ => Request}/Container/PaymentMeans.php (81%) rename lib/SaferpayJson/{ => Request}/Container/PaymentMethodsOptions.php (93%) rename lib/SaferpayJson/{ => Request}/Container/PendingNotification.php (93%) rename lib/SaferpayJson/{ => Request}/Container/Recurring.php (87%) rename lib/SaferpayJson/{ => Request}/Container/Refund.php (88%) rename lib/SaferpayJson/{ => Request}/Container/RegisterAlias.php (92%) rename lib/SaferpayJson/{ => Request}/Container/RequestHeader.php (96%) rename lib/SaferpayJson/{ => Request}/Container/ReturnUrls.php (94%) rename lib/SaferpayJson/{ => Request}/Container/SaferpayFields.php (88%) rename lib/SaferpayJson/{ => Request}/Container/Styling.php (54%) rename lib/SaferpayJson/{ => Request}/Container/TransactionReference.php (93%) rename lib/SaferpayJson/{ => Request}/Container/Twint.php (92%) rename lib/SaferpayJson/{ => Request}/Container/UpdateAlias.php (93%) rename lib/SaferpayJson/{ => Request}/Container/UpdatePaymentMeans.php (88%) rename lib/SaferpayJson/{ => Request}/Exception/HttpRequestException.php (61%) rename lib/SaferpayJson/{Exception/SaferpayErrorResponseException.php => Request/Exception/SaferpayErrorException.php} (80%) rename lib/SaferpayJson/Request/{PaymentPage => Transaction}/AuthorizeReferencedRequest.php (85%) create mode 100644 lib/SaferpayJson/Response/Container/Address.php create mode 100644 lib/SaferpayJson/Response/Container/Alias.php create mode 100644 lib/SaferpayJson/Response/Container/Amount.php rename lib/SaferpayJson/{ => Response}/Container/AuthenticationResult.php (68%) rename lib/SaferpayJson/{ => Response}/Container/BankAccount.php (60%) create mode 100644 lib/SaferpayJson/Response/Container/Brand.php create mode 100644 lib/SaferpayJson/Response/Container/Card.php rename lib/SaferpayJson/{ => Response}/Container/CheckResult.php (65%) create mode 100644 lib/SaferpayJson/Response/Container/ChosenPlan.php rename lib/SaferpayJson/{ => Response}/Container/CustomPlan.php (57%) rename lib/SaferpayJson/{ => Response}/Container/Dcc.php (57%) rename lib/SaferpayJson/{ => Response}/Container/DirectDebit.php (64%) rename lib/SaferpayJson/{ => Response}/Container/Error.php (63%) rename lib/SaferpayJson/{ => Response}/Container/HolderAuthentication.php (67%) rename lib/SaferpayJson/{ => Response}/Container/InstallmentPlan.php (55%) rename lib/SaferpayJson/{ => Response}/Container/Invoice.php (57%) rename lib/SaferpayJson/{ => Response}/Container/Liability.php (59%) rename lib/SaferpayJson/{ => Response}/Container/MastercardIssuerInstallments.php (60%) create mode 100644 lib/SaferpayJson/Response/Container/Payee.php create mode 100644 lib/SaferpayJson/Response/Container/Payer.php create mode 100644 lib/SaferpayJson/Response/Container/PaymentMeans.php rename lib/SaferpayJson/{ => Response}/Container/Redirect.php (62%) create mode 100644 lib/SaferpayJson/Response/Container/RegisterAlias.php rename lib/SaferpayJson/{ => Response}/Container/RegistrationResult.php (55%) rename lib/SaferpayJson/{ => Response}/Container/ResponseHeader.php (91%) create mode 100644 lib/SaferpayJson/Response/Container/SaferpayFields.php rename lib/SaferpayJson/{ => Response}/Container/ThreeDs.php (62%) rename lib/SaferpayJson/{ => Response}/Container/Transaction.php (59%) create mode 100644 lib/SaferpayJson/Response/Container/Twint.php rename lib/SaferpayJson/Response/{PaymentPage => Transaction}/AuthorizeReferencedResponse.php (63%) rename tests/SaferpayJson/Tests/Request/{PaymentPage => Transaction}/AuthorizeReferencedRequestTest.php (64%) diff --git a/example/PaymentPage/example-assert.php b/example/PaymentPage/example-assert.php index 31f9804..ba83ccd 100644 --- a/example/PaymentPage/example-assert.php +++ b/example/PaymentPage/example-assert.php @@ -1,6 +1,6 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/PaymentPage/example-initialize.php b/example/PaymentPage/example-initialize.php index 0dfe424..b5e2dce 100644 --- a/example/PaymentPage/example-initialize.php +++ b/example/PaymentPage/example-initialize.php @@ -1,9 +1,9 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/SecureCardData/example-alias-delete.php b/example/SecureCardData/example-alias-delete.php index 016521e..3523506 100644 --- a/example/SecureCardData/example-alias-delete.php +++ b/example/SecureCardData/example-alias-delete.php @@ -1,6 +1,6 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/SecureCardData/example-alias-insert-assert.php b/example/SecureCardData/example-alias-insert-assert.php index e036bf4..7c729f8 100644 --- a/example/SecureCardData/example-alias-insert-assert.php +++ b/example/SecureCardData/example-alias-insert-assert.php @@ -1,6 +1,6 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/SecureCardData/example-alias-insert-direct.php b/example/SecureCardData/example-alias-insert-direct.php index 152d0f6..f54ddcf 100644 --- a/example/SecureCardData/example-alias-insert-direct.php +++ b/example/SecureCardData/example-alias-insert-direct.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/SecureCardData/example-alias-insert.php b/example/SecureCardData/example-alias-insert.php index ef5d164..87dfa12 100644 --- a/example/SecureCardData/example-alias-insert.php +++ b/example/SecureCardData/example-alias-insert.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/SecureCardData/example-alias-update.php b/example/SecureCardData/example-alias-update.php index 90e57c8..b2288c4 100644 --- a/example/SecureCardData/example-alias-update.php +++ b/example/SecureCardData/example-alias-update.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/Transaction/example-authorize-referenced.php b/example/Transaction/example-authorize-referenced.php index eb7984b..9333708 100644 --- a/example/Transaction/example-authorize-referenced.php +++ b/example/Transaction/example-authorize-referenced.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/Transaction/example-cancel.php b/example/Transaction/example-cancel.php index ba4cee2..ba2721d 100644 --- a/example/Transaction/example-cancel.php +++ b/example/Transaction/example-cancel.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/Transaction/example-capture.php b/example/Transaction/example-capture.php index d3729b0..c73be6a 100644 --- a/example/Transaction/example-capture.php +++ b/example/Transaction/example-capture.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/example/Transaction/example-refund.php b/example/Transaction/example-refund.php index de6a622..9ec7f52 100644 --- a/example/Transaction/example-refund.php +++ b/example/Transaction/example-refund.php @@ -1,7 +1,7 @@ execute(); -} catch (SaferpayErrorResponseException $e) { +} catch (SaferpayErrorException $e) { die ($e->getErrorResponse()->getErrorMessage()); } diff --git a/lib/SaferpayJson/Container/Address.php b/lib/SaferpayJson/Request/Container/Address.php similarity index 92% rename from lib/SaferpayJson/Container/Address.php rename to lib/SaferpayJson/Request/Container/Address.php index 7705cce..c16f006 100644 --- a/lib/SaferpayJson/Container/Address.php +++ b/lib/SaferpayJson/Request/Container/Address.php @@ -1,107 +1,98 @@ id; - } - - public function setId(?string $id): self + public function __construct(string $id) { $this->id = $id; - - return $this; - } - - public function getLifetime(): ?int - { - return $this->lifetime; } - public function setLifetime(?int $lifetime): self + public function getId(): string { - $this->lifetime = $lifetime; - - return $this; + return $this->id; } public function getVerificationCode(): ?string diff --git a/lib/SaferpayJson/Container/Alipay.php b/lib/SaferpayJson/Request/Container/Alipay.php similarity index 86% rename from lib/SaferpayJson/Container/Alipay.php rename to lib/SaferpayJson/Request/Container/Alipay.php index e782852..0841ff3 100644 --- a/lib/SaferpayJson/Container/Alipay.php +++ b/lib/SaferpayJson/Request/Container/Alipay.php @@ -1,6 +1,6 @@ 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 86% rename from lib/SaferpayJson/Container/Payee.php rename to lib/SaferpayJson/Request/Container/BankAccount.php index e337f92..2d5bd4d 100644 --- a/lib/SaferpayJson/Container/Payee.php +++ b/lib/SaferpayJson/Request/Container/BankAccount.php @@ -1,40 +1,41 @@ iban = $iban; + } + public function getIban(): ?string { return $this->iban; @@ -43,7 +44,6 @@ public function getIban(): ?string public function setIban(?string $iban): self { $this->iban = $iban; - return $this; } diff --git a/lib/SaferpayJson/Container/Billpay.php b/lib/SaferpayJson/Request/Container/Billpay.php similarity index 89% rename from lib/SaferpayJson/Container/Billpay.php rename to lib/SaferpayJson/Request/Container/Billpay.php index 64cd0e3..35f1fef 100644 --- a/lib/SaferpayJson/Container/Billpay.php +++ b/lib/SaferpayJson/Request/Container/Billpay.php @@ -1,6 +1,6 @@ number; @@ -68,18 +51,6 @@ public function setNumber(?string $number): self 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; @@ -127,16 +98,4 @@ public function setCountryCode(?string $countryCode): self 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/CardForm.php b/lib/SaferpayJson/Request/Container/CardForm.php similarity index 66% rename from lib/SaferpayJson/Container/CardForm.php rename to lib/SaferpayJson/Request/Container/CardForm.php index a29b4c1..b3cbbb4 100644 --- a/lib/SaferpayJson/Container/CardForm.php +++ b/lib/SaferpayJson/Request/Container/CardForm.php @@ -1,6 +1,6 @@ holderName = $holderName; + return $this->holderName; } - public function getHolderName(): string + public function setHolderName(string $holderName): self { - return $this->holderName; + $this->holderName = $holderName; + + return $this; } } diff --git a/lib/SaferpayJson/Container/Check.php b/lib/SaferpayJson/Request/Container/Check.php similarity index 93% rename from lib/SaferpayJson/Container/Check.php rename to lib/SaferpayJson/Request/Container/Check.php index 4ca5fa2..06464a7 100644 --- a/lib/SaferpayJson/Container/Check.php +++ b/lib/SaferpayJson/Request/Container/Check.php @@ -1,6 +1,6 @@ numberOfInstallments; + $this->numberOfInstallments = $numberOfInstallments; } - public function setNumberOfInstallments(?int $numberOfInstallments): self + public function getNumberOfInstallments(): int { - $this->numberOfInstallments = $numberOfInstallments; - - return $this; + return $this->numberOfInstallments; } public function getInterestRate(): ?string diff --git a/lib/SaferpayJson/Container/ClientInfo.php b/lib/SaferpayJson/Request/Container/ClientInfo.php similarity index 89% rename from lib/SaferpayJson/Container/ClientInfo.php rename to lib/SaferpayJson/Request/Container/ClientInfo.php index 9d05148..a5072fd 100644 --- a/lib/SaferpayJson/Container/ClientInfo.php +++ b/lib/SaferpayJson/Request/Container/ClientInfo.php @@ -1,6 +1,6 @@ initial = $initial; } diff --git a/lib/SaferpayJson/Container/Marketplace.php b/lib/SaferpayJson/Request/Container/Marketplace.php similarity index 81% rename from lib/SaferpayJson/Container/Marketplace.php rename to lib/SaferpayJson/Request/Container/Marketplace.php index 51d0a8f..c9405d2 100644 --- a/lib/SaferpayJson/Container/Marketplace.php +++ b/lib/SaferpayJson/Request/Container/Marketplace.php @@ -1,13 +1,13 @@ submerchantId; + $this->submerchantId = $submerchantId; } - public function setSubmerchantId(?string $submerchantId): self + public function getSubmerchantId(): string { - $this->submerchantId = $submerchantId; - - return $this; + return $this->submerchantId; } public function getFee(): ?Amount 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 95% rename from lib/SaferpayJson/Container/Notification.php rename to lib/SaferpayJson/Request/Container/Notification.php index 851762f..31492d8 100644 --- a/lib/SaferpayJson/Container/Notification.php +++ b/lib/SaferpayJson/Request/Container/Notification.php @@ -1,6 +1,6 @@ ipLocation; - } - - public function setIpLocation(?string $ipLocation): self - { - $this->ipLocation = $ipLocation; - - return $this; - } - public function getLanguageCode(): ?string { return $this->languageCode; diff --git a/lib/SaferpayJson/Container/Payment.php b/lib/SaferpayJson/Request/Container/Payment.php similarity index 98% rename from lib/SaferpayJson/Container/Payment.php rename to lib/SaferpayJson/Request/Container/Payment.php index 773ca66..7f3d0de 100644 --- a/lib/SaferpayJson/Container/Payment.php +++ b/lib/SaferpayJson/Request/Container/Payment.php @@ -1,6 +1,6 @@ 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; @@ -34,6 +44,18 @@ public function setCssUrl(?string $cssUrl): self 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; diff --git a/lib/SaferpayJson/Container/TransactionReference.php b/lib/SaferpayJson/Request/Container/TransactionReference.php similarity index 93% rename from lib/SaferpayJson/Container/TransactionReference.php rename to lib/SaferpayJson/Request/Container/TransactionReference.php index 3d7c853..b75338e 100644 --- a/lib/SaferpayJson/Container/TransactionReference.php +++ b/lib/SaferpayJson/Request/Container/TransactionReference.php @@ -1,6 +1,6 @@ authentication; } - public function setAuthentication(?HolderAuthentication $authentication): self + public function setAuthentication(?Authentication $authentication): self { $this->authentication = $authentication; diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index 909bcdb..9f2d8bf 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -10,9 +10,9 @@ 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\Exception\SaferpayErrorResponseException; +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\Response; @@ -96,7 +96,7 @@ protected function doExecute(): Response 'json' ); - throw new SaferpayErrorResponseException($errorResponse); + throw new SaferpayErrorException($errorResponse); } if (200 !== $statusCode) { diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php index 80f4782..d3ad7c7 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertDirectRequest.php @@ -4,9 +4,9 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Check; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Request\Container\Check; +use Ticketpark\SaferpayJson\Request\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Request\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; use Ticketpark\SaferpayJson\Request\RequestConfig; @@ -28,14 +28,14 @@ final class AliasInsertDirectRequest extends Request /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Request\Container\PaymentMeans") */ private $paymentMeans; /** * @var Check|null * @SerializedName("Check") - * @Type("Ticketpark\SaferpayJson\Container\Check") + * @Type("Ticketpark\SaferpayJson\Request\Container\Check") */ private $check; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php index bde5bf4..1f6c9ec 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasInsertRequest.php @@ -4,12 +4,12 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\CardForm; -use Ticketpark\SaferpayJson\Container\Check; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegisterAlias; -use Ticketpark\SaferpayJson\Container\ReturnUrls; -use Ticketpark\SaferpayJson\Container\Styling; +use Ticketpark\SaferpayJson\Request\Container\CardForm; +use Ticketpark\SaferpayJson\Request\Container\Check; +use Ticketpark\SaferpayJson\Request\Container\PaymentMeans; +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; diff --git a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php index 7ae5e80..ea2761d 100755 --- a/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php +++ b/lib/SaferpayJson/Request/SecureCardData/AliasUpdateRequest.php @@ -3,8 +3,8 @@ namespace Ticketpark\SaferpayJson\Request\SecureCardData; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\UpdateAlias; -use Ticketpark\SaferpayJson\Container\UpdatePaymentMeans; +use Ticketpark\SaferpayJson\Request\Container\UpdateAlias; +use Ticketpark\SaferpayJson\Request\Container\UpdatePaymentMeans; use Ticketpark\SaferpayJson\Request\Request; use Ticketpark\SaferpayJson\Request\RequestCommonsTrait; use Ticketpark\SaferpayJson\Request\RequestConfig; diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php index b9d18b1..285cf5a 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -3,19 +3,16 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Payer; -use Ticketpark\SaferpayJson\Container\RegisterAlias; +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 - */ final class AuthorizeDirectRequest extends Request { const API_PATH = '/Payment/v1/Transaction/AuthorizeDirect'; @@ -41,6 +38,12 @@ final class AuthorizeDirectRequest extends Request */ private $paymentMeans; + /** + * @var Authentication|null + * @SerializedName("Authentication") + */ + private $authentication; + /** * @var RegisterAlias|null * @SerializedName("RegisterAlias") diff --git a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php similarity index 85% rename from lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php rename to lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php index f106d96..c84e0d2 100644 --- a/lib/SaferpayJson/Request/PaymentPage/AuthorizeReferencedRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeReferencedRequest.php @@ -1,15 +1,15 @@ authentication; } - public function setAuthentication(?HolderAuthentication $authentication): self + public function setAuthentication(?Authentication $authentication): self { $this->authentication = $authentication; diff --git a/lib/SaferpayJson/Request/Transaction/CancelRequest.php b/lib/SaferpayJson/Request/Transaction/CancelRequest.php index f54914d..5d19989 100644 --- a/lib/SaferpayJson/Request/Transaction/CancelRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CancelRequest.php @@ -3,7 +3,7 @@ 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; diff --git a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php index 7db07bb..d55a8c9 100644 --- a/lib/SaferpayJson/Request/Transaction/CaptureRequest.php +++ b/lib/SaferpayJson/Request/Transaction/CaptureRequest.php @@ -3,12 +3,12 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\Amount; -use Ticketpark\SaferpayJson\Container\Billpay; -use Ticketpark\SaferpayJson\Container\Marketplace; -use Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments; -use Ticketpark\SaferpayJson\Container\PendingNotification; -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; diff --git a/lib/SaferpayJson/Request/Transaction/RefundRequest.php b/lib/SaferpayJson/Request/Transaction/RefundRequest.php index f89b5af..9fa2573 100644 --- a/lib/SaferpayJson/Request/Transaction/RefundRequest.php +++ b/lib/SaferpayJson/Request/Transaction/RefundRequest.php @@ -3,10 +3,10 @@ namespace Ticketpark\SaferpayJson\Request\Transaction; use JMS\Serializer\Annotation\SerializedName; -use Ticketpark\SaferpayJson\Container\CaptureReference; -use Ticketpark\SaferpayJson\Container\PendingNotification; -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; 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/Container/AuthenticationResult.php b/lib/SaferpayJson/Response/Container/AuthenticationResult.php similarity index 68% rename from lib/SaferpayJson/Container/AuthenticationResult.php rename to lib/SaferpayJson/Response/Container/AuthenticationResult.php index d8f9a9a..424966e 100644 --- a/lib/SaferpayJson/Container/AuthenticationResult.php +++ b/lib/SaferpayJson/Response/Container/AuthenticationResult.php @@ -1,6 +1,6 @@ result; } - public function setResult(?string $result): self - { - $this->result = $result; - - return $this; - } - public function getMessage(): ?string { return $this->message; } - - public function setMessage(?string $message): self - { - $this->message = $message; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/BankAccount.php b/lib/SaferpayJson/Response/Container/BankAccount.php similarity index 60% rename from lib/SaferpayJson/Container/BankAccount.php rename to lib/SaferpayJson/Response/Container/BankAccount.php index 461dac9..bc334b7 100644 --- a/lib/SaferpayJson/Container/BankAccount.php +++ b/lib/SaferpayJson/Response/Container/BankAccount.php @@ -1,6 +1,6 @@ iban = $iban; - } - public function getIban(): ?string { return $this->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/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/Container/CheckResult.php b/lib/SaferpayJson/Response/Container/CheckResult.php similarity index 65% rename from lib/SaferpayJson/Container/CheckResult.php rename to lib/SaferpayJson/Response/Container/CheckResult.php index 5602c5b..fe113a2 100644 --- a/lib/SaferpayJson/Container/CheckResult.php +++ b/lib/SaferpayJson/Response/Container/CheckResult.php @@ -1,6 +1,6 @@ result; } - public function setResult(?string $result): self - { - $this->result = $result; - - return $this; - } - public function getMessage(): ?string { return $this->message; } - public function setMessage(?string $message): self - { - $this->message = $message; - - return $this; - } - public function getAuthentication(): ?HolderAuthentication { return $this->authentication; } - - public function setAuthentication(?HolderAuthentication $authentication): self - { - $this->authentication = $authentication; - - return $this; - } } 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/Container/CustomPlan.php b/lib/SaferpayJson/Response/Container/CustomPlan.php similarity index 57% rename from lib/SaferpayJson/Container/CustomPlan.php rename to lib/SaferpayJson/Response/Container/CustomPlan.php index 6232460..f4bae1c 100644 --- a/lib/SaferpayJson/Container/CustomPlan.php +++ b/lib/SaferpayJson/Response/Container/CustomPlan.php @@ -1,6 +1,6 @@ minimumNumberOfInstallments; } - public function setMinimumNumberOfInstallments(?int $minimumNumberOfInstallments): self - { - $this->minimumNumberOfInstallments = $minimumNumberOfInstallments; - - return $this; - } - public function getMaximumNumberOfInstallments(): ?int { return $this->maximumNumberOfInstallments; } - public function setMaximumNumberOfInstallments(?int $maximumNumberOfInstallments): self - { - $this->maximumNumberOfInstallments = $maximumNumberOfInstallments; - - return $this; - } - 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 getTotalAmountDue(): ?Amount { return $this->totalAmountDue; } - - public function setTotalAmountDue(?Amount $totalAmountDue): self - { - $this->totalAmountDue = $totalAmountDue; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Dcc.php b/lib/SaferpayJson/Response/Container/Dcc.php similarity index 57% rename from lib/SaferpayJson/Container/Dcc.php rename to lib/SaferpayJson/Response/Container/Dcc.php index 715d81f..400c877 100644 --- a/lib/SaferpayJson/Container/Dcc.php +++ b/lib/SaferpayJson/Response/Container/Dcc.php @@ -1,6 +1,6 @@ payerAmount; } - - public function setPayerAmount(?Amount $payerAmount): self - { - $this->payerAmount = $payerAmount; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/DirectDebit.php b/lib/SaferpayJson/Response/Container/DirectDebit.php similarity index 64% rename from lib/SaferpayJson/Container/DirectDebit.php rename to lib/SaferpayJson/Response/Container/DirectDebit.php index 9d165f9..0274b90 100644 --- a/lib/SaferpayJson/Container/DirectDebit.php +++ b/lib/SaferpayJson/Response/Container/DirectDebit.php @@ -1,6 +1,6 @@ mandateId; } - public function setMandateId(?string $mandateId): self - { - $this->mandateId = $mandateId; - - return $this; - } - public function getCreditorId(): ?string { return $this->creditorId; } - - public function setCreditorId(?string $creditorId): self - { - $this->creditorId = $creditorId; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/Error.php b/lib/SaferpayJson/Response/Container/Error.php similarity index 63% rename from lib/SaferpayJson/Container/Error.php rename to lib/SaferpayJson/Response/Container/Error.php index 033b3f0..02edf3e 100644 --- a/lib/SaferpayJson/Container/Error.php +++ b/lib/SaferpayJson/Response/Container/Error.php @@ -1,6 +1,6 @@ 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/HolderAuthentication.php b/lib/SaferpayJson/Response/Container/HolderAuthentication.php similarity index 67% rename from lib/SaferpayJson/Container/HolderAuthentication.php rename to lib/SaferpayJson/Response/Container/HolderAuthentication.php index 4f99e51..61b8348 100644 --- a/lib/SaferpayJson/Container/HolderAuthentication.php +++ b/lib/SaferpayJson/Response/Container/HolderAuthentication.php @@ -1,6 +1,6 @@ result; } - public function setResult(?string $result): self - { - $this->result = $result; - - return $this; - } - public function getMessage(): ?string { return $this->message; } - public function setMessage(?string $message): self - { - $this->message = $message; - - return $this; - } - public function getXid(): ?string { return $this->xid; } - - public function setXid(?string $xid): self - { - $this->xid = $xid; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/InstallmentPlan.php b/lib/SaferpayJson/Response/Container/InstallmentPlan.php similarity index 55% rename from lib/SaferpayJson/Container/InstallmentPlan.php rename to lib/SaferpayJson/Response/Container/InstallmentPlan.php index 26df0e0..0902a3f 100644 --- a/lib/SaferpayJson/Container/InstallmentPlan.php +++ b/lib/SaferpayJson/Response/Container/InstallmentPlan.php @@ -1,6 +1,6 @@ numberOfInstallments; } - public function setNumberOfInstallments(?int $numberOfInstallments): self - { - $this->numberOfInstallments = $numberOfInstallments; - - return $this; - } - 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/Container/Invoice.php b/lib/SaferpayJson/Response/Container/Invoice.php similarity index 57% rename from lib/SaferpayJson/Container/Invoice.php rename to lib/SaferpayJson/Response/Container/Invoice.php index 500d023..354a9e0 100644 --- a/lib/SaferpayJson/Container/Invoice.php +++ b/lib/SaferpayJson/Response/Container/Invoice.php @@ -1,17 +1,17 @@ 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/Liability.php b/lib/SaferpayJson/Response/Container/Liability.php similarity index 59% rename from lib/SaferpayJson/Container/Liability.php rename to lib/SaferpayJson/Response/Container/Liability.php index 46c3c50..4b2da74 100644 --- a/lib/SaferpayJson/Container/Liability.php +++ b/lib/SaferpayJson/Response/Container/Liability.php @@ -1,6 +1,6 @@ liabilityShift; } - public function setLiabilityShift(?bool $liabilityShift): self - { - $this->liabilityShift = $liabilityShift; - - return $this; - } - public function getLiableEntity(): ?string { return $this->liableEntity; } - public function setLiableEntity(?string $liableEntity): self - { - $this->liableEntity = $liableEntity; - - return $this; - } - public function getThreeDs(): ?ThreeDs { return $this->threeDs; } - - public function setThreeDs(?ThreeDs $threeDs): self - { - $this->threeDs = $threeDs; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php b/lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php similarity index 60% rename from lib/SaferpayJson/Container/MastercardIssuerInstallments.php rename to lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php index 3ccb901..8026931 100644 --- a/lib/SaferpayJson/Container/MastercardIssuerInstallments.php +++ b/lib/SaferpayJson/Response/Container/MastercardIssuerInstallments.php @@ -1,6 +1,6 @@ installmentPlans; } - public function setInstallmentPlans(?array $installmentPlans): self - { - $this->installmentPlans = $installmentPlans; - - return $this; - } - public function getCustomPlan(): ?CustomPlan { return $this->customPlan; } - public function setCustomPlan(?CustomPlan $customPlan): self - { - $this->customPlan = $customPlan; - - return $this; - } - public function getReceiptFreeText(): ?string { return $this->receiptFreeText; } - public function setReceiptFreeText(?string $receiptFreeText): self - { - $this->receiptFreeText = $receiptFreeText; - - return $this; - } - public function getChosenPlan(): ?ChosenPlan { return $this->chosenPlan; } - - public function setChosenPlan(?ChosenPlan $chosenPlan): self - { - $this->chosenPlan = $chosenPlan; - - return $this; - } } 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/Container/Redirect.php b/lib/SaferpayJson/Response/Container/Redirect.php similarity index 62% rename from lib/SaferpayJson/Container/Redirect.php rename to lib/SaferpayJson/Response/Container/Redirect.php index 1b8d69c..e62cd62 100644 --- a/lib/SaferpayJson/Container/Redirect.php +++ b/lib/SaferpayJson/Response/Container/Redirect.php @@ -1,6 +1,6 @@ redirectUrl; } - public function setRedirectUrl(?string $redirectUrl): self - { - $this->redirectUrl = $redirectUrl; - - return $this; - } - public function isPaymentMeansRequired(): ?bool { return $this->paymentMeansRequired; } - - public function setPaymentMeansRequired(?bool $paymentMeansRequired): self - { - $this->paymentMeansRequired = $paymentMeansRequired; - - return $this; - } } 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/Container/RegistrationResult.php b/lib/SaferpayJson/Response/Container/RegistrationResult.php similarity index 55% rename from lib/SaferpayJson/Container/RegistrationResult.php rename to lib/SaferpayJson/Response/Container/RegistrationResult.php index 0e90725..68e954d 100644 --- a/lib/SaferpayJson/Container/RegistrationResult.php +++ b/lib/SaferpayJson/Response/Container/RegistrationResult.php @@ -1,6 +1,6 @@ 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; - } - public function getAuthenticationResult(): ?AuthenticationResult { return $this->authenticationResult; } - - public function setAuthenticationResult(?AuthenticationResult $authenticationResult): self - { - $this->authenticationResult = $authenticationResult; - - return $this; - } } diff --git a/lib/SaferpayJson/Container/ResponseHeader.php b/lib/SaferpayJson/Response/Container/ResponseHeader.php similarity index 91% rename from lib/SaferpayJson/Container/ResponseHeader.php rename to lib/SaferpayJson/Response/Container/ResponseHeader.php index 2f32b98..96050c2 100644 --- a/lib/SaferpayJson/Container/ResponseHeader.php +++ b/lib/SaferpayJson/Response/Container/ResponseHeader.php @@ -1,6 +1,6 @@ token; + } +} diff --git a/lib/SaferpayJson/Container/ThreeDs.php b/lib/SaferpayJson/Response/Container/ThreeDs.php similarity index 62% rename from lib/SaferpayJson/Container/ThreeDs.php rename to lib/SaferpayJson/Response/Container/ThreeDs.php index 60b39a2..f89a906 100644 --- a/lib/SaferpayJson/Container/ThreeDs.php +++ b/lib/SaferpayJson/Response/Container/ThreeDs.php @@ -1,6 +1,6 @@ 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/Response/Container/Transaction.php similarity index 59% rename from lib/SaferpayJson/Container/Transaction.php rename to lib/SaferpayJson/Response/Container/Transaction.php index d85ff38..7d7e8b6 100644 --- a/lib/SaferpayJson/Container/Transaction.php +++ b/lib/SaferpayJson/Response/Container/Transaction.php @@ -1,12 +1,19 @@ 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 getCaptureId(): ?string { return $this->captureId; } - public function setCaptureId(?string $captureId): self - { - $this->captureId = $captureId; - - 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 + public function getAcquirerName(): ?string { - $this->acquirerReference = $acquirerReference; - - return $this; + return $this->acquirerName; } public function getSixTransactionReference(): ?string @@ -208,46 +155,18 @@ public function getSixTransactionReference(): ?string return $this->sixTransactionReference; } - public function setSixTransactionReference(?string $sixTransactionReference): self - { - $this->sixTransactionReference = $sixTransactionReference; - - return $this; - } - public function getApprovalCode(): ?string { return $this->approvalCode; } - public function setApprovalCode(?string $approvalCode): self - { - $this->approvalCode = $approvalCode; - - return $this; - } - public function getDirectDebit(): ?DirectDebit { return $this->directDebit; } - public function setDirectDebit(?DirectDebit $directDebit): self - { - $this->directDebit = $directDebit; - - return $this; - } - public function getInvoice(): ?Invoice { return $this->invoice; } - - public function setInvoice(?Invoice $invoice): self - { - $this->invoice = $invoice; - - return $this; - } } 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 9ac1a48..8c48e66 100644 --- a/lib/SaferpayJson/Response/ErrorResponse.php +++ b/lib/SaferpayJson/Response/ErrorResponse.php @@ -7,22 +7,27 @@ 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") */ private $behaviour; /** - * @var string + * @var string|null * @SerializedName("ErrorName") * @Type("string") */ private $errorName; /** - * @var string + * @var string|null * @SerializedName("ErrorMessage") * @Type("string") */ @@ -36,7 +41,7 @@ class ErrorResponse extends Response private $transactionId; /** - * @var array + * @var array|null * @SerializedName("ErrorDetail") * @Type("array") */ @@ -57,23 +62,23 @@ class ErrorResponse extends Response private $processorResult; /** - * @var string + * @var string|null * @SerializedName("ProcessorMessage") * @Type("string") */ private $processorMessage; - public function getBehaviour(): string + public function getBehaviour(): ?string { return $this->behaviour; } - public function getErrorName(): string + public function getErrorName(): ?string { return $this->errorName; } - public function getErrorMessage(): string + public function getErrorMessage(): ?string { return $this->errorMessage; } @@ -83,7 +88,7 @@ public function getTransactionId(): ?string return $this->transactionId; } - public function getErrorDetail(): array + public function getErrorDetail(): ?array { return $this->errorDetail; } diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index 273fcb4..aa89a83 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -4,13 +4,13 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Dcc; -use Ticketpark\SaferpayJson\Container\Liability; -use Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments; -use Ticketpark\SaferpayJson\Container\Payer; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegistrationResult; -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; final class AssertResponse extends Response @@ -18,49 +18,49 @@ final class AssertResponse extends Response /** * @var Transaction * @SerializedName("Transaction") - * @Type("Ticketpark\SaferpayJson\Container\Transaction") + * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** * @var Payer * @SerializedName("Payer") - * @Type("Ticketpark\SaferpayJson\Container\Payer") + * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ private $payer; /** * @var RegistrationResult * @SerializedName("RegistrationResult") - * @Type("Ticketpark\SaferpayJson\Container\RegistrationResult") + * @Type("Ticketpark\SaferpayJson\Response\Container\RegistrationResult") */ private $registrationResult; /** * @var Liability * @SerializedName("Liability") - * @Type("Ticketpark\SaferpayJson\Container\Liability") + * @Type("Ticketpark\SaferpayJson\Response\Container\Liability") */ private $liability; /** * @var Dcc * @SerializedName("Dcc") - * @Type("Ticketpark\SaferpayJson\Container\Dcc") + * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ private $dcc; /** * @var MastercardIssuerInstallments * @SerializedName("MastercardIssuerInstallments") - * @Type("Ticketpark\SaferpayJson\Container\MastercardIssuerInstallments") + * @Type("Ticketpark\SaferpayJson\Response\Container\MastercardIssuerInstallments") */ private $mastercardIssuerInstallments; diff --git a/lib/SaferpayJson/Response/Response.php b/lib/SaferpayJson/Response/Response.php index d710611..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 { /** * @var ResponseHeader * @SerializedName("ResponseHeader") - * @Type("Ticketpark\SaferpayJson\Container\ResponseHeader") + * @Type("Ticketpark\SaferpayJson\Response\Container\ResponseHeader") */ protected $responseHeader; diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php index 3367747..35fef39 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php @@ -4,9 +4,9 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Alias; -use Ticketpark\SaferpayJson\Container\CheckResult; -use Ticketpark\SaferpayJson\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\Alias; +use Ticketpark\SaferpayJson\Response\Container\CheckResult; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; final class AliasAssertInsertResponse extends Response @@ -14,21 +14,21 @@ final class AliasAssertInsertResponse extends Response /** * @var Alias * @SerializedName("Alias") - * @Type("Ticketpark\SaferpayJson\Container\Alias") + * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** * @var CheckResult * @SerializedName("CheckResult") - * @Type("Ticketpark\SaferpayJson\Container\CheckResult") + * @Type("Ticketpark\SaferpayJson\Response\Container\CheckResult") */ private $checkResult; diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php index 635675c..bfb0b26 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php @@ -4,9 +4,9 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Alias; -use Ticketpark\SaferpayJson\Container\CheckResult; -use Ticketpark\SaferpayJson\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\Alias; +use Ticketpark\SaferpayJson\Response\Container\CheckResult; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; final class AliasInsertDirectResponse extends Response @@ -14,21 +14,21 @@ final class AliasInsertDirectResponse extends Response /** * @var Alias * @SerializedName("Alias") - * @Type("Ticketpark\SaferpayJson\Container\Alias") + * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** * @var CheckResult * @SerializedName("CheckResult") - * @Type("Ticketpark\SaferpayJson\Container\CheckResult") + * @Type("Ticketpark\SaferpayJson\Response\Container\CheckResult") */ private $checkResult; diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php index 3affd05..5137daf 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php @@ -4,7 +4,7 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Redirect; +use Ticketpark\SaferpayJson\Response\Container\Redirect; use Ticketpark\SaferpayJson\Response\Response; final class AliasInsertResponse extends Response @@ -33,7 +33,7 @@ final class AliasInsertResponse extends Response /** * @var Redirect * @SerializedName("Redirect") - * @Type("Ticketpark\SaferpayJson\Container\Redirect") + * @Type("Ticketpark\SaferpayJson\Response\Container\Redirect") */ private $redirect; diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php index ce497d8..cc12388 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php @@ -4,8 +4,8 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Alias; -use Ticketpark\SaferpayJson\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Response\Container\Alias; +use Ticketpark\SaferpayJson\Response\Container\PaymentMeans; use Ticketpark\SaferpayJson\Response\Response; final class AliasUpdateResponse extends Response @@ -13,14 +13,14 @@ final class AliasUpdateResponse extends Response /** * @var Alias * @SerializedName("Alias") - * @Type("Ticketpark\SaferpayJson\Container\Alias") + * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index c768b65..a43eab7 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -4,10 +4,10 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; -use Ticketpark\SaferpayJson\Container\Payer; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegisterAlias; -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; final class AuthorizeDirectResponse extends Response @@ -15,28 +15,28 @@ final class AuthorizeDirectResponse extends Response /** * @var Transaction * @SerializedName("Transaction") - * @Type("Ticketpark\SaferpayJson\Container\Transaction") + * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** * @var PaymentMeans * @SerializedName("PaymentMeans") - * @Type("Ticketpark\SaferpayJson\Container\PaymentMeans") + * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** * @var RegisterAlias * @SerializedName("RegisterAlias") - * @Type("Ticketpark\SaferpayJson\Container\RegisterAlias") + * @Type("Ticketpark\SaferpayJson\Response\Container\RegisterAlias") */ private $registerAlias; /** * @var Payer * @SerializedName("Payer") - * @Type("Ticketpark\SaferpayJson\Container\Payer") + * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ private $payer; diff --git a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php similarity index 63% rename from lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php rename to lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php index a90d8d5..a42f1ec 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AuthorizeReferencedResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php @@ -1,13 +1,13 @@ expectException(SaferpayErrorResponseException::class); + $this->expectException(SaferpayErrorException::class); $this->successful = false; $this->executeRequest(); diff --git a/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php b/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php index 11302c6..a7120ef 100644 --- a/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/PaymentPage/InitializeRequestTest.php @@ -2,9 +2,9 @@ namespace Ticketpark\SaferpayJson\Tests\PaymentPage; -use Ticketpark\SaferpayJson\Container\Amount; -use Ticketpark\SaferpayJson\Container\Payment; -use Ticketpark\SaferpayJson\Container\ReturnUrls; +use Ticketpark\SaferpayJson\Request\Container\Amount; +use Ticketpark\SaferpayJson\Request\Container\Payment; +use Ticketpark\SaferpayJson\Request\Container\ReturnUrls; use Ticketpark\SaferpayJson\Request\PaymentPage\InitializeRequest; use Ticketpark\SaferpayJson\Response\PaymentPage\InitializeResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php index ccd3817..d6f6a0e 100755 --- a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertDirectRequestTest.php @@ -2,8 +2,8 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Container\PaymentMeans; -use Ticketpark\SaferpayJson\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Request\Container\PaymentMeans; +use Ticketpark\SaferpayJson\Request\Container\RegisterAlias; use Ticketpark\SaferpayJson\Request\SecureCardData\AliasInsertDirectRequest; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertDirectResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php index 5361061..f2dc74d 100755 --- a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasInsertRequestTest.php @@ -2,8 +2,8 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Container\RegisterAlias; -use Ticketpark\SaferpayJson\Container\ReturnUrls; +use Ticketpark\SaferpayJson\Request\Container\RegisterAlias; +use Ticketpark\SaferpayJson\Request\Container\ReturnUrls; use Ticketpark\SaferpayJson\Request\SecureCardData\AliasInsertRequest; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasInsertResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; diff --git a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php index 1ce6257..dd4f522 100755 --- a/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/SecureCardData/AliasUpdateRequestTest.php @@ -2,9 +2,9 @@ namespace Ticketpark\SaferpayJson\Tests\SecureAliasStore; -use Ticketpark\SaferpayJson\Container\Card; -use Ticketpark\SaferpayJson\Container\UpdateAlias; -use Ticketpark\SaferpayJson\Container\UpdatePaymentMeans; +use Ticketpark\SaferpayJson\Request\Container\Card; +use Ticketpark\SaferpayJson\Request\Container\UpdateAlias; +use Ticketpark\SaferpayJson\Request\Container\UpdatePaymentMeans; use Ticketpark\SaferpayJson\Request\SecureCardData\AliasUpdateRequest; use Ticketpark\SaferpayJson\Response\SecureCardData\AliasUpdateResponse; use Ticketpark\SaferpayJson\Tests\Request\CommonRequestTest; diff --git a/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php index 9bf24cc..c0f23e9 100644 --- a/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/Transaction/AuthorizeDirectRequestTest.php @@ -1,9 +1,9 @@ Date: Mon, 4 May 2020 14:40:32 +0200 Subject: [PATCH 27/34] Add contributing documentation --- .github/contributing.md | 30 ++++++++++++++++++++++++++++++ README.md | 5 +---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .github/contributing.md 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 92114f9..426c4d5 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,8 @@ https://saferpay.github.io/jsonapi/ 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 ## History From 9566d170481e288abff4a453477bd2628cd8307a Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 14:55:48 +0200 Subject: [PATCH 28/34] Minor codestyle improvements --- lib/SaferpayJson/Request/Container/AddressForm.php | 2 +- lib/SaferpayJson/Request/Container/Authentication.php | 2 ++ lib/SaferpayJson/Request/Container/BankAccount.php | 10 ++-------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/SaferpayJson/Request/Container/AddressForm.php b/lib/SaferpayJson/Request/Container/AddressForm.php index 9300040..d6636ae 100644 --- a/lib/SaferpayJson/Request/Container/AddressForm.php +++ b/lib/SaferpayJson/Request/Container/AddressForm.php @@ -31,7 +31,7 @@ final class AddressForm */ private $mandatoryFields = []; - public function __construct(bool $display = true) + public function __construct(bool $display) { $this->display = $display; } diff --git a/lib/SaferpayJson/Request/Container/Authentication.php b/lib/SaferpayJson/Request/Container/Authentication.php index 188b0b4..0665fb1 100644 --- a/lib/SaferpayJson/Request/Container/Authentication.php +++ b/lib/SaferpayJson/Request/Container/Authentication.php @@ -34,6 +34,7 @@ public function getExemption(): ?string public function setExemption(?string $exemption): self { $this->exemption = $exemption; + return $this; } @@ -45,6 +46,7 @@ public function getThreeDsChallenge(): ?string public function setThreeDsChallenge(?string $threeDsChallenge): self { $this->threeDsChallenge = $threeDsChallenge; + return $this; } } diff --git a/lib/SaferpayJson/Request/Container/BankAccount.php b/lib/SaferpayJson/Request/Container/BankAccount.php index 2d5bd4d..e22ed09 100644 --- a/lib/SaferpayJson/Request/Container/BankAccount.php +++ b/lib/SaferpayJson/Request/Container/BankAccount.php @@ -8,7 +8,7 @@ final class BankAccount { /** - * @var string|null + * @var string * @SerializedName("Iban") */ private $iban; @@ -36,17 +36,11 @@ public function __construct(?string $iban) $this->iban = $iban; } - public function getIban(): ?string + public function getIban(): string { return $this->iban; } - public function setIban(?string $iban): self - { - $this->iban = $iban; - return $this; - } - public function getHolderName(): ?string { return $this->holderName; From d3e5c3d0c55d720b68cead2ef84967dcd9907a67 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 15:00:08 +0200 Subject: [PATCH 29/34] Fix type hint --- lib/SaferpayJson/Request/Container/BankAccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SaferpayJson/Request/Container/BankAccount.php b/lib/SaferpayJson/Request/Container/BankAccount.php index e22ed09..aabbf35 100644 --- a/lib/SaferpayJson/Request/Container/BankAccount.php +++ b/lib/SaferpayJson/Request/Container/BankAccount.php @@ -31,7 +31,7 @@ final class BankAccount */ private $bankName; - public function __construct(?string $iban) + public function __construct(string $iban) { $this->iban = $iban; } From 7d00eb2554454ec392c9a551559e61b5d2e60933 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 15:09:41 +0200 Subject: [PATCH 30/34] Fix use statements in examples --- example/Transaction/example-authorize-referenced.php | 2 +- example/Transaction/example-cancel.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/example/Transaction/example-authorize-referenced.php b/example/Transaction/example-authorize-referenced.php index 9333708..4d882cf 100644 --- a/example/Transaction/example-authorize-referenced.php +++ b/example/Transaction/example-authorize-referenced.php @@ -2,7 +2,7 @@ use Ticketpark\SaferpayJson\Request\Exception\SaferpayErrorException; use Ticketpark\SaferpayJson\Request\Container; -use Ticketpark\SaferpayJson\Request\PaymentPage\AuthorizeReferencedRequest; +use Ticketpark\SaferpayJson\Request\Transaction\AuthorizeReferencedRequest; use Ticketpark\SaferpayJson\Request\RequestConfig; require_once __DIR__ . '/../../vendor/autoload.php'; diff --git a/example/Transaction/example-cancel.php b/example/Transaction/example-cancel.php index ba2721d..89ac4a7 100644 --- a/example/Transaction/example-cancel.php +++ b/example/Transaction/example-cancel.php @@ -3,6 +3,7 @@ use Ticketpark\SaferpayJson\Request\Exception\SaferpayErrorException; use \Ticketpark\SaferpayJson\Request\Container; use \Ticketpark\SaferpayJson\Request\Transaction\CancelRequest; +use Ticketpark\SaferpayJson\Request\RequestConfig; require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../credentials.php'; From f979c1f830cd8d012ce1a7cf3aa822b4944074ee Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 15:09:46 +0200 Subject: [PATCH 31/34] Fix type hints --- .../Transaction/AuthorizeDirectRequest.php | 12 ++++++++++++ .../Response/PaymentPage/AssertResponse.php | 19 ++++++++++++------- .../PaymentPage/InitializeResponse.php | 6 +++--- .../AliasAssertInsertResponse.php | 15 ++++++++++----- .../AliasInsertDirectResponse.php | 11 ++++++++--- .../SecureCardData/AliasInsertResponse.php | 8 ++++---- .../SecureCardData/AliasUpdateResponse.php | 4 ++-- .../Transaction/AuthorizeDirectResponse.php | 8 ++++---- .../AuthorizeReferencedResponse.php | 12 ++++++------ .../Response/Transaction/CancelResponse.php | 6 +++--- .../Response/Transaction/CaptureResponse.php | 10 +++++----- .../Response/Transaction/RefundResponse.php | 6 +++--- 12 files changed, 72 insertions(+), 45 deletions(-) diff --git a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php index 285cf5a..2edce3b 100644 --- a/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php +++ b/lib/SaferpayJson/Request/Transaction/AuthorizeDirectRequest.php @@ -106,6 +106,18 @@ public function setPaymentMeans(PaymentMeans $paymentMeans): self return $this; } + public function getAuthentication(): ?Authentication + { + return $this->authentication; + } + + public function setAuthentication(?Authentication $authentication): self + { + $this->authentication = $authentication; + + return $this; + } + public function getRegisterAlias(): ?RegisterAlias { return $this->registerAlias; diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index aa89a83..d0503d2 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -16,49 +16,49 @@ final class AssertResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var Payer + * @var Payer|null * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ private $payer; /** - * @var RegistrationResult + * @var RegistrationResult|null * @SerializedName("RegistrationResult") * @Type("Ticketpark\SaferpayJson\Response\Container\RegistrationResult") */ private $registrationResult; /** - * @var Liability + * @var Liability|null * @SerializedName("Liability") * @Type("Ticketpark\SaferpayJson\Response\Container\Liability") */ private $liability; /** - * @var Dcc + * @var Dcc|null * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ private $dcc; /** - * @var MastercardIssuerInstallments + * @var MastercardIssuerInstallments|null * @SerializedName("MastercardIssuerInstallments") * @Type("Ticketpark\SaferpayJson\Response\Container\MastercardIssuerInstallments") */ @@ -84,6 +84,11 @@ public function getRegistrationResult(): ?RegistrationResult return $this->registrationResult; } + public function getLiability(): ?Liability + { + return $this->liability; + } + public function getDcc(): ?Dcc { return $this->dcc; diff --git a/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php b/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php index 4d8fe0b..f138d43 100644 --- a/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/InitializeResponse.php @@ -9,21 +9,21 @@ final class InitializeResponse extends Response { /** - * @var string + * @var string|null * @SerializedName("Token") * @Type("string") */ private $token; /** - * @var \DateTime + * @var \DateTime|null * @SerializedName("Expiration") * @Type("string") */ private $expiration; /** - * @var string + * @var string|null * @SerializedName("RedirectUrl") * @Type("string") */ diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php index 35fef39..b54648c 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasAssertInsertResponse.php @@ -12,33 +12,38 @@ final class AliasAssertInsertResponse extends Response { /** - * @var Alias + * @var Alias|null * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var CheckResult + * @var CheckResult|null * @SerializedName("CheckResult") * @Type("Ticketpark\SaferpayJson\Response\Container\CheckResult") */ private $checkResult; - public function getAlias(): Alias + public function getAlias(): ?Alias { return $this->alias; } - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } + + public function getCheckResult(): ?CheckResult + { + return $this->checkResult; + } } diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php index bfb0b26..0457257 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertDirectResponse.php @@ -12,21 +12,21 @@ final class AliasInsertDirectResponse extends Response { /** - * @var Alias + * @var Alias|null * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var CheckResult + * @var CheckResult|null * @SerializedName("CheckResult") * @Type("Ticketpark\SaferpayJson\Response\Container\CheckResult") */ @@ -41,4 +41,9 @@ 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 index 5137daf..c49d631 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasInsertResponse.php @@ -10,28 +10,28 @@ final class AliasInsertResponse extends Response { /** - * @var string + * @var string|null * @SerializedName("Token") * @Type("string") */ private $token; /** - * @var \DateTime + * @var \DateTime|null * @SerializedName("Expiration") * @Type("string") */ private $expiration; /** - * @var bool + * @var bool|null * @SerializedName("RedirectRequired") * @Type("bool") */ private $redirectRequired; /** - * @var Redirect + * @var Redirect|null * @SerializedName("Redirect") * @Type("Ticketpark\SaferpayJson\Response\Container\Redirect") */ diff --git a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php index cc12388..b19473b 100755 --- a/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php +++ b/lib/SaferpayJson/Response/SecureCardData/AliasUpdateResponse.php @@ -11,14 +11,14 @@ final class AliasUpdateResponse extends Response { /** - * @var Alias + * @var Alias|null * @SerializedName("Alias") * @Type("Ticketpark\SaferpayJson\Response\Container\Alias") */ private $alias; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php index a43eab7..f463d69 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeDirectResponse.php @@ -13,28 +13,28 @@ final class AuthorizeDirectResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var RegisterAlias + * @var RegisterAlias|null * @SerializedName("RegisterAlias") * @Type("Ticketpark\SaferpayJson\Response\Container\RegisterAlias") */ private $registerAlias; /** - * @var Payer + * @var Payer|null * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ diff --git a/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php index a42f1ec..ec5024c 100644 --- a/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php +++ b/lib/SaferpayJson/Response/Transaction/AuthorizeReferencedResponse.php @@ -13,39 +13,39 @@ final class AuthorizeReferencedResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var Payer + * @var Payer|null * @SerializedName("Payer") * @Type("Ticketpark\SaferpayJson\Response\Container\Payer") */ private $payer; /** - * @var Dcc + * @var Dcc|null * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ private $dcc; - public function getTransaction(): Transaction + public function getTransaction(): ?Transaction { return $this->transaction; } - public function getPaymentMeans(): PaymentMeans + public function getPaymentMeans(): ?PaymentMeans { return $this->paymentMeans; } diff --git a/lib/SaferpayJson/Response/Transaction/CancelResponse.php b/lib/SaferpayJson/Response/Transaction/CancelResponse.php index 45b3a48..34c804c 100644 --- a/lib/SaferpayJson/Response/Transaction/CancelResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CancelResponse.php @@ -9,21 +9,21 @@ final class CancelResponse extends Response { /** - * @var string + * @var string|null * @SerializedName("TransactionId") * @Type("string") */ private $transactionId; /** - * @var string + * @var string|null * @SerializedName("OrderId") * @Type("string") */ private $orderId; /** - * @var string + * @var string|null * @SerializedName("Date") * @Type("string") */ diff --git a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php index 8cdde42..769f603 100644 --- a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php @@ -13,35 +13,35 @@ final class CaptureResponse extends Response const STATUS_CAPTURED = 'CAPTURED'; /** - * @var string + * @var string|null * @SerializedName("TransactionId") * @Type("string") */ private $transactionId; /** - * @var string + * @var string|null * @SerializedName("CaptureId") * @Type("string") */ private $captureId; /** - * @var string + * @var string|null * @SerializedName("Statis") * @Type("string") */ private $status; /** - * @var string + * @var string|null * @SerializedName("Date") * @Type("string") */ private $date; /** - * @var Invoice + * @var Invoice|null * @SerializedName("Invoice") * @Type("Ticketpark\SaferpayJson\Response\Container\Invoice") */ diff --git a/lib/SaferpayJson/Response/Transaction/RefundResponse.php b/lib/SaferpayJson/Response/Transaction/RefundResponse.php index 1ae9ef0..6bd6249 100644 --- a/lib/SaferpayJson/Response/Transaction/RefundResponse.php +++ b/lib/SaferpayJson/Response/Transaction/RefundResponse.php @@ -12,21 +12,21 @@ final class RefundResponse extends Response { /** - * @var Transaction + * @var Transaction|null * @SerializedName("Transaction") * @Type("Ticketpark\SaferpayJson\Response\Container\Transaction") */ private $transaction; /** - * @var PaymentMeans + * @var PaymentMeans|null * @SerializedName("PaymentMeans") * @Type("Ticketpark\SaferpayJson\Response\Container\PaymentMeans") */ private $paymentMeans; /** - * @var Dcc + * @var Dcc|null * @SerializedName("Dcc") * @Type("Ticketpark\SaferpayJson\Response\Container\Dcc") */ From 16cb79910b4e89203cc50c1cf8e6c29775770002 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 15:13:04 +0200 Subject: [PATCH 32/34] Fix typo in serialized name --- lib/SaferpayJson/Response/Transaction/CaptureResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php index 769f603..0ddac48 100644 --- a/lib/SaferpayJson/Response/Transaction/CaptureResponse.php +++ b/lib/SaferpayJson/Response/Transaction/CaptureResponse.php @@ -28,7 +28,7 @@ final class CaptureResponse extends Response /** * @var string|null - * @SerializedName("Statis") + * @SerializedName("Status") * @Type("string") */ private $status; From 00f358e446b858aaf2a764d1eaaeea17a297a5ac Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 19:51:42 +0200 Subject: [PATCH 33/34] Add missing method --- lib/SaferpayJson/Response/PaymentPage/AssertResponse.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php index d0503d2..6c56413 100644 --- a/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php +++ b/lib/SaferpayJson/Response/PaymentPage/AssertResponse.php @@ -93,4 +93,9 @@ public function getDcc(): ?Dcc { return $this->dcc; } + + public function getMastercardIssuerInstallments(): ?MastercardIssuerInstallments + { + return $this->mastercardIssuerInstallments; + } } From 31be6130ea25eeb8c11c30aacdf06ec86d430085 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 4 May 2020 19:52:01 +0200 Subject: [PATCH 34/34] Rename variable to improve static code analysis --- lib/SaferpayJson/Request/Request.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/SaferpayJson/Request/Request.php b/lib/SaferpayJson/Request/Request.php index 9f2d8bf..6bfeb4d 100644 --- a/lib/SaferpayJson/Request/Request.php +++ b/lib/SaferpayJson/Request/Request.php @@ -106,14 +106,14 @@ protected function doExecute(): Response )); } - /** @var Response $response */ - $response = $this->getSerializer()->deserialize( + /** @var Response $libraryResponse */ + $libraryResponse = $this->getSerializer()->deserialize( (string) $response->getBody(), $this->getResponseClass(), 'json' ); - return $response; + return $libraryResponse; } private function getUrl(): string