x_auth_key = $x_auth_key; $this->base_url = ( 'yes' == $test_mode ) ? 'https://sandboxapi.horizonafs.com/eCommerceServicesWebApi' : 'https://api.afterpay.io'; $invoice_settings = get_option( 'woocommerce_afterpay_invoice_settings' ); $this->street_number_field = ( isset( $invoice_settings['street_number_field'] ) ) ? $invoice_settings['street_number_field'] : ''; } /** * Returns formatted request header. * * @return array */ protected function request_header() { return array( 'X-Auth-Key' => $this->x_auth_key, 'Content-Type' => 'application/json', ); } /** * Returns formatted request body. * Must be overridden in child classes. */ protected function request_body() { die( 'function WC_AfterPay_Request::request_body() must be over-ridden in a sub-class.' ); } /** * Perform API request. */ public function request() { $response = wp_remote_request( $this->base_url . $this->resource_url, array( 'headers' => $this->request_header(), ) ); if ( 200 === $response['response']['code'] ) { $response_body = json_decode( $response['body'] ); echo '
'; echo esc_html( $response_body->version ); echo ''; } } } // $wc_afterpay_request = new WC_AfterPay_Request();