@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | if( $customConfig===null){ |
| 16 | - $paths = [ |
|
| 16 | + $paths = [ |
|
| 17 | 17 | dirname(__DIR__, 2) . '/viva-config.php', |
| 18 | 18 | dirname(__DIR__, 5) . '/viva-config.php' |
| 19 | 19 | ]; |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - if( $customConfig===null){ |
|
| 15 | + if ($customConfig === null) { |
|
| 16 | 16 | $paths = [ |
| 17 | - dirname(__DIR__, 2) . '/viva-config.php', |
|
| 18 | - dirname(__DIR__, 5) . '/viva-config.php' |
|
| 17 | + dirname(__DIR__, 2).'/viva-config.php', |
|
| 18 | + dirname(__DIR__, 5).'/viva-config.php' |
|
| 19 | 19 | ]; |
| 20 | 20 | $this->config = $this->loadConfigFile($paths); |
| 21 | 21 | |
| 22 | - }else{ |
|
| 22 | + } else { |
|
| 23 | 23 | |
| 24 | 24 | $this->config = $customConfig; |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | ]; |
| 20 | 20 | $this->config = $this->loadConfigFile($paths); |
| 21 | 21 | |
| 22 | - }else{ |
|
| 22 | + } else{ |
|
| 23 | 23 | |
| 24 | 24 | $this->config = $customConfig; |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | $configArray = $configObject->getConfig(); |
| 20 | 20 | $environment= $configArray['defaultProvider']; |
| 21 | 21 | |
| 22 | - if ($environment !== 'vivaDEMO' && $environment !== 'vivaPROD') { |
|
| 22 | + if ($environment !== 'vivaDEMO' && $environment !== 'vivaPROD') { |
|
| 23 | 23 | throw new \InvalidArgumentException('Invalid environment value {'.$environment.'}. It should be either "vivaDEMO" or "vivaPROD".'); |
| 24 | 24 | } |
| 25 | 25 | $this->environment = $environment; |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | private $accessToken; |
| 11 | 11 | private $environment; |
| 12 | 12 | private $statusCode; |
| 13 | - public Config|Array $configObject; |
|
| 13 | + public Config | Array $configObject; |
|
| 14 | 14 | |
| 15 | - public function __construct(Config|array $configObject){ |
|
| 15 | + public function __construct(Config | array $configObject) { |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - $this->configObject=$configObject; |
|
| 18 | + $this->configObject = $configObject; |
|
| 19 | 19 | $configArray = $configObject->getConfig(); |
| 20 | - $environment= $configArray['defaultProvider']; |
|
| 20 | + $environment = $configArray['defaultProvider']; |
|
| 21 | 21 | |
| 22 | 22 | if ($environment !== 'vivaDEMO' && $environment !== 'vivaPROD') { |
| 23 | 23 | throw new \InvalidArgumentException('Invalid environment value {'.$environment.'}. It should be either "vivaDEMO" or "vivaPROD".'); |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | $curl->addHeader('Content-Type: application/x-www-form-urlencoded'); |
| 36 | 36 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
| 37 | 37 | $curl->addHeader('Accept: */*'); |
| 38 | - $curl->setBasicAuth($config->getEnvConfig('VIVA_CLIENT_ID'),$config->getEnvConfig('VIVA_CLIENT_SECRET')); |
|
| 38 | + $curl->setBasicAuth($config->getEnvConfig('VIVA_CLIENT_ID'), $config->getEnvConfig('VIVA_CLIENT_SECRET')); |
|
| 39 | 39 | $response = $curl->post(array('grant_type' => 'client_credentials')); |
| 40 | 40 | $this->statusCode = $curl->getStatusCode(); |
| 41 | - $response = json_decode($response,true); |
|
| 41 | + $response = json_decode($response, true); |
|
| 42 | 42 | |
| 43 | 43 | $this->accessToken = $response['access_token']; |
| 44 | 44 | return $this->accessToken; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | $curl->addHeader('Content-Type: application/x-www-form-urlencoded'); |
| 53 | 53 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
| 54 | 54 | $curl->addHeader('Accept: */*'); |
| 55 | - $curl->setBasicAuth($config->getEnvConfig('VIVA_MERCHANT_ID'),$config->getEnvConfig('VIVA_API_KEY')); |
|
| 55 | + $curl->setBasicAuth($config->getEnvConfig('VIVA_MERCHANT_ID'), $config->getEnvConfig('VIVA_API_KEY')); |
|
| 56 | 56 | |
| 57 | 57 | $response = $curl->get(); |
| 58 | 58 | |
| 59 | - $response = json_decode($response,true); |
|
| 59 | + $response = json_decode($response, true); |
|
| 60 | 60 | return $response; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -14,12 +14,12 @@ discard block |
||
| 14 | 14 | use getConfigSettings; |
| 15 | 15 | |
| 16 | 16 | private $accessToken; |
| 17 | - public Config|Array $configObject; |
|
| 17 | + public Config | Array $configObject; |
|
| 18 | 18 | |
| 19 | - public function __construct($accessToken,Config|array $configObject) |
|
| 19 | + public function __construct($accessToken, Config | array $configObject) |
|
| 20 | 20 | { |
| 21 | 21 | $this->accessToken = $accessToken; |
| 22 | - $this->configObject=$configObject; |
|
| 22 | + $this->configObject = $configObject; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if (!$vivaTransaction) throw new \Exception('Invalid transaction code'); |
| 35 | 35 | $config = $this->configObject; |
| 36 | 36 | $url = $config->getEnvConfig('VIVA_URL'); |
| 37 | - $curl = new CurlWrapper($url . '/api/transactions/' . $vivaTransaction); |
|
| 37 | + $curl = new CurlWrapper($url.'/api/transactions/'.$vivaTransaction); |
|
| 38 | 38 | $curl->addHeader('Content-Type: application/json'); |
| 39 | 39 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
| 40 | 40 | $curl->addHeader('Accept: */*'); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | if (!$vivaTransaction) throw new \Exception('Invalid transaction code'); |
| 67 | 67 | $token = $this->accessToken->getToken(); |
| 68 | 68 | $config = $this->configObject; |
| 69 | - $url = $config->getEnvConfig('VIVA_API_URL') . '/checkout/v2/transactions/' . $vivaTransaction; |
|
| 69 | + $url = $config->getEnvConfig('VIVA_API_URL').'/checkout/v2/transactions/'.$vivaTransaction; |
|
| 70 | 70 | $curl = new CurlWrapper($url); |
| 71 | 71 | $curl->addHeader('Content-Type: application/json'); |
| 72 | 72 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
| 73 | 73 | $curl->setBearer($token); |
| 74 | 74 | $response = $curl->get(); |
| 75 | 75 | $response = json_decode($response, true); |
| 76 | - $response['PaymentStatus'] = Enums\TransactionStatus::fromValue($response['statusId']); |
|
| 76 | + $response['PaymentStatus'] = Enums\TransactionStatus::fromValue($response['statusId']); |
|
| 77 | 77 | $response['TransactionType'] = Enums\TransactionType::fromValue($response['transactionTypeId']); |
| 78 | 78 | return $response; |
| 79 | 79 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | if (!$orderCode) throw new \Exception('Invalid transaction code'); |
| 86 | 86 | $config = $this->configObject; |
| 87 | 87 | $url = $config->getEnvConfig('VIVA_URL'); |
| 88 | - $curl = new CurlWrapper($url . '/api/orders/' . $orderCode); |
|
| 88 | + $curl = new CurlWrapper($url.'/api/orders/'.$orderCode); |
|
| 89 | 89 | $curl->addHeader('Content-Type: application/json'); |
| 90 | 90 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
| 91 | 91 | $curl->addHeader('Accept: */*'); |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | public function getByTransaction($vivaTransaction) |
| 32 | 32 | { |
| 33 | 33 | // https://demo.vivapayments.com/api/transactions/:transaction_id |
| 34 | - if (!$vivaTransaction) throw new \Exception('Invalid transaction code'); |
|
| 34 | + if (!$vivaTransaction) { |
|
| 35 | + throw new \Exception('Invalid transaction code'); |
|
| 36 | + } |
|
| 35 | 37 | $config = $this->configObject; |
| 36 | 38 | $url = $config->getEnvConfig('VIVA_URL'); |
| 37 | 39 | $curl = new CurlWrapper($url . '/api/transactions/' . $vivaTransaction); |
@@ -63,7 +65,9 @@ discard block |
||
| 63 | 65 | public function getByTransactionV2($vivaTransaction) |
| 64 | 66 | { |
| 65 | 67 | // https://demo.vivapayments.com/checkout/v2/transactions/:transaction_id |
| 66 | - if (!$vivaTransaction) throw new \Exception('Invalid transaction code'); |
|
| 68 | + if (!$vivaTransaction) { |
|
| 69 | + throw new \Exception('Invalid transaction code'); |
|
| 70 | + } |
|
| 67 | 71 | $token = $this->accessToken->getToken(); |
| 68 | 72 | $config = $this->configObject; |
| 69 | 73 | $url = $config->getEnvConfig('VIVA_API_URL') . '/checkout/v2/transactions/' . $vivaTransaction; |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | public function getByOrderCode($orderCode) |
| 83 | 87 | { |
| 84 | 88 | // https://demo.vivapayments.com/api/orders/:orderCode |
| 85 | - if (!$orderCode) throw new \Exception('Invalid transaction code'); |
|
| 89 | + if (!$orderCode) { |
|
| 90 | + throw new \Exception('Invalid transaction code'); |
|
| 91 | + } |
|
| 86 | 92 | $config = $this->configObject; |
| 87 | 93 | $url = $config->getEnvConfig('VIVA_URL'); |
| 88 | 94 | $curl = new CurlWrapper($url . '/api/orders/' . $orderCode); |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | |
| 101 | 101 | public function send() |
| 102 | 102 | { |
| 103 | - $config = $this->configObject; |
|
| 103 | + $config = $this->configObject; |
|
| 104 | 104 | //For debugin - Set it to config |
| 105 | 105 | // if ($this->getConfigSettings()->getEnvConfig('VIVA_DEBUG')) { |
| 106 | 106 | if ($config->getEnvConfig('VIVA_DEBUG')) { |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | private $response; |
| 22 | 22 | private $paymentMethods; |
| 23 | 23 | private $paymentMethodFees; |
| 24 | - public Config|Array $configObject; |
|
| 24 | + public Config | Array $configObject; |
|
| 25 | 25 | |
| 26 | - public function __construct(?array $order, $accessToken,Config|array $configObject) |
|
| 26 | + public function __construct(?array $order, $accessToken, Config | array $configObject) |
|
| 27 | 27 | { |
| 28 | - $this->configObject=$configObject; |
|
| 28 | + $this->configObject = $configObject; |
|
| 29 | 29 | $this->order = $order; |
| 30 | 30 | $this->accessToken = $accessToken; |
| 31 | 31 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $config = $this->configObject; |
| 64 | 64 | $order = $this->order; |
| 65 | - $order['sourceCode'] = $config->getEnvConfig('VIVA_SOURCE_CODE'); |
|
| 65 | + $order['sourceCode'] = $config->getEnvConfig('VIVA_SOURCE_CODE'); |
|
| 66 | 66 | // $order['sourceCode'] = $this->getConfigSettings()->getEnvConfig('VIVA_SOURCE_CODE'); |
| 67 | 67 | $order['customer'] = $this->getCustomer(); |
| 68 | 68 | $order['paymentMethods'] = $this->paymentMethods; |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | if ($config->getEnvConfig('VIVA_DEBUG')) { |
| 107 | 107 | $method = __METHOD__; |
| 108 | 108 | $parentDir = dirname(dirname(dirname(__FILE__))); |
| 109 | - $fp = fopen($parentDir . '/debug_viva.txt', 'a+'); |
|
| 110 | - fwrite($fp, '------- ' . $method . ' -------' . PHP_EOL . $this->toJson() . PHP_EOL . '------------------------------' . PHP_EOL); |
|
| 109 | + $fp = fopen($parentDir.'/debug_viva.txt', 'a+'); |
|
| 110 | + fwrite($fp, '------- '.$method.' -------'.PHP_EOL.$this->toJson().PHP_EOL.'------------------------------'.PHP_EOL); |
|
| 111 | 111 | fclose($fp); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $token = $this->accessToken->getToken(); |
| 115 | 115 | $url = $config->getEnvConfig('VIVA_API_URL'); |
| 116 | 116 | // $url = $this->getConfigSettings()->getEnvConfig('VIVA_API_URL'); |
| 117 | - $curl = new CurlWrapper($url . '/checkout/v2/orders'); |
|
| 117 | + $curl = new CurlWrapper($url.'/checkout/v2/orders'); |
|
| 118 | 118 | |
| 119 | 119 | $curl->addHeader('Content-Type: application/json'); |
| 120 | 120 | $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1'); |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | public function redirectUrl( |
| 148 | 148 | ?string $color = null, |
| 149 | - string|RequestLang $lang = null, |
|
| 150 | - int|PaymentMethods $PaymentMethods = null |
|
| 149 | + string | RequestLang $lang = null, |
|
| 150 | + int | PaymentMethods $PaymentMethods = null |
|
| 151 | 151 | ) { |
| 152 | 152 | $params = ''; |
| 153 | 153 | $config = $this->configObject; |
@@ -156,24 +156,24 @@ discard block |
||
| 156 | 156 | // $params .= "&color=" . $this->getConfigSettings()->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR'); |
| 157 | 157 | // } |
| 158 | 158 | if (!$color && $config->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR')) { |
| 159 | - $params .= "&color=" . $config->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR'); |
|
| 159 | + $params .= "&color=".$config->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR'); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ($color) $params .= "&color=" . $color; |
|
| 162 | + if ($color) $params .= "&color=".$color; |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | 165 | if ($lang instanceof RequestLang) { |
| 166 | - $params .= "&lang=" . $lang->value; |
|
| 166 | + $params .= "&lang=".$lang->value; |
|
| 167 | 167 | } elseif (is_string($lang)) { |
| 168 | - $params .= "&lang=" . $lang; |
|
| 168 | + $params .= "&lang=".$lang; |
|
| 169 | 169 | } else { |
| 170 | 170 | $params .= "&lang=el-GR"; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | if ($lang instanceof PaymentMethods) { |
| 174 | - $params .= "&paymentMethod=" . $PaymentMethods->value; |
|
| 174 | + $params .= "&paymentMethod=".$PaymentMethods->value; |
|
| 175 | 175 | } elseif (is_int($PaymentMethods)) { |
| 176 | - $params .= "&paymentMethod=" . $PaymentMethods; |
|
| 176 | + $params .= "&paymentMethod=".$PaymentMethods; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -181,6 +181,6 @@ discard block |
||
| 181 | 181 | $orderCode = $this->vivaOrderCode; |
| 182 | 182 | $url = $config->getEnvConfig('VIVA_URL'); |
| 183 | 183 | // $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL'); |
| 184 | - return $url . '/web2?ref=' . $orderCode . $params; |
|
| 184 | + return $url.'/web2?ref='.$orderCode.$params; |
|
| 185 | 185 | } |
| 186 | 186 | } |
@@ -159,7 +159,9 @@ |
||
| 159 | 159 | $params .= "&color=" . $config->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR'); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ($color) $params .= "&color=" . $color; |
|
| 162 | + if ($color) { |
|
| 163 | + $params .= "&color=" . $color; |
|
| 164 | + } |
|
| 163 | 165 | |
| 164 | 166 | |
| 165 | 167 | if ($lang instanceof RequestLang) { |