'; } if( $_POST['donor_lastname'] != ''){ $donor_lastname = $_POST['donor_lastname']; } else{ $valid = false; $msg.= 'Last Name is required '; } if( $_POST['donor_email'] != ''){ $donor_email = $_POST['donor_email']; if( preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/" , $donor_email)){} else{ $valid = false; $msg.= 'Invalid email format '; } } else{ $valid = false; $msg.= 'E-mail is required '; } if( $_POST['donation_amount'] != ''){ $donation_amount = $_POST['donation_amount']; if( (is_numeric($donation_amount)) && ( (strlen($donation_amount) > '1') || (strlen($donation_amount) == '1')) ){} else{ $valid = false; $msg.= 'Amount cannot be less then $1'; } } else{ $valid = false; $msg.= 'Amount is required '; } if( $_POST['donor_card_number'] != ''){ $donor_card_number = $_POST['donor_card_number']; if( (is_numeric($donor_card_number)) && (strlen($donor_card_number) > '15') ){} else{ $valid = false; $msg.= 'Please enter valid Card Number'; } } else{ $valid = false; $msg.= 'Card Number is required '; } if( $_POST['donor_cvv'] != ''){ $donor_cvv = $_POST['donor_cvv']; if( (is_numeric($donor_cvv)) && (strlen($donor_cvv) == '3') ){} else{ $valid = false; $msg.= 'Please enter valid CVV '; } } else{ $valid = false; $msg.= 'CVV is required '; } if( $_POST['donor_card_expiry'] != ''){ $donor_card_expiry = $_POST['donor_card_expiry']; if( (is_numeric($donor_card_expiry)) && (strlen($donor_card_expiry) == '4') ){} else{ $valid = false; $msg.= 'Please enter valid Card Expiry Date'; } } else{ $valid = false; $msg.= 'Card Expiry Date is required '; } if( $valid ){ $donor_firstname; $donor_lastname; $donor_email; $donation_amount; $donor_card_number; $donor_cvv; $donor_card_expiry; $auth_login_id = get_option('wds_donation_login_id'); $auth_transaction_key = get_option('wds_donation_transaction_key'); $auth_mode = get_option('wds_donation_mode'); //$flag_admin = get_option('wds_admin_notification'); //$flag_donor = get_option('wds_donor_notification'); $processor_description = get_option('wds_processor_description'); if( get_option('wds_donation_mode') == "live" ){ $post_url = "https://secure.authorize.net/gateway/transact.dll"; } else{ $post_url = "https://test.authorize.net/gateway/transact.dll"; } $post_values = array( "x_login" => $auth_login_id, "x_tran_key" => $auth_transaction_key, "x_version" => "3.1", "x_delim_data" => "TRUE", "x_delim_char" => "|", "x_relay_response" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_card_num" => $donor_card_number, "x_card_code" => $donor_cvv, "x_exp_date" => $donor_card_expiry, "x_amount" => $donation_amount, "x_description" => $processor_description, "x_first_name" => $donor_firstname, "x_last_name" => $donor_lastname, "x_email" => $donor_email, "x_address" => "", "x_state" => "", "x_zip" => "" ); $post_string = ""; foreach( $post_values as $key => $value ) { $post_string .= "$key=" . urlencode( $value ) . "&"; } $post_string = rtrim( $post_string, "& " ); $request = curl_init($post_url); curl_setopt($request, CURLOPT_HEADER, 0); curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); $post_response = curl_exec($request); // Connection to Authorize.net curl_close ($request); // close curl object $response_array = explode($post_values["x_delim_char"],$post_response); $transaction_id = $response_array[7]; $last_4 = $response_array[50]; $approval_code = $response_array[4]; if($response_array[0] =='1'){ $post = array( 'post_type' => 'wds_donation', 'post_title' => 'Donation - '. sanitize_text_field($_POST['donor_firstname']). ' '. sanitize_text_field($_POST['donor_lastname']), 'post_status' => 'publish', 'post_author' => 1, ); $post_id = wp_insert_post( $post ); add_post_meta($post_id, 'donor_firstname', sanitize_text_field($_POST['donor_firstname']), true); add_post_meta($post_id, 'donor_lastname', sanitize_text_field($_POST['donor_lastname']), true); add_post_meta($post_id, 'donor_email', sanitize_text_field($_POST['donor_email']), true); add_post_meta($post_id, 'donation_amount', sanitize_text_field($_POST['donation_amount']), true); add_post_meta($post_id, 'transaction_id', sanitize_text_field($transaction_id), true); add_post_meta($post_id, 'last_4', sanitize_text_field($last_4), true); add_post_meta($post_id, 'approval_code', sanitize_text_field($approval_code), true); $donation = true; } else if($response_array[0] =='2'){ $msg .= $response_array[3] ; } else{ $msg .= $response_array[3]; } } else{ } endif; if($msg != ''){ $html .= '
Settings saved.
Use shortcode [wds_donate]