@@ -68,5 +68,5 @@ |
||
| 68 | 68 | /** |
| 69 | 69 | * @return AccessToken |
| 70 | 70 | */ |
| 71 | - function getToken():? AccessToken; |
|
| 71 | + function getToken(): ? AccessToken; |
|
| 72 | 72 | } |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | * @param integer $expiresIn |
| 21 | 21 | * @param string|null $scope |
| 22 | 22 | */ |
| 23 | - function __construct(string $token, string $type, int $expiresIn, string $scope = null){ |
|
| 23 | + function __construct(string $token, string $type, int $expiresIn, string $scope = null) { |
|
| 24 | 24 | $this->token = $token; |
| 25 | 25 | $this->type = $type; |
| 26 | 26 | $this->expiration = time() + $expiresIn; |
| 27 | 27 | |
| 28 | - if($scope !== null) { |
|
| 28 | + if ($scope !== null) { |
|
| 29 | 29 | $this->scope = $scope; |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | * @param string $scope[,$scope[,$scope[,...]]] |
| 87 | 87 | * @return boolean |
| 88 | 88 | */ |
| 89 | - function canAccess(string $scope){ |
|
| 89 | + function canAccess(string $scope) { |
|
| 90 | 90 | $scopes = func_get_args(); |
| 91 | 91 | $diff = array_diff($scopes, $this->scope); |
| 92 | - return count($diff)>0; |
|
| 92 | + return count($diff) > 0; |
|
| 93 | 93 | } |
| 94 | 94 | } |
@@ -11,115 +11,115 @@ |
||
| 11 | 11 | const OAUTH_AUTHORIZATION = '/authorize'; |
| 12 | 12 | const OAUTH_TOKEN = '/token'; |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Generate an url to merchant authorization. |
|
| 16 | - * |
|
| 17 | - * @param ContextInterface $context |
|
| 18 | - * @param boolean $minimal |
|
| 19 | - * @return string |
|
| 20 | - */ |
|
| 21 | - public static function getAuthorizationURL(ContextInterface $context, $minimal = true) |
|
| 22 | - { |
|
| 23 | - $queryString = [ |
|
| 24 | - 'client_id' => $context->getClientId(), |
|
| 25 | - 'client_secret' => $context->getClientSecret(), |
|
| 26 | - 'redirect_uri' => $context->getRedirectUri(), |
|
| 27 | - 'response_type' => 'code', |
|
| 28 | - ]; |
|
| 29 | - |
|
| 30 | - if (!$minimal) { |
|
| 31 | - $queryString = array_merge($queryString, [ |
|
| 32 | - 'scope' => $context->getScope(), |
|
| 33 | - 'state' => $context->getState(), |
|
| 34 | - ]); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Request an acess token from sumup services. |
|
| 42 | - * |
|
| 14 | + /** |
|
| 15 | + * Generate an url to merchant authorization. |
|
| 16 | + * |
|
| 17 | + * @param ContextInterface $context |
|
| 18 | + * @param boolean $minimal |
|
| 19 | + * @return string |
|
| 20 | + */ |
|
| 21 | + public static function getAuthorizationURL(ContextInterface $context, $minimal = true) |
|
| 22 | + { |
|
| 23 | + $queryString = [ |
|
| 24 | + 'client_id' => $context->getClientId(), |
|
| 25 | + 'client_secret' => $context->getClientSecret(), |
|
| 26 | + 'redirect_uri' => $context->getRedirectUri(), |
|
| 27 | + 'response_type' => 'code', |
|
| 28 | + ]; |
|
| 29 | + |
|
| 30 | + if (!$minimal) { |
|
| 31 | + $queryString = array_merge($queryString, [ |
|
| 32 | + 'scope' => $context->getScope(), |
|
| 33 | + 'state' => $context->getState(), |
|
| 34 | + ]); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Request an acess token from sumup services. |
|
| 42 | + * |
|
| 43 | 43 | * @param ContextInterface $context |
| 44 | 44 | * @param array|null $scopes |
| 45 | 45 | * @param array $options |
| 46 | 46 | * @return \BPCI\SumUp\OAuth\AccessToken |
| 47 | - */ |
|
| 47 | + */ |
|
| 48 | 48 | public static function getAccessToken( |
| 49 | 49 | ContextInterface $context, |
| 50 | 50 | array $scopes = null, |
| 51 | 51 | array $options = [] |
| 52 | 52 | ): AccessToken |
| 53 | - { |
|
| 54 | - $formParams = [ |
|
| 55 | - 'grant_type' => 'client_credentials', |
|
| 56 | - 'client_id' => $context->getClientId(), |
|
| 57 | - 'client_secret' => $context->getClientSecret(), |
|
| 58 | - ]; |
|
| 53 | + { |
|
| 54 | + $formParams = [ |
|
| 55 | + 'grant_type' => 'client_credentials', |
|
| 56 | + 'client_id' => $context->getClientId(), |
|
| 57 | + 'client_secret' => $context->getClientSecret(), |
|
| 58 | + ]; |
|
| 59 | 59 | |
| 60 | - if ($scopes !== null) { |
|
| 61 | - $formParams['scope'] = implode(',', $scopes); |
|
| 62 | - } |
|
| 60 | + if ($scopes !== null) { |
|
| 61 | + $formParams['scope'] = implode(',', $scopes); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | $client = SumUp::getClient($options); |
| 65 | 65 | |
| 66 | - $response = $client->request( |
|
| 67 | - 'POST', |
|
| 68 | - self::OAUTH_TOKEN, |
|
| 69 | - [ |
|
| 70 | - 'form_params' => $formParams, |
|
| 71 | - ]); |
|
| 72 | - |
|
| 73 | - $code = $response->getStatusCode(); |
|
| 74 | - if ($code !== 200) { |
|
| 75 | - $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
| 76 | - throw new BadRequestException($message); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $body = json_decode($response->getBody()->getContents(), true); |
|
| 80 | - $token_params = [ |
|
| 81 | - $body['access_token'], |
|
| 82 | - $body['token_type'], |
|
| 83 | - $body['expires_in'], |
|
| 84 | - ]; |
|
| 85 | - |
|
| 86 | - if (isset($body['scope'])) { |
|
| 87 | - $token_params[] = $body['scope']; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - return new AccessToken(...$token_params); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * If available check token or generate a new token |
|
| 95 | - * |
|
| 96 | - * @param ContextInterface $context |
|
| 97 | - * @param AccessToken $token |
|
| 98 | - * @param array $scopes |
|
| 66 | + $response = $client->request( |
|
| 67 | + 'POST', |
|
| 68 | + self::OAUTH_TOKEN, |
|
| 69 | + [ |
|
| 70 | + 'form_params' => $formParams, |
|
| 71 | + ]); |
|
| 72 | + |
|
| 73 | + $code = $response->getStatusCode(); |
|
| 74 | + if ($code !== 200) { |
|
| 75 | + $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
| 76 | + throw new BadRequestException($message); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $body = json_decode($response->getBody()->getContents(), true); |
|
| 80 | + $token_params = [ |
|
| 81 | + $body['access_token'], |
|
| 82 | + $body['token_type'], |
|
| 83 | + $body['expires_in'], |
|
| 84 | + ]; |
|
| 85 | + |
|
| 86 | + if (isset($body['scope'])) { |
|
| 87 | + $token_params[] = $body['scope']; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + return new AccessToken(...$token_params); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * If available check token or generate a new token |
|
| 95 | + * |
|
| 96 | + * @param ContextInterface $context |
|
| 97 | + * @param AccessToken $token |
|
| 98 | + * @param array $scopes |
|
| 99 | 99 | * @param array $options |
| 100 | 100 | * |
| 101 | 101 | * @return \BPCI\SumUp\OAuth\AccessToken |
| 102 | - */ |
|
| 102 | + */ |
|
| 103 | 103 | public static function getValidToken( |
| 104 | 104 | ContextInterface $context, |
| 105 | 105 | AccessToken $token = null, |
| 106 | 106 | array $scopes = null, |
| 107 | 107 | array $options = [] |
| 108 | 108 | ): AccessToken |
| 109 | - { |
|
| 110 | - if ($token === null || !$token->isValid()) { |
|
| 109 | + { |
|
| 110 | + if ($token === null || !$token->isValid()) { |
|
| 111 | 111 | $token = AuthenticationHelper::getAccessToken($context, $scopes, $options); |
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $token; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - public static function getOAuthHeader(AccessToken $token): array |
|
| 118 | - { |
|
| 119 | - return [ |
|
| 120 | - 'headers' => [ |
|
| 121 | - 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
| 122 | - ], |
|
| 123 | - ]; |
|
| 124 | - } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $token; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + public static function getOAuthHeader(AccessToken $token): array |
|
| 118 | + { |
|
| 119 | + return [ |
|
| 120 | + 'headers' => [ |
|
| 121 | + 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
| 122 | + ], |
|
| 123 | + ]; |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | class InvalidCheckoutException extends \RuntimeException |
| 8 | 8 | { |
| 9 | 9 | public function __construct(CheckoutInterface $checkout, $code = 10, Throwable $previous = null) |
| 10 | - { |
|
| 11 | - $message = sprintf(<<<MSG |
|
| 10 | + { |
|
| 11 | + $message = sprintf(<<<MSG |
|
| 12 | 12 | Something is wrong with this checkout: |
| 13 | 13 | checkout_reference: %s |
| 14 | 14 | amount: %s |
@@ -19,6 +19,6 @@ discard block |
||
| 19 | 19 | $checkout->getAmount(), |
| 20 | 20 | $checkout->getPayToEmail() |
| 21 | 21 | ); |
| 22 | - parent::__construct($message, $code, $previous); |
|
| 23 | - } |
|
| 22 | + parent::__construct($message, $code, $previous); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - public function getToken():? string |
|
| 61 | + public function getToken(): ? string |
|
| 62 | 62 | { |
| 63 | 63 | return $this->token; |
| 64 | 64 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - public function getActive():? bool |
|
| 85 | + public function getActive(): ? bool |
|
| 86 | 86 | { |
| 87 | 87 | return $this->active; |
| 88 | 88 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - public function getType():? string |
|
| 109 | + public function getType(): ? string |
|
| 110 | 110 | { |
| 111 | 111 | return $this->type; |
| 112 | 112 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return string |
| 132 | 132 | */ |
| 133 | - public function getLast4Digits():? string |
|
| 133 | + public function getLast4Digits(): ? string |
|
| 134 | 134 | { |
| 135 | 135 | return $this->last4Digits; |
| 136 | 136 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @return string |
| 156 | 156 | */ |
| 157 | - public function getCardType():? string |
|
| 157 | + public function getCardType(): ? string |
|
| 158 | 158 | { |
| 159 | 159 | return $this->cardSchema; |
| 160 | 160 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @see http://docs.sumup.com/rest-api/checkouts-api/#customers-payment-instruments-post |
| 184 | 184 | * @return array |
| 185 | 185 | */ |
| 186 | - public function getCard():? array |
|
| 186 | + public function getCard(): ? array |
|
| 187 | 187 | { |
| 188 | 188 | return [ |
| 189 | 189 | 'last_4_digits' => $this->getLast4Digits(), |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * @param PaymentInstrumentInterface $card |
| 23 | 23 | * @return bool |
| 24 | 24 | */ |
| 25 | - public function disable(PaymentInstrumentInterface $card):? bool; |
|
| 25 | + public function disable(PaymentInstrumentInterface $card): ? bool; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param CustomerInterface $customer |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @return null|string |
| 15 | 15 | */ |
| 16 | - function getToken():? string; |
|
| 16 | + function getToken(): ? string; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param null|string $token |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @return null|string |
| 37 | 37 | */ |
| 38 | - function getType():? string; |
|
| 38 | + function getType(): ? string; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @param null|string $type |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @return array|null |
| 48 | 48 | */ |
| 49 | - function getCard():? array; |
|
| 49 | + function getCard(): ? array; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @param array|null $data |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @return null|string |
| 59 | 59 | */ |
| 60 | - function getLast4Digits():? string; |
|
| 60 | + function getLast4Digits(): ? string; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param null|string $digits |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * @return null|string |
| 70 | 70 | */ |
| 71 | - function getCardType():? string; |
|
| 71 | + function getCardType(): ? string; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param null|string $schema |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Retrieve a paymentInstrument from server and fill the $paymentInstrument Object with response. |
| 40 | - * |
|
| 41 | - */ |
|
| 40 | + * |
|
| 41 | + */ |
|
| 42 | 42 | public function get(): array |
| 43 | 43 | { |
| 44 | 44 | $response = []; |
@@ -50,49 +50,49 @@ discard block |
||
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | 52 | return $response; |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | + /** |
|
| 56 | 56 | * Delete an paymentInstrument from server. |
| 57 | - * |
|
| 57 | + * |
|
| 58 | 58 | * @param PaymentInstrumentInterface $paymentInstrument |
| 59 | 59 | * @return bool |
| 60 | - */ |
|
| 60 | + */ |
|
| 61 | 61 | public function disable(PaymentInstrumentInterface $paymentInstrument):?bool |
| 62 | 62 | { |
| 63 | 63 | $uri = self::getEndPoint().'/'.$paymentInstrument->getToken(); |
| 64 | 64 | |
| 65 | 65 | return $this->request('delete', $paymentInstrument, $uri); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * CheckoutClientInterface constructor. |
|
| 70 | - * @param ContextInterface $context |
|
| 68 | + /** |
|
| 69 | + * CheckoutClientInterface constructor. |
|
| 70 | + * @param ContextInterface $context |
|
| 71 | 71 | * @param array $options |
| 72 | 72 | */ |
| 73 | 73 | public function __construct(ContextInterface $context, ?array $options = []) |
| 74 | - { |
|
| 74 | + { |
|
| 75 | 75 | $this->context = $context; |
| 76 | 76 | $this->options = $options; |
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Return last response of client |
|
| 81 | - * @return ResponseInterface |
|
| 82 | - */ |
|
| 83 | - function getLastResponse(): ResponseInterface |
|
| 84 | - { |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Return last response of client |
|
| 81 | + * @return ResponseInterface |
|
| 82 | + */ |
|
| 83 | + function getLastResponse(): ResponseInterface |
|
| 84 | + { |
|
| 85 | 85 | return $this->lastResponse; |
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * return the context used to created the client. |
|
| 90 | - * @return ContextInterface |
|
| 91 | - */ |
|
| 92 | - function getContext(): ContextInterface |
|
| 93 | - { |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * return the context used to created the client. |
|
| 90 | + * @return ContextInterface |
|
| 91 | + */ |
|
| 92 | + function getContext(): ContextInterface |
|
| 93 | + { |
|
| 94 | 94 | return $this->context; |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @param PaymentInstrumentInterface $object |
@@ -167,5 +167,5 @@ discard block |
||
| 167 | 167 | public function getCustomer(): CustomerInterface |
| 168 | 168 | { |
| 169 | 169 | return $this->customer; |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * @param PaymentInstrumentInterface $paymentInstrument |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function disable(PaymentInstrumentInterface $paymentInstrument):?bool |
|
| 61 | + public function disable(PaymentInstrumentInterface $paymentInstrument): ?bool |
|
| 62 | 62 | { |
| 63 | - $uri = self::getEndPoint().'/'.$paymentInstrument->getToken(); |
|
| 63 | + $uri = self::getEndPoint() . '/' . $paymentInstrument->getToken(); |
|
| 64 | 64 | |
| 65 | 65 | return $this->request('delete', $paymentInstrument, $uri); |
| 66 | 66 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | function getEndPoint(): string |
| 130 | 130 | { |
| 131 | - return 'customers/'.$this->customer->getCustomerId().'/payment-instruments'; |
|
| 131 | + return 'customers/' . $this->customer->getCustomerId() . '/payment-instruments'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | /** |
| 146 | 146 | * @return AccessToken |
| 147 | 147 | */ |
| 148 | - function getToken():? AccessToken |
|
| 148 | + function getToken(): ? AccessToken |
|
| 149 | 149 | { |
| 150 | 150 | return $this->token; |
| 151 | 151 | } |
@@ -4,132 +4,132 @@ |
||
| 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 | - * |
|
| 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 | 80 | * @param string $name Customer Name |
| 81 | 81 | * @return Customer|CustomerInterface |
| 82 | - */ |
|
| 83 | - public function setName(?string $name): CustomerInterface |
|
| 84 | - { |
|
| 85 | - $this->name = $name; |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Get customer phone |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getPhone(): ?string |
|
| 96 | - { |
|
| 97 | - return $this->phone; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Set customer phone |
|
| 102 | - * |
|
| 82 | + */ |
|
| 83 | + public function setName(?string $name): CustomerInterface |
|
| 84 | + { |
|
| 85 | + $this->name = $name; |
|
| 86 | + |
|
| 87 | + return $this; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Get customer phone |
|
| 92 | + * |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 95 | + public function getPhone(): ?string |
|
| 96 | + { |
|
| 97 | + return $this->phone; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Set customer phone |
|
| 102 | + * |
|
| 103 | 103 | * @param string $phone Customer phone |
| 104 | 104 | * @return Customer|CustomerInterface |
| 105 | - */ |
|
| 106 | - public function setPhone(?string $phone): CustomerInterface |
|
| 107 | - { |
|
| 108 | - $this->phone = $phone; |
|
| 109 | - |
|
| 110 | - return $this; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Get cusomter address |
|
| 115 | - * |
|
| 116 | - * @return AddressInterface |
|
| 117 | - */ |
|
| 118 | - public function getAddress(): AddressInterface |
|
| 119 | - { |
|
| 120 | - return $this->address; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Set cusomter address |
|
| 125 | - * |
|
| 126 | - * @param AddressInterface $address |
|
| 127 | - * @return Customer|CustomerInterface |
|
| 128 | - */ |
|
| 129 | - public function setAddress(AddressInterface $address): CustomerInterface |
|
| 130 | - { |
|
| 131 | - $this->address = $address; |
|
| 132 | - return $this; |
|
| 133 | - } |
|
| 105 | + */ |
|
| 106 | + public function setPhone(?string $phone): CustomerInterface |
|
| 107 | + { |
|
| 108 | + $this->phone = $phone; |
|
| 109 | + |
|
| 110 | + return $this; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Get cusomter address |
|
| 115 | + * |
|
| 116 | + * @return AddressInterface |
|
| 117 | + */ |
|
| 118 | + public function getAddress(): AddressInterface |
|
| 119 | + { |
|
| 120 | + return $this->address; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Set cusomter address |
|
| 125 | + * |
|
| 126 | + * @param AddressInterface $address |
|
| 127 | + * @return Customer|CustomerInterface |
|
| 128 | + */ |
|
| 129 | + public function setAddress(AddressInterface $address): CustomerInterface |
|
| 130 | + { |
|
| 131 | + $this->address = $address; |
|
| 132 | + return $this; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | } |