id = 'authorize'; $this->method_title = __('Authorize.net', 'tech'); $this->icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.gif'; $this->has_fields = false; $this->init_form_fields(); $this->init_settings(); $this->title = $this->settings['title']; $this->description = $this->settings['description']; $this->login = $this->settings['login_id']; $this->mode = $this->settings['working_mode']; $this->transaction_mode = $this->settings['transaction_mode']; $this->transaction_key = $this->settings['transaction_key']; $this->signature_key = $this->settings['signature_key']; $this->success_message = $this->settings['success_message']; $this->failed_message = $this->settings['failed_message']; $this->liveurl = 'https://secure2.authorize.net/gateway/transact.dll'; $this->testurl = 'https://test.authorize.net/gateway/transact.dll'; $this->powerpay = 'https://verifi.powerpay.biz/cart/ausi.php'; $this->msg['message'] = ""; $this->msg['class'] = ""; add_action('init', array(&$this, 'check_authorize_response')); //update for woocommerce >2.0 add_action( 'woocommerce_api_wc_tech_autho' , array( $this, 'check_authorize_response' ) ); add_action('valid-authorize-request', array(&$this, 'successful_request')); if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) { add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); } else { add_action( 'woocommerce_update_options_payment_gateways', array( &$this, 'process_admin_options' ) ); } add_action('woocommerce_receipt_authorize', array(&$this, 'receipt_page')); add_action('woocommerce_thankyou_authorize',array(&$this, 'thankyou_page')); if( function_exists('indatos_woo_auth_process_refund') ){ $this->supports = array( 'products', 'refunds' ); }else{ } } function process_refund($order_id, $amount = null, $reason = '') { return indatos_woo_auth_process_refund($order_id, $amount = null, $reason = ''); } function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => __('Enable/Disable', 'tech'), 'type' => 'checkbox', 'label' => __('Enable Authorize.net Payment Module.', 'tech'), 'default' => 'no'), 'title' => array( 'title' => __('Title:', 'tech'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'tech'), 'default' => __('Authorize.net', 'tech')), 'description' => array( 'title' => __('Description:', 'tech'), 'type' => 'textarea', 'description' => __('This controls the description which the user sees during checkout.', 'tech'), 'default' => __('Pay securely by Credit or Debit Card through Authorize.net Secure Servers.', 'tech')), 'login_id' => array( 'title' => __('Login ID', 'tech'), 'type' => 'password', 'description' => __('This is API Login ID')), 'transaction_key' => array( 'title' => __('Transaction Key', 'tech'), 'type' => 'password', 'description' => __('API Transaction Key', 'tech')), 'signature_key' => array( 'title' => __('Signature Key', 'tech'), 'type' => 'password', 'description' => __('Signature Key is required to validate the response from Authorize.net. Paste 128 character key as it is. Refer to generate signature keyhttps://support.authorize.net/s/article/What-is-a-Signature-Key. NOTE: make sure when you copy and paste signature there is no whitespace before after.', 'tech')), 'success_message' => array( 'title' => __('Transaction Success Message', 'tech'), 'type' => 'textarea', 'description'=> __('Message to be displayed on successful transaction.', 'tech'), 'default' => __('Your payment has been procssed successfully.', 'tech')), 'failed_message' => array( 'title' => __('Transaction Failed Message', 'tech'), 'type' => 'textarea', 'description' => __('Message to be displayed on failed transaction.', 'tech'), 'default' => __('Your transaction has been declined.', 'tech')), 'working_mode' => array( 'title' => __('API Mode'), 'type' => 'select', 'options' => array('false'=>'Live/Production Mode', 'false_test' => 'Live/Production API in Test Mode', 'true'=>'Sandbox/Developer API Mode'), 'description' => "Live or Production / Sandbox Mode" ), 'transaction_mode' => array( 'title' => __('Transaction Mode'), 'type' => 'select', 'options' => array( 'auth_capture'=>'Authorize and Capture', 'authorize'=>'Authorize Only'), 'description' => "Transaction Mode. If you are not sure what to use set to Authorize and Capture" ) ); } /** * Admin Panel Options * - Options for bits like 'title' and availability on a country-by-country basis **/ public function admin_options() { echo '
'.__('Authorize.net is most popular payment gateway for online payment processing. For any support connect with Tech Support team on Our Site For GDPR details, contact support.').'
Limited Period Discount. Download Now! Authorize.net Certified Version $49.00 $29.60 Limited time offder.
Fill in this to receive priority notification on updates for this plugin(optional).
'; echo ''.__('Thank you for your order, please click the button below to pay with Authorize.net.', 'tech').'
'; echo $this->generate_authorize_form($order); } /** * Process the payment and return the result **/ function process_payment($order_id) { $order = new WC_Order($order_id); return array( 'result' => 'success', 'redirect' => $order->get_checkout_payment_url( true ) ); } /** * Check for valid Authorize.net server callback to validate the transaction response. **/ function check_authorize_response() { global $woocommerce; $temp_order = new WC_Order(); if ( count($_POST) ){ $redirect_url = ''; $this->msg['class'] = 'error'; $this->msg['message'] = $this->failed_message; $order = new WC_Order($_POST['x_invoice_num']); $signatureKey = ($this->signature_key != '') ? $this->signature_key : ''; $hashData = implode('^', [ $_POST['x_trans_id'], $_POST['x_test_request'], $_POST['x_response_code'], $_POST['x_auth_code'], $_POST['x_cvv2_resp_code'], $_POST['x_cavv_response'], $_POST['x_avs_code'], $_POST['x_method'], $_POST['x_account_number'], $_POST['x_amount'], $_POST['x_company'], $_POST['x_first_name'], $_POST['x_last_name'], $_POST['x_address'], $_POST['x_city'], $_POST['x_state'], $_POST['x_zip'], $_POST['x_country'], $_POST['x_phone'], $_POST['x_fax'], $_POST['x_email'], $_POST['x_ship_to_company'], $_POST['x_ship_to_first_name'], $_POST['x_ship_to_last_name'], $_POST['x_ship_to_address'], $_POST['x_ship_to_city'], $_POST['x_ship_to_state'], $_POST['x_ship_to_zip'], $_POST['x_ship_to_country'], $_POST['x_invoice_num'], ]); $digest = strtoupper(HASH_HMAC('sha512',"^".$hashData."^",hex2bin($signatureKey))); if ( $_POST['x_response_code'] != '' && ( strtoupper($_POST['x_SHA2_Hash']) == $digest ) ){ try{ $amount = $_POST['x_amount']; $hash = $_POST['x_SHA2_Hash']; $transauthorised = false; if ( $order->get_status() != 'completed'){ if ( $_POST['x_response_code'] == 1 ){ $transauthorised = true; $this->msg['message'] = $this->success_message; $this->msg['class'] = 'success'; if ( $order->get_status() == 'processing' ){ } else{ $order->payment_complete($_REQUEST['x_trans_id']); $order->add_order_note('Autorize.net payment successful