| | |
| | | namespace JVBase\integrations\services; |
| | | use Exception; |
| | | use JVBase\integrations\Integrations; |
| | | use JVBase\managers\Emails; |
| | | use JVBase\managers\queue\executors\IntegrationExecutor; |
| | | use JVBase\managers\queue\Queue; |
| | | use JVBase\managers\queue\TypeConfig; |
| | | use JVBase\meta\Form; |
| | | use JVBase\meta\Meta; |
| | |
| | | |
| | | protected string $environment = 'sandbox'; |
| | | |
| | | private const PASSWORD_RESET_INTERVAL = 3; // Reset password every 3 logins, for customers |
| | | // Reset password every 3 logins, for customers |
| | | |
| | | /** |
| | | * OAuth Configuration |
| | |
| | | ? 'https://connect.squareup.com' |
| | | : 'https://connect.squareupsandbox.com'; |
| | | |
| | | $this->oauth['authorize'] = $baseUrl . '/oauth2/authorize'; |
| | | $this->oauth['token'] = $baseUrl . '/oauth2/token'; |
| | | $this->oauth['revoke'] = $baseUrl . '/oauth2/revoke'; |
| | | $this->oauth->getAuthorize() = $baseUrl . '/oauth2/authorize'; |
| | | $this->oauth->getToken() = $baseUrl . '/oauth2/token'; |
| | | $this->oauth->getRevoke() = $baseUrl . '/oauth2/revoke'; |
| | | |
| | | // Set up API endpoints with version |
| | | $this->apiEndpoints = [ |
| | |
| | | 'redirect_uri' => $this->getRedirectUri() |
| | | ]; |
| | | |
| | | $response = wp_remote_post($this->oauth['token'], [ |
| | | $response = wp_remote_post($this->oauth->getToken(), [ |
| | | 'body' => json_encode($body), |
| | | 'headers' => [ |
| | | 'Content-Type' => 'application/json', |
| | |
| | | return false; |
| | | } |
| | | |
| | | $response = wp_remote_post($this->oauth['token'], [ |
| | | $response = wp_remote_post($this->oauth->getToken(), [ |
| | | 'body' => [ |
| | | 'client_id' => $this->credentials['client_id'], |
| | | 'client_secret' => $this->credentials['client_secret'], |
| | |
| | | try { |
| | | // Revoke the token with Square |
| | | if (!empty($this->credentials['access_token'])) { |
| | | wp_remote_post($this->oauth['revoke'], [ |
| | | wp_remote_post($this->oauth->getRevoke(), [ |
| | | 'body' => [ |
| | | 'client_id' => $this->credentials['client_id'] ?? '', |
| | | 'access_token' => $this->credentials['access_token'] |