From 6511979777bda85afe317bd5ad8dd1f5004ae962 Mon Sep 17 00:00:00 2001 From: karneaud Date: Mon, 24 Jun 2024 18:42:49 -0400 Subject: [PATCH] add rotessa sdk --- .../src/Omnipay/Rotessa/AbstractClient.php | 21 +++++ .../src/Omnipay/Rotessa/ApiTrait.php | 41 ++++++++ .../src/Omnipay/Rotessa/ClientInterface.php | 11 +++ .../Omnipay/Rotessa/Exception/Exceptions.php | 43 +++++++++ .../src/Omnipay/Rotessa/Gateway.php | 74 +++++++++++++++ .../src/Omnipay/Rotessa/Http/Client.php | 82 ++++++++++++++++ .../Rotessa/Http/Response/Response.php | 32 +++++++ .../src/Omnipay/Rotessa/IsValidTypeTrait.php | 12 +++ .../Message/Request/AbstractRequest.php | 52 ++++++++++ .../Rotessa/Message/Request/BaseRequest.php | 93 ++++++++++++++++++ .../Request/DeleteTransactionSchedulesId.php | 18 ++++ .../Rotessa/Message/Request/GetCustomers.php | 14 +++ .../Message/Request/GetCustomersId.php | 19 ++++ .../Request/GetTransactionSchedulesId.php | 17 ++++ .../Message/Request/PatchCustomersId.php | 65 +++++++++++++ .../Request/PatchTransactionSchedulesId.php | 22 +++++ .../Rotessa/Message/Request/PostCustomers.php | 60 ++++++++++++ .../PostCustomersShowWithCustomIdentifier.php | 19 ++++ .../Request/PostTransactionSchedules.php | 31 ++++++ ...ionSchedulesCreateWithCustomIdentifier.php | 16 ++++ .../PostTransactionSchedulesUpdateViaPost.php | 24 +++++ .../Message/Request/RequestInterface.php | 10 ++ .../Message/Response/AbstractResponse.php | 16 ++++ .../Rotessa/Message/Response/BaseResponse.php | 44 +++++++++ .../Message/Response/ResponseInterface.php | 9 ++ .../Omnipay/Rotessa/Model/AbstractModel.php | 63 +++++++++++++ .../src/Omnipay/Rotessa/Model/BaseModel.php | 24 +++++ .../Omnipay/Rotessa/Model/CustomerModel.php | 94 +++++++++++++++++++ .../Rotessa/Model/CustomerPatchModel.php | 16 ++++ .../Omnipay/Rotessa/Model/ModelInterface.php | 8 ++ .../Model/TransactionScheduleModel.php | 84 +++++++++++++++++ .../Model/TransactionSchedulesIdBodyModel.php | 23 +++++ ...sactionSchedulesUpdateViaPostBodyModel.php | 24 +++++ .../src/Omnipay/Rotessa/Object/Address.php | 53 +++++++++++ .../Rotessa/Object/AuthorizationType.php | 28 ++++++ .../Rotessa/Object/BankAccountType.php | 28 ++++++ .../src/Omnipay/Rotessa/Object/Country.php | 33 +++++++ .../Omnipay/Rotessa/Object/CustomerType.php | 28 ++++++ .../src/Omnipay/Rotessa/Object/Frequency.php | 64 +++++++++++++ 39 files changed, 1415 insertions(+) create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/AbstractClient.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ApiTrait.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ClientInterface.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Exception/Exceptions.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Gateway.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Client.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Response/Response.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/IsValidTypeTrait.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/AbstractRequest.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/BaseRequest.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/DeleteTransactionSchedulesId.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetCustomers.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetCustomersId.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetTransactionSchedulesId.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchCustomersId.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchTransactionSchedulesId.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomers.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomersShowWithCustomIdentifier.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedules.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesCreateWithCustomIdentifier.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesUpdateViaPost.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/RequestInterface.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/AbstractResponse.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/BaseResponse.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/ResponseInterface.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/AbstractModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/BaseModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerPatchModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/ModelInterface.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionScheduleModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesIdBodyModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesUpdateViaPostBodyModel.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Address.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/AuthorizationType.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/BankAccountType.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Country.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/CustomerType.php create mode 100644 app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Frequency.php diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/AbstractClient.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/AbstractClient.php new file mode 100644 index 000000000000..c84a97322717 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/AbstractClient.php @@ -0,0 +1,21 @@ +default_parameters; + } + + public function setDefaultParameters(array $params) { + $this->default_parameters = $params; + } + +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ApiTrait.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ApiTrait.php new file mode 100644 index 000000000000..5fc947713f3a --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ApiTrait.php @@ -0,0 +1,41 @@ +createRequest('GetCustomers', [] ); + } + public function postCustomers(array $params) : RequestInterface { + return $this->createRequest('PostCustomers', $params ); + } + public function getCustomersId(array $params) : RequestInterface { + return $this->createRequest('GetCustomersId', $params ); + } + public function patchCustomersId(array $params) : RequestInterface { + return $this->createRequest('PatchCustomersId', $params ); + } + public function postCustomersShowWithCustomIdentifier(array $params) : RequestInterface { + return $this->createRequest('PostCustomersShowWithCustomIdentifier', $params ); + } + public function getTransactionSchedulesId(array $params) : RequestInterface { + return $this->createRequest('GetTransactionSchedulesId', $params ); + } + public function deleteTransactionSchedulesId(array $params) : RequestInterface { + return $this->createRequest('DeleteTransactionSchedulesId', $params ); + } + public function patchTransactionSchedulesId(array $params) : RequestInterface { + return $this->createRequest('PatchTransactionSchedulesId', $params ); + } + public function postTransactionSchedules(array $params) : RequestInterface { + return $this->createRequest('PostTransactionSchedules', $params ); + } + public function postTransactionSchedulesCreateWithCustomIdentifier(array $params) : RequestInterface { + return $this->createRequest('PostTransactionSchedulesCreateWithCustomIdentifier', $params ); + } + public function postTransactionSchedulesUpdateViaPost(array $params) : RequestInterface { + return $this->createRequest('PostTransactionSchedulesUpdateViaPost', $params ); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ClientInterface.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ClientInterface.php new file mode 100644 index 000000000000..4d08fb0441f2 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/ClientInterface.php @@ -0,0 +1,11 @@ + 1234567890 ]; + + protected $test_mode = true; + + protected $api_key; + + public function getName() + { + return 'Rotessa'; + } + + public function getDefaultParameters() : array + { + return array_merge($this->default_parameters, array('api_key' => $this->api_key, 'test_mode' => $this->test_mode ) ); + } + + public function setTestMode($value) { + $this->test_mode = $value; + } + + public function getTestMode() { + return $this->test_mode; + } + + protected function createRequest($class_name, ?array $parameters = [] ) :RequestInterface { + $class = null; + $class_name = "Omnipay\\Rotessa\\Message\\Request\\$class_name"; + $parameters = $class_name::hasModel() ? (($parameters = ($class_name::getModel($parameters)))->validate() ? $parameters->jsonSerialize() : null ) : $parameters; + try { + $class = new $class_name($this->httpClient, $this->httpRequest, $this->getDefaultParameters() + $parameters ); + } catch (\Throwable $th) { + throw $th; + } + + return $class; + } + + function setApiKey($value) { + $this->api_key = $value; + } + + function getApiKey() { + return $this->api_key; + } + + function authorize(array $options = []) : RequestInterface { + return $this->postCustomers($options); + } + + function capture(array $options = []) : RequestInterface { + return array_key_exists('customer_id', $options)? $this->postTransactionSchedules($options) : $this->postTransactionSchedulesCreateWithCustomIdentifier($options) ; + } + + function updateCustomer(array $options) : RequestInterface { + return $this->patchCustomersId($options); + } + + function fetchTransaction($id = null) : RequestInterface { + return $this->getTransactionSchedulesId(compact('id')); + } + +} \ No newline at end of file diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Client.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Client.php new file mode 100644 index 000000000000..4c8ea0d29075 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Client.php @@ -0,0 +1,82 @@ +httpClient = $httpClient ?: HttpClientDiscovery::find(); + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); + parent::__construct($httpClient, $requestFactory); + } + + /** + * @param $method + * @param $uri + * @param array $headers + * @param string|array|resource|StreamInterface|null $body + * @param string $protocolVersion + * @return ResponseInterface + * @throws \Http\Client\Exception + */ + public function request( + $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return $this->sendRequest($method, $uri, $headers, $body, $protocolVersion); + + } + + /** + * @param RequestInterface $request + * @return ResponseInterface + * @throws \Http\Client\Exception + */ + private function sendRequest( $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1') + { + + $response = null; + + try { + if( method_exists($this->httpClient, 'sendRequest')) + $response = $this->httpClient->sendRequest( $this->requestFactory->createRequest($method, $uri, $headers, $body, $protocolVersion)); + else $response = $this->httpClient->request($method, $uri, compact('body','headers')); + } catch (\Http\Client\Exception\NetworkException $networkException) { + throw new NetworkException($networkException->getMessage(), $request, $networkException); + } catch (\Exception $exception) { + throw new RequestException($exception->getMessage(), $request, $exception); + } + + return $response; + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Response/Response.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Response/Response.php new file mode 100644 index 000000000000..8d665ac8546e --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Http/Response/Response.php @@ -0,0 +1,32 @@ +content, true) )) { + $data = $data['errors'][0]; + $this->reason_phrase = $data['error_message'] ; + $this->reason_code = $data['error_message'] ; + } + } + + public function getReasonPhrase() { + return $this->reason_phrase; + } + + public function getReasonCode() { + return $this->reason_code; + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/IsValidTypeTrait.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/IsValidTypeTrait.php new file mode 100644 index 000000000000..266ba3036d9d --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/IsValidTypeTrait.php @@ -0,0 +1,12 @@ +api_key = $value; + } + + public function getData() { + try { + if(empty($this->api_key)) throw new \Exception('No Api Key Found!'); + $this->validate( ...array_keys($data = $this->getParameters())); + } catch (\Throwable $th) { + throw new \Omnipay\Rotessa\Exception\ValidationException($th->getMessage() , 600, $th); + } + + return (array) $data; + } + + abstract public function sendData($data) : ResponseInterface; + + abstract protected function sendRequest(string $method, string $endpoint, array $headers = [], array $data = [] ); + + abstract protected function createResponse(array $data) : ResponseInterface; + + abstract public function getEndpointUrl(): string; + + public function getEndpoint() : string { + return $this->endpoint; + } + + public function getTestMode() { + return $this->test_mode; + } + + public function setTestMode($mode) { + $this->test_mode = $mode; + } + } \ No newline at end of file diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/BaseRequest.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/BaseRequest.php new file mode 100644 index 000000000000..4b68cf0aa2ff --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/BaseRequest.php @@ -0,0 +1,93 @@ +initialize($model); + } + + protected function sendRequest(string $method, string $endpoint, array $headers = [], array $data = []) + { + /** + * @param $method + * @param $uri + * @param array $headers + * @param string|resource|StreamInterface|null $body + * @param string $protocolVersion + * @return ResponseInterface + * @throws \Http\Client\Exception + */ + $response = $this->httpClient->request($method, $endpoint, $headers, json_encode($data) ) ; + $this->response = new Response ($response->getBody()->getContents(), $response->getStatusCode(), $response->getHeaders(), true); + } + + + protected function createResponse(array $data): ResponseInterface { + + return new BaseResponse($this, $data, $this->response->getStatusCode(), $this->response->getReasonPhrase()); + } + + protected function replacePlaceholder($string, $array) { + $pattern = "/\{([^}]+)\}/"; + $replacement = function($matches) use($array) { + $key = $matches[1]; + if (array_key_exists($key, $array)) { + return $array[$key]; + } else { + return $matches[0]; + } + }; + + return preg_replace_callback($pattern, $replacement, $string); + } + + public function sendData($data) :ResponseInterface { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'Authorization' => "Token token={$this->api_key}" + ]; + + $this->sendRequest( + $this->method, + $this->getEndpointUrl(), + $headers, + $data); + + return $this->createResponse(json_decode($this->response->getContent(), true)); + } + + public function getEndpoint() : string { + return $this->replacePlaceholder($this->endpoint, $this->getParameters()); + } + + public function getEndpointUrl() : string { + return sprintf('https://%s.%s/v%d%s',$this->test_mode ? self::ENVIRONMENT_SANDBOX : self::ENVIRONMENT_LIVE ,$this->base_url, $this->api_version, $this->getEndpoint()); + } + + public static function hasModel() : bool { + return (bool) static::$model; + } + + public static function getModel($parameters = []) { + $class_name = static::$model; + $class_name = "Omnipay\\Rotessa\\Model\\{$class_name}Model"; + return new $class_name($parameters); + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/DeleteTransactionSchedulesId.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/DeleteTransactionSchedulesId.php new file mode 100644 index 000000000000..7c03c42b0dc6 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/DeleteTransactionSchedulesId.php @@ -0,0 +1,18 @@ +setParameter('id',$value); + } + +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetCustomers.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetCustomers.php new file mode 100644 index 000000000000..17ffde5355d9 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetCustomers.php @@ -0,0 +1,14 @@ +setParameter('id',$value); + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetTransactionSchedulesId.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetTransactionSchedulesId.php new file mode 100644 index 000000000000..47578d06eb8b --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/GetTransactionSchedulesId.php @@ -0,0 +1,17 @@ +setParameter('id',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchCustomersId.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchCustomersId.php new file mode 100644 index 000000000000..092e378b9fd5 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchCustomersId.php @@ -0,0 +1,65 @@ +setParameter('id',$value); + } + public function setCustomIdentifier(string $value) { + $this->setParameter('custom_identifier',$value); + } + public function setName(string $value) { + $this->setParameter('name',$value); + } + public function setEmail(string $value) { + $this->setParameter('email',$value); + } + public function setCustomerType(string $value) { + $this->setParameter('customer_type',$value); + } + public function setHomePhone(string $value) { + $this->setParameter('home_phone',$value); + } + public function setPhone(string $value) { + $this->setParameter('phone',$value); + } + public function setBankName(string $value) { + $this->setParameter('bank_name',$value); + } + public function setInstitutionNumber(string $value) { + $this->setParameter('institution_number',$value); + } + public function setTransitNumber(string $value) { + $this->setParameter('transit_number',$value); + } + public function setBankAccountType(string $value) { + $this->setParameter('bank_account_type',$value); + } + public function setAuthorizationType(string $value) { + $this->setParameter('authorization_type',$value); + } + public function setRoutingNumber(string $value) { + $this->setParameter('routing_number',$value); + } + public function setAccountNumber(string $value) { + $this->setParameter('account_number',$value); + } + public function setAddress(array $value) { + $this->setParameter('address',$value); + } + public function setTransactionSchedules(array $value) { + $this->setParameter('transaction_schedules',$value); + } + public function setFinancialTransactions(array $value) { + $this->setParameter('financial_transactions',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchTransactionSchedulesId.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchTransactionSchedulesId.php new file mode 100644 index 000000000000..fa04b9f05da6 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PatchTransactionSchedulesId.php @@ -0,0 +1,22 @@ +setParameter('id',$value); + } + public function setAmount(int $value) { + $this->setParameter('amount',$value); + } + public function setComment(string $value) { + $this->setParameter('comment',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomers.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomers.php new file mode 100644 index 000000000000..a0c54fe65ca9 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomers.php @@ -0,0 +1,60 @@ +setParameter('id',$value); + } + public function setCustomIdentifier(string $value) { + $this->setParameter('custom_identifier',$value); + } + public function setName(string $value) { + $this->setParameter('name',$value); + } + public function setEmail(string $value) { + $this->setParameter('email',$value); + } + public function setCustomerType(string $value) { + $this->setParameter('customer_type',$value); + } + public function setHomePhone(string $value) { + $this->setParameter('home_phone',$value); + } + public function setPhone(string $value) { + $this->setParameter('phone',$value); + } + public function setBankName(string $value) { + $this->setParameter('bank_name',$value); + } + public function setInstitutionNumber(string $value = '') { + $this->setParameter('institution_number',$value); + } + public function setTransitNumber(string $value = '') { + $this->setParameter('transit_number',$value); + } + public function setBankAccountType(string $value) { + $this->setParameter('bank_account_type',$value); + } + public function setAuthorizationType(string $value = '') { + $this->setParameter('authorization_type',$value); + } + public function setRoutingNumber(string $value = '') { + $this->setParameter('routing_number',$value); + } + public function setAccountNumber(string $value) { + $this->setParameter('account_number',$value); + } + public function setAddress(array $value) { + $this->setParameter('address',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomersShowWithCustomIdentifier.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomersShowWithCustomIdentifier.php new file mode 100644 index 000000000000..d590cb618526 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostCustomersShowWithCustomIdentifier.php @@ -0,0 +1,19 @@ +setParameter('custom_identifier',$value); + } + +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedules.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedules.php new file mode 100644 index 000000000000..80e28a7f5083 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedules.php @@ -0,0 +1,31 @@ +setParameter('customer_id',$value); + } + public function setProcessDate(string $value) { + $this->setParameter('process_date',$value); + } + public function setFrequency(string $value) { + $this->setParameter('frequency',$value); + } + public function setInstallments(int $value) { + $this->setParameter('installments',$value); + } + public function setComment(string $value) { + $this->setParameter('comment',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesCreateWithCustomIdentifier.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesCreateWithCustomIdentifier.php new file mode 100644 index 000000000000..fd5111dc9a74 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesCreateWithCustomIdentifier.php @@ -0,0 +1,16 @@ +setParameter('custom_identifier',$value); + } + +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesUpdateViaPost.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesUpdateViaPost.php new file mode 100644 index 000000000000..e037c5b4d322 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/PostTransactionSchedulesUpdateViaPost.php @@ -0,0 +1,24 @@ +setParameter('id',$value); + } + public function setAmount(int $value) { + $this->setParameter('amount',$value); + } + public function setComment(string $value) { + $this->setParameter('comment',$value); + } + } diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/RequestInterface.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/RequestInterface.php new file mode 100644 index 000000000000..cfbcf0095b24 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Request/RequestInterface.php @@ -0,0 +1,10 @@ +code = $code; + $this->message = $message; + } + + public function getData() { + return $this->getParameters(); + } + + public function getCode() { + return (int) $this->code; + } + + public function isSuccessful() { + return $this->code < 300; + } + + public function getMessage() { + return $this->message; + } + + protected function getParameters() { + return $this->data; + } + + public function getParameter(string $key) { + return $this->getParameters()[$key]; + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/ResponseInterface.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/ResponseInterface.php new file mode 100644 index 000000000000..080eaab504b1 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Message/Response/ResponseInterface.php @@ -0,0 +1,9 @@ +required), array_filter($this->getParameters()) ); + if(!empty($required)) throw new ValidationException("Could not validate " . implode(",", array_keys($required)) ); + + return true; + } + + public function __get($key) { + return array_key_exists($key, $this->attributes) ? $this->getParameter($key) : null; + } + + public function __set($key, $value) { + if(array_key_exists($key, $this->attributes)) $this->setParameter($key, $value); + } + + public function __toString() : string { + return json_encode($this); + } + + public function toString() : string { + return $this->__toString(); + } + + public function __toArray() : array { + return $this->getParameters(); + } + + + public function toArray() : array { + return $this->__toArray(); + } + + public function initialize(array $params = []) { + $this->parameters = new ParameterBag; + $parameters = array_merge($this->defaults, $params); + if ($parameters) { + foreach ($this->attributes as $param => $type) { + $value = @$parameters[$param]; + if($value){ + settype($value, $type); + $this->setParameter($param, $value); + } + } + } + + return $this; + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/BaseModel.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/BaseModel.php new file mode 100644 index 000000000000..8064662068c4 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/BaseModel.php @@ -0,0 +1,24 @@ + "string" + ]; + protected $required = ['id']; + protected $defaults = ['id' => 0 ]; + + public function __construct($parameters = array()) { + $this->initialize($parameters); + } + + public function jsonSerialize() : array { + return array_intersect_key($this->toArray(), array_flip($this->required) ); + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerModel.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerModel.php new file mode 100644 index 000000000000..0fd67aea9441 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerModel.php @@ -0,0 +1,94 @@ + "string", + "custom_identifier" => "string", + "name" => "string", + "email" => "string", + "customer_type" => "string", + "home_phone" => "string", + "phone" => "string", + "bank_name" => "string", + "institution_number" => "string", + "transit_number" => "string", + "bank_account_type" => "string", + "authorization_type" => "string", + "routing_number" => "string", + "account_number" => "string", + "address" => "object", + "transaction_schedules" => "array", + "financial_transactions" => "array", + "active" => "bool" + ]; + + protected $defaults = ["active" => false,"customer_type" =>'Business',"bank_account_type" =>'Savings',"authorization_type" =>'Online',]; + protected $required = ["name","email","customer_type","home_phone","phone","bank_name","institution_number","transit_number","bank_account_type","authorization_type","routing_number","account_number","address",'custom_identifier']; + + public function validate() : bool { + try { + $country = $this->address->country; + if(!self::isValidCountry($country)) throw new \Exception("Invalid country!"); + + $this->required = array_diff($this->required, Country::isAmerican($country) ? ["institution_number", "transit_number"] : ["bank_account_type", "routing_number"]); + parent::validate(); + if(Country::isCanadian($country) ) { + if(!self::isValidTransitNumber($this->getParameter('transit_number'))) throw new \Exception("Invalid transit number!"); + if(!self::isValidInstitutionNumber($this->getParameter('institution_number'))) throw new \Exception("Invalid institution number!"); + } + if(!self::isValidCustomerType($this->getParameter('customer_type'))) throw new \Exception("Invalid customer type!"); + if(!self::isValidBankAccountType($this->getParameter('bank_account_type'))) throw new \Exception("Invalid bank account type!"); + if(!self::isValidAuthorizationType($this->getParameter('authorization_type'))) throw new \Exception("Invalid authorization type!"); + } catch (\Throwable $th) { + throw new ValidationException($th->getMessage()); + } + + return true; + } + + public static function isValidCountry(string $country ) : bool { + return Country::isValidCountryCode($country) || Country::isValidCountryName($country); + } + + public static function isValidTransitNumber(string $value ) : bool { + return strlen($value) == 5; + } + + public static function isValidInstitutionNumber(string $value ) : bool { + return strlen($value) == 3; + } + + public static function isValidCustomerType(string $value ) : bool { + return CustomerType::isValid($value); + } + + public static function isValidBankAccountType(string $value ) : bool { + return BankAccountType::isValid($value); + } + + public static function isValidAuthorizationType(string $value ) : bool { + return AuthorizationType::isValid($value); + } + + public function toArray() : array { + return [ 'address' => (array) $this->getParameter('address') ] + parent::toArray(); + } + + public function jsonSerialize() : array { + $address = (array) $this->getParameter('address'); + unset($address['country']); + + return compact('address') + parent::jsonSerialize(); + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerPatchModel.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerPatchModel.php new file mode 100644 index 000000000000..c2e51d50b135 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/CustomerPatchModel.php @@ -0,0 +1,16 @@ + "string", + "amount" => "float", + "comment" => "string", + "created_at" => "date", + "financial_transactions" => "array", + "frequency" => "string", + "installments" => "integer", + "next_process_date" => "date", + "process_date" => "date", + "updated_at" => "date", + "customer_id" => "string", + "custom_identifier" => "string", + ]; + + public const DATE_FORMAT = 'F j, Y'; + + protected $defaults = ["amount" =>0.00,"comment" =>' ',"financial_transactions" =>0,"frequency" =>'Once',"installments" =>1]; + + protected $required = ["amount","comment","frequency","installments","process_date"]; + + public function validate() : bool { + try { + parent::validate(); + if(!self::isValidDate($this->process_date)) throw new \Exception("Could not validate date "); + if(!self::isValidFrequency($this->frequency)) throw new \Exception("Invalid frequency"); + if(is_null($this->customer_id) && is_null($this->custom_identifier)) throw new \Exception("customer id or custom identifier is invalid"); + } catch (\Throwable $th) { + throw new ValidationException($th->getMessage()); + } + + return true; + } + + public function jsonSerialize() : array { + return ['customer_id' => $this->getParameter('customer_id'), 'custom_identifier' => $this->getParameter('custom_identifier') ] + parent::jsonSerialize() ; + } + + public function __toArray() : array { + return parent::__toArray() ; + } + + public function initialize(array $params = [] ) { + $o_params = array_intersect_key( + $params = array_intersect_key($params, $this->attributes), + ($attr = array_filter($this->attributes, fn($p) => $p != "date")) + ); + parent::initialize($o_params); + $d_params = array_diff_key($params, $attr); + array_walk($d_params, function($v,$k) { + $this->setParameter($k, self::formatDate( $v) ); + }, ); + + return $this; + } + + public static function isValidDate($date) : bool { + $d = DateTime::createFromFormat(self::DATE_FORMAT, $date); + // Check if the date is valid and matches the format + return $d && $d->format(self::DATE_FORMAT) === $date; + } + + public static function isValidFrequency($value) : bool { + return Frequency::isValid($value); + } + + protected static function formatDate($date) : string { + $d = new DateTime($date); + return $d->format(self::DATE_FORMAT); + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesIdBodyModel.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesIdBodyModel.php new file mode 100644 index 000000000000..119ac03999cb --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesIdBodyModel.php @@ -0,0 +1,23 @@ + "int", + "comment" => "string", + ]; + + public const DATE_FORMAT = 'Y-m-d H:i:s'; + + private $_is_error = false; + + protected $defaults = ["amount" =>0,"comment" =>'0',]; + + protected $required = ["amount","comment",]; +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesUpdateViaPostBodyModel.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesUpdateViaPostBodyModel.php new file mode 100644 index 000000000000..749ae2f6b967 --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Model/TransactionSchedulesUpdateViaPostBodyModel.php @@ -0,0 +1,24 @@ + "int", + "amount" => "int", + "comment" => "string", + ]; + + public const DATE_FORMAT = 'Y-m-d H:i:s'; + + private $_is_error = false; + + protected $defaults = ["amount" =>0,"comment" =>'0',]; + + protected $required = ["amount","comment",]; +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Address.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Address.php new file mode 100644 index 000000000000..1c5952b112ef --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/Address.php @@ -0,0 +1,53 @@ + "string", + "address_2" => "string", + "city" => "string", + "id" => "int", + "postal_code" => "string", + "province_code" => "string", + "country" => "string" + ]; + + protected $required = ["address_1","address_2","city","postal_code","province_code",]; + + public function jsonSerialize() { + return array_intersect_key($this->getParameters(), array_flip($this->required)); + } + + public function getCountry() : string { + return $this->getParameter('country'); + } + + public function initialize(array $parameters) { + foreach($this->attributes as $param => $type) { + $value = @$parameters[$param] ; + settype($value, $type); + $value = $value ?? null; + $this->parameters->set($param, $value); + } + } + + public function __toArray() : array { + return $this->getParameters(); + } + + public function __toString() : string { + return $this->getFullAddress(); + } + + public function getFullAddress() :string { + $full_address = $this->getParameters(); + extract($full_address); + + return "$address_1 $address_2, $city, $postal_code $province_code, $country"; + } +} diff --git a/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/AuthorizationType.php b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/AuthorizationType.php new file mode 100644 index 000000000000..39dcebfa342f --- /dev/null +++ b/app/PaymentDrivers/Rotessa/vendor/karneaud/omnipay-rotessa/src/Omnipay/Rotessa/Object/AuthorizationType.php @@ -0,0 +1,28 @@ +