Changeset 2094189
- Timestamp:
- 05/24/2019 01:05:08 AM (7 years ago)
- Location:
- pay-advantage/trunk
- Files:
-
- 16 edited
-
README.txt (modified) (2 diffs)
-
admin/html/options-html.php (modified) (1 diff)
-
admin/initialize-options.php (modified) (1 diff)
-
admin/js/options-page.js (modified) (3 diffs)
-
admin/options-ajax.php (modified) (3 diffs)
-
includes/class-payadvantage-deactivator.php (modified) (1 diff)
-
payadvantage.php (modified) (3 diffs)
-
public/html/bpay-tab-html.php (modified) (1 diff)
-
public/html/creditcard-tab-html.php (modified) (1 diff)
-
public/html/woocommerce-payment-fields-html.php (modified) (1 diff)
-
public/payadvantage-bpay-register-api-call.php (modified) (1 diff)
-
public/payadvantage-creditcard-ajax.php (modified) (1 diff)
-
public/payadvantage-creditcard.php (modified) (1 diff)
-
public/payadvantage-woocommerce.php (modified) (1 diff)
-
shared/payadvantage-api-error-handler.php (modified) (1 diff)
-
shared/payadvantage-auth.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pay-advantage/trunk/README.txt
r2044255 r2094189 4 4 Requires at least: 4.6 5 5 Tested up to: 5.1 6 Stable tag: 1.1.06 Stable tag: 2.0.0 7 7 Requires PHP: 5.2.4 8 8 License: GPLv2 or later … … 47 47 48 48 = 1.1.0 = 49 * Multiple updates, bug fixes and general imporovements. Please ensure you update to this version. 49 * Multiple updates, bug fixes and general improvements. Please ensure you update to this version. 50 51 = 2.0.0 = 52 * Multiple updates, settings page improvements. Please ensure you update to this version. -
pay-advantage/trunk/admin/html/options-html.php
r2017348 r2094189 31 31 <table class="form-table"> 32 32 <tbody> 33 <tr> 34 <th> 35 <label for="payAdvantageEnv">API Environment</label> 36 </th> 37 <td> 38 <input class="regular-text" type="radio" id="payAdvantageEnv" name="payAdvantageEnv" value="sandbox" <?php echo esc_attr( get_option('pay_advantage_env') ) != "live" ? "checked" : ""; ?>/> Sandbox 39 <input class="regular-text" type="radio" id="payAdvantageEnv" name="payAdvantageEnv" value="live" <?php echo esc_attr( get_option('pay_advantage_env') ) == "live" ? "checked" : ""; ?>/> Live 40 </td> 41 </tr> 33 42 <tr> 34 43 <th> -
pay-advantage/trunk/admin/initialize-options.php
r2040227 r2094189 6 6 // Creates columns in the database. 7 7 function pay_advantage_register_settings() { 8 add_option( 'pay_advantage_env', 'sandbox' ); 9 add_option( 'pay_advantage_url', '' ); 8 10 add_option( 'pay_advantage_user_name', '' ); 9 11 add_option( 'pay_advantage_password', '' ); -
pay-advantage/trunk/admin/js/options-page.js
r1946429 r2094189 6 6 e.preventDefault() 7 7 const anonymousPermission = $('#payAdvantageAnonymousPermission').prop('checked') 8 const env = $('#payAdvantageEnv:checked').val() 8 9 const username = $('#payAdvantageUsername').val() 9 10 const password = $('#payAdvantagePassword').val() … … 16 17 17 18 const payload = { 19 'payadvantageenv': env, 18 20 'payadvantageusername': username, 19 21 'payadvantagepassword': password, … … 66 68 const username = jQuery('#payAdvantageUsername').val() 67 69 const password = jQuery('#payAdvantagePassword').val() 70 const env = jQuery('#payAdvantageEnv:checked').val() 68 71 var payload = { 72 'payadvantageenv': env, 69 73 'payadvantageusername': username, 70 74 'payadvantagepassword': password 71 75 } 76 77 jQuery('#payAdvantageAuthCheck').text(''); 72 78 73 79 payAdvantageAjaxCall('pay_advantage_test_auth_action', payload) -
pay-advantage/trunk/admin/options-ajax.php
r2040227 r2094189 26 26 } 27 27 28 $env = sanitize_user( $_POST['payadvantageenv'] ); 28 29 $username = sanitize_user( $_POST['payadvantageusername'] ); 29 30 $password = wp_strip_all_tags( $_POST['payadvantagepassword'] ); … … 35 36 $anonymous_permission = filter_var( $_POST["payadvantageanonymouspermission"], FILTER_VALIDATE_BOOLEAN ) ? 1 : 0; 36 37 38 $url = $env == "live" ? PAYADV_API_URL_LIVE : PAYADV_API_URL_SANDBOX; 39 40 update_option( 'pay_advantage_url', $url ); 41 update_option( 'pay_advantage_env', $env ); 37 42 update_option( 'pay_advantage_user_name', $username ); 38 43 update_option( 'pay_advantage_password', $password ); … … 79 84 80 85 // TODO: Sanitize 86 $env = sanitize_user($_POST['payadvantageenv']); 81 87 $username = sanitize_user($_POST['payadvantageusername']); 82 88 $password = wp_strip_all_tags( $_POST['payadvantagepassword'] ); 83 89 84 90 $auth_data = array( 85 'grant_type' => "password",86 91 'username' => $username, 87 92 'password' => $password 88 93 ); 89 $return_data = $auth->get_auth_token( json_encode( $auth_data ) ); 94 95 $url = $env == "live" ? PAYADV_API_URL_LIVE : PAYADV_API_URL_SANDBOX; 96 $return_data = $auth->get_auth_token( $auth_data, $url ); 90 97 91 98 if (!isset($return_data['ErrorMessages'])) { -
pay-advantage/trunk/includes/class-payadvantage-deactivator.php
r1946429 r2094189 14 14 */ 15 15 public static function deactivate() { 16 delete_option( 'pay_advantage_env' ); 17 delete_option( 'pay_advantage_url' ); 16 18 delete_option( 'pay_advantage_user_name' ); 17 19 delete_option( 'pay_advantage_password' ); -
pay-advantage/trunk/payadvantage.php
r2040278 r2094189 16 16 * Plugin URI: https://www.payadvantage.com.au/ 17 17 * Description: This plugin adds a payment gateway to woo commerce as well as a widget for credit card and BPay donations. 18 * Version: 1.1.018 * Version: 2.0.0 19 19 * Author: Pay Advantage 20 * Author URI: https://www.payadvantage.com.au/20 * Author URI: ben.m@payadvantage.com 21 21 * License: GPL-2.0+ 22 22 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 25 25 */ 26 26 27 28 29 27 /** 30 28 * Currently plugin version. … … 32 30 * Rename this for your plugin and update it as you release new versions. 33 31 */ 34 define( 'PayAdvantage', ' 1.1.0' );32 define( 'PayAdvantage', '2.0.0' ); 35 33 36 34 include( plugin_dir_path( __FILE__ ) . '/includes/payadvantage-files.php'); 37 35 38 36 // Constants 39 define( 'PAYADV_API_URL', 'https://api.payadvantage.com.au/latest' ); 37 define( 'PAYADV_APP_ID', 'wp-payadv' ); 38 define( 'PAYADV_API_URL_SANDBOX', 'https://api.test.payadvantage.com.au/latest' ); 39 define( 'PAYADV_API_URL_LIVE', 'https://api.payadvantage.com.au/latest' ); 40 40 define( 'PAYADV_OPTIONS_REQUIRE_MOBILE', 1 ); 41 41 define( 'PAYADV_OPTIONS_REQUIRE_ADDRESS', 0 ); -
pay-advantage/trunk/public/html/bpay-tab-html.php
r2040227 r2094189 29 29 </div> 30 30 </div> 31 32 <?php if (esc_attr(get_option('pay_advantage_env')) != "live"):?> 33 <h4 style="color:red">Sandbox environment</h4> 34 <?php endif;?> 31 35 32 36 <p> -
pay-advantage/trunk/public/html/creditcard-tab-html.php
r2040227 r2094189 20 20 </div> 21 21 </div> 22 22 <?php if (esc_attr(get_option('pay_advantage_env')) != "live"):?> 23 <h4 style="color:red">Sandbox environment</h4> 24 <?php endif;?> 23 25 <h4> 24 26 A bit about you -
pay-advantage/trunk/public/html/woocommerce-payment-fields-html.php
r2040227 r2094189 9 9 function pay_advantage_woocommerce_payment_fields() { 10 10 ?> 11 <?php if (esc_attr(get_option('pay_advantage_env')) != "live"):?> 12 <h4 style="color:red">Sandbox environment</h4> 13 <?php endif;?> 11 14 <p class="form-row validation-required"> 12 15 <label for="payAdvantageCardHoldersName">Card Holders Name <span class="required">*</span></label> -
pay-advantage/trunk/public/payadvantage-bpay-register-api-call.php
r2040227 r2094189 3 3 * Calls the BPay registration api 4 4 */ 5 include_once( plugin_dir_path( __FILE__ ) . '../shared/payadvantage-result-processor.php');5 include_once(plugin_dir_path(__FILE__) . '../shared/payadvantage-result-processor.php'); 6 6 7 function pay_advantage_api_call( $json_data ) { 8 $result_processor = new Pay_Advantage_Result_Processor(); 9 $auth_provider = new Pay_Advantage_Auth(); 10 $token = $auth_provider->get_auth_token( null ); 11 12 if (isset($token['ErrorMessages']) > 0) 13 return $token; 14 15 $access_token = $token['access_token']; 7 function pay_advantage_api_call($json_data) 8 { 9 $result_processor = new Pay_Advantage_Result_Processor(); 10 $auth_provider = new Pay_Advantage_Auth(); 11 $token = $auth_provider->get_auth_token(null, null); 16 12 17 $url = PAYADV_API_URL . '/customers?with=bpayref'; 18 $body = $json_data; 19 $data = array( 20 'headers' => array( 21 'Content-Type' => 'application/json', 22 'Expect' => '', 23 'Authorization' => "Bearer $access_token" 24 ), 25 'body' => $body 26 ); 27 $response = wp_remote_post( $url, $data ); 13 if (isset($token['ErrorMessages']) > 0) 14 return $token; 28 15 29 return $result_processor->process_result( $response, 'BPay Registration', 'bpay' ); 16 $access_token = $token['access_token']; 17 18 $url = get_option('pay_advantage_url') . '/customers?with=bpayref'; 19 $body = $json_data; 20 $data = array( 21 'headers' => array( 22 'Content-Type' => 'application/json', 23 'Expect' => '', 24 'Authorization' => "Bearer $access_token" 25 ), 26 'body' => $body, 27 'timeout' => 30 // Bpay reference with the prefix option take more time to be generated 28 ); 29 $response = wp_remote_post($url, $data); 30 31 return $result_processor->process_result($response, 'BPay Registration', 'bpay'); 30 32 } 31 32 ?> -
pay-advantage/trunk/public/payadvantage-creditcard-ajax.php
r1946429 r2094189 39 39 40 40 $payment_result = $credit_card_payment->process_credit_card_payment( 41 null,42 41 $billing_data, 43 42 sanitize_text_field( $_POST['payadvantageamount'] ), -
pay-advantage/trunk/public/payadvantage-creditcard.php
r2040227 r2094189 4 4 */ 5 5 6 include_once( plugin_dir_path( __FILE__ ) . '/payadvantage-json-converter.php');7 include_once( plugin_dir_path( __FILE__ ) . '/payadvantage-validator.php');8 include_once( plugin_dir_path( __FILE__ ) . '../shared/payadvantage-result-processor.php');6 include_once(plugin_dir_path(__FILE__) . '/payadvantage-json-converter.php'); 7 include_once(plugin_dir_path(__FILE__) . '/payadvantage-validator.php'); 8 include_once(plugin_dir_path(__FILE__) . '../shared/payadvantage-result-processor.php'); 9 9 10 class Pay_Advantage_Credit_Card_Payment 11 { 10 12 11 class Pay_Advantage_Credit_Card_Payment { 13 protected $pay_advantage_url = ''; 14 protected $access_token = ''; 12 15 13 protected $pay_advantage_url = ''; 14 protected $access_token = ''; 15 16 /** 17 * This method orchestrates the credit card payments, 18 */ 19 public function process_credit_card_payment( $auth, $billing_data, $amount, $description ) { 20 $json_converter = new Pay_Advantage_Json_Converter(); 21 $auth_provider = new Pay_Advantage_Auth(); 22 $this->pay_advantage_url = PAYADV_API_URL; 23 $token = $auth_provider->get_auth_token( $auth ); 24 25 if (isset($token['ErrorMessages']) > 0) 26 return $token; 27 28 $this->access_token = $token['access_token']; 16 /** 17 * This method orchestrates the credit card payments, 18 */ 19 public function process_credit_card_payment($billing_data, $amount, $description) 20 { 21 $json_converter = new Pay_Advantage_Json_Converter(); 22 $auth_provider = new Pay_Advantage_Auth(); 23 $this->pay_advantage_url = get_option('pay_advantage_url'); 24 $token = $auth_provider->get_auth_token(null, null); 29 25 30 $customer_code = $this->get_customer_code( $billing_data ); 31 if ( isset( $existing_customer['ErrorMessages'] ) ) { 32 return $customer_code; 33 } 34 35 $json_credit_card_token_request = $json_converter->create_credit_card_token_json( $customer_code ); 36 $credit_card_token = $this->create_token_for_credit_card( $json_credit_card_token_request ); 26 if (isset($token['ErrorMessages']) > 0) 27 return $token; 37 28 38 if ( isset( $credit_card_token['ErrorMessages'] ) ) { 39 return $credit_card_token; 40 } 29 $this->access_token = $token['access_token']; 41 30 42 $json_charge = $json_converter->create_payment_credit_card_charge_json( $amount, $description ); 43 $payment_result = $this->charge_credit_card( $credit_card_token['Code'], $json_charge ); 44 return $payment_result; 45 } 46 47 /** 48 * Gets the customer code, creates the customer if it has to or returns an error. 49 */ 50 private function get_customer_code( $billing_data ) { 51 $json_converter = new Pay_Advantage_Json_Converter(); 52 $query_customer_result = $this->customer_query_api_call( 53 $billing_data['email'], 54 $billing_data['first_name'], 55 $billing_data['last_name'] 56 ); 57 if ( isset( $query_customer_result['ErrorMessages'] ) ) { 58 return $query_customer_result; 59 } 60 61 $existing_customer = $query_customer_result['Records']; 62 63 if ( $existing_customer == array() ) { 64 $json_customer = $json_converter->create_customer_json( $billing_data ); 65 $customer = $this->create_customer_for_credit_card_payment( $json_customer ); 66 67 if ( isset( $existing_customer['ErrorMessages'] ) ) { 68 return $existing_customer; 69 } 70 71 return $customer_code = $customer['Code']; 72 } else { 73 return $customer_code = $existing_customer[0]['Code']; 74 } 31 $customer_code = $this->get_customer_code($billing_data); 32 if (isset($customer_code['ErrorMessages'])) { 33 return $customer_code; 75 34 } 76 35 77 /** 78 * Queries the customer to see if their existing. 79 */ 80 private function customer_query_api_call( $email, $first_name, $last_name ) { 81 $result_processor = new Pay_Advantage_Result_Processor(); 82 $url = "$this->pay_advantage_url/customers?email=$email&firstname=$first_name&lastname=$last_name"; 83 $headers = array( 84 'headers' => array( 85 'Content-Type' => 'application/json', 86 'Authorization' => "Bearer $this->access_token" 87 ) 88 ); 36 $json_credit_card_token_request = $json_converter->create_credit_card_token_json($customer_code); 37 $credit_card_token = $this->create_token_for_credit_card($json_credit_card_token_request); 89 38 90 $response = wp_remote_get( $url, $headers );91 return $result_processor->process_result( $response, 'Query', 'creditcard' );39 if (isset($credit_card_token['ErrorMessages'])) { 40 return $credit_card_token; 92 41 } 93 42 94 /** 95 * Creates customer 96 */ 97 private function create_customer_for_credit_card_payment( $json_customer ) { 98 $result_processor = new Pay_Advantage_Result_Processor(); 99 $json_converter = new Pay_Advantage_Json_Converter(); 100 $url = "$this->pay_advantage_url/customers"; 101 $data = array( 102 'headers' => array( 103 'Content-Type' => 'application/json', 104 'Expect' => '', 105 'Authorization' => "Bearer $this->access_token" 106 ), 107 'body' => $json_customer 108 ); 43 $json_charge = $json_converter->create_payment_credit_card_charge_json($amount, $description); 44 $payment_result = $this->charge_credit_card($credit_card_token['Code'], $json_charge); 45 return $payment_result; 46 } 109 47 110 $response = wp_remote_post( $url, $data ); 111 112 return $result_processor->process_result( $response, 'Query', 'creditcard' ); 48 /** 49 * Gets the customer code, creates the customer if it has to or returns an error. 50 */ 51 private function get_customer_code($billing_data) 52 { 53 $json_converter = new Pay_Advantage_Json_Converter(); 54 $query_customer_result = $this->customer_query_api_call( 55 $billing_data['email'], 56 $billing_data['first_name'], 57 $billing_data['last_name'] 58 ); 59 if (isset($query_customer_result['ErrorMessages'])) { 60 return $query_customer_result; 113 61 } 114 62 115 /** 116 * Hits api for Credit Card token 117 */ 118 private function create_token_for_credit_card( $json_card_info ) { 119 $result_processor = new Pay_Advantage_Result_Processor(); 120 $url = "$this->pay_advantage_url/credit_cards"; 121 $data = array( 122 'headers' => array( 123 'Content-Type' => 'application/json', 124 'Expect' => '', 125 'Authorization' => "Bearer $this->access_token" 126 ), 127 'body' => $json_card_info 128 ); 63 $existing_customer = $query_customer_result['Records']; 129 64 130 $response = wp_remote_post( $url, $data ); 65 if ($existing_customer == array()) { 66 $json_customer = $json_converter->create_customer_json($billing_data); 67 $customer = $this->create_customer_for_credit_card_payment($json_customer); 131 68 132 return $result_processor->process_result( $response, 'token', 'creditcard' ); 69 if (isset($customer['ErrorMessages'])) { 70 return $customer; 71 } 72 73 return $customer_code = $customer['Code']; 74 } else { 75 return $customer_code = $existing_customer[0]['Code']; 133 76 } 77 } 134 78 135 /** 136 * Sends the api call to charge the consumer. 137 */ 138 private function charge_credit_card( $credit_card_code, $charges_json ) { 139 $result_processor = new Pay_Advantage_Result_Processor(); 140 $url = "$this->pay_advantage_url/credit_cards/$credit_card_code/charges"; 141 $data = array( 142 'headers' => array( 143 'Content-Type' => 'application/json', 144 'Expect' => '', 145 'Authorization' => "Bearer $this->access_token" 146 ), 147 'body' => $charges_json 148 ); 79 /** 80 * Queries the customer to see if their existing. 81 */ 82 private function customer_query_api_call($email, $first_name, $last_name) 83 { 84 $result_processor = new Pay_Advantage_Result_Processor(); 85 $url = "$this->pay_advantage_url/customers?email=$email&firstname=$first_name&lastname=$last_name"; 86 $headers = array( 87 'headers' => array( 88 'Content-Type' => 'application/json', 89 'Authorization' => "Bearer $this->access_token" 90 ) 91 ); 149 92 150 $response = wp_remote_post( $url, $data ); 93 $response = wp_remote_get($url, $headers); 94 return $result_processor->process_result($response, 'Query', 'creditcard'); 95 } 151 96 152 return $result_processor->process_result( $response, 'charge', 'creditcard' ); 153 } 97 /** 98 * Creates customer 99 */ 100 private function create_customer_for_credit_card_payment($json_customer) 101 { 102 $result_processor = new Pay_Advantage_Result_Processor(); 103 $json_converter = new Pay_Advantage_Json_Converter(); 104 $url = "$this->pay_advantage_url/customers"; 105 $data = array( 106 'headers' => array( 107 'Content-Type' => 'application/json', 108 'Expect' => '', 109 'Authorization' => "Bearer $this->access_token" 110 ), 111 'body' => $json_customer 112 ); 113 114 $response = wp_remote_post($url, $data); 115 116 return $result_processor->process_result($response, 'Query', 'creditcard'); 117 } 118 119 /** 120 * Hits api for Credit Card token 121 */ 122 private function create_token_for_credit_card($json_card_info) 123 { 124 $result_processor = new Pay_Advantage_Result_Processor(); 125 $url = "$this->pay_advantage_url/credit_cards"; 126 $data = array( 127 'headers' => array( 128 'Content-Type' => 'application/json', 129 'Expect' => '', 130 'Authorization' => "Bearer $this->access_token" 131 ), 132 'body' => $json_card_info 133 ); 134 135 $response = wp_remote_post($url, $data); 136 137 return $result_processor->process_result($response, 'token', 'creditcard'); 138 } 139 140 /** 141 * Sends the api call to charge the consumer. 142 */ 143 private function charge_credit_card($credit_card_code, $charges_json) 144 { 145 $result_processor = new Pay_Advantage_Result_Processor(); 146 $url = "$this->pay_advantage_url/credit_cards/$credit_card_code/charges"; 147 $data = array( 148 'headers' => array( 149 'Content-Type' => 'application/json', 150 'Expect' => '', 151 'Authorization' => "Bearer $this->access_token" 152 ), 153 'body' => $charges_json 154 ); 155 156 $response = wp_remote_post($url, $data); 157 158 return $result_processor->process_result($response, 'charge', 'creditcard'); 159 } 154 160 } 155 156 ?> -
pay-advantage/trunk/public/payadvantage-woocommerce.php
r2017348 r2094189 140 140 private function process_credit_card_payment( $billing_data, $amount, $description ) { 141 141 $credit_card_api = new Pay_Advantage_Credit_Card_Payment(); 142 $auth_data = array(143 "grant_type" => "password",144 "username" => $this->api_username,145 "password" => $this->api_password146 );147 142 148 $result = $credit_card_api->process_credit_card_payment( json_encode( $auth_data ),$billing_data, $amount, $description );143 $result = $credit_card_api->process_credit_card_payment( $billing_data, $amount, $description ); 149 144 150 145 if ( isset( $result['ErrorMessages'] ) ) { -
pay-advantage/trunk/shared/payadvantage-api-error-handler.php
r2040227 r2094189 4 4 */ 5 5 6 class Pay_Advantage_Api_Error_Handler { 6 class Pay_Advantage_Api_Error_Handler 7 { 7 8 /** 8 9 * The main function that looks for errors and tries to spit out some generic ones. 9 */ 10 public function check_for_errors( $api_result, $type, $stage, $code ) { 11 if ( $api_result == null || $code == 404 ) { 12 return '{"type":"' . $type . '", "ErrorMessages":["Error communicating with PayAdvantage."] , "console":"' . $stage . '"}'; 10 */ 11 public function check_for_errors($api_result, $type, $stage, $code) 12 { 13 if ($api_result == null || $code == 404) { 14 return '{"type":"' . $type . '", "ErrorMessages":["Error communicating with PayAdvantage."] , "console":"' . $stage . '"}'; 13 15 } 14 16 15 if ( $code >=500) {17 if ($code > 500) { 16 18 return '{"type":"' . $type . '", "ErrorMessages":["Internal Error has occurred."] , "console":"' . $stage . '"}'; 17 19 } 18 20 19 $json_api_response = json_decode( $api_result, 1);21 $json_api_response = json_decode($api_result, 1); 20 22 21 if ( isset( $json_api_response['ErrorCode']) && (isset($json_api_response['Messages']) || isset($json_api_response['message']))) {22 return '{"type":"' . $type . '", "ErrorMessages":["' . "(" . sanitize_text_field($json_api_response['ErrorCode']) . ") " . sanitize_text_field( $json_api_response['Messages'][0]) . '"] , "console":"' . $stage . '"}';23 if (isset($json_api_response['ErrorCode']) && (isset($json_api_response['Messages']) || isset($json_api_response['message']))) { 24 return '{"type":"' . $type . '", "ErrorMessages":["' . "(" . sanitize_text_field($json_api_response['ErrorCode']) . ") " . sanitize_text_field($json_api_response['Messages'][0]) . '"] , "console":"' . $stage . '"}'; 23 25 } 24 26 25 27 return '{"type":"' . $type . '", "ErrorMessages":["Internal Error has occurred."] , "console":"' . $stage . '"}'; 26 28 } 27 29 28 30 /** 29 31 * Logs to the options page errors that come through 30 32 */ 31 public function log_error( $response ) { 32 $current_log = get_option( 'pay_advantage_error_logging' ); 33 if ( $current_log == 0 ) { 34 $current_log = gmdate( 'Y-m-d\TH:i:s\Z' ) . ': ' . sanitize_text_field( $response ) . ' '; 33 public function log_error($response) 34 { 35 $current_log = get_option('pay_advantage_error_logging'); 36 if ($current_log == 0) { 37 $current_log = gmdate('Y-m-d\TH:i:s\Z') . ': ' . sanitize_text_field($response) . ' '; 35 38 } else { 36 $current_log = gmdate('Y-m-d\TH:i:s\Z') . ': ' . sanitize_text_field( $response ) . ' ' . sanitize_text_field( $current_log);39 $current_log = gmdate('Y-m-d\TH:i:s\Z') . ': ' . sanitize_text_field($response) . ' ' . sanitize_text_field($current_log); 37 40 } 38 39 if ( strlen( $current_log ) > PAYADV_MAX_LOG_SIZE_CHARS) {40 $current_log = substr( $current_log , 0, PAYADV_MAX_LOG_SIZE_CHARS);41 42 if (strlen($current_log) > PAYADV_MAX_LOG_SIZE_CHARS) { 43 $current_log = substr($current_log, 0, PAYADV_MAX_LOG_SIZE_CHARS); 41 44 } 42 update_option( 'pay_advantage_error_logging', $current_log);45 update_option('pay_advantage_error_logging', $current_log); 43 46 } 44 47 } 45 46 ?> -
pay-advantage/trunk/shared/payadvantage-auth.php
r2040227 r2094189 12 12 $username = sanitize_user( get_option( 'pay_advantage_user_name' ) ); 13 13 $password = wp_strip_all_tags ( get_option( 'pay_advantage_password' ) ); 14 return '{ 15 "grant_type" :"password", 16 "username" :"'.$username.'", 17 "password" :"'.$password.'" 18 }'; 14 return array( 15 "username" => $username, 16 "password" => $password 17 ); 19 18 } 20 19 … … 22 21 * Used to get auth token from the server. 23 22 */ 24 public function get_auth_token( $auth_data )23 public function get_auth_token( $auth_data, $url ) 25 24 { 26 25 $result_processor = new Pay_Advantage_Result_Processor(); … … 30 29 } 31 30 32 $url = PAYADV_API_URL . '/token'; 31 $auth["appId"] = PAYADV_APP_ID; 32 33 if(empty($url)) { 34 $url = get_option('pay_advantage_url'); 35 } 36 37 $url .= '/app-token'; 33 38 $data = array( 34 39 'headers' => array( … … 36 41 'Expect' => '' 37 42 ), 38 'body' => $auth43 'body' => json_encode($auth) 39 44 ); 40 45 $response = wp_remote_post( $url, $data );
Note: See TracChangeset
for help on using the changeset viewer.