'POST', 'timeout' => 30, 'redirection' => 0, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode( $pcaAccCode . ':' . $pcaToken ) ), 'body' => '{"AccountCode":"' . $pcaAccCode . '"}', 'cookies' => array() ) ); if ( is_wp_error( $response ) ) { } else { $jData = json_decode( $response['body'] ); $planDetails = array( 'current_plan_name' => $jData->currentPlanName, 'current_plan_credits' => $jData->currentPlanCredits, 'current_plan_period' => $jData->currentPlanPeriod, 'current_plan_refresh_date' => str_replace( 'T',' ', $jData->currentPlanRefreshDate ), 'current_plan_credits_used' => ( $jData->currentPlanCredits - $jData->currentPlanCreditsRemaining ), 'current_plan_percentage_used' => floor( 100 - ( $jData->currentPlanCreditsRemaining * 100 / $jData->currentPlanCredits ) ) ); update_option( '_adrsy_plan_details', $planDetails ); } } catch ( Exception $e ) { die( $e->getMessage() ); } } } function addressy_refresh_settings_from_server() { $pcaOptions = get_option( '_adrsy_settings' ); $pcaAccCode = $pcaOptions[ 'account_code' ]; $pcaToken = $pcaOptions[ 'account_token' ]; $pcaLicenseKey = $pcaOptions[ 'license_key' ]; $pcaFieldMappings = $pcaOptions[ 'field_mappings' ]; $pcaCustomJavaScript = $pcaOptions[ 'custom_javascript' ]; if ( $pcaAccCode && $pcaToken && $pcaLicenseKey ) { try { $response = wp_remote_post( 'https://app_api.pcapredict.com/api/getlicensedetails', array( 'method' => 'POST', 'timeout' => 30, 'redirection' => 0, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode( $pcaAccCode . ':' . $pcaToken ) ), 'body' => '{"Key":"' . $pcaLicenseKey . '", "ReturnKeyusage":true, "UsageDaysBack":10}', 'cookies' => array() ) ); if ( is_wp_error( $response ) ) { } else { $jData = json_decode( $response['body'] ); $settings = array( 'account_code' => $pcaAccCode, 'account_token' => $pcaToken, 'license_key' => $pcaLicenseKey, 'field_mappings' => $pcaFieldMappings, 'custom_javascript' => $pcaCustomJavaScript, 'daily_limit' => $jData->dailyLimit, 'user_limit' => $jData->userLimit, 'url_restrictions' => $jData->urlRestrictions, 'key_name' => $jData->keyName, 'key_usage' => $jData->keyUsage, 'key_usage_sum' => 0 ); for ( $i = 0; $i < 10; $i++) { $settings['key_usage_sum'] += $settings['key_usage'][$i]; } /* var_dump($settings); die(); */ update_option( '_adrsy_settings', $settings ); } } catch ( Exception $e ) { die( $e->getMessage() ); } } } /** * addressy_settings_page_content() * Builds the content for the admin settings page. */ function addressy_settings_page_content() { addressy_get_current_plan_details(); addressy_refresh_settings_from_server(); $pcaPlan = get_option( '_adrsy_plan_details' ); $pcaCurrentPlanName = $pcaPlan[ 'current_plan_name' ]; $pcaCurrentPlanCredits = $pcaPlan[ 'current_plan_credits' ]; $pcaCurrentPlanPeriod = $pcaPlan[ 'current_plan_period' ]; $pcaCurrentPlanRefreshDate = $pcaPlan[ 'current_plan_refresh_date' ]; $pcaCurrentPlanCreditsUsed = $pcaPlan[ 'current_plan_credits_used' ]; $pcaCurrentPlanPercentageUsed = $pcaPlan[ 'current_plan_percentage_used' ]; $pcaOptions = get_option( '_adrsy_settings' ); $pcaAccCode = strtoupper( $pcaOptions[ 'account_code' ] ); $pcaToken = $pcaOptions[ 'account_token' ]; $pcaLicenseKey = $pcaOptions[ 'license_key' ]; $pcaDailyLimit = $pcaOptions[ 'daily_limit' ]; $pcaLimitPerUser = $pcaOptions[ 'user_limit' ]; $pcaLimitByUrl = $pcaOptions[ 'url_restrictions' ]; $pcaMappings = json_decode( $pcaOptions[ 'field_mappings' ] ); $pcaCustomJS = json_decode( $pcaOptions[ 'custom_javascript' ] ); $pcaKeyName = $pcaOptions[ 'key_name' ]; $pcaKeyUsageSum = $pcaOptions[ 'key_usage_sum' ]; ?>

Address Verification

.