| | |
| | | */ |
| | | public function enqueueScripts(): void |
| | | { |
| | | jvbInlineStyles('forms'); |
| | | $this->loadCredentials(); |
| | | $sdk_url = $this->environment === 'production' |
| | | ? 'https://web.squarecdn.com/v1/square.js' |
| | |
| | | wp_register_script( |
| | | 'jvb-checkout', |
| | | JVB_URL . 'assets/js/min/checkout.min.js', |
| | | ['jvb-utility', 'jvb-queue', 'jvb-a11y', 'jvb-cache', 'jvb-tabs', 'jvb-popup'], |
| | | '1.1.31', |
| | | ['jvb-utility', 'jvb-queue', 'jvb-a11y', 'jvb-cache', 'jvb-tabs', 'jvb-popup', 'jvb-login'], |
| | | '1.1.32', |
| | | ['strategy' => 'defer', 'in_footer' => true] |
| | | ); |
| | | |
| | |
| | | 'jvb-square-checkout', |
| | | JVB_URL . 'assets/js/min/square.min.js', |
| | | ['jvb-checkout', 'square-payments-sdk'], |
| | | '1.1.31', |
| | | '1.1.32', |
| | | ['strategy' => 'defer', 'in_footer' => true] |
| | | ); |
| | | |
| | |
| | | 'application_id' => $this->credentials['client_id'] ?? '', |
| | | 'location_id' => $this->locationId, |
| | | 'environment' => $this->environment, |
| | | 'api_url' => rest_url('jvb/v1/square/'), |
| | | 'nonce' => wp_create_nonce('wp_rest'), |
| | | 'currency' => get_option(BASE . 'currency', 'CAD'), |
| | | 'is_logged_in' => is_user_logged_in(), |
| | | 'user_email' => is_user_logged_in() ? wp_get_current_user()->user_email : '', |
| | |
| | | ]; |
| | | } |
| | | public function getAdditionalFields(?string $content_type = null):array { |
| | | if ($content_type === 'customer') { |
| | | return $this->getCustomerFields(); |
| | | } |
| | | if ($content_type && array_key_exists($content_type, $this->contentTypes)){ |
| | | $array = $this->contentTypes[$content_type]; |
| | | return array_combine( |
| | |
| | | $array |
| | | ); |
| | | } |
| | | |
| | | protected function getCustomerFields():array |
| | | { |
| | | return [ |
| | | 'customer_id' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Square Customer ID', |
| | | 'hidden'=> true, |
| | | ], |
| | | 'address_line_1' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Address Line 1', |
| | | 'hint' => 'ex: 6551 111 St NW', |
| | | 'required' => true, |
| | | 'section' => 'about' |
| | | ], |
| | | 'address_line_2' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Address Line 2', |
| | | 'hint' => 'ex: Unit 2', |
| | | 'section' => 'about' |
| | | ], |
| | | 'city' => [ |
| | | 'type' => 'text', |
| | | 'label'=> 'City', |
| | | 'section' => 'about', |
| | | 'required' => true, |
| | | ], |
| | | 'state' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Province', |
| | | 'hint' => 'The two-character code, example: AB', |
| | | 'default'=> 'AB', |
| | | 'section' => 'about', |
| | | 'required' => true, |
| | | ], |
| | | 'countryCode' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Country Code', |
| | | 'hint' => 'The tw-character country code, example: CA', |
| | | 'default' => 'CA', |
| | | 'section' => 'about', |
| | | 'required' => true, |
| | | ] |
| | | ]; |
| | | } |
| | | protected function setBaseFields():array |
| | | { |
| | | return [ |