| | |
| | | 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'] |
| | |
| | | |
| | | protected function registerAdditionalQueueTypes(IntegrationExecutor $executor): void |
| | | { |
| | | $queue = JVB()->queue(); |
| | | $queue = Queue::getInstance(); |
| | | |
| | | $queue->registry()->register(self::$syncCustomer, new TypeConfig( |
| | | executor: $executor, |
| | |
| | | "If you didn't create this account, please ignore this email.\n\n" . |
| | | "Thanks,\n", |
| | | $site_name, |
| | | JVB()->email()->button('Reset Password', $reset_url), |
| | | JVB()->email()->link($reset_url), |
| | | Emails::getInstance()->button('Reset Password', $reset_url), |
| | | Emails::getInstance()->link($reset_url), |
| | | ); |
| | | |
| | | JVB()->email()->sendEmail( |
| | | Emails::getInstance()->sendEmail( |
| | | $user->user_email, |
| | | sprintf('[%s] Welcome! Set Your Password', $site_name), |
| | | $message |
| | |
| | | |
| | | public function addDashboardPages():void |
| | | { |
| | | $page = JVB()->dashboard()->addPage('Your Orders', 'orders', 'receipt'); |
| | | $page = Dashboard::getInstance()->addPage('Your Orders', 'orders', 'receipt'); |
| | | $page->setScripts(['jvb-crud']); |
| | | } |
| | | public function renderDashPage():void |