@@ -16,169 +16,169 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class CheckoutClient implements CheckoutClientInterface |
| 18 | 18 | { |
| 19 | - const ENDPOINT = 'checkouts'; |
|
| 20 | - protected $context; |
|
| 21 | - protected $lastResponse; |
|
| 22 | - |
|
| 23 | - function __construct(ContextInterface $context) |
|
| 24 | - { |
|
| 25 | - $this->context = $context; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @inheritDoc |
|
| 30 | - * @throws BadResponseException |
|
| 31 | - * @throws ConnectException |
|
| 32 | - */ |
|
| 33 | - public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 34 | - { |
|
| 35 | - return $this->request('post', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @inheritDoc |
|
| 40 | - * @throws BadResponseException |
|
| 41 | - * @throws ConnectException |
|
| 42 | - */ |
|
| 43 | - public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 44 | - { |
|
| 45 | - return $this->request('get', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @inheritDoc |
|
| 51 | - * @throws BadResponseException |
|
| 52 | - * @throws ConnectException |
|
| 53 | - */ |
|
| 54 | - public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 55 | - { |
|
| 56 | - return $this->request('put', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @param string $action |
|
| 61 | - * @param CheckoutInterface $checkout |
|
| 62 | - * @param AccessToken $accessToken |
|
| 63 | - * @param array $scopes |
|
| 64 | - * @return bool|null |
|
| 65 | - * @throws BadResponseException |
|
| 66 | - * @throws ConnectException |
|
| 67 | - */ |
|
| 68 | - protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes):? bool |
|
| 69 | - { |
|
| 70 | - $accessToken = AuthenticationHelper::getValidToken($this->context, $accessToken, $scopes??self::getScopes()); |
|
| 71 | - |
|
| 72 | - $client = SumUp::getClient(); |
|
| 73 | - $options = AuthenticationHelper::getOAuthHeader($accessToken); |
|
| 74 | - $options['form_params'] = self::getCheckoutBody($checkout); |
|
| 75 | - |
|
| 76 | - $uri = self::ENDPOINT . '/' . $checkout->getId(); |
|
| 77 | - if($action=='post'){ |
|
| 78 | - $uri = self::ENDPOINT; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** @var Response $response */ |
|
| 82 | - $response = $client->{$action}($uri, $options); |
|
| 83 | - $this->lastResponse = $response; |
|
| 84 | - if($response->getStatusCode() < 300 && $response->getStatusCode() >= 200){ |
|
| 85 | - $hydrator = SumUp::getHydrator(); |
|
| 86 | - $data = \GuzzleHttp\json_decode($response->getBody(), true); |
|
| 87 | - $hydrator->hydrate($data, $checkout); |
|
| 88 | - return true; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Generate a body to create a new checkout |
|
| 96 | - * |
|
| 97 | - * @param CheckoutInterface $checkout |
|
| 98 | - * @return array |
|
| 99 | - */ |
|
| 100 | - public static function getCheckoutBody(CheckoutInterface $checkout): array |
|
| 101 | - { |
|
| 102 | - return [ |
|
| 103 | - "checkout_reference" => $checkout->getReference(), |
|
| 104 | - "amount" => $checkout->getAmount(), |
|
| 105 | - "currency" => $checkout->getCurrency(), |
|
| 106 | - "fee_amount" => $checkout->getFeeAmount(), |
|
| 107 | - "pay_to_email" => $checkout->getPayToEmail(), |
|
| 108 | - "pay_from_email" => $checkout->getPayFromEmail(), |
|
| 109 | - "description" => $checkout->getDescription(), |
|
| 110 | - "return_url" => $checkout->getRedirectUrl(), |
|
| 111 | - ]; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - public static function getCompleteCheckoutBody(CheckoutInterface $checkout): array |
|
| 115 | - { |
|
| 116 | - $defaultBody = self::getCheckoutBody($checkout); |
|
| 117 | - switch ($checkout->getType()) { |
|
| 118 | - case 'card': |
|
| 119 | - $completeBody = self::getCardBody($checkout); |
|
| 120 | - break; |
|
| 121 | - |
|
| 122 | - case 'boleto': |
|
| 123 | - $completeBody = self::getBoletoBody($checkout); |
|
| 124 | - break; |
|
| 125 | - |
|
| 126 | - default: |
|
| 127 | - $completeBody = []; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return array_merge($defaultBody, $completeBody); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - private static function getCardBody(CheckoutInterface $checkout): array |
|
| 134 | - { |
|
| 135 | - return [ |
|
| 136 | - 'payment_type' => $checkout->getType(), |
|
| 137 | - 'token' => $checkout->getCard()->getToken(), |
|
| 138 | - 'customer_id' => $checkout->getCustomer()->getCustomerId() |
|
| 139 | - ]; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - private static function getBoletoBody(CheckoutInterface $checkout): array |
|
| 143 | - { |
|
| 144 | - $customer = $checkout->getCustomer(); |
|
| 145 | - return [ |
|
| 146 | - 'payment_type' => $checkout->getType(), |
|
| 147 | - 'description' => $checkout->getDescription(), |
|
| 148 | - 'boleto_details' => [ |
|
| 149 | - 'cpf_cnpj' => $customer->getCpfCnpj(), |
|
| 150 | - 'payer_name' => $customer->getName(), |
|
| 151 | - 'payer_address' => $customer->getAddress(), |
|
| 152 | - 'payer_city' => $customer->getAddress()->getCity(), |
|
| 153 | - 'payer_state_code' => $customer->getAddress()->getState(), |
|
| 154 | - 'payer_post_code' => $customer->getAddress()->getPostalCode() |
|
| 155 | - ], |
|
| 156 | - ]; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * @inheritDoc |
|
| 161 | - */ |
|
| 162 | - public static function getScopes(): array |
|
| 163 | - { |
|
| 164 | - return [ |
|
| 165 | - 'payments', |
|
| 166 | - 'boleto' |
|
| 167 | - ]; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - function getLastResponse(): ResponseInterface |
|
| 171 | - { |
|
| 172 | - return $this->lastResponse; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * return the context used to created the client. |
|
| 177 | - * @return ContextInterface |
|
| 178 | - */ |
|
| 179 | - function getContext(): ContextInterface |
|
| 180 | - { |
|
| 181 | - return $this->context; |
|
| 182 | - } |
|
| 19 | + const ENDPOINT = 'checkouts'; |
|
| 20 | + protected $context; |
|
| 21 | + protected $lastResponse; |
|
| 22 | + |
|
| 23 | + function __construct(ContextInterface $context) |
|
| 24 | + { |
|
| 25 | + $this->context = $context; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @inheritDoc |
|
| 30 | + * @throws BadResponseException |
|
| 31 | + * @throws ConnectException |
|
| 32 | + */ |
|
| 33 | + public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 34 | + { |
|
| 35 | + return $this->request('post', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @inheritDoc |
|
| 40 | + * @throws BadResponseException |
|
| 41 | + * @throws ConnectException |
|
| 42 | + */ |
|
| 43 | + public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 44 | + { |
|
| 45 | + return $this->request('get', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @inheritDoc |
|
| 51 | + * @throws BadResponseException |
|
| 52 | + * @throws ConnectException |
|
| 53 | + */ |
|
| 54 | + public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 55 | + { |
|
| 56 | + return $this->request('put', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @param string $action |
|
| 61 | + * @param CheckoutInterface $checkout |
|
| 62 | + * @param AccessToken $accessToken |
|
| 63 | + * @param array $scopes |
|
| 64 | + * @return bool|null |
|
| 65 | + * @throws BadResponseException |
|
| 66 | + * @throws ConnectException |
|
| 67 | + */ |
|
| 68 | + protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes):? bool |
|
| 69 | + { |
|
| 70 | + $accessToken = AuthenticationHelper::getValidToken($this->context, $accessToken, $scopes??self::getScopes()); |
|
| 71 | + |
|
| 72 | + $client = SumUp::getClient(); |
|
| 73 | + $options = AuthenticationHelper::getOAuthHeader($accessToken); |
|
| 74 | + $options['form_params'] = self::getCheckoutBody($checkout); |
|
| 75 | + |
|
| 76 | + $uri = self::ENDPOINT . '/' . $checkout->getId(); |
|
| 77 | + if($action=='post'){ |
|
| 78 | + $uri = self::ENDPOINT; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** @var Response $response */ |
|
| 82 | + $response = $client->{$action}($uri, $options); |
|
| 83 | + $this->lastResponse = $response; |
|
| 84 | + if($response->getStatusCode() < 300 && $response->getStatusCode() >= 200){ |
|
| 85 | + $hydrator = SumUp::getHydrator(); |
|
| 86 | + $data = \GuzzleHttp\json_decode($response->getBody(), true); |
|
| 87 | + $hydrator->hydrate($data, $checkout); |
|
| 88 | + return true; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Generate a body to create a new checkout |
|
| 96 | + * |
|
| 97 | + * @param CheckoutInterface $checkout |
|
| 98 | + * @return array |
|
| 99 | + */ |
|
| 100 | + public static function getCheckoutBody(CheckoutInterface $checkout): array |
|
| 101 | + { |
|
| 102 | + return [ |
|
| 103 | + "checkout_reference" => $checkout->getReference(), |
|
| 104 | + "amount" => $checkout->getAmount(), |
|
| 105 | + "currency" => $checkout->getCurrency(), |
|
| 106 | + "fee_amount" => $checkout->getFeeAmount(), |
|
| 107 | + "pay_to_email" => $checkout->getPayToEmail(), |
|
| 108 | + "pay_from_email" => $checkout->getPayFromEmail(), |
|
| 109 | + "description" => $checkout->getDescription(), |
|
| 110 | + "return_url" => $checkout->getRedirectUrl(), |
|
| 111 | + ]; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + public static function getCompleteCheckoutBody(CheckoutInterface $checkout): array |
|
| 115 | + { |
|
| 116 | + $defaultBody = self::getCheckoutBody($checkout); |
|
| 117 | + switch ($checkout->getType()) { |
|
| 118 | + case 'card': |
|
| 119 | + $completeBody = self::getCardBody($checkout); |
|
| 120 | + break; |
|
| 121 | + |
|
| 122 | + case 'boleto': |
|
| 123 | + $completeBody = self::getBoletoBody($checkout); |
|
| 124 | + break; |
|
| 125 | + |
|
| 126 | + default: |
|
| 127 | + $completeBody = []; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return array_merge($defaultBody, $completeBody); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + private static function getCardBody(CheckoutInterface $checkout): array |
|
| 134 | + { |
|
| 135 | + return [ |
|
| 136 | + 'payment_type' => $checkout->getType(), |
|
| 137 | + 'token' => $checkout->getCard()->getToken(), |
|
| 138 | + 'customer_id' => $checkout->getCustomer()->getCustomerId() |
|
| 139 | + ]; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + private static function getBoletoBody(CheckoutInterface $checkout): array |
|
| 143 | + { |
|
| 144 | + $customer = $checkout->getCustomer(); |
|
| 145 | + return [ |
|
| 146 | + 'payment_type' => $checkout->getType(), |
|
| 147 | + 'description' => $checkout->getDescription(), |
|
| 148 | + 'boleto_details' => [ |
|
| 149 | + 'cpf_cnpj' => $customer->getCpfCnpj(), |
|
| 150 | + 'payer_name' => $customer->getName(), |
|
| 151 | + 'payer_address' => $customer->getAddress(), |
|
| 152 | + 'payer_city' => $customer->getAddress()->getCity(), |
|
| 153 | + 'payer_state_code' => $customer->getAddress()->getState(), |
|
| 154 | + 'payer_post_code' => $customer->getAddress()->getPostalCode() |
|
| 155 | + ], |
|
| 156 | + ]; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * @inheritDoc |
|
| 161 | + */ |
|
| 162 | + public static function getScopes(): array |
|
| 163 | + { |
|
| 164 | + return [ |
|
| 165 | + 'payments', |
|
| 166 | + 'boleto' |
|
| 167 | + ]; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + function getLastResponse(): ResponseInterface |
|
| 171 | + { |
|
| 172 | + return $this->lastResponse; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * return the context used to created the client. |
|
| 177 | + * @return ContextInterface |
|
| 178 | + */ |
|
| 179 | + function getContext(): ContextInterface |
|
| 180 | + { |
|
| 181 | + return $this->context; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | } |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | * @throws BadResponseException |
| 31 | 31 | * @throws ConnectException |
| 32 | 32 | */ |
| 33 | - public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 33 | + public function create(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
| 34 | 34 | { |
| 35 | - return $this->request('post', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 35 | + return $this->request('post', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @throws BadResponseException |
| 41 | 41 | * @throws ConnectException |
| 42 | 42 | */ |
| 43 | - public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 43 | + public function get(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
| 44 | 44 | { |
| 45 | - return $this->request('get', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 45 | + return $this->request('get', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @throws BadResponseException |
| 52 | 52 | * @throws ConnectException |
| 53 | 53 | */ |
| 54 | - public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
| 54 | + public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
| 55 | 55 | { |
| 56 | - return $this->request('put', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
| 56 | + return $this->request('put', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @throws BadResponseException |
| 66 | 66 | * @throws ConnectException |
| 67 | 67 | */ |
| 68 | - protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes):? bool |
|
| 68 | + protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes): ? bool |
|
| 69 | 69 | { |
| 70 | 70 | $accessToken = AuthenticationHelper::getValidToken($this->context, $accessToken, $scopes??self::getScopes()); |
| 71 | 71 | |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | $options['form_params'] = self::getCheckoutBody($checkout); |
| 75 | 75 | |
| 76 | 76 | $uri = self::ENDPOINT . '/' . $checkout->getId(); |
| 77 | - if($action=='post'){ |
|
| 77 | + if ($action == 'post') { |
|
| 78 | 78 | $uri = self::ENDPOINT; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** @var Response $response */ |
| 82 | 82 | $response = $client->{$action}($uri, $options); |
| 83 | 83 | $this->lastResponse = $response; |
| 84 | - if($response->getStatusCode() < 300 && $response->getStatusCode() >= 200){ |
|
| 84 | + if ($response->getStatusCode() < 300 && $response->getStatusCode() >= 200) { |
|
| 85 | 85 | $hydrator = SumUp::getHydrator(); |
| 86 | 86 | $data = \GuzzleHttp\json_decode($response->getBody(), true); |
| 87 | 87 | $hydrator->hydrate($data, $checkout); |
@@ -10,211 +10,211 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | interface CheckoutInterface |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @return null|string |
|
| 15 | - */ |
|
| 16 | - function getId(): ?string; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @param string $id |
|
| 20 | - * @return CheckoutInterface |
|
| 21 | - */ |
|
| 22 | - function setId(string $id): self; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @return null|string |
|
| 26 | - */ |
|
| 27 | - function getStatus(): ?string; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @param string $status |
|
| 31 | - * @return CheckoutInterface |
|
| 32 | - */ |
|
| 33 | - function setStatus(string $status): self; |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @param float $amount |
|
| 38 | - * @return CheckoutInterface |
|
| 39 | - */ |
|
| 40 | - function setAmount(float $amount): self; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @return float |
|
| 44 | - */ |
|
| 45 | - function getAmount():? float; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @return float|null |
|
| 49 | - */ |
|
| 50 | - function getFeeAmount(): ?float; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @param float $amount |
|
| 54 | - * @return CheckoutInterface |
|
| 55 | - */ |
|
| 56 | - function setFeeAmount(float $amount): self; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return null|string |
|
| 60 | - */ |
|
| 61 | - function getCurrency(): ?string; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @param string $currency |
|
| 65 | - * @return CheckoutInterface |
|
| 66 | - */ |
|
| 67 | - function setCurrency(string $currency): self; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return CustomerInterface|null |
|
| 71 | - */ |
|
| 72 | - function getCustomer(): ?CustomerInterface; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param CustomerInterface $customer |
|
| 76 | - * @return CheckoutInterface |
|
| 77 | - */ |
|
| 78 | - function setCustomer(CustomerInterface $customer): self; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @return CardInterface|null |
|
| 82 | - */ |
|
| 83 | - function getCard(): ?CardInterface; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param CardInterface $card |
|
| 87 | - * @return CheckoutInterface |
|
| 88 | - */ |
|
| 89 | - function setCard(CardInterface $card): self; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return null|string |
|
| 93 | - */ |
|
| 94 | - function getPayToEmail(): ?string; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @param string $email |
|
| 98 | - * @return CheckoutInterface |
|
| 99 | - */ |
|
| 100 | - function setPayToEmail(string $email): self; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return null|string |
|
| 104 | - */ |
|
| 105 | - function getPayFromEmail(): ?string; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @param string $email |
|
| 109 | - * @return CheckoutInterface |
|
| 110 | - */ |
|
| 111 | - function setPayFromEmail(string $email): self; |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return null|string |
|
| 115 | - */ |
|
| 116 | - function getReference(): ?string; |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param string $reference |
|
| 120 | - * @return CheckoutInterface |
|
| 121 | - */ |
|
| 122 | - function setReference(string $reference): self; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @return null|string |
|
| 126 | - */ |
|
| 127 | - function getDescription(): ?string; |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param string $description |
|
| 131 | - * @return CheckoutInterface |
|
| 132 | - */ |
|
| 133 | - function setDescription(string $description): self; |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @return null|string |
|
| 137 | - */ |
|
| 138 | - function getRedirectUrl(): ?string; |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @param string $url |
|
| 142 | - * @return CheckoutInterface |
|
| 143 | - */ |
|
| 144 | - function setRedirectUrl(string $url): self; |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return string |
|
| 148 | - */ |
|
| 149 | - function getValidUntil():? string; |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @param string $timestamp |
|
| 153 | - * @return CheckoutInterface |
|
| 154 | - */ |
|
| 155 | - function setValidUntil(string $timestamp): self; |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @return null|string |
|
| 159 | - */ |
|
| 160 | - function getTransactionCode(): ?string; |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $code |
|
| 164 | - * @return CheckoutInterface |
|
| 165 | - */ |
|
| 166 | - function setTransactionCode(string $code): self; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @return null|string |
|
| 170 | - */ |
|
| 171 | - function getTransactionId(): ?string; |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * @param string $id |
|
| 175 | - * @return CheckoutInterface |
|
| 176 | - */ |
|
| 177 | - function setTransactionId(string $id): self; |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @return array|null |
|
| 181 | - */ |
|
| 182 | - function getTransactions(): ?array; |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @param array $transactions |
|
| 186 | - * @return CheckoutInterface |
|
| 187 | - */ |
|
| 188 | - function setTransactions(array $transactions): self; |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return null|string |
|
| 192 | - */ |
|
| 193 | - function getToken(): ?string; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * @param string $token |
|
| 197 | - * @return CheckoutInterface |
|
| 198 | - */ |
|
| 199 | - function setToken(string $token): self; |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * @return bool|null |
|
| 203 | - */ |
|
| 204 | - function isValid(): ?bool; |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @param string|null $type |
|
| 208 | - * @return CheckoutInterface |
|
| 209 | - */ |
|
| 210 | - function setType(string $type = null): self; |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @return null|string |
|
| 214 | - */ |
|
| 215 | - function getType():? string; |
|
| 216 | - |
|
| 217 | - function setInstallments(?string $installments):? self; |
|
| 218 | - function getInstallments():? string; |
|
| 13 | + /** |
|
| 14 | + * @return null|string |
|
| 15 | + */ |
|
| 16 | + function getId(): ?string; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @param string $id |
|
| 20 | + * @return CheckoutInterface |
|
| 21 | + */ |
|
| 22 | + function setId(string $id): self; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @return null|string |
|
| 26 | + */ |
|
| 27 | + function getStatus(): ?string; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param string $status |
|
| 31 | + * @return CheckoutInterface |
|
| 32 | + */ |
|
| 33 | + function setStatus(string $status): self; |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @param float $amount |
|
| 38 | + * @return CheckoutInterface |
|
| 39 | + */ |
|
| 40 | + function setAmount(float $amount): self; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @return float |
|
| 44 | + */ |
|
| 45 | + function getAmount():? float; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @return float|null |
|
| 49 | + */ |
|
| 50 | + function getFeeAmount(): ?float; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param float $amount |
|
| 54 | + * @return CheckoutInterface |
|
| 55 | + */ |
|
| 56 | + function setFeeAmount(float $amount): self; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return null|string |
|
| 60 | + */ |
|
| 61 | + function getCurrency(): ?string; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @param string $currency |
|
| 65 | + * @return CheckoutInterface |
|
| 66 | + */ |
|
| 67 | + function setCurrency(string $currency): self; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return CustomerInterface|null |
|
| 71 | + */ |
|
| 72 | + function getCustomer(): ?CustomerInterface; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param CustomerInterface $customer |
|
| 76 | + * @return CheckoutInterface |
|
| 77 | + */ |
|
| 78 | + function setCustomer(CustomerInterface $customer): self; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @return CardInterface|null |
|
| 82 | + */ |
|
| 83 | + function getCard(): ?CardInterface; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param CardInterface $card |
|
| 87 | + * @return CheckoutInterface |
|
| 88 | + */ |
|
| 89 | + function setCard(CardInterface $card): self; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return null|string |
|
| 93 | + */ |
|
| 94 | + function getPayToEmail(): ?string; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @param string $email |
|
| 98 | + * @return CheckoutInterface |
|
| 99 | + */ |
|
| 100 | + function setPayToEmail(string $email): self; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return null|string |
|
| 104 | + */ |
|
| 105 | + function getPayFromEmail(): ?string; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @param string $email |
|
| 109 | + * @return CheckoutInterface |
|
| 110 | + */ |
|
| 111 | + function setPayFromEmail(string $email): self; |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return null|string |
|
| 115 | + */ |
|
| 116 | + function getReference(): ?string; |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param string $reference |
|
| 120 | + * @return CheckoutInterface |
|
| 121 | + */ |
|
| 122 | + function setReference(string $reference): self; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @return null|string |
|
| 126 | + */ |
|
| 127 | + function getDescription(): ?string; |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param string $description |
|
| 131 | + * @return CheckoutInterface |
|
| 132 | + */ |
|
| 133 | + function setDescription(string $description): self; |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @return null|string |
|
| 137 | + */ |
|
| 138 | + function getRedirectUrl(): ?string; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @param string $url |
|
| 142 | + * @return CheckoutInterface |
|
| 143 | + */ |
|
| 144 | + function setRedirectUrl(string $url): self; |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return string |
|
| 148 | + */ |
|
| 149 | + function getValidUntil():? string; |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param string $timestamp |
|
| 153 | + * @return CheckoutInterface |
|
| 154 | + */ |
|
| 155 | + function setValidUntil(string $timestamp): self; |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @return null|string |
|
| 159 | + */ |
|
| 160 | + function getTransactionCode(): ?string; |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param string $code |
|
| 164 | + * @return CheckoutInterface |
|
| 165 | + */ |
|
| 166 | + function setTransactionCode(string $code): self; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @return null|string |
|
| 170 | + */ |
|
| 171 | + function getTransactionId(): ?string; |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * @param string $id |
|
| 175 | + * @return CheckoutInterface |
|
| 176 | + */ |
|
| 177 | + function setTransactionId(string $id): self; |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @return array|null |
|
| 181 | + */ |
|
| 182 | + function getTransactions(): ?array; |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @param array $transactions |
|
| 186 | + * @return CheckoutInterface |
|
| 187 | + */ |
|
| 188 | + function setTransactions(array $transactions): self; |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @return null|string |
|
| 192 | + */ |
|
| 193 | + function getToken(): ?string; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * @param string $token |
|
| 197 | + * @return CheckoutInterface |
|
| 198 | + */ |
|
| 199 | + function setToken(string $token): self; |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * @return bool|null |
|
| 203 | + */ |
|
| 204 | + function isValid(): ?bool; |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param string|null $type |
|
| 208 | + * @return CheckoutInterface |
|
| 209 | + */ |
|
| 210 | + function setType(string $type = null): self; |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @return null|string |
|
| 214 | + */ |
|
| 215 | + function getType():? string; |
|
| 216 | + |
|
| 217 | + function setInstallments(?string $installments):? self; |
|
| 218 | + function getInstallments():? string; |
|
| 219 | 219 | |
| 220 | 220 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * @return float |
| 44 | 44 | */ |
| 45 | - function getAmount():? float; |
|
| 45 | + function getAmount(): ? float; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @return float|null |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - function getValidUntil():? string; |
|
| 149 | + function getValidUntil(): ? string; |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * @param string $timestamp |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | /** |
| 213 | 213 | * @return null|string |
| 214 | 214 | */ |
| 215 | - function getType():? string; |
|
| 215 | + function getType(): ? string; |
|
| 216 | 216 | |
| 217 | - function setInstallments(?string $installments):? self; |
|
| 218 | - function getInstallments():? string; |
|
| 217 | + function setInstallments(?string $installments): ? self; |
|
| 218 | + function getInstallments(): ? string; |
|
| 219 | 219 | |
| 220 | 220 | } |
@@ -10,108 +10,108 @@ |
||
| 10 | 10 | |
| 11 | 11 | class AuthenticationHelper |
| 12 | 12 | { |
| 13 | - const OAUTH_AUTHORIZATION = 'authorize'; |
|
| 14 | - const OAUTH_TOKEN = 'token'; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * Generate an url to merchant authorization. |
|
| 18 | - * |
|
| 19 | - * @param ContextInterface $context |
|
| 20 | - * @param boolean $minimal |
|
| 21 | - * @return string |
|
| 22 | - */ |
|
| 23 | - public static function getAuthorizationURL(ContextInterface $context, $minimal = true) |
|
| 24 | - { |
|
| 25 | - $queryString = [ |
|
| 26 | - 'client_id' => $context->getClientId(), |
|
| 27 | - 'client_secret' => $context->getClientSecret(), |
|
| 28 | - 'redirect_uri' => $context->getRedirectUri(), |
|
| 29 | - 'response_type' => 'code', |
|
| 30 | - ]; |
|
| 31 | - |
|
| 32 | - if (!$minimal) { |
|
| 33 | - $queryString = array_merge($queryString, [ |
|
| 34 | - 'scope' => $context->getScope(), |
|
| 35 | - 'state' => $context->getState(), |
|
| 36 | - ]); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Request an acess token from sumup services. |
|
| 44 | - * |
|
| 45 | - * @param Context $context |
|
| 46 | - * @param Array|null $scopes |
|
| 47 | - * @return AccessToken |
|
| 48 | - * @throws BadRequestException |
|
| 49 | - */ |
|
| 50 | - public static function getAccessToken(ContextInterface $context, array $scopes = null): AccessToken |
|
| 51 | - { |
|
| 52 | - $formParams = [ |
|
| 53 | - 'grant_type' => 'client_credentials', |
|
| 54 | - 'client_id' => $context->getClientId(), |
|
| 55 | - 'client_secret' => $context->getClientSecret(), |
|
| 56 | - ]; |
|
| 57 | - |
|
| 58 | - if ($scopes !== null) { |
|
| 59 | - $formParams['scope'] = implode(',', $scopes); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $client = new Client(['base_uri' => SumUp::ENTRYPOINT]); |
|
| 63 | - |
|
| 64 | - $response = $client->request( |
|
| 65 | - 'POST', |
|
| 66 | - self::OAUTH_TOKEN, |
|
| 67 | - [ |
|
| 68 | - 'form_params' => $formParams, |
|
| 69 | - ]); |
|
| 70 | - |
|
| 71 | - $code = $response->getStatusCode(); |
|
| 72 | - if ($code !== 200) { |
|
| 73 | - $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
| 74 | - throw new BadRequestException($message); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $body = json_decode($response->getBody()->getContents(), true); |
|
| 78 | - $token_params = [ |
|
| 79 | - $body['access_token'], |
|
| 80 | - $body['token_type'], |
|
| 81 | - $body['expires_in'], |
|
| 82 | - ]; |
|
| 83 | - |
|
| 84 | - if (isset($body['scope'])) { |
|
| 85 | - $token_params[] = $body['scope']; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return new AccessToken(...$token_params); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * If available check token or generate a new token |
|
| 93 | - * |
|
| 94 | - * @param ContextInterface $context |
|
| 95 | - * @param AccessToken $token |
|
| 96 | - * @param array $scopes |
|
| 97 | - * |
|
| 98 | - * @return AccessToken |
|
| 99 | - */ |
|
| 100 | - public static function getValidToken(ContextInterface $context, AccessToken $token = null, array $scopes = null): AccessToken |
|
| 101 | - { |
|
| 102 | - if ($token === null || !$token->isValid()) { |
|
| 103 | - $token = AuthenticationHelper::getAccessToken($context, $scopes); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $token; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public static function getOAuthHeader(AccessToken $token): array |
|
| 110 | - { |
|
| 111 | - return [ |
|
| 112 | - 'headers' => [ |
|
| 113 | - 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
| 114 | - ], |
|
| 115 | - ]; |
|
| 116 | - } |
|
| 13 | + const OAUTH_AUTHORIZATION = 'authorize'; |
|
| 14 | + const OAUTH_TOKEN = 'token'; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * Generate an url to merchant authorization. |
|
| 18 | + * |
|
| 19 | + * @param ContextInterface $context |
|
| 20 | + * @param boolean $minimal |
|
| 21 | + * @return string |
|
| 22 | + */ |
|
| 23 | + public static function getAuthorizationURL(ContextInterface $context, $minimal = true) |
|
| 24 | + { |
|
| 25 | + $queryString = [ |
|
| 26 | + 'client_id' => $context->getClientId(), |
|
| 27 | + 'client_secret' => $context->getClientSecret(), |
|
| 28 | + 'redirect_uri' => $context->getRedirectUri(), |
|
| 29 | + 'response_type' => 'code', |
|
| 30 | + ]; |
|
| 31 | + |
|
| 32 | + if (!$minimal) { |
|
| 33 | + $queryString = array_merge($queryString, [ |
|
| 34 | + 'scope' => $context->getScope(), |
|
| 35 | + 'state' => $context->getState(), |
|
| 36 | + ]); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Request an acess token from sumup services. |
|
| 44 | + * |
|
| 45 | + * @param Context $context |
|
| 46 | + * @param Array|null $scopes |
|
| 47 | + * @return AccessToken |
|
| 48 | + * @throws BadRequestException |
|
| 49 | + */ |
|
| 50 | + public static function getAccessToken(ContextInterface $context, array $scopes = null): AccessToken |
|
| 51 | + { |
|
| 52 | + $formParams = [ |
|
| 53 | + 'grant_type' => 'client_credentials', |
|
| 54 | + 'client_id' => $context->getClientId(), |
|
| 55 | + 'client_secret' => $context->getClientSecret(), |
|
| 56 | + ]; |
|
| 57 | + |
|
| 58 | + if ($scopes !== null) { |
|
| 59 | + $formParams['scope'] = implode(',', $scopes); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $client = new Client(['base_uri' => SumUp::ENTRYPOINT]); |
|
| 63 | + |
|
| 64 | + $response = $client->request( |
|
| 65 | + 'POST', |
|
| 66 | + self::OAUTH_TOKEN, |
|
| 67 | + [ |
|
| 68 | + 'form_params' => $formParams, |
|
| 69 | + ]); |
|
| 70 | + |
|
| 71 | + $code = $response->getStatusCode(); |
|
| 72 | + if ($code !== 200) { |
|
| 73 | + $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
| 74 | + throw new BadRequestException($message); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $body = json_decode($response->getBody()->getContents(), true); |
|
| 78 | + $token_params = [ |
|
| 79 | + $body['access_token'], |
|
| 80 | + $body['token_type'], |
|
| 81 | + $body['expires_in'], |
|
| 82 | + ]; |
|
| 83 | + |
|
| 84 | + if (isset($body['scope'])) { |
|
| 85 | + $token_params[] = $body['scope']; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return new AccessToken(...$token_params); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * If available check token or generate a new token |
|
| 93 | + * |
|
| 94 | + * @param ContextInterface $context |
|
| 95 | + * @param AccessToken $token |
|
| 96 | + * @param array $scopes |
|
| 97 | + * |
|
| 98 | + * @return AccessToken |
|
| 99 | + */ |
|
| 100 | + public static function getValidToken(ContextInterface $context, AccessToken $token = null, array $scopes = null): AccessToken |
|
| 101 | + { |
|
| 102 | + if ($token === null || !$token->isValid()) { |
|
| 103 | + $token = AuthenticationHelper::getAccessToken($context, $scopes); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $token; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public static function getOAuthHeader(AccessToken $token): array |
|
| 110 | + { |
|
| 111 | + return [ |
|
| 112 | + 'headers' => [ |
|
| 113 | + 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
| 114 | + ], |
|
| 115 | + ]; |
|
| 116 | + } |
|
| 117 | 117 | } |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | |
| 7 | 7 | class InvalidCheckoutException extends \RuntimeException |
| 8 | 8 | { |
| 9 | - public function __construct($message = "",CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
| 10 | - { |
|
| 11 | - $message = sprintf(<<<MSG |
|
| 9 | + public function __construct($message = "",CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
| 10 | + { |
|
| 11 | + $message = sprintf(<<<MSG |
|
| 12 | 12 | %s |
| 13 | 13 | Something is wrong with this checkout: |
| 14 | 14 | checkout_reference: %s |
| 15 | 15 | amount: %s |
| 16 | 16 | pay_to_email: %s |
| 17 | 17 | MSG |
| 18 | - , $message, $checkout->getReference(), $checkout->getAmount(), $checkout->getPayToEmail()); |
|
| 19 | - parent::__construct($message, $code, $previous); |
|
| 20 | - } |
|
| 18 | + , $message, $checkout->getReference(), $checkout->getAmount(), $checkout->getPayToEmail()); |
|
| 19 | + parent::__construct($message, $code, $previous); |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | class InvalidCheckoutException extends \RuntimeException |
| 8 | 8 | { |
| 9 | - public function __construct($message = "",CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
| 9 | + public function __construct($message = "", CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
| 10 | 10 | { |
| 11 | 11 | $message = sprintf(<<<MSG |
| 12 | 12 | %s |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | class NotAllowedProperty extends \RuntimeException |
| 15 | 15 | { |
| 16 | - public function __construct($object, $property, Throwable $previous = null) |
|
| 17 | - { |
|
| 18 | - $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
| 19 | - parent::__construct($message, 100, $previous); |
|
| 20 | - } |
|
| 16 | + public function __construct($object, $property, Throwable $previous = null) |
|
| 17 | + { |
|
| 18 | + $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
| 19 | + parent::__construct($message, 100, $previous); |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct($object, $property, Throwable $previous = null) |
| 17 | 17 | { |
| 18 | - $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
| 18 | + $message = sprintf('Not allowed property %s into %s class!', $property, get_class($object)); |
|
| 19 | 19 | parent::__construct($message, 100, $previous); |
| 20 | 20 | } |
| 21 | 21 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | protected $lastResponse; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * CheckoutClientInterface constructor. |
|
| 22 | - * @param ContextInterface $context |
|
| 23 | - */ |
|
| 24 | - public function __construct(ContextInterface $context) |
|
| 25 | - { |
|
| 26 | - $this->context = $context; |
|
| 27 | - } |
|
| 21 | + * CheckoutClientInterface constructor. |
|
| 22 | + * @param ContextInterface $context |
|
| 23 | + */ |
|
| 24 | + public function __construct(ContextInterface $context) |
|
| 25 | + { |
|
| 26 | + $this->context = $context; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @inheritDoc |
@@ -88,47 +88,47 @@ discard block |
||
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes):? CustomerInterface |
|
| 92 | - { |
|
| 93 | - $accessToken = AuthenticationHelper::getValidToken( |
|
| 94 | - $this->context, |
|
| 95 | - $accessToken, |
|
| 96 | - $scopes??self::getScopes() |
|
| 97 | - ); |
|
| 98 | - |
|
| 99 | - $client = SumUp::getClient(); |
|
| 100 | - $options = AuthenticationHelper::getOAuthHeader($accessToken); |
|
| 101 | - $options['form_params'] = self::getCustomerBody($customer); |
|
| 102 | - |
|
| 103 | - $successCode=200; |
|
| 104 | - $uri = self::ENDPOINT . '/' . $customer->getCustomerId(); |
|
| 105 | - switch (true){ |
|
| 106 | - case $action==='create': { |
|
| 107 | - $action='post'; |
|
| 108 | - $successCode=201; |
|
| 109 | - $uri = self::ENDPOINT; |
|
| 110 | - break; |
|
| 111 | - } |
|
| 112 | - case $action==='complete': { |
|
| 113 | - $action='put'; |
|
| 114 | - break; |
|
| 115 | - } |
|
| 116 | - default:{ |
|
| 117 | - $action='get'; |
|
| 118 | - break; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** @var ResponseInterface $response */ |
|
| 123 | - $response = $client->{$action}($uri, $options); |
|
| 124 | - $this->lastResponse = $response; |
|
| 125 | - if($successCode===$response->getStatusCode()){ |
|
| 126 | - $wrapper = new Hydrator($response); |
|
| 127 | - return $wrapper->hydrate($customer); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return null; |
|
| 131 | - } |
|
| 91 | + private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes):? CustomerInterface |
|
| 92 | + { |
|
| 93 | + $accessToken = AuthenticationHelper::getValidToken( |
|
| 94 | + $this->context, |
|
| 95 | + $accessToken, |
|
| 96 | + $scopes??self::getScopes() |
|
| 97 | + ); |
|
| 98 | + |
|
| 99 | + $client = SumUp::getClient(); |
|
| 100 | + $options = AuthenticationHelper::getOAuthHeader($accessToken); |
|
| 101 | + $options['form_params'] = self::getCustomerBody($customer); |
|
| 102 | + |
|
| 103 | + $successCode=200; |
|
| 104 | + $uri = self::ENDPOINT . '/' . $customer->getCustomerId(); |
|
| 105 | + switch (true){ |
|
| 106 | + case $action==='create': { |
|
| 107 | + $action='post'; |
|
| 108 | + $successCode=201; |
|
| 109 | + $uri = self::ENDPOINT; |
|
| 110 | + break; |
|
| 111 | + } |
|
| 112 | + case $action==='complete': { |
|
| 113 | + $action='put'; |
|
| 114 | + break; |
|
| 115 | + } |
|
| 116 | + default:{ |
|
| 117 | + $action='get'; |
|
| 118 | + break; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** @var ResponseInterface $response */ |
|
| 123 | + $response = $client->{$action}($uri, $options); |
|
| 124 | + $this->lastResponse = $response; |
|
| 125 | + if($successCode===$response->getStatusCode()){ |
|
| 126 | + $wrapper = new Hydrator($response); |
|
| 127 | + return $wrapper->hydrate($customer); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return null; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Validate an customer |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | public function setContext(ContextInterface $context): CustomerClientInterface |
| 172 | - { |
|
| 173 | - $this->context = $context; |
|
| 174 | - } |
|
| 172 | + { |
|
| 173 | + $this->context = $context; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * @inheritDoc |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | ]; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - function getLastResponse(): ResponseInterface |
|
| 187 | - { |
|
| 188 | - return $this->lastResponse; |
|
| 189 | - } |
|
| 186 | + function getLastResponse(): ResponseInterface |
|
| 187 | + { |
|
| 188 | + return $this->lastResponse; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * return the context used to created the client. |
|
| 194 | - * @return ContextInterface |
|
| 195 | - */ |
|
| 196 | - function getContext(): ContextInterface |
|
| 197 | - { |
|
| 198 | - // TODO: Implement getContext() method. |
|
| 199 | - } |
|
| 192 | + /** |
|
| 193 | + * return the context used to created the client. |
|
| 194 | + * @return ContextInterface |
|
| 195 | + */ |
|
| 196 | + function getContext(): ContextInterface |
|
| 197 | + { |
|
| 198 | + // TODO: Implement getContext() method. |
|
| 199 | + } |
|
| 200 | 200 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'headers' => $headers |
| 72 | 72 | ], $body); |
| 73 | 73 | $successul = $response->getStatusCode() === 201; |
| 74 | - } catch(\GuzzleHttp\Exception\RequestException $e){ |
|
| 74 | + } catch (\GuzzleHttp\Exception\RequestException $e) { |
|
| 75 | 75 | throw new BadRequestException( |
| 76 | 76 | $e->getMessage(), |
| 77 | 77 | $e->getRequest(), |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes):? CustomerInterface |
|
| 91 | + private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes): ? CustomerInterface |
|
| 92 | 92 | { |
| 93 | 93 | $accessToken = AuthenticationHelper::getValidToken( |
| 94 | 94 | $this->context, |
@@ -100,21 +100,21 @@ discard block |
||
| 100 | 100 | $options = AuthenticationHelper::getOAuthHeader($accessToken); |
| 101 | 101 | $options['form_params'] = self::getCustomerBody($customer); |
| 102 | 102 | |
| 103 | - $successCode=200; |
|
| 103 | + $successCode = 200; |
|
| 104 | 104 | $uri = self::ENDPOINT . '/' . $customer->getCustomerId(); |
| 105 | - switch (true){ |
|
| 106 | - case $action==='create': { |
|
| 107 | - $action='post'; |
|
| 108 | - $successCode=201; |
|
| 105 | + switch (true) { |
|
| 106 | + case $action === 'create': { |
|
| 107 | + $action = 'post'; |
|
| 108 | + $successCode = 201; |
|
| 109 | 109 | $uri = self::ENDPOINT; |
| 110 | 110 | break; |
| 111 | 111 | } |
| 112 | - case $action==='complete': { |
|
| 113 | - $action='put'; |
|
| 112 | + case $action === 'complete': { |
|
| 113 | + $action = 'put'; |
|
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | default:{ |
| 117 | - $action='get'; |
|
| 117 | + $action = 'get'; |
|
| 118 | 118 | break; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | /** @var ResponseInterface $response */ |
| 123 | 123 | $response = $client->{$action}($uri, $options); |
| 124 | 124 | $this->lastResponse = $response; |
| 125 | - if($successCode===$response->getStatusCode()){ |
|
| 125 | + if ($successCode === $response->getStatusCode()) { |
|
| 126 | 126 | $wrapper = new Hydrator($response); |
| 127 | 127 | return $wrapper->hydrate($customer); |
| 128 | 128 | } |
@@ -4,142 +4,142 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Customer implements CustomerInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Customer SumUp ID |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - protected $customerId; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * Customer Name |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $name; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Customer phone |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected $phone; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Cusomter address |
|
| 30 | - * |
|
| 31 | - * @var AddressInterface |
|
| 32 | - */ |
|
| 33 | - protected $address; |
|
| 34 | - |
|
| 35 | - function __construct(?array $data = []) |
|
| 36 | - { |
|
| 37 | - $this->setCustomerId($data['customer_id']??null); |
|
| 38 | - $personal_details = $data['personal_details']??$data; |
|
| 39 | - $this->setName($personal_details['name']??null); |
|
| 40 | - $this->setPhone($personal_details['phone']??null); |
|
| 41 | - $this->setAddress(new Address($personal_details['address']??null)); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Get customer SumUp ID |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - public function getCustomerId(): ?string |
|
| 50 | - { |
|
| 51 | - return $this->customerId; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Set customer SumUp ID |
|
| 56 | - * |
|
| 57 | - * @param string $customerId Customer SumUp ID |
|
| 58 | - * @return CustomerInterface |
|
| 59 | - */ |
|
| 60 | - public function setCustomerId(?string $customerId): CustomerInterface |
|
| 61 | - { |
|
| 62 | - $this->customerId = $customerId; |
|
| 63 | - |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Get customer Name |
|
| 69 | - * |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - public function getName(): ?string |
|
| 73 | - { |
|
| 74 | - return $this->name; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Set customer Name |
|
| 79 | - * |
|
| 80 | - * @param string $name Customer Name |
|
| 81 | - * |
|
| 82 | - * @return self |
|
| 83 | - */ |
|
| 84 | - public function setName(?string $name): CustomerInterface |
|
| 85 | - { |
|
| 86 | - $this->name = $name; |
|
| 87 | - |
|
| 88 | - return $this; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Get customer phone |
|
| 93 | - * |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function getPhone(): ?string |
|
| 97 | - { |
|
| 98 | - return $this->phone; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Set customer phone |
|
| 103 | - * |
|
| 104 | - * @param string $phone Customer phone |
|
| 105 | - * |
|
| 106 | - * @return self |
|
| 107 | - */ |
|
| 108 | - public function setPhone(?string $phone): CustomerInterface |
|
| 109 | - { |
|
| 110 | - $this->phone = $phone; |
|
| 111 | - |
|
| 112 | - return $this; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Get cusomter address |
|
| 117 | - * |
|
| 118 | - * @return AddressInterface |
|
| 119 | - */ |
|
| 120 | - public function getAddress(): AddressInterface |
|
| 121 | - { |
|
| 122 | - return $this->address; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Set cusomter address |
|
| 127 | - * |
|
| 128 | - * @param AddressInterface $address |
|
| 129 | - * @return Customer|CustomerInterface |
|
| 130 | - */ |
|
| 131 | - public function setAddress(AddressInterface $address): CustomerInterface |
|
| 132 | - { |
|
| 133 | - $this->address = $address; |
|
| 134 | - return $this; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @return bool |
|
| 139 | - */ |
|
| 140 | - function isValid():bool |
|
| 141 | - { |
|
| 142 | - return $this->getCustomerId()!==null; |
|
| 143 | - } |
|
| 7 | + /** |
|
| 8 | + * Customer SumUp ID |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + protected $customerId; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * Customer Name |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $name; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Customer phone |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected $phone; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Cusomter address |
|
| 30 | + * |
|
| 31 | + * @var AddressInterface |
|
| 32 | + */ |
|
| 33 | + protected $address; |
|
| 34 | + |
|
| 35 | + function __construct(?array $data = []) |
|
| 36 | + { |
|
| 37 | + $this->setCustomerId($data['customer_id']??null); |
|
| 38 | + $personal_details = $data['personal_details']??$data; |
|
| 39 | + $this->setName($personal_details['name']??null); |
|
| 40 | + $this->setPhone($personal_details['phone']??null); |
|
| 41 | + $this->setAddress(new Address($personal_details['address']??null)); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Get customer SumUp ID |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + public function getCustomerId(): ?string |
|
| 50 | + { |
|
| 51 | + return $this->customerId; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Set customer SumUp ID |
|
| 56 | + * |
|
| 57 | + * @param string $customerId Customer SumUp ID |
|
| 58 | + * @return CustomerInterface |
|
| 59 | + */ |
|
| 60 | + public function setCustomerId(?string $customerId): CustomerInterface |
|
| 61 | + { |
|
| 62 | + $this->customerId = $customerId; |
|
| 63 | + |
|
| 64 | + return $this; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Get customer Name |
|
| 69 | + * |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + public function getName(): ?string |
|
| 73 | + { |
|
| 74 | + return $this->name; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Set customer Name |
|
| 79 | + * |
|
| 80 | + * @param string $name Customer Name |
|
| 81 | + * |
|
| 82 | + * @return self |
|
| 83 | + */ |
|
| 84 | + public function setName(?string $name): CustomerInterface |
|
| 85 | + { |
|
| 86 | + $this->name = $name; |
|
| 87 | + |
|
| 88 | + return $this; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Get customer phone |
|
| 93 | + * |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function getPhone(): ?string |
|
| 97 | + { |
|
| 98 | + return $this->phone; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Set customer phone |
|
| 103 | + * |
|
| 104 | + * @param string $phone Customer phone |
|
| 105 | + * |
|
| 106 | + * @return self |
|
| 107 | + */ |
|
| 108 | + public function setPhone(?string $phone): CustomerInterface |
|
| 109 | + { |
|
| 110 | + $this->phone = $phone; |
|
| 111 | + |
|
| 112 | + return $this; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Get cusomter address |
|
| 117 | + * |
|
| 118 | + * @return AddressInterface |
|
| 119 | + */ |
|
| 120 | + public function getAddress(): AddressInterface |
|
| 121 | + { |
|
| 122 | + return $this->address; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Set cusomter address |
|
| 127 | + * |
|
| 128 | + * @param AddressInterface $address |
|
| 129 | + * @return Customer|CustomerInterface |
|
| 130 | + */ |
|
| 131 | + public function setAddress(AddressInterface $address): CustomerInterface |
|
| 132 | + { |
|
| 133 | + $this->address = $address; |
|
| 134 | + return $this; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @return bool |
|
| 139 | + */ |
|
| 140 | + function isValid():bool |
|
| 141 | + { |
|
| 142 | + return $this->getCustomerId()!==null; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | 145 | } |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | */ |
| 140 | 140 | function isValid():bool |
| 141 | 141 | { |
| 142 | - return $this->getCustomerId()!==null; |
|
| 142 | + return $this->getCustomerId() !== null; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | } |
@@ -8,390 +8,390 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Address implements AddressInterface |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * First address line |
|
| 13 | - * |
|
| 14 | - * @var string $line1 |
|
| 15 | - */ |
|
| 16 | - protected $line1; |
|
| 17 | - /** |
|
| 18 | - * Second address line |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $line2; |
|
| 23 | - /** |
|
| 24 | - * Address Country |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $country; |
|
| 29 | - /** |
|
| 30 | - * Address postal code |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - protected $postalCode; |
|
| 35 | - /** |
|
| 36 | - * Address City |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - protected $city; |
|
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - protected $countryEnName; |
|
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - protected $countryNativeName; |
|
| 49 | - /** |
|
| 50 | - * @var integer |
|
| 51 | - */ |
|
| 52 | - protected $regionId; |
|
| 53 | - /** |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - protected $regionName; |
|
| 57 | - /** |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - protected $postCode; |
|
| 61 | - /** |
|
| 62 | - * @var string |
|
| 63 | - */ |
|
| 64 | - protected $landline; |
|
| 65 | - /** |
|
| 66 | - * @var string |
|
| 67 | - */ |
|
| 68 | - protected $addressLine1; |
|
| 69 | - /** |
|
| 70 | - * @var string |
|
| 71 | - */ |
|
| 72 | - protected $addressLine2; |
|
| 73 | - /** |
|
| 74 | - * Address State |
|
| 75 | - * |
|
| 76 | - * @var string |
|
| 77 | - */ |
|
| 78 | - protected $state; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Address constructor. |
|
| 82 | - * @param array|null $data |
|
| 83 | - */ |
|
| 84 | - function __construct(?array $data = []) |
|
| 85 | - { |
|
| 86 | - $this->setAddressLine1($data['address_line1']??null); |
|
| 87 | - $this->setAddressLine2($data['address_line2']??null); |
|
| 88 | - $this->setCity($data['city']??null); |
|
| 89 | - $this->setCountry($data['country']??null); |
|
| 90 | - $this->setCountryEnName($data['country_en_name']??null); |
|
| 91 | - $this->setCountryNativeName($data['country_native_name']??null); |
|
| 92 | - $this->setRegionId($data['region_id']??null); |
|
| 93 | - $this->setRegionName($data['region_name']??null); |
|
| 94 | - $this->setPostCode($data['post_code']??null); |
|
| 95 | - $this->setLandline($data['landline']??null); |
|
| 96 | - $this->setLine1($data['line1']??null); |
|
| 97 | - $this->setLine2($data['line2']??null); |
|
| 98 | - $this->setPostalCode($data['postal_code']??null); |
|
| 99 | - $this->setState($data['state']??null); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Get $line1 |
|
| 104 | - * |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function getLine1(): ?string |
|
| 108 | - { |
|
| 109 | - return $this->line1; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Set $line1 |
|
| 114 | - * |
|
| 115 | - * @param string $line1 $line1 |
|
| 116 | - * |
|
| 117 | - * @return AddressInterface |
|
| 118 | - */ |
|
| 119 | - public function setLine1(?string $line1): AddressInterface |
|
| 120 | - { |
|
| 121 | - $this->line1 = $line1; |
|
| 122 | - |
|
| 123 | - return $this; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Get second address line |
|
| 128 | - * |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public function getLine2(): ?string |
|
| 132 | - { |
|
| 133 | - return $this->line2; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Set second address line |
|
| 138 | - * |
|
| 139 | - * @param string $line2 Second address line |
|
| 140 | - * |
|
| 141 | - * @return AddressInterface |
|
| 142 | - */ |
|
| 143 | - public function setLine2(?string $line2): AddressInterface |
|
| 144 | - { |
|
| 145 | - $this->line2 = $line2; |
|
| 146 | - |
|
| 147 | - return $this; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Get address Country |
|
| 152 | - * |
|
| 153 | - * @return string |
|
| 154 | - */ |
|
| 155 | - public function getCountry(): ?string |
|
| 156 | - { |
|
| 157 | - return $this->country; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Set address Country |
|
| 162 | - * |
|
| 163 | - * @param string $country Address Country |
|
| 164 | - * |
|
| 165 | - * @return AddressInterface |
|
| 166 | - */ |
|
| 167 | - public function setCountry(?string $country): AddressInterface |
|
| 168 | - { |
|
| 169 | - $this->country = $country; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Get address postal code |
|
| 176 | - * |
|
| 177 | - * @return string |
|
| 178 | - */ |
|
| 179 | - public function getPostalCode(): ?string |
|
| 180 | - { |
|
| 181 | - return $this->postalCode; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Set address postal code |
|
| 186 | - * |
|
| 187 | - * @param string $postalCode Address postal code |
|
| 188 | - * |
|
| 189 | - * @return AddressInterface |
|
| 190 | - */ |
|
| 191 | - public function setPostalCode(?string $postalCode): AddressInterface |
|
| 192 | - { |
|
| 193 | - $this->postalCode = $postalCode; |
|
| 194 | - |
|
| 195 | - return $this; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Get address City |
|
| 200 | - * |
|
| 201 | - * @return string |
|
| 202 | - */ |
|
| 203 | - public function getCity(): ?string |
|
| 204 | - { |
|
| 205 | - return $this->city; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Set address City |
|
| 210 | - * |
|
| 211 | - * @param string $city Address City |
|
| 212 | - * |
|
| 213 | - * @return AddressInterface |
|
| 214 | - */ |
|
| 215 | - public function setCity(?string $city): AddressInterface |
|
| 216 | - { |
|
| 217 | - $this->city = $city; |
|
| 218 | - |
|
| 219 | - return $this; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @return mixed |
|
| 224 | - */ |
|
| 225 | - public function getCountryEnName():? string |
|
| 226 | - { |
|
| 227 | - return $this->countryEnName; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param mixed $countryEnName |
|
| 232 | - * @return AddressInterface |
|
| 233 | - */ |
|
| 234 | - public function setCountryEnName($countryEnName): AddressInterface |
|
| 235 | - { |
|
| 236 | - $this->countryEnName = $countryEnName; |
|
| 237 | - |
|
| 238 | - return $this; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @return mixed |
|
| 243 | - */ |
|
| 244 | - public function getCountryNativeName():? string |
|
| 245 | - { |
|
| 246 | - return $this->countryNativeName; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * @param mixed $countryNativeName |
|
| 251 | - * @return Address |
|
| 252 | - */ |
|
| 253 | - public function setCountryNativeName(?string $countryNativeName): AddressInterface |
|
| 254 | - { |
|
| 255 | - $this->countryNativeName = $countryNativeName; |
|
| 256 | - |
|
| 257 | - return $this; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * @return number|null |
|
| 262 | - */ |
|
| 263 | - public function getRegionId():? number |
|
| 264 | - { |
|
| 265 | - return $this->regionId; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * @param number|null $regionId |
|
| 270 | - * @return Address |
|
| 271 | - */ |
|
| 272 | - public function setRegionId(?number $regionId): AddressInterface |
|
| 273 | - { |
|
| 274 | - $this->regionId = $regionId; |
|
| 275 | - |
|
| 276 | - return $this; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * @return string|null |
|
| 281 | - */ |
|
| 282 | - public function getRegionName():? string |
|
| 283 | - { |
|
| 284 | - return $this->regionName; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * @param string|null $regionName |
|
| 289 | - * @return AddressInterface |
|
| 290 | - */ |
|
| 291 | - public function setRegionName(?string $regionName): AddressInterface |
|
| 292 | - { |
|
| 293 | - $this->regionName = $regionName; |
|
| 294 | - |
|
| 295 | - return $this; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * @return string|null |
|
| 300 | - */ |
|
| 301 | - public function getPostCode():? string |
|
| 302 | - { |
|
| 303 | - return $this->postCode; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * @param string|null $postCode |
|
| 308 | - * @return AddressInterface |
|
| 309 | - */ |
|
| 310 | - public function setPostCode(?string $postCode): AddressInterface |
|
| 311 | - { |
|
| 312 | - $this->postCode = $postCode; |
|
| 313 | - |
|
| 314 | - return $this; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * @return string|null |
|
| 319 | - */ |
|
| 320 | - public function getLandline():? string |
|
| 321 | - { |
|
| 322 | - return $this->landline; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * @param string|null $landline |
|
| 327 | - * @return AddressInterface |
|
| 328 | - */ |
|
| 329 | - public function setLandline(?string $landline): AddressInterface |
|
| 330 | - { |
|
| 331 | - $this->landline = $landline; |
|
| 332 | - |
|
| 333 | - return $this; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @return string|null |
|
| 338 | - */ |
|
| 339 | - public function getAddressLine1():? string |
|
| 340 | - { |
|
| 341 | - return $this->addressLine1; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * @param string|null $addressLine1 |
|
| 346 | - * @return AddressInterface |
|
| 347 | - */ |
|
| 348 | - public function setAddressLine1(?string $addressLine1): AddressInterface |
|
| 349 | - { |
|
| 350 | - $this->addressLine1 = $addressLine1; |
|
| 351 | - |
|
| 352 | - return $this; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * @return string|null |
|
| 357 | - */ |
|
| 358 | - public function getAddressLine2():? string |
|
| 359 | - { |
|
| 360 | - return $this->addressLine2; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * @param string|null $addressLine2 |
|
| 365 | - * @return AddressInterface |
|
| 366 | - */ |
|
| 367 | - public function setAddressLine2(?string $addressLine2): AddressInterface |
|
| 368 | - { |
|
| 369 | - $this->addressLine2 = $addressLine2; |
|
| 370 | - |
|
| 371 | - return $this; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * Get address State |
|
| 376 | - * |
|
| 377 | - * @return string|null |
|
| 378 | - */ |
|
| 379 | - public function getState(): ?string |
|
| 380 | - { |
|
| 381 | - return $this->state; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Set address State |
|
| 386 | - * |
|
| 387 | - * @param string|null $state Address State |
|
| 388 | - * |
|
| 389 | - * @return AddressInterface |
|
| 390 | - */ |
|
| 391 | - public function setState(?string $state): AddressInterface |
|
| 392 | - { |
|
| 393 | - $this->state = $state; |
|
| 394 | - |
|
| 395 | - return $this; |
|
| 396 | - } |
|
| 11 | + /** |
|
| 12 | + * First address line |
|
| 13 | + * |
|
| 14 | + * @var string $line1 |
|
| 15 | + */ |
|
| 16 | + protected $line1; |
|
| 17 | + /** |
|
| 18 | + * Second address line |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $line2; |
|
| 23 | + /** |
|
| 24 | + * Address Country |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $country; |
|
| 29 | + /** |
|
| 30 | + * Address postal code |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + protected $postalCode; |
|
| 35 | + /** |
|
| 36 | + * Address City |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + protected $city; |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + protected $countryEnName; |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + protected $countryNativeName; |
|
| 49 | + /** |
|
| 50 | + * @var integer |
|
| 51 | + */ |
|
| 52 | + protected $regionId; |
|
| 53 | + /** |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + protected $regionName; |
|
| 57 | + /** |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + protected $postCode; |
|
| 61 | + /** |
|
| 62 | + * @var string |
|
| 63 | + */ |
|
| 64 | + protected $landline; |
|
| 65 | + /** |
|
| 66 | + * @var string |
|
| 67 | + */ |
|
| 68 | + protected $addressLine1; |
|
| 69 | + /** |
|
| 70 | + * @var string |
|
| 71 | + */ |
|
| 72 | + protected $addressLine2; |
|
| 73 | + /** |
|
| 74 | + * Address State |
|
| 75 | + * |
|
| 76 | + * @var string |
|
| 77 | + */ |
|
| 78 | + protected $state; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Address constructor. |
|
| 82 | + * @param array|null $data |
|
| 83 | + */ |
|
| 84 | + function __construct(?array $data = []) |
|
| 85 | + { |
|
| 86 | + $this->setAddressLine1($data['address_line1']??null); |
|
| 87 | + $this->setAddressLine2($data['address_line2']??null); |
|
| 88 | + $this->setCity($data['city']??null); |
|
| 89 | + $this->setCountry($data['country']??null); |
|
| 90 | + $this->setCountryEnName($data['country_en_name']??null); |
|
| 91 | + $this->setCountryNativeName($data['country_native_name']??null); |
|
| 92 | + $this->setRegionId($data['region_id']??null); |
|
| 93 | + $this->setRegionName($data['region_name']??null); |
|
| 94 | + $this->setPostCode($data['post_code']??null); |
|
| 95 | + $this->setLandline($data['landline']??null); |
|
| 96 | + $this->setLine1($data['line1']??null); |
|
| 97 | + $this->setLine2($data['line2']??null); |
|
| 98 | + $this->setPostalCode($data['postal_code']??null); |
|
| 99 | + $this->setState($data['state']??null); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Get $line1 |
|
| 104 | + * |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function getLine1(): ?string |
|
| 108 | + { |
|
| 109 | + return $this->line1; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Set $line1 |
|
| 114 | + * |
|
| 115 | + * @param string $line1 $line1 |
|
| 116 | + * |
|
| 117 | + * @return AddressInterface |
|
| 118 | + */ |
|
| 119 | + public function setLine1(?string $line1): AddressInterface |
|
| 120 | + { |
|
| 121 | + $this->line1 = $line1; |
|
| 122 | + |
|
| 123 | + return $this; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Get second address line |
|
| 128 | + * |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public function getLine2(): ?string |
|
| 132 | + { |
|
| 133 | + return $this->line2; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Set second address line |
|
| 138 | + * |
|
| 139 | + * @param string $line2 Second address line |
|
| 140 | + * |
|
| 141 | + * @return AddressInterface |
|
| 142 | + */ |
|
| 143 | + public function setLine2(?string $line2): AddressInterface |
|
| 144 | + { |
|
| 145 | + $this->line2 = $line2; |
|
| 146 | + |
|
| 147 | + return $this; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Get address Country |
|
| 152 | + * |
|
| 153 | + * @return string |
|
| 154 | + */ |
|
| 155 | + public function getCountry(): ?string |
|
| 156 | + { |
|
| 157 | + return $this->country; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Set address Country |
|
| 162 | + * |
|
| 163 | + * @param string $country Address Country |
|
| 164 | + * |
|
| 165 | + * @return AddressInterface |
|
| 166 | + */ |
|
| 167 | + public function setCountry(?string $country): AddressInterface |
|
| 168 | + { |
|
| 169 | + $this->country = $country; |
|
| 170 | + |
|
| 171 | + return $this; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Get address postal code |
|
| 176 | + * |
|
| 177 | + * @return string |
|
| 178 | + */ |
|
| 179 | + public function getPostalCode(): ?string |
|
| 180 | + { |
|
| 181 | + return $this->postalCode; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Set address postal code |
|
| 186 | + * |
|
| 187 | + * @param string $postalCode Address postal code |
|
| 188 | + * |
|
| 189 | + * @return AddressInterface |
|
| 190 | + */ |
|
| 191 | + public function setPostalCode(?string $postalCode): AddressInterface |
|
| 192 | + { |
|
| 193 | + $this->postalCode = $postalCode; |
|
| 194 | + |
|
| 195 | + return $this; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Get address City |
|
| 200 | + * |
|
| 201 | + * @return string |
|
| 202 | + */ |
|
| 203 | + public function getCity(): ?string |
|
| 204 | + { |
|
| 205 | + return $this->city; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Set address City |
|
| 210 | + * |
|
| 211 | + * @param string $city Address City |
|
| 212 | + * |
|
| 213 | + * @return AddressInterface |
|
| 214 | + */ |
|
| 215 | + public function setCity(?string $city): AddressInterface |
|
| 216 | + { |
|
| 217 | + $this->city = $city; |
|
| 218 | + |
|
| 219 | + return $this; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @return mixed |
|
| 224 | + */ |
|
| 225 | + public function getCountryEnName():? string |
|
| 226 | + { |
|
| 227 | + return $this->countryEnName; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param mixed $countryEnName |
|
| 232 | + * @return AddressInterface |
|
| 233 | + */ |
|
| 234 | + public function setCountryEnName($countryEnName): AddressInterface |
|
| 235 | + { |
|
| 236 | + $this->countryEnName = $countryEnName; |
|
| 237 | + |
|
| 238 | + return $this; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @return mixed |
|
| 243 | + */ |
|
| 244 | + public function getCountryNativeName():? string |
|
| 245 | + { |
|
| 246 | + return $this->countryNativeName; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * @param mixed $countryNativeName |
|
| 251 | + * @return Address |
|
| 252 | + */ |
|
| 253 | + public function setCountryNativeName(?string $countryNativeName): AddressInterface |
|
| 254 | + { |
|
| 255 | + $this->countryNativeName = $countryNativeName; |
|
| 256 | + |
|
| 257 | + return $this; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * @return number|null |
|
| 262 | + */ |
|
| 263 | + public function getRegionId():? number |
|
| 264 | + { |
|
| 265 | + return $this->regionId; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * @param number|null $regionId |
|
| 270 | + * @return Address |
|
| 271 | + */ |
|
| 272 | + public function setRegionId(?number $regionId): AddressInterface |
|
| 273 | + { |
|
| 274 | + $this->regionId = $regionId; |
|
| 275 | + |
|
| 276 | + return $this; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * @return string|null |
|
| 281 | + */ |
|
| 282 | + public function getRegionName():? string |
|
| 283 | + { |
|
| 284 | + return $this->regionName; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * @param string|null $regionName |
|
| 289 | + * @return AddressInterface |
|
| 290 | + */ |
|
| 291 | + public function setRegionName(?string $regionName): AddressInterface |
|
| 292 | + { |
|
| 293 | + $this->regionName = $regionName; |
|
| 294 | + |
|
| 295 | + return $this; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * @return string|null |
|
| 300 | + */ |
|
| 301 | + public function getPostCode():? string |
|
| 302 | + { |
|
| 303 | + return $this->postCode; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * @param string|null $postCode |
|
| 308 | + * @return AddressInterface |
|
| 309 | + */ |
|
| 310 | + public function setPostCode(?string $postCode): AddressInterface |
|
| 311 | + { |
|
| 312 | + $this->postCode = $postCode; |
|
| 313 | + |
|
| 314 | + return $this; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * @return string|null |
|
| 319 | + */ |
|
| 320 | + public function getLandline():? string |
|
| 321 | + { |
|
| 322 | + return $this->landline; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * @param string|null $landline |
|
| 327 | + * @return AddressInterface |
|
| 328 | + */ |
|
| 329 | + public function setLandline(?string $landline): AddressInterface |
|
| 330 | + { |
|
| 331 | + $this->landline = $landline; |
|
| 332 | + |
|
| 333 | + return $this; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @return string|null |
|
| 338 | + */ |
|
| 339 | + public function getAddressLine1():? string |
|
| 340 | + { |
|
| 341 | + return $this->addressLine1; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * @param string|null $addressLine1 |
|
| 346 | + * @return AddressInterface |
|
| 347 | + */ |
|
| 348 | + public function setAddressLine1(?string $addressLine1): AddressInterface |
|
| 349 | + { |
|
| 350 | + $this->addressLine1 = $addressLine1; |
|
| 351 | + |
|
| 352 | + return $this; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * @return string|null |
|
| 357 | + */ |
|
| 358 | + public function getAddressLine2():? string |
|
| 359 | + { |
|
| 360 | + return $this->addressLine2; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * @param string|null $addressLine2 |
|
| 365 | + * @return AddressInterface |
|
| 366 | + */ |
|
| 367 | + public function setAddressLine2(?string $addressLine2): AddressInterface |
|
| 368 | + { |
|
| 369 | + $this->addressLine2 = $addressLine2; |
|
| 370 | + |
|
| 371 | + return $this; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * Get address State |
|
| 376 | + * |
|
| 377 | + * @return string|null |
|
| 378 | + */ |
|
| 379 | + public function getState(): ?string |
|
| 380 | + { |
|
| 381 | + return $this->state; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Set address State |
|
| 386 | + * |
|
| 387 | + * @param string|null $state Address State |
|
| 388 | + * |
|
| 389 | + * @return AddressInterface |
|
| 390 | + */ |
|
| 391 | + public function setState(?string $state): AddressInterface |
|
| 392 | + { |
|
| 393 | + $this->state = $state; |
|
| 394 | + |
|
| 395 | + return $this; |
|
| 396 | + } |
|
| 397 | 397 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * @return mixed |
| 224 | 224 | */ |
| 225 | - public function getCountryEnName():? string |
|
| 225 | + public function getCountryEnName(): ? string |
|
| 226 | 226 | { |
| 227 | 227 | return $this->countryEnName; |
| 228 | 228 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | /** |
| 242 | 242 | * @return mixed |
| 243 | 243 | */ |
| 244 | - public function getCountryNativeName():? string |
|
| 244 | + public function getCountryNativeName(): ? string |
|
| 245 | 245 | { |
| 246 | 246 | return $this->countryNativeName; |
| 247 | 247 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | /** |
| 261 | 261 | * @return number|null |
| 262 | 262 | */ |
| 263 | - public function getRegionId():? number |
|
| 263 | + public function getRegionId(): ? number |
|
| 264 | 264 | { |
| 265 | 265 | return $this->regionId; |
| 266 | 266 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @return string|null |
| 281 | 281 | */ |
| 282 | - public function getRegionName():? string |
|
| 282 | + public function getRegionName(): ? string |
|
| 283 | 283 | { |
| 284 | 284 | return $this->regionName; |
| 285 | 285 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * @return string|null |
| 300 | 300 | */ |
| 301 | - public function getPostCode():? string |
|
| 301 | + public function getPostCode(): ? string |
|
| 302 | 302 | { |
| 303 | 303 | return $this->postCode; |
| 304 | 304 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | /** |
| 318 | 318 | * @return string|null |
| 319 | 319 | */ |
| 320 | - public function getLandline():? string |
|
| 320 | + public function getLandline(): ? string |
|
| 321 | 321 | { |
| 322 | 322 | return $this->landline; |
| 323 | 323 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | /** |
| 337 | 337 | * @return string|null |
| 338 | 338 | */ |
| 339 | - public function getAddressLine1():? string |
|
| 339 | + public function getAddressLine1(): ? string |
|
| 340 | 340 | { |
| 341 | 341 | return $this->addressLine1; |
| 342 | 342 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | /** |
| 356 | 356 | * @return string|null |
| 357 | 357 | */ |
| 358 | - public function getAddressLine2():? string |
|
| 358 | + public function getAddressLine2(): ? string |
|
| 359 | 359 | { |
| 360 | 360 | return $this->addressLine2; |
| 361 | 361 | } |
@@ -16,84 +16,84 @@ |
||
| 16 | 16 | ]; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Retieve a card from server and fill the $card Object with response. |
|
| 21 | - * |
|
| 22 | - * @param CardInterface $card |
|
| 23 | - * @param CustomerInterface $customer |
|
| 24 | - * @param ContextInterface $context |
|
| 25 | - * @param AccessToken $accessToken |
|
| 26 | - * @return CardInterface |
|
| 27 | - */ |
|
| 28 | - public static function get( |
|
| 29 | - CardInterface $card, |
|
| 30 | - CustomerInterface $customer, |
|
| 31 | - ContextInterface $context, |
|
| 32 | - AccessToken $accessToken |
|
| 33 | - ): CardInterface { |
|
| 34 | - // TODO: Implement get() method. |
|
| 35 | - } |
|
| 19 | + /** |
|
| 20 | + * Retieve a card from server and fill the $card Object with response. |
|
| 21 | + * |
|
| 22 | + * @param CardInterface $card |
|
| 23 | + * @param CustomerInterface $customer |
|
| 24 | + * @param ContextInterface $context |
|
| 25 | + * @param AccessToken $accessToken |
|
| 26 | + * @return CardInterface |
|
| 27 | + */ |
|
| 28 | + public static function get( |
|
| 29 | + CardInterface $card, |
|
| 30 | + CustomerInterface $customer, |
|
| 31 | + ContextInterface $context, |
|
| 32 | + AccessToken $accessToken |
|
| 33 | + ): CardInterface { |
|
| 34 | + // TODO: Implement get() method. |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Delete an card from server. |
|
| 39 | - * |
|
| 40 | - * @param CardInterface $card |
|
| 41 | - * @param CustomerInterface $customer |
|
| 42 | - * @param ContextInterface $context |
|
| 43 | - * @param AccessToken $accessToken |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public static function delete( |
|
| 47 | - CardInterface $card, |
|
| 48 | - CustomerInterface $customer, |
|
| 49 | - ContextInterface $context, |
|
| 50 | - AccessToken $accessToken |
|
| 51 | - ): void { |
|
| 52 | - // TODO: Implement delete() method. |
|
| 53 | - } |
|
| 37 | + /** |
|
| 38 | + * Delete an card from server. |
|
| 39 | + * |
|
| 40 | + * @param CardInterface $card |
|
| 41 | + * @param CustomerInterface $customer |
|
| 42 | + * @param ContextInterface $context |
|
| 43 | + * @param AccessToken $accessToken |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public static function delete( |
|
| 47 | + CardInterface $card, |
|
| 48 | + CustomerInterface $customer, |
|
| 49 | + ContextInterface $context, |
|
| 50 | + AccessToken $accessToken |
|
| 51 | + ): void { |
|
| 52 | + // TODO: Implement delete() method. |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * CheckoutClientInterface constructor. |
|
| 57 | - * @param ContextInterface $context |
|
| 58 | - */ |
|
| 59 | - public function __construct(ContextInterface $context) |
|
| 60 | - { |
|
| 61 | - parent::__construct($context); |
|
| 62 | - } |
|
| 55 | + /** |
|
| 56 | + * CheckoutClientInterface constructor. |
|
| 57 | + * @param ContextInterface $context |
|
| 58 | + */ |
|
| 59 | + public function __construct(ContextInterface $context) |
|
| 60 | + { |
|
| 61 | + parent::__construct($context); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Return last response of client |
|
| 66 | - * @return ResponseInterface |
|
| 67 | - */ |
|
| 68 | - function getLastResponse(): ResponseInterface |
|
| 69 | - { |
|
| 70 | - // TODO: Implement getLastResponse() method. |
|
| 71 | - } |
|
| 64 | + /** |
|
| 65 | + * Return last response of client |
|
| 66 | + * @return ResponseInterface |
|
| 67 | + */ |
|
| 68 | + function getLastResponse(): ResponseInterface |
|
| 69 | + { |
|
| 70 | + // TODO: Implement getLastResponse() method. |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * return the context used to created the client. |
|
| 75 | - * @return ContextInterface |
|
| 76 | - */ |
|
| 77 | - function getContext(): ContextInterface |
|
| 78 | - { |
|
| 79 | - // TODO: Implement getContext() method. |
|
| 80 | - } |
|
| 73 | + /** |
|
| 74 | + * return the context used to created the client. |
|
| 75 | + * @return ContextInterface |
|
| 76 | + */ |
|
| 77 | + function getContext(): ContextInterface |
|
| 78 | + { |
|
| 79 | + // TODO: Implement getContext() method. |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Create a new card resource and fill the $card Object with response. |
|
| 84 | - * |
|
| 85 | - * @param CardInterface $card |
|
| 86 | - * @param CustomerInterface $costumer |
|
| 87 | - * @param ContextInterface $context |
|
| 88 | - * @param AccessToken $accessToken |
|
| 89 | - * @return CardInterface |
|
| 90 | - */ |
|
| 91 | - public static function create( |
|
| 92 | - CardInterface $card, |
|
| 93 | - CustomerInterface $costumer, |
|
| 94 | - ContextInterface $context, |
|
| 95 | - AccessToken $accessToken |
|
| 96 | - ): CardInterface { |
|
| 97 | - // TODO: Implement create() method. |
|
| 98 | - } |
|
| 82 | + /** |
|
| 83 | + * Create a new card resource and fill the $card Object with response. |
|
| 84 | + * |
|
| 85 | + * @param CardInterface $card |
|
| 86 | + * @param CustomerInterface $costumer |
|
| 87 | + * @param ContextInterface $context |
|
| 88 | + * @param AccessToken $accessToken |
|
| 89 | + * @return CardInterface |
|
| 90 | + */ |
|
| 91 | + public static function create( |
|
| 92 | + CardInterface $card, |
|
| 93 | + CustomerInterface $costumer, |
|
| 94 | + ContextInterface $context, |
|
| 95 | + AccessToken $accessToken |
|
| 96 | + ): CardInterface { |
|
| 97 | + // TODO: Implement create() method. |
|
| 98 | + } |
|
| 99 | 99 | } |