diff --git a/lib/Api/TatraPayPlusAPIApi.php b/lib/Api/TatraPayPlusAPIApi.php index 48d643b..8ea2dd9 100755 --- a/lib/Api/TatraPayPlusAPIApi.php +++ b/lib/Api/TatraPayPlusAPIApi.php @@ -47,6 +47,9 @@ class TatraPayPlusAPIApi 'setLogo' => [ 'application/json', ], + 'loanPrecalculation' => [ + 'application/json', + ], ]; /** * @var object @@ -106,7 +109,7 @@ public function __construct( } else { $this->client = $client; } - $this->config = \Tatrapayplus\TatrapayplusApiClient\Configuration::getDefaultConfiguration($mode); + $this->config = new \Tatrapayplus\TatrapayplusApiClient\Configuration($mode); } /** @@ -992,4 +995,69 @@ public function log(HttpResponse $response, array $additional_data = null): void $this->logger->log($response, $additional_data); } } + + /** + * Operation loanPrecalculation + * + * Calculate loan parameters from input + * + * @param \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationRequest precalculation_request Request body (required) + * + * @return array of \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationResponseItem, HTTP status code, HTTP response headers (array of strings) + * + * @throws InvalidArgumentException + * @throws ApiException on non-2xx response or if the response body is not in the expected format + */ + public function loanPrecalculation($precalculation_request) + { + $request = $this->loanPrecalculationRequest($precalculation_request); + + return $this->processRequest($request, '\Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationResponseItem', '\Tatrapayplus\TatrapayplusApiClient\Model\Model400ErrorBody'); + } + + /** + * Create request for operation 'loanPrecalculation' + * + * @param \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationRequest precalculation_request Request body (required) + * + * @return Request + * + * @throws InvalidArgumentException + */ + public function loanPrecalculationRequest($precalculation_request) + { + // verify the required parameter 'precalculation_request' is set + if ($precalculation_request === null || (is_array($precalculation_request) && count($precalculation_request) === 0)) { + throw new InvalidArgumentException('Missing the required parameter precalculation_request when calling loanPrecalculation'); + } + + $resourcePath = '/v1/payments/loans/precalculation'; + + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + self::contentTypes['loanPrecalculation'][0], + false + ); + + $httpBody = static::json_encode(ObjectSerializer::sanitizeForSerialization($precalculation_request)); + + // this endpoint requires OAuth (access token) + $headers = $this->addAuthHeader($headers); + + $defaultHeaders = $this->getDefaultHeaders(); + + $headers = array_merge( + $defaultHeaders, + $headers + ); + + $operationHost = $this->config->getHost(); + + return new Request( + 'PUT', + $operationHost . $resourcePath, + $headers, + $httpBody + ); + } } diff --git a/lib/CurlClient.php b/lib/CurlClient.php index ce749a6..6b1d34a 100644 --- a/lib/CurlClient.php +++ b/lib/CurlClient.php @@ -39,6 +39,9 @@ public function send(Request $request): HttpResponse } elseif ($request->method === "PATCH") { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_setopt($ch, CURLOPT_POSTFIELDS, $request->httpBody); + } elseif ($request->method === "PUT") { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $request->httpBody); } else { exit("Unsupported request type"); } diff --git a/lib/Model/BasicCalculationRequest.php b/lib/Model/BasicCalculationRequest.php new file mode 100644 index 0000000..69685c4 --- /dev/null +++ b/lib/Model/BasicCalculationRequest.php @@ -0,0 +1,528 @@ + + */ +class BasicCalculationRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'basicCalculationRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'payment_method' => 'string', + 'loan_amount' => 'float', + 'capacity_info' => '\Tatrapayplus\TatrapayplusApiClient\Model\CapacityInfo' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'payment_method' => null, + 'loan_amount' => 'double', + 'capacity_info' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'payment_method' => false, + 'loan_amount' => false, + 'capacity_info' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'payment_method' => 'paymentMethod', + 'loan_amount' => 'loanAmount', + 'capacity_info' => 'capacityInfo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'payment_method' => 'setPaymentMethod', + 'loan_amount' => 'setLoanAmount', + 'capacity_info' => 'setCapacityInfo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'payment_method' => 'getPaymentMethod', + 'loan_amount' => 'getLoanAmount', + 'capacity_info' => 'getCapacityInfo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const PAYMENT_METHOD_PAY_LATER = 'PAY_LATER'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPaymentMethodAllowableValues() + { + return [ + self::PAYMENT_METHOD_PAY_LATER, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('payment_method', $data ?? [], null); + $this->setIfExists('loan_amount', $data ?? [], null); + $this->setIfExists('capacity_info', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getPaymentMethodAllowableValues(); + if (!is_null($this->container['payment_method']) && !in_array($this->container['payment_method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'payment_method', must be one of '%s'", + $this->container['payment_method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['loan_amount'] === null) { + $invalidProperties[] = "'loan_amount' can't be null"; + } + if (($this->container['loan_amount'] > 40000)) { + $invalidProperties[] = "invalid value for 'loan_amount', must be smaller than or equal to 40000."; + } + + if (($this->container['loan_amount'] < 100)) { + $invalidProperties[] = "invalid value for 'loan_amount', must be bigger than or equal to 100."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets payment_method + * + * @return string|null + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param string|null $payment_method Only if isPrecalculationAllowed = true + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + if (is_null($payment_method)) { + throw new \InvalidArgumentException('non-nullable payment_method cannot be null'); + } + $allowedValues = $this->getPaymentMethodAllowableValues(); + if (!in_array($payment_method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'payment_method', must be one of '%s'", + $payment_method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['payment_method'] = $payment_method; + + return $this; + } + + /** + * Gets loan_amount + * + * @return float + */ + public function getLoanAmount() + { + return $this->container['loan_amount']; + } + + /** + * Sets loan_amount + * + * @param float $loan_amount Loan amount in EUR + * + * @return self + */ + public function setLoanAmount($loan_amount) + { + if (is_null($loan_amount)) { + throw new \InvalidArgumentException('non-nullable loan_amount cannot be null'); + } + + if (($loan_amount > 40000)) { + throw new \InvalidArgumentException('invalid value for $loan_amount when calling BasicCalculationRequest., must be smaller than or equal to 40000.'); + } + if (($loan_amount < 100)) { + throw new \InvalidArgumentException('invalid value for $loan_amount when calling BasicCalculationRequest., must be bigger than or equal to 100.'); + } + + $this->container['loan_amount'] = $loan_amount; + + return $this; + } + + /** + * Gets capacity_info + * + * @return \Tatrapayplus\TatrapayplusApiClient\Model\CapacityInfo|null + */ + public function getCapacityInfo() + { + return $this->container['capacity_info']; + } + + /** + * Sets capacity_info + * + * @param \Tatrapayplus\TatrapayplusApiClient\Model\CapacityInfo|null $capacity_info capacity_info + * + * @return self + */ + public function setCapacityInfo($capacity_info) + { + if (is_null($capacity_info)) { + throw new \InvalidArgumentException('non-nullable capacity_info cannot be null'); + } + $this->container['capacity_info'] = $capacity_info; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/BasicCalculationResponseItem.php b/lib/Model/BasicCalculationResponseItem.php new file mode 100644 index 0000000..08d3f4d --- /dev/null +++ b/lib/Model/BasicCalculationResponseItem.php @@ -0,0 +1,724 @@ + + */ +class BasicCalculationResponseItem implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'basicCalculationResponseItem'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'loan_interest_rate' => 'float', + 'installment_amount' => 'float', + 'loan_duration' => 'int', + 'preference' => 'bool', + 'main_preference' => 'bool', + 'capacity_validity' => 'bool', + 'rpmn' => 'float', + 'total_amount' => 'float', + 'loan_fee' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'loan_interest_rate' => 'double', + 'installment_amount' => 'double', + 'loan_duration' => null, + 'preference' => null, + 'main_preference' => null, + 'capacity_validity' => null, + 'rpmn' => 'double', + 'total_amount' => 'double', + 'loan_fee' => 'double' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'loan_interest_rate' => false, + 'installment_amount' => false, + 'loan_duration' => false, + 'preference' => false, + 'main_preference' => false, + 'capacity_validity' => false, + 'rpmn' => false, + 'total_amount' => false, + 'loan_fee' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'loan_interest_rate' => 'loanInterestRate', + 'installment_amount' => 'installmentAmount', + 'loan_duration' => 'loanDuration', + 'preference' => 'preference', + 'main_preference' => 'mainPreference', + 'capacity_validity' => 'capacityValidity', + 'rpmn' => 'rpmn', + 'total_amount' => 'totalAmount', + 'loan_fee' => 'loanFee' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'loan_interest_rate' => 'setLoanInterestRate', + 'installment_amount' => 'setInstallmentAmount', + 'loan_duration' => 'setLoanDuration', + 'preference' => 'setPreference', + 'main_preference' => 'setMainPreference', + 'capacity_validity' => 'setCapacityValidity', + 'rpmn' => 'setRpmn', + 'total_amount' => 'setTotalAmount', + 'loan_fee' => 'setLoanFee' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'loan_interest_rate' => 'getLoanInterestRate', + 'installment_amount' => 'getInstallmentAmount', + 'loan_duration' => 'getLoanDuration', + 'preference' => 'getPreference', + 'main_preference' => 'getMainPreference', + 'capacity_validity' => 'getCapacityValidity', + 'rpmn' => 'getRpmn', + 'total_amount' => 'getTotalAmount', + 'loan_fee' => 'getLoanFee' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('loan_interest_rate', $data ?? [], null); + $this->setIfExists('installment_amount', $data ?? [], null); + $this->setIfExists('loan_duration', $data ?? [], null); + $this->setIfExists('preference', $data ?? [], null); + $this->setIfExists('main_preference', $data ?? [], null); + $this->setIfExists('capacity_validity', $data ?? [], null); + $this->setIfExists('rpmn', $data ?? [], null); + $this->setIfExists('total_amount', $data ?? [], null); + $this->setIfExists('loan_fee', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['loan_interest_rate'] === null) { + $invalidProperties[] = "'loan_interest_rate' can't be null"; + } + if ($this->container['installment_amount'] === null) { + $invalidProperties[] = "'installment_amount' can't be null"; + } + if ($this->container['loan_duration'] === null) { + $invalidProperties[] = "'loan_duration' can't be null"; + } + if ($this->container['preference'] === null) { + $invalidProperties[] = "'preference' can't be null"; + } + if ($this->container['main_preference'] === null) { + $invalidProperties[] = "'main_preference' can't be null"; + } + if ($this->container['capacity_validity'] === null) { + $invalidProperties[] = "'capacity_validity' can't be null"; + } + if ($this->container['rpmn'] === null) { + $invalidProperties[] = "'rpmn' can't be null"; + } + if ($this->container['total_amount'] === null) { + $invalidProperties[] = "'total_amount' can't be null"; + } + if (($this->container['total_amount'] > 40000)) { + $invalidProperties[] = "invalid value for 'total_amount', must be smaller than or equal to 40000."; + } + + if (($this->container['total_amount'] < 100)) { + $invalidProperties[] = "invalid value for 'total_amount', must be bigger than or equal to 100."; + } + + if ($this->container['loan_fee'] === null) { + $invalidProperties[] = "'loan_fee' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets loan_interest_rate + * + * @return float + */ + public function getLoanInterestRate() + { + return $this->container['loan_interest_rate']; + } + + /** + * Sets loan_interest_rate + * + * @param float $loan_interest_rate Loan interest rate + * + * @return self + */ + public function setLoanInterestRate($loan_interest_rate) + { + if (is_null($loan_interest_rate)) { + throw new \InvalidArgumentException('non-nullable loan_interest_rate cannot be null'); + } + $this->container['loan_interest_rate'] = $loan_interest_rate; + + return $this; + } + + /** + * Gets installment_amount + * + * @return float + */ + public function getInstallmentAmount() + { + return $this->container['installment_amount']; + } + + /** + * Sets installment_amount + * + * @param float $installment_amount Installment amount + * + * @return self + */ + public function setInstallmentAmount($installment_amount) + { + if (is_null($installment_amount)) { + throw new \InvalidArgumentException('non-nullable installment_amount cannot be null'); + } + $this->container['installment_amount'] = $installment_amount; + + return $this; + } + + /** + * Gets loan_duration + * + * @return int + */ + public function getLoanDuration() + { + return $this->container['loan_duration']; + } + + /** + * Sets loan_duration + * + * @param int $loan_duration Loan duration + * + * @return self + */ + public function setLoanDuration($loan_duration) + { + if (is_null($loan_duration)) { + throw new \InvalidArgumentException('non-nullable loan_duration cannot be null'); + } + $this->container['loan_duration'] = $loan_duration; + + return $this; + } + + /** + * Gets preference + * + * @return bool + */ + public function getPreference() + { + return $this->container['preference']; + } + + /** + * Sets preference + * + * @param bool $preference Preferred maturity of loan offer (max 3) + * + * @return self + */ + public function setPreference($preference) + { + if (is_null($preference)) { + throw new \InvalidArgumentException('non-nullable preference cannot be null'); + } + $this->container['preference'] = $preference; + + return $this; + } + + /** + * Gets main_preference + * + * @return bool + */ + public function getMainPreference() + { + return $this->container['main_preference']; + } + + /** + * Sets main_preference + * + * @param bool $main_preference Main preferred maturity of loan offer (max 1) + * + * @return self + */ + public function setMainPreference($main_preference) + { + if (is_null($main_preference)) { + throw new \InvalidArgumentException('non-nullable main_preference cannot be null'); + } + $this->container['main_preference'] = $main_preference; + + return $this; + } + + /** + * Gets capacity_validity + * + * @return bool + */ + public function getCapacityValidity() + { + return $this->container['capacity_validity']; + } + + /** + * Sets capacity_validity + * + * @param bool $capacity_validity Loan offer is valid with respect to entered capacity + * + * @return self + */ + public function setCapacityValidity($capacity_validity) + { + if (is_null($capacity_validity)) { + throw new \InvalidArgumentException('non-nullable capacity_validity cannot be null'); + } + $this->container['capacity_validity'] = $capacity_validity; + + return $this; + } + + /** + * Gets rpmn + * + * @return float + */ + public function getRpmn() + { + return $this->container['rpmn']; + } + + /** + * Sets rpmn + * + * @param float $rpmn Calculated RPMN + * + * @return self + */ + public function setRpmn($rpmn) + { + if (is_null($rpmn)) { + throw new \InvalidArgumentException('non-nullable rpmn cannot be null'); + } + $this->container['rpmn'] = $rpmn; + + return $this; + } + + /** + * Gets total_amount + * + * @return float + */ + public function getTotalAmount() + { + return $this->container['total_amount']; + } + + /** + * Sets total_amount + * + * @param float $total_amount Total amount of the order including all fees, insurance, shipping,... + * + * @return self + */ + public function setTotalAmount($total_amount) + { + if (is_null($total_amount)) { + throw new \InvalidArgumentException('non-nullable total_amount cannot be null'); + } + + if (($total_amount > 40000)) { + throw new \InvalidArgumentException('invalid value for $total_amount when calling BasicCalculationResponseItem., must be smaller than or equal to 40000.'); + } + if (($total_amount < 100)) { + throw new \InvalidArgumentException('invalid value for $total_amount when calling BasicCalculationResponseItem., must be bigger than or equal to 100.'); + } + + $this->container['total_amount'] = $total_amount; + + return $this; + } + + /** + * Gets loan_fee + * + * @return float + */ + public function getLoanFee() + { + return $this->container['loan_fee']; + } + + /** + * Sets loan_fee + * + * @param float $loan_fee loan_fee + * + * @return self + */ + public function setLoanFee($loan_fee) + { + if (is_null($loan_fee)) { + throw new \InvalidArgumentException('non-nullable loan_fee cannot be null'); + } + $this->container['loan_fee'] = $loan_fee; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/CardDetail.php b/lib/Model/CardDetail.php index 7d5f613..475064e 100644 --- a/lib/Model/CardDetail.php +++ b/lib/Model/CardDetail.php @@ -63,7 +63,8 @@ class CardDetail implements ModelInterface, ArrayAccess, \JsonSerializable 'card_holder' => 'string', 'billing_address' => '\Tatrapayplus\TatrapayplusApiClient\Model\Address', 'shipping_address' => '\Tatrapayplus\TatrapayplusApiClient\Model\Address', - 'comfort_pay' => '\Tatrapayplus\TatrapayplusApiClient\Model\CardIdentifierOrRegister' + 'comfort_pay' => '\Tatrapayplus\TatrapayplusApiClient\Model\CardIdentifierOrRegister', + 'ipsp_data' => '\Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData' ]; /** @@ -79,7 +80,8 @@ class CardDetail implements ModelInterface, ArrayAccess, \JsonSerializable 'card_holder' => null, 'billing_address' => null, 'shipping_address' => null, - 'comfort_pay' => null + 'comfort_pay' => null, + 'ipsp_data' => null ]; /** @@ -93,7 +95,8 @@ class CardDetail implements ModelInterface, ArrayAccess, \JsonSerializable 'card_holder' => false, 'billing_address' => false, 'shipping_address' => false, - 'comfort_pay' => false + 'comfort_pay' => false, + 'ipsp_data' => false ]; /** @@ -187,7 +190,8 @@ public function isNullableSetToNull(string $property): bool 'card_holder' => 'cardHolder', 'billing_address' => 'billingAddress', 'shipping_address' => 'shippingAddress', - 'comfort_pay' => 'comfortPay' + 'comfort_pay' => 'comfortPay', + 'ipsp_data' => 'ipspData' ]; /** @@ -201,7 +205,8 @@ public function isNullableSetToNull(string $property): bool 'card_holder' => 'setCardHolder', 'billing_address' => 'setBillingAddress', 'shipping_address' => 'setShippingAddress', - 'comfort_pay' => 'setComfortPay' + 'comfort_pay' => 'setComfortPay', + 'ipsp_data' => 'setIpspData' ]; /** @@ -215,7 +220,8 @@ public function isNullableSetToNull(string $property): bool 'card_holder' => 'getCardHolder', 'billing_address' => 'getBillingAddress', 'shipping_address' => 'getShippingAddress', - 'comfort_pay' => 'getComfortPay' + 'comfort_pay' => 'getComfortPay', + 'ipsp_data' => 'getIpspData' ]; /** @@ -310,6 +316,7 @@ public function __construct(?array $data = null) $this->setIfExists('billing_address', $data ?? [], null); $this->setIfExists('shipping_address', $data ?? [], null); $this->setIfExists('comfort_pay', $data ?? [], null); + $this->setIfExists('ipsp_data', $data ?? [], null); } /** @@ -559,6 +566,33 @@ public function setComfortPay($comfort_pay) return $this; } + + /** + * Gets ipsp_data + * + * @return \Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData|null + */ + public function getIpspData() + { + return $this->container['ipsp_data']; + } + + /** + * Sets ipsp_data + * + * @param \Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData|null $ipsp_data ipsp_data + * + * @return self + */ + public function setIpspData($ipsp_data) + { + if (is_null($ipsp_data)) { + throw new \InvalidArgumentException('non-nullable ipsp_data cannot be null'); + } + $this->container['ipsp_data'] = $ipsp_data; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/InitiateDirectTransactionRequest.php b/lib/Model/InitiateDirectTransactionRequest.php index a5503c3..ed1625e 100644 --- a/lib/Model/InitiateDirectTransactionRequest.php +++ b/lib/Model/InitiateDirectTransactionRequest.php @@ -62,7 +62,7 @@ class InitiateDirectTransactionRequest implements ModelInterface, ArrayAccess, \ 'end_to_end' => '\Tatrapayplus\TatrapayplusApiClient\Model\E2e', 'is_pre_authorization' => 'bool', 'tds_data' => '\Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionTDSData', - 'ipsp_data' => '\Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData', + 'ipsp_data' => '\Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData', 'token' => '\Tatrapayplus\TatrapayplusApiClient\Model\Token' ]; @@ -448,7 +448,7 @@ public function setTdsData($tds_data) /** * Gets ipsp_data * - * @return \Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData|null + * @return \Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData|null */ public function getIpspData() { @@ -458,7 +458,7 @@ public function getIpspData() /** * Sets ipsp_data * - * @param \Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData|null $ipsp_data ipsp_data + * @param \Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData|null $ipsp_data ipsp_data * * @return self */ diff --git a/lib/Model/Model400ErrorBody.php b/lib/Model/Model400ErrorBody.php index 345785c..0321429 100644 --- a/lib/Model/Model400ErrorBody.php +++ b/lib/Model/Model400ErrorBody.php @@ -255,6 +255,11 @@ public function getModelName() public const ERROR_CODE_CB_TOO_OLD = 'CB_TOO_OLD'; public const ERROR_CODE_CB_ERROR = 'CB_ERROR'; public const ERROR_CODE_NO_AVAIL_PAY_METH = 'NO_AVAIL_PAY_METH'; + public const ERROR_CODE_LOAN_AMNT_LOW = 'LOAN_AMNT_LOW'; + public const ERROR_CODE_LOAN_AMNT_HIGH = 'LOAN_AMNT_HIGH'; + public const ERROR_CODE_NEGATIVE_VALUE_NOT_ALLOWED = 'NEGATIVE_VALUE_NOT_ALLOWED'; + public const ERROR_CODE_INSUFFICIENT_CAPACITY = 'INSUFFICIENT_CAPACITY'; + public const ERROR_CODE_INVALID_PARAMETER = 'INVALID_PARAMETER'; /** * Gets allowable values of the enum @@ -279,6 +284,11 @@ public function getErrorCodeAllowableValues() self::ERROR_CODE_CB_TOO_OLD, self::ERROR_CODE_CB_ERROR, self::ERROR_CODE_NO_AVAIL_PAY_METH, + self::ERROR_CODE_LOAN_AMNT_LOW, + self::ERROR_CODE_LOAN_AMNT_HIGH, + self::ERROR_CODE_NEGATIVE_VALUE_NOT_ALLOWED, + self::ERROR_CODE_INSUFFICIENT_CAPACITY, + self::ERROR_CODE_INVALID_PARAMETER, ]; } diff --git a/lib/Model/DirectTransactionIPSPData.php b/lib/Model/TransactionIPSPData.php similarity index 95% rename from lib/Model/DirectTransactionIPSPData.php rename to lib/Model/TransactionIPSPData.php index c01ee8c..ad3e94b 100644 --- a/lib/Model/DirectTransactionIPSPData.php +++ b/lib/Model/TransactionIPSPData.php @@ -1,6 +1,6 @@ */ -class DirectTransactionIPSPData implements ModelInterface, ArrayAccess, \JsonSerializable +class TransactionIPSPData implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -49,7 +50,7 @@ class DirectTransactionIPSPData implements ModelInterface, ArrayAccess, \JsonSer * * @var string */ - protected static $openAPIModelName = 'directTransactionIPSPData'; + protected static $openAPIModelName = 'transactionIPSPData'; /** * Array of property to type mappings. Used for (de)serialization @@ -362,7 +363,7 @@ public function setSubMerchantId($sub_merchant_id) } if ((!preg_match("/^\\d{1,15}$/", ObjectSerializer::toString($sub_merchant_id)))) { - throw new \InvalidArgumentException("invalid value for \$sub_merchant_id when calling DirectTransactionIPSPData., must conform to the pattern /^\\d{1,15}$/."); + throw new \InvalidArgumentException("invalid value for \$sub_merchant_id when calling TransactionIPSPData., must conform to the pattern /^\\d{1,15}$/."); } $this->container['sub_merchant_id'] = $sub_merchant_id; @@ -394,7 +395,7 @@ public function setName($name) } if ((!preg_match("/^[ 0-9a-zA-Z\\.:\/\\*-]{1,25}$/", ObjectSerializer::toString($name)))) { - throw new \InvalidArgumentException("invalid value for \$name when calling DirectTransactionIPSPData., must conform to the pattern /^[ 0-9a-zA-Z\\.:\/\\*-]{1,25}$/."); + throw new \InvalidArgumentException("invalid value for \$name when calling TransactionIPSPData., must conform to the pattern /^[ 0-9a-zA-Z\\.:\/\\*-]{1,25}$/."); } $this->container['name'] = $name; @@ -426,7 +427,7 @@ public function setLocation($location) } if ((!preg_match("/^[ 0-9a-zA-Z-]{1,13}$/", ObjectSerializer::toString($location)))) { - throw new \InvalidArgumentException("invalid value for \$location when calling DirectTransactionIPSPData., must conform to the pattern /^[ 0-9a-zA-Z-]{1,13}$/."); + throw new \InvalidArgumentException("invalid value for \$location when calling TransactionIPSPData., must conform to the pattern /^[ 0-9a-zA-Z-]{1,13}$/."); } $this->container['location'] = $location; @@ -458,7 +459,7 @@ public function setCountry($country) } if ((!preg_match("/[A-Z]{2}/", ObjectSerializer::toString($country)))) { - throw new \InvalidArgumentException("invalid value for \$country when calling DirectTransactionIPSPData., must conform to the pattern /[A-Z]{2}/."); + throw new \InvalidArgumentException("invalid value for \$country when calling TransactionIPSPData., must conform to the pattern /[A-Z]{2}/."); } $this->container['country'] = $country; diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php index 17422f3..84817b8 100755 --- a/lib/ObjectSerializer.php +++ b/lib/ObjectSerializer.php @@ -473,7 +473,16 @@ public static function deserialize($data, $class, $httpHeaders = null) $data = is_string($data) ? TatraPayPlusAPIApi::json_decode($data) : $data; if (is_array($data)) { - $data = (object) $data; + if (array_is_list($data)) { + // for loans - pure list of class objects + $instance = []; + foreach ($data as $item) { + $instance[] = self::deserialize($item, $class, $httpHeaders); + } + return $instance; + } else { + $data = (object) $data; + } } // If a discriminator is defined and points to a valid subclass, use it. diff --git a/tatrapayplus_api_sandbox.json b/tatrapayplus_api_sandbox.json index 1b5c9c3..7680f38 100644 --- a/tatrapayplus_api_sandbox.json +++ b/tatrapayplus_api_sandbox.json @@ -322,6 +322,73 @@ } } }, + "/v1/payments/loans/precalculation": { + "put": { + "summary": "Loan precalculation", + "description": "Loan precalculation", + "operationId": "loanPrecalculation", + "tags": [ + "TatraPayPlus API" + ], + "security": [ + { + "oAuth2ClientCredentials": [] + } + ], + "parameters": [ + { + "$ref": "#/components/parameters/X-Request-ID" + }, + { + "$ref": "#/components/parameters/IP-Address" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/basicCalculationRequestBody" + }, + "responses": { + "200": { + "$ref": "#/components/responses/OK_200_BasicCalculation" + }, + "400": { + "$ref": "#/components/responses/BAD_REQUEST_400" + }, + "401": { + "$ref": "#/components/responses/UNAUTHORIZED_401" + }, + "403": { + "$ref": "#/components/responses/FORBIDDEN_403" + }, + "404": { + "$ref": "#/components/responses/NOT_FOUND_404" + }, + "405": { + "$ref": "#/components/responses/METHOD_NOT_ALLOWED_405" + }, + "406": { + "$ref": "#/components/responses/NOT_ACCEPTABLE_406" + }, + "408": { + "$ref": "#/components/responses/REQUEST_TIMEOUT_408" + }, + "409": { + "$ref": "#/components/responses/CONFLICT_409" + }, + "415": { + "$ref": "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" + }, + "429": { + "$ref": "#/components/responses/TOO_MANY_REQUESTS_429" + }, + "500": { + "$ref": "#/components/responses/INTERNAL_SERVER_ERROR_500" + }, + "503": { + "$ref": "#/components/responses/SERVICE_UNAVAILABLE_503" + } + } + } + }, "/v1/payments-direct": { "post": { "summary": "Create direct transaction request", @@ -522,6 +589,130 @@ } }, "schemas": { + "basicCalculationResponseItem": { + "type": "object", + "required": [ + "loanInterestRate", + "installmentAmount", + "loanDuration", + "preference", + "mainPreference", + "capacityValidity", + "rpmn", + "totalAmount", + "loanFee" + ], + "properties": { + "loanInterestRate": { + "$ref": "#/components/schemas/loanInterestRate" + }, + "installmentAmount": { + "$ref": "#/components/schemas/installmentAmount" + }, + "loanDuration": { + "$ref": "#/components/schemas/loanDuration" + }, + "preference": { + "$ref": "#/components/schemas/preference" + }, + "mainPreference": { + "$ref": "#/components/schemas/mainPreference" + }, + "capacityValidity": { + "$ref": "#/components/schemas/capacityValidity" + }, + "rpmn": { + "$ref": "#/components/schemas/rpmn" + }, + "totalAmount": { + "$ref": "#/components/schemas/totalAmount" + }, + "loanFee": { + "$ref": "#/components/schemas/loanFee" + } + } + }, + "loanInterestRate": { + "type": "number", + "format": "double", + "description": "Loan interest rate" + }, + "installmentAmount": { + "type": "number", + "format": "double", + "description": "Installment amount" + }, + "loanDuration": { + "type": "integer", + "description": "Loan duration" + }, + "preference": { + "type": "boolean", + "description": "Preferred maturity of loan offer (max 3)" + }, + "mainPreference": { + "type": "boolean", + "description": "Main preferred maturity of loan offer (max 1)" + }, + "capacityValidity": { + "type": "boolean", + "description": "Loan offer is valid with respect to entered capacity" + }, + "rpmn": { + "type": "number", + "format": "double", + "description": "Calculated RPMN" + }, + "totalAmount": { + "type": "number", + "format": "double", + "description": "Total amount of the order including all fees, insurance, shipping,...", + "minimum": 100, + "maximum": 40000, + "multipleOf": 0.01, + "example": 156.95 + }, + "loanAmount": { + "type": "number", + "format": "double", + "description": "Loan amount in EUR", + "minimum": 100, + "maximum": 40000, + "multipleOf": 0.01, + "example": 156.95 + }, + "loanFee": { + "type": "number", + "format": "double" + }, + "basicCalculationResponse": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/components/schemas/basicCalculationResponseItem" + } + }, + "basicCalculationRequest": { + "type": "object", + "required": [ + "loanAmount" + ], + "properties": { + "paymentMethod": { + "description": "Only if isPrecalculationAllowed = true", + "type": "string", + "enum": [ + "PAY_LATER" + ] + }, + "loanAmount": { + "$ref": "#/components/schemas/loanAmount" + }, + "capacityInfo": { + "$ref": "#/components/schemas/capacityInfo" + } + } + }, "paymentIntentUpdateResponse": { "description": "\n**TatraPayPlus payment update response. **\n\n| selectedPaymentMethod | attribute supported |\n| ---------------- | ------------|\n| BANK_TRANSFER | N/A |\n| CARD_PAY | cardPayStatusStructure |\n| PAY_LATER | N/A |\n", "type": "object", @@ -697,7 +888,7 @@ "$ref": "#/components/schemas/directTransactionTDSData" }, "ipspData": { - "$ref": "#/components/schemas/directTransactionIPSPData" + "$ref": "#/components/schemas/transactionIPSPData" }, "token": { "$ref": "#/components/schemas/token" @@ -820,7 +1011,11 @@ "CB_NOT_FOUND", "CB_TOO_OLD", "CB_ERROR", - "NO_AVAIL_PAY_METH" + "NO_AVAIL_PAY_METH", + "LOAN_AMNT_LOW", + "LOAN_AMNT_HIGH", + "NEGATIVE_VALUE_NOT_ALLOWED", + "INSUFFICIENT_CAPACITY" ] }, "errorDescription": { @@ -1353,6 +1548,10 @@ }, "allowedBankProviders": { "$ref": "#/components/schemas/allowedBankProviders" + }, + "isPrecalculationAllowed": { + "type": "boolean", + "default": false } } }, @@ -1530,7 +1729,8 @@ "type": "string", "description": "Value of paymentData.paymentMethodData.tokenizationData.token" }, - "directTransactionIPSPData": { + "transactionIPSPData": { + "description": "In case of payment facilitator mode - this structure is mandatory", "type": "object", "required": [ "subMerchantId", @@ -1593,6 +1793,9 @@ }, "comfortPay": { "$ref": "#/components/schemas/cardIdentifierOrRegister" + }, + "ipspData": { + "$ref": "#/components/schemas/transactionIPSPData" } } }, @@ -1897,7 +2100,7 @@ "format": "DDMMYYYYHHMISS" }, "required": true, - "example": 1092014125505 + "example": "01092014125505" }, "User-Id": { "name": "User-Id", @@ -1951,6 +2154,16 @@ } }, "requestBodies": { + "basicCalculationRequestBody": { + "description": "Request body for a loan precalculation.\n", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/basicCalculationRequest" + } + } + } + }, "initiateDirectTransaction": { "description": "DirectAPI transaction", "required": true, @@ -2007,6 +2220,21 @@ } }, "responses": { + "OK_200_BasicCalculation": { + "description": "Basic calculation provided", + "headers": { + "X-Request-ID": { + "$ref": "#/components/headers/X-Request-ID" + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/basicCalculationResponse" + } + } + } + }, "OK_201_Logo_created": { "description": "TatraPayPlus Apearance set", "headers": { diff --git a/tatrapayplus_api_v1.1.0.yaml b/tatrapayplus_api_v1.1.0.yaml deleted file mode 100755 index e3dc94a..0000000 --- a/tatrapayplus_api_v1.1.0.yaml +++ /dev/null @@ -1,1612 +0,0 @@ -openapi: 3.0.1 -info: - title: TatraPayPlus API - version: "0.0.1_2024-02-22v1" - -servers: - - url: https://api.tatrabanka.sk/tatrapayplus/production - description: TatraPayPlus API production - - url: https://api.tatrabanka.sk/tatrapayplus/sandbox - description: TatraPayPlus API sandbox - - -paths: - /v1/payments: - post: - security: - - oAuth2ClientCredentials: - - TATRAPAYPLUS - summary: Initiate payment intent - description: Initiate payment intent - operationId: initiatePayment - tags: - - TatraPayPlus API - parameters: - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - $ref: "#/components/parameters/Redirect-URI" - #- $ref: "#/components/parameters/Webhook-URI" - #- $ref: "#/components/parameters/Signature" - - $ref: "#/components/parameters/Preferred-Method" - #- $ref: "#/components/parameters/Timestamp" - - $ref: "#/components/parameters/Accept-Language" - - requestBody: - $ref: "#/components/requestBodies/initiatePaymentBody" - - responses: - '201': - $ref: "#/components/responses/OK_201_InitiatePaymentResponse" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - /v1/payments/methods: - get: - summary: Payment methods list - description: Payment methods list - operationId: getMethods - tags: - - TatraPayPlus API - parameters: - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - responses: - '200': - $ref: "#/components/responses/OK_200_PaymentMethodsList" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - /v1/payments/{payment-id}/status: - get: - summary: Payment intent status. - description: Payment intent status - operationId: getPaymentIntentStatus - tags: - - TatraPayPlus API - parameters: - - $ref: "#/components/parameters/Payment-id" - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - - responses: - '200': - $ref: "#/components/responses/OK_200_PaymentIntentStatus" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - /v1/payments/{payment-id}: - patch: - summary: Update payment intent - description: Update payment intent. Only available for payments initiated by the CARD_PAY method. - operationId: updatePaymentIntent - tags: - - TatraPayPlus API - parameters: - - $ref: "#/components/parameters/Payment-id" - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - $ref: "#/components/parameters/Idempotency-Key" - requestBody: - $ref: "#/components/requestBodies/updatePaymentBody" - - responses: - '200': - $ref: "#/components/responses/OK_200_PaymentIntentUpdate" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - delete: - summary: Cancel payment intent. - description: Cancel payment intent. Available in general if authorizationStatus is NEW. This method is also available for payments initiated by the PAY_LATER payment method, but only if the status is CUSTOMER_CREATION_IN_PROGRESS. - operationId: cancelPaymentIntent - tags: - - TatraPayPlus API - parameters: - - $ref: "#/components/parameters/Payment-id" - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - - responses: - '200': - $ref: "#/components/responses/OK_200_PaymentIntentCancelation" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - - /v1/appearances: - post: - summary: Set appearance parameters for TatraPayPlus - description: Set appearance parameters for TatraPayPlus - operationId: setAppearance - tags: - - TatraPayPlus Appearance API - parameters: - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - requestBody: - $ref: "#/components/requestBodies/appearanceBody" - - responses: - '201': - $ref: "#/components/responses/OK_201_Appearance_created" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - /v1/appearances/logo: - post: - summary: Set logo for TatraPayPlus - description: | - Logo appearance request body. Logo must follow these rules: - MaxLength: 256px - MaxHeight: 64px - operationId: setLogo - tags: - - TatraPayPlus Appearance API - parameters: - - $ref: "#/components/parameters/X-Request-ID" - - $ref: "#/components/parameters/IP-Address" - - requestBody: - $ref: "#/components/requestBodies/logoBody" - - responses: - '201': - $ref: "#/components/responses/OK_201_Logo_created" - '400': - $ref: "#/components/responses/BAD_REQUEST_400" - '401': - $ref: "#/components/responses/UNAUTHORIZED_401" - '403': - $ref: "#/components/responses/FORBIDDEN_403" - '404': - $ref: "#/components/responses/NOT_FOUND_404" - '405': - $ref: "#/components/responses/METHOD_NOT_ALLOWED_405" - '406': - $ref: "#/components/responses/NOT_ACCEPTABLE_406" - '408': - $ref: "#/components/responses/REQUEST_TIMEOUT_408" - '409': - $ref: "#/components/responses/CONFLICT_409" - '415': - $ref: "#/components/responses/UNSUPPORTED_MEDIA_TYPE_415" - '429': - $ref: "#/components/responses/TOO_MANY_REQUESTS_429" - '500': - $ref: "#/components/responses/INTERNAL_SERVER_ERROR_500" - '503': - $ref: "#/components/responses/SERVICE_UNAVAILABLE_503" - - - -components: - securitySchemes: - oAuth2ClientCredentials: - type: oauth2 - description: See https://datatracker.ietf.org/doc/html/rfc6749#section-4.4 - flows: - clientCredentials: - tokenUrl: /auth/oauth/v2/token - scopes: - TATRAPAYPLUS: access to TatraPay Plus API - schemas: - #request/response schemas - - paymentIntentUpdateResponse: - description: | - - **TatraPayPlus payment update response. ** - - | selectedPaymentMethod | attribute supported | - | ---------------- | ------------| - | BANK_TRANSFER | N/A | - | CARD_PAY | cardPayStatusStructure | - | PAY_LATER | N/A | - - type: object - properties: - status: - oneOf: - - $ref: '#/components/schemas/cardPayStatusStructure' - - - paymentIntentCancelResponse: - description: | - - **TatraPayPlus cancel response. ** - - type: object - properties: - selectedPaymentMethod: - $ref: '#/components/schemas/paymentMethod' - - - paymentIntentStatusResponse: - description: | - - **TatraPayPlus status response. For each payment method will be sent specific status structure** - - | selectedPaymentMethod | status structure | - | ---------------- | ------------| - | BANK_TRANSFER | bankTransferStatus | - | CARD_PAY | cardPayStatusStructure | - | PAY_LATER | payLaterStatus | - - type: object - required: - - authorizationStatus - - properties: - selectedPaymentMethod: - $ref: '#/components/schemas/paymentMethod' - - authorizationStatus: - type: string - enum: - - NEW - - PAY_METHOD_SELECTED - - AUTH_DONE - - AUTH_FAILED - - EXPIRED - - CANCELLED_BY_TPP - - CANCELLED_BY_USER - description: Status of payment intent authorization progress. Be aware, It doesnt indicate payment status! To get payment status see attribute status. - status: - oneOf: - - $ref: '#/components/schemas/cardPayStatusStructure' - - $ref: '#/components/schemas/bankTransferStatus' - - $ref: '#/components/schemas/payLaterStatus' - - - paymentMethodsListResponse: - description: TatraPayPlus methods list, in case BANK_TRANSFER method is allowed for client,allowedBankProviders will be also provided - - type: object - required: - - paymentMethods - properties: - paymentMethods: - $ref: '#/components/schemas/paymentMethods' - - appearanceLogoRequest: - type: object - description: The logo image. - required: - - logoImage - properties: - logoImage: - type: string - description: base64 Encoded image. MaxLength - 256px MaxHeight - 64px, Max size 1MB(base64 encoded string). Supported formats are SVG, JPEG, PNG - maxLength: 1000000 - format: byte - - appearanceRequest: - type: object - description: Attributes that can be customised - properties: - theme: - type: string - enum: - - DARK - - LIGHT - - SYSTEM - default: SYSTEM - - tintOnAccent: - $ref: '#/components/schemas/colorAttribute' - tintAccent: - $ref: '#/components/schemas/colorAttribute' - surfaceAccent: - $ref: '#/components/schemas/colorAttribute' - - - - colorAttribute: - type: object - description: Color attributes for specific theme. Choose colour with sufficient contrast for the specific theme - properties: - colorDarkMode: - $ref: '#/components/schemas/color' - colorLightMode: - $ref: '#/components/schemas/color' - - color: - type: string - description: Hexadecimal value of the color - pattern: "^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$" - - udpatePaymentRequest: - $ref: '#/components/schemas/cardPayUpdateInstruction' - - cardPayUpdateInstruction: - description: CardPay update instruction. For CONFIRM_PRE_AUTHORIZATION, CHARGEBACK is amount mandatory. - type: object - required: - - operationType - - properties: - operationType: - type: string - enum: - - CONFIRM_PRE_AUTHORIZATION - - CANCEL_PRE_AUTHORIZATION - - CHARGEBACK - amount: - $ref: '#/components/schemas/amountValue' - - initiatePaymentRequest: - description: Body for payment initiation - type: object - required: - - basePayment - properties: - basePayment: - $ref: '#/components/schemas/basePayment' - userData: - $ref: '#/components/schemas/userData' - bankTransfer: - $ref: '#/components/schemas/bankTransfer' - cardDetail: - $ref: '#/components/schemas/cardDetail' - #comfortPay: - # $ref: '#/components/schemas/comfortPay' - payLater: - $ref: '#/components/schemas/payLater' - - initiatePaymentResponse: - type: object - required: - - paymentId - properties: - paymentId: - $ref: '#/components/schemas/paymentId' - tatraPayPlusUrl: - $ref: '#/components/schemas/tatraPayPlusUrl' - availablePaymentMethods: - type: array - description: List of availibility of each possible methods. - items: - $ref: '#/components/schemas/availablePaymentMethod' - - 400_errorBody: - type: object - properties: - errorCode: - type: string - maxLength: 20 - enum: - - NO_CONTRACT - - ILLEGAL_ARGUMENT - - TOT_AMNT_LOW - - TOT_AMNT_MISMATCH - - PAYMENT_NOT_FOUND - - NOT_ALLOWED_OPER - - DUPLICATE_CALL - - PA_AMOUNT_EXCEEDED - - PA_NOT_FOUND - - PA_ERROR - - CB_AMOUNT_EXCEEDED - - CB_NOT_FOUND - - CB_TOO_OLD - - CB_ERROR - - NO_AVAIL_PAY_METH - errorDescription: - type: string - maxLength: 255 - availablePaymentMethods: - type: array - description: Reason codes of declined methods - items: - $ref: '#/components/schemas/availablePaymentMethod' - - - #common schemas - - amount: - type: object - required: - - amountValue - - currency - properties: - amountValue: - $ref: '#/components/schemas/amountValue' - currency: - $ref: '#/components/schemas/currencyCode' - - availablePaymentMethod: - type: object - required: - - paymentMethod - - isAvailable - properties: - paymentMethod: - $ref: '#/components/schemas/paymentMethod' - isAvailable: - type: boolean - description: if true, method will be shown to user. Otherwise reasonCode will be provided - reasonCodeMethodAvailability: - type: string - description: reason code. List of enumaration will be provided in documentation - enum: - - NO_CONTRACT - - NOT_FEASIBLE_CURRENCY - - OUT_OF_RANGE_AMOUNT - - MANDATORY_STRUCTURE_NOT_PROVIDED - - UNSUPPORTED_BANK_PROVIDER - - INCORRECT_INPUT - reasonCodeMethodAvailabilityDescription: - type: string - description: reason code description - - - scaAuthLink: - description: sca authorization link - format: $url - type: string - - cardPayStatus: - description: | - - **CardPay status** - - | Enum | description | - | ---------------- | ------------| - | OK | processed successfully transaction | - | FAIL | failed transaction | - | PA | pre-authorization | - | CPA | completed pre-authorization | - | SPA | canceled preauthorization | - | XPA | expired pre-authorization | - | CB | returned payment | - type: string - enum: - - OK - - FAIL - - PA - - CPA - - SPA - - XPA - - CB - cardPayStatusStructure: - description: card pay status structure - type: object - required: - - status - - currency - properties: - status: - $ref: '#/components/schemas/cardPayStatus' - currency: - $ref: '#/components/schemas/currencyCode' - amount: - $ref: '#/components/schemas/amountValue' - preAuthorization: - $ref: '#/components/schemas/cardPayAmount' - chargeBack: - $ref: '#/components/schemas/cardPayAmount' - comfortPay: - type: object - required: - - status - properties: - status: - $ref: '#/components/schemas/comfortPayStatus' - cid: - $ref: '#/components/schemas/cardId' - maskedCardNumber: - $ref: '#/components/schemas/maskedCardNumber' - reasonCode: - oneOf: - - $ref: '#/components/schemas/cardPayReasonCodes3Chars' - - $ref: '#/components/schemas/cardPayReasonCodes2Chars' - - maskedCardNumber: - description: Masked card number. - type: string - maxLength: 19 - - cardPayReasonCodes3Chars: - description: FDS,TDS, SYS. - type: string - maxLength: 3 - - cardPayReasonCodes2Chars: - description: 2 chars card reasonCode, https://developer.visa.com/request_response_codes#action_code , https://developer.mastercard.com/mastercard-send-disbursements/documentation/response-error-codes/network-response-codes/ - type: string - maxLength: 2 - - comfortPayStatus: - type: string - enum: - - OK - - FAIL - - cardPayAmount: - type: object - required: - - amount - properties: - amount: - $ref: '#/components/schemas/amountValue' - - payLaterStatus: - type: string - description: Finance application status - enum: - - NEW - - CUSTOMER_CREATION_IN_PROGRESS - - LOAN_APPLICATION_IN_PROGRESS - - LOAN_APPLICATION_FINISHED - - LOAN_DISBURSED - - CANCELED - - EXPIRED - - bankTransferStatus: - description: | - The transaction status is filled with codes of the ISO 20022 - type: string - enum: - - "ACCC" - - "ACCP" - - "ACSC" - - "ACSP" - - "ACTC" - - "ACWC" - - "ACWP" - - "RCVD" - - "PDNG" - - "RJCT" - - "CANC" - - "ACFC" - - "PATC" - - "PART" - example: "ACCP" - - # properties - tatraPayPlusUrl: - description: URL address for FE redirect to tatraPayPlus app - type: string - format: $url - - paymentId: - description: Payment intent identifier - type: string - format: $uuid - - payLater: - type: object - required: - - order - - applicant - properties: - order: - $ref: '#/components/schemas/order' - #applicant: - # $ref: '#/components/schemas/applicant' - capacityInfo: - $ref: "#/components/schemas/capacityInfo" - - capacityInfo: - type: object - description: "Capacity posibilities of user. It is used to specify the calculation of the client's request. Based on this, the bank can make a more accurate calculation of the possibility of obtaining a loan" - required: - - monthlyIncome - - monthlyExpenses - - numberOfChildren - properties: - monthlyIncome: - $ref: "#/components/schemas/monthlyIncome" - monthlyExpenses: - $ref: "#/components/schemas/monthlyExpenses" - numberOfChildren: - $ref: "#/components/schemas/numberOfChildren" - - monthlyIncome: - type: number - format: double - description: Declared monthly income by user - - monthlyExpenses: - type: number - format: double - description: Declared monthly expenses by user - - numberOfChildren: - type: integer - minimum: 0 - description: Declared number of children of user - - - userData: - type: object - required: - - firstName - - lastName - properties: - externalApplicantId: - $ref: "#/components/schemas/externalApplicantId" - firstName: - $ref: "#/components/schemas/name" - lastName: - $ref: "#/components/schemas/name" - email: - $ref: "#/components/schemas/email" - phone: - $ref: "#/components/schemas/phone" - - externalApplicantId: - type: string - maxLength: 255 - minLength: 1 - description: External applicant ID, could be generated by application - - name: - type: string - maxLength: 30 - minLength: 1 - pattern: ^[a-zA-Z0-9À-ž ]{1,30}$ - - - phone: - description: Conditionally mandatory.It is mandatory only if the email attribute is not provided. - type: string - pattern: '\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$' - - #Order properties - orderNo: - type: string - maxLength: 100 - minLength: 1 - description: | - Order Number. Sending the same orderNo will affect that previously created application status will change to 'CANCELLED' and new application will be created. In case that application is in state that its not possible to cancel, the error state 422 will be returned - - quantity: - type: integer - format: int64 - description: "Quantity of the item" - - totalItemPrice: - type: number - format: double - description: "Total item price (including quantity e.g.:(item price*quantity))" - - itemName: - type: string - maxLength: 255 - minLength: 1 - - itemDescription: - type: string - maxLength: 1000 - minLength: 1 - - itemDetailLangUnit: - type: object - required: - - itemName - properties: - itemName: - $ref: "#/components/schemas/itemName" - itemDescription: - $ref: "#/components/schemas/itemDescription" - - itemDetail: - type: object - required: - - itemDetailSK - properties: - itemDetailSK: - $ref: "#/components/schemas/itemDetailLangUnit" - itemDetailEN: - $ref: "#/components/schemas/itemDetailLangUnit" - - - itemInfoURL: - type: string - format: uri - - itemImage: - type: string - maxLength: 1000000 - description: "base64 encoded image h:48px w:48px" - - - orderItem: - type: object - required: - - quantity - - totalItemPrice - - itemDetail - properties: - quantity: - $ref: "#/components/schemas/quantity" - totalItemPrice: - $ref: "#/components/schemas/totalItemPrice" - itemDetail: - $ref: "#/components/schemas/itemDetail" - itemInfoURL: - $ref: "#/components/schemas/itemInfoURL" - itemImage: - $ref: "#/components/schemas/itemImage" - - - orderItems: - type: array - maxItems: 1000 - minItems: 1 - items: - $ref: "#/components/schemas/orderItem" - - - remittanceInformation: - type: string - description: "Information for creditor" - pattern: ^[ 0-9a-zA-Z?:()\/\.,'+-]{1,100}$ - minLength: 1 - maxLength: 100 - - - - preferredLoanDuration: - type: integer - format: int64 - description: "Preferred loan payment period" - - downPayment: - type: number - format: double - description: "Downpayment for activation of service" - - - order: - type: object - description: "Order detail informations" - required: - - orderNo - - totalAmount - - orderItems - - orderPaymentData - properties: - orderNo: - $ref: '#/components/schemas/orderNo' - orderItems: - $ref: '#/components/schemas/orderItems' - preferredLoanDuration: - $ref: '#/components/schemas/preferredLoanDuration' - downPayment: - $ref: '#/components/schemas/downPayment' - - allowedBankProviders: - description: Allowed bank providers for BANK_TRNASFER method selected by TatraPayPlus client - type: array - items: - $ref: '#/components/schemas/provider' - - bankProvider: - description: BANK_TRNASFER type bank provider, for full list see documentation - type: string - - paymentMethods: - description: TatraPayPlus methods list - type: array - items: - $ref: '#/components/schemas/paymentMethodRules' - - paymentMethodRules: - type: object - required: - - paymentmethod - properties: - paymentmethod: - $ref: '#/components/schemas/paymentMethod' - amountRangeRule: - $ref: '#/components/schemas/amountRangeRule' - supportedCurrency: - type: array - items: - $ref: '#/components/schemas/currencyCode' - allowedBankProviders: - $ref: '#/components/schemas/allowedBankProviders' - - - amountRangeRule: - type: object - description: Range of amounts allowed for a given payment method - properties: - minAmount: - type: number - maxAmount: - type: number - - - paymentMethod: - description: TatraPayPlus enumaration - type: string - enum: - - BANK_TRANSFER - - CARD_PAY - - PAY_LATER - - provider: - description: Data provider - type: object - required: - - countryCode - - providerName - - providerCode - - swiftCode - properties: - countryCode: - $ref: "#/components/schemas/countryCode" - providerName: - type: string - maxLength: 500 - example: Dummie bank - providerCode: - maxLength: 50 - type: string - swiftCode: - $ref: "#/components/schemas/bicfi" - - - bicfi: - description: | - BICFI - type: string - pattern: '[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}' - example: "AAAADEBBXXX" - - - basePayment: - description: Common instruction detail - type: object - required: - - instructedAmount - - endToEnd - properties: - instructedAmount: - $ref: '#/components/schemas/amount' - endToEnd: - $ref: '#/components/schemas/e2e' - - bankTransfer: - description: Bank transder attributes - type: object - properties: - remittanceInformationUnstructured: - $ref: '#/components/schemas/remittanceInformationUnstructured' - - comfortPay: - description: ComfortPay attributes - type: object - required: - - name - properties: - cardIdentifier: - $ref: '#/components/schemas/cardIdentifierOrRegister' - cardDetail: - description: Card pay information - type: object - required: - - cardHolder - properties: - cardPayLangOverride: - description: | - It is possible to override the accept-language header for the CardPay payment method. This override only affects CardPay itself, not the whole TatraPayPlus service. - If it is empty , then accept-language is taken into account - type: string - enum: - - SK - - EN - - DE - - HU - - CZ - - ES - - FR - - IT - - PL - isPreAuthorization: - description: If true - pre-authorization transaction - type: boolean - cardHolder: - description: | - Unstructured remittance information. At present, Tatrabanka bank transfer does not display the remittance information. - - type: string - pattern: ^[ 0-9a-zA-Z.@_-]{2,45}$ - maxLength: 45 - minLength: 2 - billingAddress: - $ref: "#/components/schemas/address" - shippingAddress: - $ref: "#/components/schemas/address" - comfortPay: - $ref: '#/components/schemas/cardIdentifierOrRegister' - - registerForComfortPay: - description: Flag to register the card for ComfortPay - type: boolean - default: false - example: false - - registerForComfortPayObj: - type: object - properties: - registerForComfortPay: - $ref: '#/components/schemas/registerForComfortPay' - - - signedCardIdObj: - type: object - properties: - signedCardId: - $ref: '#/components/schemas/signedCardId' - - cardIdentifierOrRegister: - oneOf: - - $ref: '#/components/schemas/registerForComfortPayObj' - - $ref: '#/components/schemas/signedCardIdObj' - - cardId: - description: Card identifier for ComfortPay - type: string - maxLength: 18 - pattern: "[0-9]{1,18}" - - signedCardId: - description: Signed registered card identifier by client signing certificate for direct ComfortPay in base64 encoded string - type: string - maxLength: 1024 - - address: - type: object - required: - - country - properties: - streetName: - type: string - maxLength: 40 - buildingNumber: - type: string - maxLength: 10 - townName: - type: string - maxLength: 35 - postCode: - type: string - maxLength: 10 - country: - $ref: "#/components/schemas/countryCode" - - - - countryCode: - description: ISO 3166 ALPHA2 country code. - type: string - pattern: "[A-Z]{2}" - example: "SE" - - - e2e: - description: EndToEndId or paymentSymbols - oneOf: - - $ref: '#/components/schemas/paymentSymbols' - - $ref: '#/components/schemas/endToEndId' - - paymentSymbols: - type: object - required: - - variableSymbol - properties: - variableSymbol: - $ref: "#/components/schemas/variableSymbol" - specificSymbol: - $ref: "#/components/schemas/specificSymbol" - constantSymbol: - $ref: "#/components/schemas/constantSymbol" - - variableSymbol: - type: string - pattern: "^[0-9]{1,10}$" - example: 123456 - - specificSymbol: - type: string - pattern: "^[0-9]{1,10}$" - - constantSymbol: - type: string - description: In case of payment method CardPay will be automatically rewrite to value 0608 - pattern: "^[0-9]{1,4}$" - - endToEndId: - description: | - Max 35 alphanumeric characters - - - pattern: ^[0-9a-zA-Z\/\. -]{1,35}$ - type: string - minLength: 1 - maxLength: 35 - - - currencyCode: - description: | - ISO 4217 Alpha 3 currency code. - type: string - pattern: '[A-Z]{3}' - example: EUR - amountValue: - description: > - The amount given with fractional digits, where fractions must be - compliant to the currency definition. Negative amounts are signed by minus. - - The decimal separator is a dot. - - - **Example:** - - Valid representations for EUR with up to two decimals are: - - * 1056 - * 5768.2 - * -1.50 - * 5877.78 - type: number - pattern: '-?[0-9]{1,9}(\.[0-9]{1,2})?' - - dateTime: - type: string - format: date-time - example: "2017-10-25T15:30:35.035Z" - date: - type: string - format: date - example: "2017-10-25" - - status: - description: Status of calculation - type: string - enum: - - OFFER - - NO_OFFER - - OPEN - - PROCESSING - - email: - description: Conditionally mandatory.It is mandatory only if the phone attribute is not provided. If the email is not provided, the user will not receive the cardPay notification and payLater will ask for the email in the app. - type: string - maxLength: 50 - format: email - - - iban: - type: string - description: IBAN of an account. - pattern: "[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}" - example: "FR7612345987650123456789014" - - bban: - description: | - Basic Bank Account Number (BBAN) Identifier. - - This data element can be used in the body of the consent request. - Message for retrieving account access consent from this account. This - data elements is used for payment accounts which have no IBAN. - ISO20022: Basic Bank Account Number (BBAN). - - Identifier used nationally by financial institutions, i.e., in individual countries, - generally as part of a National Account Numbering Scheme(s), - which uniquely identifies the account of a customer. - type: string - pattern: "[a-zA-Z0-9]{1,30}" - example: "BARC12345612345678" - - accountReference: - description: | - Reference to an account by IBAN, of a payment accounts - - type: object - properties: - iban: - $ref: "#/components/schemas/iban" - - - remittanceInformationUnstructured: - description: | - Unstructured remittance information. At present, Tatrabanka bank transfer does not display the remittance information. SEPA remittanceInformationUnstructured contains 140 characters. For TatraPayPlus purposes, the first 40 characters are assigned to the paymentId. Others 100 characters are free to use - - type: string - pattern: ^[ 0-9a-zA-Z?:()\/\.,'+-]{1,100}$ - maxLength: 100 - example: "Ref Number Merchant" - - - #all input parameters - parameters: - - Automatic-Redirect: - name: Redirect-URI - in: header - description: | - If it is set to 'true', the customer will be automatically redirect to Redirect-URI(if is set) after 9 seconds, otherwise the last page will wait for customer action to click to button - schema: - type: string - format: uri - required: false - - Redirect-URI: - name: Redirect-URI - in: header - description: | - URI of the client application endpoint, where the user shall be redirected to after payment process. URI has to be registered in Developer portal - - schema: - type: string - format: uri - required: true - - Webhook-URI: - name: Webhook-URI - in: header - description: | - URI of the client application webhook endpoint, where the user shall be sent notifications - schema: - type: string - format: uri - required: false - - X-Request-ID: - name: X-Request-ID - in: header - description: ID of the request, unique to the call, as determined by the initiating party. - required: true - example: "99391c7e-ad88-49ec-a2ad-99ddcb1f7721" - schema: - type: string - format: uuid - - Idempotency-Key: - name: Idempotency-Key - in: header - description: An idempotency key is a unique value generated by the client which the resource server uses to recognize subsequent retries of the same request. The Idempotency-Key HTTP request header field carries this key. - required: true - example: "99391c7e-ad88-49ec-a2ad-99ddcb1f7721" - schema: - type: string - format: uuid - - IP-Address: - name: IP-Address - in: header - description: | - The forwarded IP Address header field consists of the corresponding http request IP Address field between PSU and Identity app/Customer app - schema: - type: string - format: ipv4 - required: true - example: 192.168.8.78 - - Signature: - name: Signature - in: header - description: > - Signature for payment body - schema: - type: string - required: true - example: 8a91ea4e87c3db6c695051c5ac72498c54099114fc83554fdfabb784b485eea4 - - Preferred-Method: - name: Preferred-Method - in: header - description: > - Preferred payment intent method - schema: - $ref: "#/components/schemas/paymentMethod" - required: false - example: BANK_TRANSFER - - Timestamp: - name: Timestamp - in: header - description: > - Timestamp. Only +/-1h from UTC(GMT) - schema: - type: string - format: DDMMYYYYHHMISS - required: true - example: 01092014125505 - - User-Id: - name: User-Id - in: header - description: | - The user id, if available. - schema: - type: string - required: false - - Accept-Language: - name: Accept-Language - in: header - description: The "Accept-Language" header field is used by user agents to indicate the set of natural languages that are preferred. Available "en" and "sk" - required: false - example: "sk" - schema: - type: string - enum: - - en - - sk - default: sk - - #path - Payment-id: - name: payment-id - in: path - description: | - payment intent identifier - schema: - type: string - format: uuid - required: true - - #all headers req/resp - headers: - X-Request-ID: - description: ID of the request, unique to the call, as determined by the initiating party. - required: true - example: "99391c7e-ad88-49ec-a2ad-99ddcb1f7721" - schema: - type: string - format: uuid - - #all request bodies - - requestBodies: - - initiatePaymentBody: - description: | - - **The table bellow describes required objects for specific payment method** - - | Base structures | Mandatory for Payment method | - | ---------------- | ------------| - | basePayment | Always mandatory | - | userData | CARD_PAY, PAY_LATER| - - | Method specific structures | Mandatory for Payment method | - | ---------------- | ------------| - | bankTransfer | BANK_TRANSFER | - | cardDetail | CARD_PAY| - | payLater | PAY_LATER| - - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/initiatePaymentRequest" - - updatePaymentBody: - description: | - - **TatraPayPlus update request** - - | Payment method | mandatory structure | - | ---------------- | ------------| - | BANK_TRANSFER | N/A | - | CARD_PAY | cardPayUpdateInstruction | - | PAY_LATER | N/A | - - - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/udpatePaymentRequest" - - - appearanceBody: - description: Appearance request body - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/appearanceRequest" - - - logoBody: - required: true - content: # Response body - application/json: - schema: - $ref: "#/components/schemas/appearanceLogoRequest" - - - #all responses - - responses: - ##################################################### - # Positive Responses - ##################################################### - - OK_201_Logo_created: - description: TatraPayPlus Apearance set - - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - - OK_201_Appearance_created: - description: TatraPayPlus Apearance set - - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - - - - OK_201_InitiatePaymentResponse: - description: TatraPayPlus transaction initiated - - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - content: - application/json: - schema: - $ref: "#/components/schemas/initiatePaymentResponse" - - - OK_200_PaymentMethodsList: - description: OK - - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - - content: - application/json: - schema: - $ref: "#/components/schemas/paymentMethodsListResponse" - - OK_200_PaymentIntentStatus: - description: OK - - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - - content: - application/json: - schema: - $ref: "#/components/schemas/paymentIntentStatusResponse" - - OK_200_PaymentIntentCancelation: - description: Cancel payment intent. Its supported for state 'NEW' - headers: - X-Request-ID: - $ref: '#/components/headers/X-Request-ID' - - - OK_200_PaymentIntentUpdate: - description: Payment intent successfully updated - headers: - X-Request-ID: - $ref: '#/components/headers/X-Request-ID' - - - - ##################################################### - # Negative Responses - ##################################################### - - - BAD_REQUEST_400: - description: Bad Request - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - content: - application/json: - schema: - $ref: "#/components/schemas/400_errorBody" - - UNAUTHORIZED_401: - description: Unauthorized - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - FORBIDDEN_403: - description: Forbidden - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - NOT_FOUND_404: - description: Not found - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - METHOD_NOT_ALLOWED_405: - description: Method not allowed - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - NOT_ACCEPTABLE_406: - description: Not acceptable - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - REQUEST_TIMEOUT_408: - description: Request timeout - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - CONFLICT_409: - description: Conflict - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - UNSUPPORTED_MEDIA_TYPE_415: - description: Unsupported media type - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - TOO_MANY_REQUESTS_429: - description: Too many requests - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - INTERNAL_SERVER_ERROR_500: - description: Internal server error - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" - SERVICE_UNAVAILABLE_503: - description: Service unavailable - headers: - X-Request-ID: - $ref: "#/components/headers/X-Request-ID" -security: - - oAuth2ClientCredentials: [] - -tags: - ##################################################### - # Predefined Tags to Group Methods - ##################################################### - - - name: TatraPayPlus API - - name: TatraPayPlus Appearance API - - - diff --git a/tests/tests.php b/tests/tests.php index cd11762..eb139ae 100644 --- a/tests/tests.php +++ b/tests/tests.php @@ -9,7 +9,7 @@ use Tatrapayplus\TatrapayplusApiClient\Model\CardPayStatus; use Tatrapayplus\TatrapayplusApiClient\Model\CardPayUpdateInstruction; use Tatrapayplus\TatrapayplusApiClient\Model\ColorAttribute; -use Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData; +use Tatrapayplus\TatrapayplusApiClient\Model\TransactionIPSPData; use Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionTDSData; use Tatrapayplus\TatrapayplusApiClient\Model\InitiateDirectTransactionRequest; use Tatrapayplus\TatrapayplusApiClient\Model\InitiatePaymentRequest; @@ -33,6 +33,9 @@ use Tatrapayplus\TatrapayplusApiClient\Model\OrderItem; use Tatrapayplus\TatrapayplusApiClient\Model\ItemDetail; use Tatrapayplus\TatrapayplusApiClient\Model\ItemDetailLangUnit; +use Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationRequest; +use Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationResponseItem; +use Tatrapayplus\TatrapayplusApiClient\Model\CapacityInfo; use Tatrapayplus\TatrapayplusApiClient\CurlClient; use Tatrapayplus\TatrapayplusApiClient\ObjectSerializer; use Tatrapayplus\TatrapayplusApiClient\TatraPayPlusLogger; @@ -102,7 +105,7 @@ private function getDirectTransactionPayload( "billing_address" => $address, "shipping_address" => $address, ]), - "ipsp_data" => new DirectTransactionIPSPData([ + "ipsp_data" => new TransactionIPSPData([ "sub_merchant_id" => "12345", "name" => "Test 123", "location" => "Test 123", @@ -712,6 +715,31 @@ public function testMapSimpleStatus() $this->assertSame($simple_status, $expected_result); } } + + public function testLoanPrecalculation() + { + $request = new BasicCalculationRequest([ + "payment_method" => PaymentMethod::PAY_LATER, + "loan_amount" => 150.45, + ]); + $api_instance = new TatraPayPlusAPIApi( + $this->client_id, + $this->client_secret, + mode: TatraPayPlusAPIApi::PRODUCTION + ); + + $response = $api_instance->loanPrecalculation($request); + + $this->assertSame($response["response"]->getStatusCode(), 200); + $response_list = $response['object']; + $this->assertIsArray($response_list); + $this->assertTrue(array_is_list($response_list)); + foreach ($response_list as $item) { + $this->assertInstanceOf(BasicCalculationResponseItem::class, $item); + } + $first_offer = $response_list[0]; + $this->assertTrue(! is_null($first_offer->getLoanInterestRate())); + } } function mock_addAuthHeader($headers)