Changeset 3211366
- Timestamp:
- 12/21/2024 04:43:52 AM (12 months ago)
- Location:
- profiler-donations-gravityforms
- Files:
-
- 9 edited
- 23 copied
-
tags/2.5.0 (copied) (copied from profiler-donations-gravityforms/trunk)
-
tags/2.5.0/LICENSE.md (copied) (copied from profiler-donations-gravityforms/trunk/LICENSE.md)
-
tags/2.5.0/README.md (copied) (copied from profiler-donations-gravityforms/trunk/README.md) (1 diff)
-
tags/2.5.0/cacert.pem (copied) (copied from profiler-donations-gravityforms/trunk/cacert.pem)
-
tags/2.5.0/cardprocess.js (copied) (copied from profiler-donations-gravityforms/trunk/cardprocess.js)
-
tags/2.5.0/cardprocess.php (copied) (copied from profiler-donations-gravityforms/trunk/cardprocess.php)
-
tags/2.5.0/class-profilercommon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilercommon.php) (21 diffs)
-
tags/2.5.0/class-profilerdonate-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerdonate-gfaddon.php) (27 diffs)
-
tags/2.5.0/class-profilerevents-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerevents-gfaddon.php)
-
tags/2.5.0/class-profilerinteraction-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerinteraction-gfaddon.php)
-
tags/2.5.0/class-profilerlists-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerlists-gfaddon.php)
-
tags/2.5.0/class-profilerlistsbasic-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerlistsbasic-gfaddon.php)
-
tags/2.5.0/class-profilermembership-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilermembership-gfaddon.php) (2 diffs)
-
tags/2.5.0/class-profilerpostdonate-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerpostdonate-gfaddon.php) (6 diffs)
-
tags/2.5.0/class-profilerupdate-gfaddon.php (copied) (copied from profiler-donations-gravityforms/trunk/class-profilerupdate-gfaddon.php)
-
tags/2.5.0/index.php (copied) (copied from profiler-donations-gravityforms/trunk/index.php) (2 diffs)
-
tags/2.5.0/readme.txt (copied) (copied from profiler-donations-gravityforms/trunk/readme.txt) (1 diff)
-
tags/2.5.0/shortcodes.php (copied) (copied from profiler-donations-gravityforms/trunk/shortcodes.php)
-
tags/2.5.0/states_australia.php (copied) (copied from profiler-donations-gravityforms/trunk/states_australia.php)
-
tags/2.5.0/sync_orgtype.php (copied) (copied from profiler-donations-gravityforms/trunk/sync_orgtype.php)
-
tags/2.5.0/sync_users.php (copied) (copied from profiler-donations-gravityforms/trunk/sync_users.php) (1 diff)
-
tags/2.5.0/woocommerce (copied) (copied from profiler-donations-gravityforms/trunk/woocommerce)
-
tags/2.5.0/woocommerce/integration.php (copied) (copied from profiler-donations-gravityforms/trunk/woocommerce/integration.php) (8 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/class-profilercommon.php (modified) (21 diffs)
-
trunk/class-profilerdonate-gfaddon.php (modified) (27 diffs)
-
trunk/class-profilermembership-gfaddon.php (modified) (2 diffs)
-
trunk/class-profilerpostdonate-gfaddon.php (modified) (6 diffs)
-
trunk/index.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/sync_users.php (modified) (1 diff)
-
trunk/woocommerce/integration.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
profiler-donations-gravityforms/tags/2.5.0/README.md
r2698068 r3211366 15 15 * [Gravity Forms](http://www.gravityforms.com) 16 16 * Payment Gateway integration with Gravity Forms (must be pre-existing and use standard Gravity Forms payment hooks and database fields) 17 * For Australian non-profits, we recommend the official Gravity Forms Stripe plugin17 * We recommend the official Gravity Forms Stripe plugin 18 18 * Full administrative access to Profiler 19 19 * CURL and XML Enabled on Web Server -
profiler-donations-gravityforms/tags/2.5.0/class-profilercommon.php
r3136560 r3211366 7 7 protected $_title = "Profiler / Gravity Forms - Integration Feed"; 8 8 9 protected $api_type = "form"; // form or json 10 protected $api_domain = "profilersystem.com"; 9 11 protected $apifield_apikey = "apikey"; 10 12 protected $apifield_apipass = "apipass"; … … 27 29 add_filter('gform_stripe_charge_description', array($this, 'stripe_payment_description'), 10, 5); 28 30 add_filter('gform_stripe_payment_element_initial_payment_information', array($this, 'stripe_elements_setup'), 10, 3); 29 } 31 32 // Metabox for Profiler Logs 33 add_filter('gform_entry_detail_meta_boxes', array($this, 'meta_box_entry'), 10, 3); 34 } 35 36 public function get_menu_icon() { 37 //return 'dashicons-admin-generic'; 38 return plugins_url('icon-profiler.png', __FILE__); 39 } 30 40 31 41 public function feed_settings_fields() { … … 65 75 "name" => "profiler".$this->gffield_legacyname."_instancedomainname", 66 76 "required" => true, 67 "tooltip" => "Your Instance Domain Name can be found in your login URL: e.g. 'https://instance.profiler.net.au/' is 'instance.profiler.net.au'", 68 ); 69 70 $fields[] = array( 71 "label" => 'Profiler Database Name', 72 "type" => "text", 73 "name" => "profiler".$this->gffield_legacyname."_dbname", 74 "required" => true, 75 ); 77 "tooltip" => "Your Instance Domain Name can be found in your login URL: e.g. 'https://instance.profilersystem.com/' is 'instance.profilesystem.com'", 78 ); 79 80 if($this->api_type !== 'json') { 81 $fields[] = array( 82 "label" => 'Profiler Database Name', 83 "type" => "text", 84 "name" => "profiler".$this->gffield_legacyname."_dbname", 85 "required" => true, 86 ); 87 } 76 88 77 89 $fields[] = array( … … 138 150 // Loop over mailing list fields 139 151 152 if($this->api_type !== 'json') { 153 $fields[] = array( 154 "label" => 'Mailing List #'.$i.': UDF', 155 "type" => "select", 156 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf", 157 "required" => false, 158 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing", 159 "choices" => $userdefinedfields, 160 ); 161 } 162 140 163 $fields[] = array( 141 "label" => 'Mailing List #'.$i.': UDF', 142 "type" => "select", 143 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf", 144 "required" => false, 145 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing", 146 "choices" => $userdefinedfields, 147 ); 148 149 $fields[] = array( 150 "label" => 'Mailing List #'.$i.': UDF Text', 164 "label" => ($this->api_type == 'json' ? 'Mailing List #'.$i.': Mailing Type Code' : 'Mailing List #'.$i.': UDF Text'), 151 165 "type" => "text", 152 166 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext", 153 167 "required" => false, 154 "tooltip" => "Enter the string Profiler is expecting in this UDF",168 "tooltip" => ($this->api_type == 'json' ? "Enter the Profiler Mailing Type Code" : "Enter the string Profiler is expecting in this UDF") . ". This field also accept post meta merge fields in this format: {postmeta:meta_field_name}", 155 169 ); 156 170 157 171 $fields[] = array( 158 172 "label" => 'Mailing List #'.$i.': Field', … … 161 175 "tooltip" => 'Link it to a checkbox field - when checked, the mailing will be sent', 162 176 "required" => false, 163 "choices" => $checkboxFields177 "choices" => array_merge($checkboxRadioFields, array(array("value" => "always", "label" => "Always Subscribe"))), 164 178 ); 165 179 } … … 203 217 204 218 $fields[] = array( 205 "label" => 'Profiler Logs',206 "type" => "select",207 "name" => "profiler".$this->gffield_legacyname."_logs",208 "tooltip" => 'Link it to a Hidden field that will hold Profiler Response Logs',209 "required" => false,210 "choices" => $hiddenFields211 );212 213 $fields[] = array(214 219 "label" => 'SSL Mode', 215 220 "type" => "select", … … 259 264 $postData = array(); 260 265 261 $postData['DB'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_dbname']; 266 if($this->api_type !== 'json') { 267 $postData['DB'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_dbname']; 268 } 262 269 $postData[$this->apifield_apikey] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apikey']; 263 270 $postData[$this->apifield_apipass] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apipass']; … … 265 272 if(empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname']) && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'])) { 266 273 // Respect the setting from when we only accepted the first part of the domain name 267 $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'] . ".profiler .net.au";274 $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'] . ".profilersystem.com"; 268 275 } 269 276 … … 282 289 if(isset($field['pf_apifield']) && $this->get_field_value($form, $entry, $feed['meta'][$field['name']]) != '') { 283 290 $postData[$field['pf_apifield']] = trim($this->get_field_value($form, $entry, $feed['meta'][$field['name']])); 291 292 // Auto formatting for phone fields 293 if(isset($field['auto_format']) && $field['auto_format'] == "phone") { 294 $postData[$field['pf_apifield']] = $this->auto_format_phone($postData[$field['pf_apifield']]); 295 } 284 296 } 285 297 } … … 301 313 if($this->apifield_formurl === true && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl'])) { 302 314 $postData['userdefined' . $feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl']] = $entry['source_url']; 315 } else if($this->apifield_formurl !== false) { 316 $postData[$this->apifield_formurl] = $entry['source_url']; 303 317 } 304 318 … … 322 336 } 323 337 324 if( $feed['meta']['profilerdonation_userdefined_gatewaycustomerid'] !== "" &&isset($payment_intent)) {338 if(isset($payment_intent)) { 325 339 // Gateway Customer ID 326 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycustomerid']] = $payment_intent->customer;327 } 328 329 if( $feed['meta']['profilerdonation_userdefined_gatewaycardtoken'] !== "" &&isset($payment_intent)) {340 $postData['paymentGatewayCustomerId'] = $payment_intent->customer; 341 } 342 343 if(isset($payment_intent)) { 330 344 // Gateway Card Token 331 345 try { 332 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycardtoken']] = $payment_intent->charges->data[0]->payment_method;346 $postData['gatewayCardToken'] = $payment_intent->charges->data[0]->payment_method; 333 347 } catch(Exception $e) { 334 348 error_log("STRIPE/PROFILER CARD TOKEN ERROR: " . print_r($e, true)); … … 338 352 339 353 // PayFURL-supplied Gateway Token 340 if( $feed['meta']['profilerdonation_userdefined_gatewaycardtoken'] !== "" &&isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider'])) {354 if(isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider'])) { 341 355 $payfurl_provider_token = $_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider']; 342 356 343 357 if(!empty($payfurl_provider_token)) { 344 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycardtoken']] = $payfurl_provider_token;358 $postData['gatewayCardToken'] = $payfurl_provider_token; 345 359 } 346 360 } … … 349 363 if($this->supports_custom_fields === true && !empty($feed['meta']['profiler_customfields_count'])) { 350 364 for($i = 1; $i <= $feed['meta']['profiler_customfields_count']; $i++) { 351 $postData["userdefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"])); 365 366 $value = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"])); 367 368 if($this->api_type == 'json') { 369 if(!isset($postData['userDefinedFields'])) { 370 $postData['userDefinedFields'] = array(); 371 } 372 373 $postData['userDefinedFields']["userDefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = $value; 374 375 } else { 376 $postData["userdefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = $value; 377 } 378 379 352 380 } 353 381 } … … 358 386 // Loop over mailing list fields 359 387 $mailingFieldValue = $this->get_field_value($form, $entry, $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"]); 360 $udf = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf"];361 388 $udfText = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext"]; 362 389 363 if(!empty($udf) && !empty($udfText) && !empty($mailingFieldValue)) { 364 $postData['userdefined' . $udf] = $udfText; 365 } 366 390 // Allow merging post meta fields into $udfText 391 if(isset($entry['post_id']) && !empty($entry['post_id'])) { 392 $post_id = $entry['post_id']; 393 } else { 394 global $post; 395 if(isset($post)) { 396 $post_id = $post->ID; 397 } 398 } 399 400 if(isset($post_id)) { 401 preg_match_all("/{postmeta:(.*?)}/", $udfText, $matches); 402 403 if(is_array($matches) && isset($matches[1])) { 404 foreach($matches[1] as $match) { 405 $post_meta = get_post_meta($post_id, $match, true); 406 $udfText = str_replace("{postmeta:".$match."}", $post_meta, $udfText); 407 } 408 } 409 } 410 411 if($this->api_type == 'json') { 412 413 if(!isset($postData['mailingList'])) { 414 $postData['mailingList'] = ''; 415 } 416 417 if(!empty($udfText) && (!empty($mailingFieldValue) || $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"] == 'always')) { 418 $postData['mailingList'] .= (!empty($postData['mailingList']) ? ',' : '') . $udfText; 419 } 420 421 } else { 422 $udf = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf"]; 423 424 if(!empty($udf) && !empty($udfText) && (!empty($mailingFieldValue) || $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"] == 'always')) { 425 $postData['userdefined' . $udf] = $udfText; 426 } 427 } 367 428 } 368 429 } … … 386 447 $postData = apply_filters('profiler_integration_api_request_data', $postData, $form, $entry, $this->apifield_endpoint); 387 448 449 // Update URL for newer APIs 450 if($this->api_domain !== 'profilersystem.com') { 451 $API_URL = str_replace(".profilersystem.com", "." . $this->api_domain, $API_URL); 452 } 453 388 454 // Send data to Profiler 389 455 $pfResponse = $this->sendDataToProfiler($API_URL, $postData, $feed['meta']['profiler'.$this->gffield_legacyname.'_sslmode']); … … 391 457 if($fromValidatorProcessPFGateway === false) { 392 458 // Save Profiler response data back to the form entry 393 $logsToStore = json_encode($pfResponse );459 $logsToStore = json_encode($pfResponse, JSON_PRETTY_PRINT); 394 460 $logsToStore = str_replace($postData['cardnumber'], "--REDACTED--", $logsToStore); 395 461 $logsToStore = str_replace($postData[$this->apifield_apikey], "--REDACTED--", $logsToStore); 396 462 $logsToStore = str_replace($postData[$this->apifield_apipass], "--REDACTED--", $logsToStore); 397 $entry[$feed['meta']['profiler'.$this->gffield_legacyname.'_logs']] = htmlentities($logsToStore); 398 GFAPI::update_entry($entry); 463 gform_add_meta($entry["id"], "profiler_logs", $logsToStore, $form['id']); 399 464 400 465 if(method_exists($this, 'process_feed_success')) { 401 466 $this->process_feed_success($feed, $entry, $form, $pfResponse, $postData); 402 } 467 } 468 403 469 } else { 404 470 return $pfResponse; … … 651 717 } 652 718 719 if(isset($profiler_query['DB'])) { 720 $url .= '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit')); 721 } 722 653 723 $ch = curl_init(); 654 curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit'))); 724 curl_setopt($ch, CURLOPT_URL, $url); 725 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 655 726 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 656 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query)))); 657 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($profiler_query)); 658 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 659 727 660 728 if($ssl_mode == "bundled_ca") { 661 729 // Use the CA Cert bundled with this plugin … … 669 737 } 670 738 739 if($this->api_type === 'json') { 740 // JSON POST 741 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($profiler_query)); 742 curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 743 744 } else { 745 // FORM POST 746 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query)))); 747 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($profiler_query)); 748 } 749 671 750 $result = curl_exec($ch); 672 751 $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 673 752 674 753 if(curl_error($ch)) { 675 754 $cURL_error = curl_error($ch); … … 677 756 $cURL_error = null; 678 757 } 679 758 680 759 curl_close($ch); 681 760 761 if($this->api_type === 'json') { 762 $data_decoded = json_decode($result, true); 763 } else { 764 $data_decoded = json_decode(json_encode((array)simplexml_load_string($result)), true); 765 } 766 682 767 return array( 683 768 "httpstatus" => $status_code, 769 "url" => $url, 684 770 "dataSent" => $profiler_query, 685 771 "data" => $result, 686 "dataXML" => simplexml_load_string($result), 687 "dataArray" => json_decode(json_encode((array)simplexml_load_string($result)), 1), 772 "dataArray" => $data_decoded, 688 773 "cURLError" => $cURL_error, 689 774 "cURL_SSL_Mode" => $ssl_mode, 775 "api_type" => $this->api_type, 690 776 ); 691 777 } … … 707 793 708 794 foreach($pfResponse['dataSent'] as $key => $val) { 709 if($key == "apikey" || $key == "apipass" || $key == " cardnumber" || $key == "api_user" || $key == "api_pass" || $key == $this->apifield_apikey || $key == $this->apifield_apipass) {795 if($key == "apikey" || $key == "apipass" || $key == "apipassword" || $key == "cardnumber" || $key == "api_user" || $key == "api_pass" || $key == $this->apifield_apikey || $key == $this->apifield_apipass) { 710 796 $val = "--REDACTED--"; 711 797 } … … 1023 1109 1024 1110 } 1111 1112 public function meta_box_entry($meta_boxes, $entry, $form) { 1113 // Custom Metabox 1114 1115 if($this->get_active_feeds($form['id'])) { 1116 1117 $profiler_logs_meta = gform_get_meta($entry['id'], 'profiler_logs'); 1118 1119 if(!empty($profiler_logs_meta)) { 1120 $meta_boxes[$this->_slug] = array( 1121 'title' => 'Profiler API', 1122 'callback' => array($this, 'meta_box_entry_render'), 1123 'context' => 'side', 1124 'callback_args' => array($entry, $form), 1125 ); 1126 } 1127 } 1128 1129 return $meta_boxes; 1130 } 1131 1132 public function meta_box_entry_render($data) { 1133 // Render the Custom Metabox 1134 $html = ''; 1135 1136 $meta_fields = array( 1137 "profiler_integrationid" => "Integration ID", 1138 "profiler_integration_guid" => "Integration GUID", 1139 "profiler_logs" => "Profiler API Logs", 1140 ); 1141 1142 foreach($meta_fields as $field_name => $field_title) { 1143 1144 $meta_value = gform_get_meta($data['entry']['id'], $field_name); 1145 1146 if(!empty($meta_value)) { 1147 $html .= '<p><strong>'.$field_title.'</strong>:<br /><pre style="width: 100%; overflow-x: scroll;">'.esc_html($meta_value).'</pre></p>'; 1148 } 1149 } 1150 1151 echo $html; 1152 } 1153 1154 private function auto_format_phone($phone_number_original) { 1155 // This function auto-formats a phone number into an Australian format (0000 000 000 or 00 0000 0000) 1156 1157 // Remove certain characters 1158 $phone_number = str_replace(array(" ", "-", "(", ")"), array("", "", "", ""), $phone_number_original); 1159 1160 // Remove +61 prefix 1161 if(substr($phone_number, 0, 3) == "+61") { 1162 $phone_number = substr($phone_number, 3); 1163 1164 if(strlen($phone_number) === 9) { 1165 $phone_number = "0" . $phone_number; 1166 } 1167 } 1168 1169 // International number. Return as-is 1170 if(substr($phone_number, 0, 1) == "+") { 1171 return $phone_number; 1172 } 1173 1174 // Probably an Australian number 1175 if(strlen($phone_number) == 10) { 1176 // 0000 000 000 1177 if(substr($phone_number, 0, 2) == "04") { 1178 $phone_number = substr($phone_number, 0, 4) . " " . substr($phone_number, 4, 3) . " " . substr($phone_number, 7); 1179 return $phone_number; 1180 } 1181 1182 // 00 0000 0000 1183 $phone_number = substr($phone_number, 0, 2) . " " . substr($phone_number, 2, 4) . " " . substr($phone_number, 6); 1184 return $phone_number; 1185 } 1186 1187 // Probably Australian landline with no area prefix 1188 if(strlen($phone_number) == 8) { 1189 // Adjust to 0000 0000 format 1190 $phone_number = substr($phone_number, 0, 4) . " " . substr($phone_number, 4); 1191 } 1192 1193 return $phone_number; 1194 } 1025 1195 } 1026 1196 -
profiler-donations-gravityforms/tags/2.5.0/class-profilerdonate-gfaddon.php
r3136560 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/Legacy/"; 13 protected $apifield_apikey = "apikey"; 14 protected $apifield_apipass = "apipass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "donation"; 18 20 protected $supports_custom_fields = true; … … 129 131 "required" => false, 130 132 "choices" => $field_settings, 131 "tooltip" => "The value of this field must be set to ' monthly' or 'yearly'. This field will be used if 'Donation Type' is set to 'regular'."133 "tooltip" => "The value of this field must be set to 'weekly', 'monthly' or 'yearly'. This field will be used if 'Donation Type' is set to 'regular'." 132 134 ); 133 135 … … 139 141 "choices" => $product_field_settings, 140 142 "tooltip" => "This amount field will be used if Donation Type is set to 'regular'.", 141 );142 143 $fields[] = array(144 "label" => 'UDF: Pledge Type ID',145 "type" => "select",146 "name" => "profilerdonation_userdefined_pledgetypeid",147 "required" => false,148 "tooltip" => "Pick the Profiler User Defined Field you wish the Pledge Type ID to be sent to",149 "choices" => $userdefinedfields,150 143 ); 151 144 … … 182 175 "required" => false, 183 176 "choices" => $field_settings, 184 "pf_apifield" => "first name",177 "pf_apifield" => "firstName", 185 178 ); 186 179 … … 193 186 "pf_apifield" => "surname", 194 187 ); 188 189 $fields[] = array( 190 "label" => 'Client: Gender', 191 "type" => "select", 192 "name" => "profilerdonation_clientgender", 193 "required" => false, 194 "choices" => $field_settings, 195 "pf_apifield" => "clientGender", 196 "tooltip" => "Gender values are defined in Profiler in Setup > Client > Gender.", 197 ); 195 198 196 199 $fields[] = array( … … 263 266 "required" => false, 264 267 "choices" => $field_settings, 265 "pf_apifield" => "phone ah",266 ); 267 268 "pf_apifield" => "phoneAH", 269 ); 270 268 271 $fields[] = array( 269 272 "label" => 'Client: Business Phone', … … 272 275 "required" => false, 273 276 "choices" => $field_settings, 274 "pf_apifield" => "phonebus", 275 ); 276 277 "pf_apifield" => "phoneBus", 278 "auto_format" => "phone", 279 ); 280 277 281 $fields[] = array( 278 282 "label" => 'Client: Mobile Phone', … … 281 285 "required" => false, 282 286 "choices" => $field_settings, 283 "pf_apifield" => "phonemobile", 284 ); 285 287 "pf_apifield" => "phoneMobile", 288 "auto_format" => "phone", 289 ); 290 291 $fields[] = array( 292 "label" => 'Client: Phone', 293 "type" => "select", 294 "name" => "profilerdonation_clientphonemobile", 295 "required" => false, 296 "choices" => $field_settings, 297 "pf_apifield" => "phoneMobile", 298 "auto_format" => "phone", 299 ); 300 286 301 $fields[] = array( 287 302 "label" => 'Client: Website', … … 323 338 "required" => false, 324 339 "choices" => $field_settings, 325 "pf_apifield" => "comments", 326 ); 327 328 $fields[] = array( 329 "label" => 'UDF: Receipt Name', 330 "type" => "select", 331 "name" => "profilerdonation_userdefined_receiptname", 332 "required" => false, 333 "tooltip" => "Pick the Profiler User Defined Field you wish the donation receipt name to be sent to", 334 "choices" => $userdefinedfields, 340 ); 341 342 $fields[] = array( 343 "label" => 'Extra Comments Text', 344 "type" => "textarea", 345 "name" => "profilerdonation_commentsextra", 346 "required" => false, 347 "class" => "merge-tag-support", 348 "tooltip" => "This is extra text to be sent to Profiler in the Comments field. Youc an include Gravity Forms Merge Fields in this textarea to accept additional user input.", 349 ); 350 351 $fields[] = array( 352 "label" => 'Interaction: Type', 353 "type" => "select", 354 "name" => "profilerdonation_interaction_type", 355 "required" => false, 356 "choices" => $field_settings, 357 "pf_apifield" => "interactionType", 358 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Type here, and your Interaction Text below. This is separate to the 'Comments' field above.", 359 ); 360 361 $fields[] = array( 362 "label" => 'Interaction: Text', 363 "type" => "select", 364 "name" => "profilerdonation_interaction_text", 365 "required" => false, 366 "choices" => $field_settings, 367 "pf_apifield" => "interactionText", 368 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text here, and your Interaction Type above. This is separate to the 'Comments' field above.", 369 ); 370 371 $fields[] = array( 372 "label" => 'Interaction: Tag', 373 "type" => "select", 374 "name" => "profilerdonation_interaction_tag", 375 "required" => false, 376 "choices" => $field_settings, 377 "pf_apifield" => "interactionTag", 378 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text and Interaction Type above, and your Interaction Tag here. This is separate to the 'Comments' field above.", 379 ); 380 381 $fields[] = array( 382 "label" => 'Interaction: Sub-Tag', 383 "type" => "select", 384 "name" => "profilerdonation_interaction_subtag", 385 "required" => false, 386 "choices" => $field_settings, 387 "pf_apifield" => "interactionSubTag", 388 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text and Interaction Type above, and your Interaction Sub-Tag here. This is separate to the 'Comments' field above.", 389 ); 390 391 $fields[] = array( 392 "label" => 'Role: Add Role By Role Name', 393 "type" => "select", 394 "name" => "profilerdonation_role_name", 395 "required" => false, 396 "choices" => $field_settings, 397 "pf_apifield" => "roleName", 398 "tooltip" => "If you wish to add a Role to a Client by Role Name, enter the Role Name here.", 399 ); 400 401 $fields[] = array( 402 "label" => 'Role: Add Role By Role ID', 403 "type" => "select", 404 "name" => "profilerdonation_role_id", 405 "required" => false, 406 "choices" => $field_settings, 407 "pf_apifield" => "roleId", 408 "tooltip" => "If you wish to add a Role to a Client by Role ID, enter the Role ID here.", 335 409 ); 336 410 … … 341 415 "required" => false, 342 416 "choices" => $field_settings, 343 ); 344 345 $fields[] = array( 346 "label" => 'UDF: Donation Source Code', 347 "type" => "select", 348 "name" => "profilerdonation_userdefined_sourcecode", 349 "required" => false, 350 "tooltip" => "Pick the Profiler User Defined Field you wish the donation source code to be sent to", 351 "choices" => $userdefinedfields, 352 ); 353 417 "pf_apifield" => "receiptName", 418 ); 419 354 420 $fields[] = array( 355 421 "label" => 'Donation Source Code - Default Value', … … 374 440 + self::$_instance->formFields("Form Field: "), 375 441 ); 376 377 $fields[] = array( 378 "label" => 'UDF: Pledge Source Code', 379 "type" => "select", 380 "name" => "profilerdonation_userdefined_pledgesourcecode", 381 "required" => false, 382 "tooltip" => "Pick the Profiler User Defined Field you wish the pledge source code to be sent to", 383 "choices" => $userdefinedfields, 384 ); 385 442 386 443 $fields[] = array( 387 444 "label" => 'Pledge Source Code - Default Value', … … 406 463 + self::$_instance->formFields("Form Field: "), 407 464 ); 408 409 $fields[] = array( 410 "label" => 'UDF: Pledge Acquisition Code', 411 "type" => "select", 412 "name" => "profilerdonation_userdefined_pledgeacquisitioncode", 413 "required" => false, 414 "tooltip" => "Pick the Profiler User Defined Field you wish the pledge acquisition code to be sent to", 415 "choices" => $userdefinedfields, 416 ); 417 465 418 466 $fields[] = array( 419 467 "label" => 'Pledge Acquisition Code - Default Value', … … 425 473 426 474 $fields[] = array( 427 "label" => 'UDF: Client Acquisition',428 "type" => "select",429 "name" => "profilerdonation_userdefined_clientacquisitioncode",430 "required" => false,431 "tooltip" => "Pick the Profiler User Defined Field you wish the client acquisition code to be sent to.",432 "choices" => $userdefinedfields,433 );434 435 $fields[] = array(436 475 "label" => 'Client Acquisition Field', 437 476 "type" => "select", … … 441 480 "choices" => $field_settings 442 481 ); 443 444 $fields[] = array(445 "label" => 'UDF: Donation Purpose',446 "type" => "select",447 "name" => "profilerdonation_userdefined_donationpurposecode",448 "required" => false,449 "tooltip" => "Pick the Profiler User Defined Field you wish the donation's purpose code to be sent to",450 "choices" => $userdefinedfields,451 );452 482 453 483 $fields[] = array( … … 461 491 462 492 $fields[] = array( 463 "label" => 'UDF: Donation Tag',464 "type" => "select",465 "name" => "profilerdonation_userdefined_donationtagcode",466 "required" => false,467 "tooltip" => "Pick the Profiler User Defined Field you wish the donation's tag code to be sent to. Do not set this up if you use Tag Automation within Profiler.",468 "choices" => $userdefinedfields,469 );470 471 $fields[] = array(472 493 "label" => 'Donation Tag Field', 473 494 "type" => "select", … … 479 500 480 501 $fields[] = array( 481 "label" => 'UDF: Client Preferred Contact Method', 482 "type" => "select", 483 "name" => "profilerdonation_userdefined_clientpreferredcontactmethod", 484 "required" => false, 485 "tooltip" => "Pick the Profiler User Defined Field you wish the client's preferred contact method to be sent to", 486 "choices" => $userdefinedfields, 487 ); 488 502 "label" => 'Interaction: Membership/Regular Mapping Text', 503 "type" => "select", 504 "name" => "profilerdonation_membership_mapping_text", 505 "required" => false, 506 "choices" => $field_settings, 507 "pf_apifield" => "membershipMappingText", 508 "tooltip" => "If you configure a 'Membership/Regular Type Map' in Profiler, you can use this field to perform the Mapping.", 509 ); 510 511 $fields[] = array( 512 "label" => 'Payment Split-Out Text', 513 "type" => "select", 514 "name" => "profilerdonation_payment_split_out_text", 515 "required" => false, 516 "choices" => $field_settings, 517 "pf_apifield" => "splitOutText", 518 "tooltip" => "In Profiler, you can setup a text mapping for a Split / Breakdown Payment. If configured, it uses the text in this field to perform the split. For example, a Payment comes in for 100 and split is setup in Profiler for word POSTAGE, the payment recorded in Profiler will have separate amounts for two source codes.", 519 ); 520 489 521 $fields[] = array( 490 522 "label" => 'Client Preferred Contact Method Field', … … 497 529 498 530 $fields[] = array( 499 "label" => 'UDF: Client Privacy Preference',500 "type" => "select",501 "name" => "profilerdonation_userdefined_clientprivacypreference",502 "required" => false,503 "tooltip" => "Pick the Profiler User Defined Field you wish the client's privacy preference (true/false) to be sent to",504 "choices" => $userdefinedfields,505 );506 507 $fields[] = array(508 531 "label" => 'Client Privacy Preference Field', 509 532 "type" => "select", … … 512 535 "tooltip" => "If this checkbox is true, this client will be marked as 'private'.", 513 536 "choices" => $checkboxFields 514 );515 516 $fields[] = array(517 "label" => 'UDF: Client IP Address',518 "type" => "select",519 "name" => "profilerdonation_userdefined_clientip",520 "required" => false,521 "tooltip" => "Pick the Profiler User Defined Field you wish the client's IP address to be sent to",522 "choices" => $userdefinedfields,523 );524 525 $fields[] = array(526 "label" => 'UDF: Gateway Transaction ID / Gateway Response',527 "type" => "select",528 "name" => "profilerdonation_userdefined_gatewaytransactionid",529 "required" => false,530 "tooltip" => "Pick the Profiler User Defined Field you wish the gateway transaction ID to be sent to (certain gateways only)",531 "choices" => $userdefinedfields,532 );533 534 $fields[] = array(535 "label" => 'UDF: Payment Gateway ID Used',536 "type" => "select",537 "name" => "profilerdonation_userdefined_paymentgatewayidused",538 "required" => false,539 "tooltip" => "Pick the Profiler User Defined Field you wish the payment gateway ID to be sent to",540 "choices" => $userdefinedfields,541 537 ); 542 538 … … 558 554 "choices" => $field_settings 559 555 ); 560 561 if(function_exists('gf_stripe') || class_exists('GF_PayFURL')) {562 // Stripe & PayFURL only fields563 $fields[] = array(564 "label" => 'UDF: Payment Gateway Card Token',565 "type" => "select",566 "name" => "profilerdonation_userdefined_gatewaycardtoken",567 "required" => false,568 "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Card Token to",569 "choices" => $userdefinedfields,570 );571 }572 573 if(function_exists('gf_stripe')) {574 // Stripe only fields575 $fields[] = array(576 "label" => 'UDF: Payment Gateway Customer ID',577 "type" => "select",578 "name" => "profilerdonation_userdefined_gatewaycustomerid",579 "required" => false,580 "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Customer ID to",581 "choices" => $userdefinedfields,582 );583 }584 556 585 557 … … 620 592 } else { 621 593 // Profiler will just record integration data 622 $postData['method'] = "integration.send"; 623 $postData['datatype'] = "OLDON"; 594 $postData['dataType'] = "OLDON"; 624 595 } 625 596 … … 634 605 $postData['pledgeamount'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_amount']); 635 606 } 636 637 $postData['clientname'] = $postData['firstname'] . ' ' . $postData['surname'];638 607 639 608 // Credit card fields: … … 645 614 $postData['ccv'] = $cardDetails['ccv']; 646 615 647 if($feed['meta']['profilerdonation_userdefined_receiptname'] !== "") { 648 // Receipt Name 649 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_receiptname']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_receiptname']); 650 } 651 652 if($feed['meta']['profilerdonation_userdefined_paymentgatewayidused'] !== "") { 653 // Payment Gateway ID Used 654 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentgatewayidused']); 655 656 if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']])) { 657 // Use default value 658 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $feed['meta']['profilerdonation_paymentgatewayidused_default']; 659 } 660 } 661 616 // Payment Gateway ID Used 617 $postData['paymentGatewayIdUsed'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentgatewayidused']); 618 619 if(empty($postData['paymentGatewayIdUsed'])) { 620 // Use default value 621 $postData['paymentGatewayIdUsed'] = $feed['meta']['profilerdonation_paymentgatewayidused_default']; 622 } 662 623 663 624 // Source codes … … 671 632 } 672 633 673 $postData['sourcecode'] = $donationSourceCode; 674 675 if($feed['meta']['profilerdonation_userdefined_sourcecode'] !== "") { 676 // Donation Source Code 677 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']] = $donationSourceCode; 678 } 679 680 if($feed['meta']['profilerdonation_userdefined_pledgesourcecode'] !== "") { 681 // Pledge Source Code 682 683 if(isset($feed['meta']['profilerdonation_pledgesourcecodemode']) && $feed['meta']['profilerdonation_pledgesourcecodemode'] !== "normal") { 684 // The source code is a value of a specified field 685 $pledgeSourceCode = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgesourcecodemode']); 686 687 } else { 688 // Regular behaviour 689 $pledgeSourceCode = $this->getDonationCode($feed, 'pledgesourcecode', $form); 690 } 691 692 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgesourcecode']] = $pledgeSourceCode; 693 } 694 695 if($feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode'] !== "") { 696 // Pledge Acqusition code 697 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode']] = $this->getDonationCode($feed, 'pledgeacquisitioncode', $form); 698 } 699 700 if($feed['meta']['profilerdonation_userdefined_pledgetypeid'] !== "") { 701 // Pledge Type ID 702 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgetypeid']); 703 704 if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']])) { 705 // Default value if above field is empty 706 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $feed['meta']['profilerdonation_pledgetypeid_default']; 707 } 708 } 709 710 if($feed['meta']['profilerdonation_userdefined_clientacquisitioncode'] !== "" && $feed['meta']['profilerdonation_clientacquisitioncode'] !== "") { 634 $postData['donationSourceCode'] = $donationSourceCode; 635 636 // Pledge Source Code 637 638 if(isset($feed['meta']['profilerdonation_pledgesourcecodemode']) && $feed['meta']['profilerdonation_pledgesourcecodemode'] !== "normal") { 639 // The source code is a value of a specified field 640 $pledgeSourceCode = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgesourcecodemode']); 641 642 } else { 643 // Regular behaviour 644 $pledgeSourceCode = $this->getDonationCode($feed, 'pledgesourcecode', $form); 645 } 646 647 $postData['regularSourceCode'] = $pledgeSourceCode; 648 649 // Pledge Acqusition code 650 $postData['regularAcquiredReason'] = $this->getDonationCode($feed, 'pledgeacquisitioncode', $form); 651 652 // Pledge Type ID 653 $postData['regularType'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgetypeid']); 654 655 if(empty($postData['regularType'])) { 656 // Default value if above field is empty 657 $postData['regularType'] = $feed['meta']['profilerdonation_pledgetypeid_default']; 658 } 659 660 if($feed['meta']['profilerdonation_clientacquisitioncode'] !== "") { 711 661 // Client Acqusition code 712 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_clientacquisitioncode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientacquisitioncode']);713 714 } else if ($feed['meta']['profilerdonation_userdefined_clientacquisitioncode'] !== ""){715 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_clientacquisitioncode']] = $this->getDonationCode($feed, 'clientacquisitioncode', $form);716 } 717 718 if($feed['meta']['profilerdonation_ userdefined_donationpurposecode'] !== "" && $feed['meta']['profilerdonation_donationpurposecode'] !== "") {719 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_donationpurposecode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationpurposecode']);720 } 721 722 if($feed['meta']['profilerdonation_ userdefined_donationtagcode'] !== "" && $feed['meta']['profilerdonation_donationtagcode'] !== "") {723 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_donationtagcode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtagcode']);724 } 725 726 if( $feed['meta']['profilerdonation_userdefined_gatewaytransactionid'] !== "" &&isset($entry['transaction_id'])) {662 $postData['clientAcquiredReason'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientacquisitioncode']); 663 664 } else { 665 $postData['clientAcquiredReason'] = $this->getDonationCode($feed, 'clientacquisitioncode', $form); 666 } 667 668 if($feed['meta']['profilerdonation_donationpurposecode'] !== "") { 669 $postData['paymentPupose'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationpurposecode']); 670 } 671 672 if($feed['meta']['profilerdonation_donationtagcode'] !== "") { 673 $postData['paymentTag'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtagcode']); 674 } 675 676 if(isset($entry['transaction_id'])) { 727 677 // Gateway transaction id 728 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaytransactionid']] = $entry['transaction_id'];729 } 730 731 if( $feed['meta']['profilerdonation_userdefined_gatewaytransactionid'] !== "" &&isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id'])) {678 $postData['gatewayResponseId'] = $entry['transaction_id']; 679 } 680 681 if(isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id'])) { 732 682 // PayFURL-supplied Gateway Response 733 683 $payfurl_gateway_response = $_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id']; 734 684 735 685 if(!empty($payfurl_gateway_response)) { 736 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaytransactionid']] = $payfurl_gateway_response;686 $postData['gatewayResponseId'] = $payfurl_gateway_response; 737 687 } 738 688 } … … 743 693 } 744 694 745 if($feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod'] !== "") { 746 // Client Preferred Contact Method 747 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientpreferredcontactmethod']); 748 } 749 750 if($feed['meta']['profilerdonation_userdefined_clientprivacypreference'] !== "") { 751 // Client Privacy Preference 752 753 $privacy_field_value = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientprivacypreference']); 754 755 if(!empty($privacy_field_value)) { 756 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_clientprivacypreference']] = 'true'; 757 } 758 } 695 // Client Preferred Contact Method 696 $postData['clientPreferredContactMethod'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientpreferredcontactmethod']); 697 698 // Client Privacy Preference 699 $privacy_field_value = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientprivacypreference']); 700 if(!empty($privacy_field_value)) { 701 $postData['clientPrivacyPreference'] = 'true'; 702 } 703 704 // Comments field 705 $comments = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_comments']); 706 707 if(!empty($feed['meta']['profilerdonation_commentsextra'])) { 708 // Extra text to append to comments field 709 $comments .= GFCommon::replace_variables($feed['meta']['profilerdonation_commentsextra'], $form, $entry, false, true, false, 'text'); 710 } 711 712 $comments = html_entity_decode($comments); 713 714 // Only allow ASCII printable characters. 715 // This is a work-around to the API endpoint not allowing some characters 716 $comments = preg_replace('/[^\x20-\x7E]/','', $comments); 717 718 // Comments 719 $postData['comments'] = $comments; 759 720 760 721 if($this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtype']) == "regular") { 761 722 // Recurring donation 762 $postData['data type'] = "PLG";763 $postData['pledge type'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgefreq']);764 765 if(empty($postData['pledge type'])) {723 $postData['dataType'] = "PLG"; 724 $postData['pledgeType'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgefreq']); 725 726 if(empty($postData['pledgeType'])) { 766 727 // We assume a monthly pledge if no frequency is specified 767 $postData['pledge type'] = "monthly";728 $postData['pledgeType'] = "monthly"; 768 729 } 769 730 770 if($feed['meta']['profilerdonation_userdefined_sourcecode'] !== "") { 771 // If it's recurring, the donation gets the pledge source code instead of the donation code 772 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']] = $this->getDonationCode($feed, 'pledgesourcecode', $form); 773 } 731 // If it's recurring, the donation gets the pledge source code instead of the donation code 732 $postData['donationSourceCode'] = $this->getDonationCode($feed, 'pledgesourcecode', $form); 774 733 775 734 // Store the donation type 776 gform_add_meta($entry["id"], "profiler_type", "regular", $form _id);735 gform_add_meta($entry["id"], "profiler_type", "regular", $form['id']); 777 736 778 737 } elseif($useAsGateway == false) { … … 786 745 787 746 unset($postData['pledgeamount']); 788 unset($postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode']]);789 unset($postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_pledgesourcecode']]);747 unset($postData['regularAcquiredReason']); 748 unset($postData['regularSourceCode']); 790 749 791 750 } else { … … 810 769 unset($postData['cardexpiry']); 811 770 812 $postData['b ankaccountname'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountname"]);813 $postData['b ankbsb'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_bsb"]);814 $postData['b ankaccountnumber'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountnumber"]);771 $postData['bsbAccName'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountname"]); 772 $postData['bsb'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_bsb"]); 773 $postData['bsbAccNum'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountnumber"]); 815 774 816 775 } elseif($this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentmethod']) == "paypal") { … … 829 788 public function process_feed_success($feed, $entry, $form, $pfResponse, $postData) { 830 789 831 if(!isset($pfResponse['dataArray']['status']) || $pfResponse['dataArray']['status'] != "Pass") { 790 if(isset($pfResponse['dataArray']['success']) && $pfResponse['dataArray']['success'] === true) { 791 // Store the Integration ID as meta so we can use it later 792 if(isset($pfResponse['dataArray']['integrationId'])) { 793 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['integrationId'], $form['id']); 794 gform_add_meta($entry["id"], "profiler_integration_guid", $pfResponse['dataArray']['integrationGuid'], $form['id']); 795 gform_add_meta($entry["id"], "profiler_sourcecode", $postData['donationSourceCode'], $form['id']); 796 } 797 } else { 832 798 // Profiler failed. Send the failure email. 833 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']['profiler_erroremailaddress']); 834 835 } else { 836 // Store the Integration ID as meta so we can use it later 837 if(isset($pfResponse['dataArray']['id'])) { 838 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['id'], $form['id']); 839 gform_add_meta($entry["id"], "profiler_sourcecode", $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']], $form['id']); 840 } 841 } 842 799 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']["profiler".$this->gffield_legacyname."_erroremailaddress"]); 800 } 843 801 } 844 802 -
profiler-donations-gravityforms/tags/2.5.0/class-profilermembership-gfaddon.php
r2750662 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/Legacy/"; 13 protected $apifield_apikey = "apikey"; 14 protected $apifield_apipass = "apipass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "membership"; 18 20 … … 43 45 $fields = parent::feed_settings_fields_custom(); 44 46 45 foreach($fields as $fieldKey => $fieldVal) { 46 if($fieldVal['label'] == "Use Profiler As A Gateway?") { 47 $fields[$fieldKey]['choices'][] = array( 48 'label' => 'Manual - Profiler will Process Payments, manually later on via a Pledge', 49 'value' => 'manual', 50 ); 47 if(apply_filters('profiler_integration_allow_profiler_gateway', true) == true) { 48 // This filter allows us to disable the Profiler Gateway feature on a site 49 50 foreach($fields as $fieldKey => $fieldVal) { 51 if($fieldVal['label'] == "Use Profiler As A Gateway?") { 52 $fields[$fieldKey]['choices'][] = array( 53 'label' => 'Manual - Profiler will Process Payments, manually later on via a Pledge', 54 'value' => 'manual', 55 ); 56 } 51 57 } 58 59 $fields[] = array( 60 "label" => 'UDF: Stored Card Number', 61 "type" => "select", 62 "name" => "profilerdonation_userdefined_storedcard_number", 63 "required" => false, 64 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card number in", 65 "choices" => $userdefinedfields, 66 ); 67 68 $fields[] = array( 69 "label" => 'UDF: Stored Card Expiry', 70 "type" => "select", 71 "name" => "profilerdonation_userdefined_storedcard_expiry", 72 "required" => false, 73 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card expiry in", 74 "choices" => $userdefinedfields, 75 ); 76 77 $fields[] = array( 78 "label" => 'UDF: Stored Card CCV', 79 "type" => "select", 80 "name" => "profilerdonation_userdefined_storedcard_ccv", 81 "required" => false, 82 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card CCV in", 83 "choices" => $userdefinedfields, 84 ); 85 86 $fields[] = array( 87 "label" => 'UDF: Stored Card Name', 88 "type" => "select", 89 "name" => "profilerdonation_userdefined_storedcard_name", 90 "required" => false, 91 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card name in", 92 "choices" => $userdefinedfields, 93 ); 94 52 95 } 53 54 $fields[] = array(55 "label" => 'UDF: Stored Card Number',56 "type" => "select",57 "name" => "profilerdonation_userdefined_storedcard_number",58 "required" => false,59 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card number in",60 "choices" => $userdefinedfields,61 );62 63 $fields[] = array(64 "label" => 'UDF: Stored Card Expiry',65 "type" => "select",66 "name" => "profilerdonation_userdefined_storedcard_expiry",67 "required" => false,68 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card expiry in",69 "choices" => $userdefinedfields,70 );71 72 $fields[] = array(73 "label" => 'UDF: Stored Card CCV',74 "type" => "select",75 "name" => "profilerdonation_userdefined_storedcard_ccv",76 "required" => false,77 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card CCV in",78 "choices" => $userdefinedfields,79 );80 81 $fields[] = array(82 "label" => 'UDF: Stored Card Name',83 "type" => "select",84 "name" => "profilerdonation_userdefined_storedcard_name",85 "required" => false,86 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card name in",87 "choices" => $userdefinedfields,88 );89 96 90 97 return $fields; -
profiler-donations-gravityforms/tags/2.5.0/class-profilerpostdonate-gfaddon.php
r2750662 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/LegacyPost/"; 13 protected $apifield_apikey = "api_user"; 14 protected $apifield_apipass = "api_pass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "donation"; 18 20 protected $supports_custom_fields = true; … … 59 61 60 62 $fields[] = array( 61 "label" => 'UDF: Comments',62 "type" => "select",63 "name" => "profilerdonation_userdefined_comments",64 "required" => false,65 "tooltip" => "Pick the Profiler User Defined Field you wish to use for the Comments field",66 "choices" => $userdefinedfields,67 );68 69 $fields[] = array(70 63 "label" => 'Extra Comments Text', 71 64 "type" => "textarea", 72 65 "name" => "profilerdonation_commentsextra", 73 "required" => true,66 "required" => false, 74 67 "class" => "merge-tag-support", 75 68 "tooltip" => "This is extra text to be sent to Profiler as an Interaction. Protip: Include Gravity Forms Merge Fields in this textarea to accept user input.", … … 109 102 public function process_feed_custom($feed, $entry, $form, $postData, $fromValidatorProcessPFGateway = false) { 110 103 111 $postData['method'] = "integration.send";112 104 $postData['datatype'] = "OLDON"; 113 105 … … 123 115 // Comments 124 116 $postData['comments'] = $comments; 125 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_comments']] = $comments; 126 117 127 118 $gfEntryId = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_gfentryid']); 128 119 $pfIntegrationId = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_profilerid']); … … 147 138 148 139 // This is the ID of the actual donation entry 149 $postData[' HoldingID'] = $pfIntegrationId;140 $postData['holdingId'] = $pfIntegrationId; 150 141 151 142 return $postData; … … 154 145 public function process_feed_success($feed, $entry, $form, $pfResponse, $postData) { 155 146 156 if(!isset($pfResponse['dataArray']['status']) || $pfResponse['dataArray']['status'] != "Pass") { 147 if(isset($pfResponse['dataArray']['success']) && $pfResponse['dataArray']['success'] === true) { 148 // Store the Integration ID as meta so we can use it later 149 if(isset($pfResponse['dataArray']['integrationId'])) { 150 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['integrationId'], $form['id']); 151 gform_add_meta($entry["id"], "profiler_integration_guid", $pfResponse['dataArray']['integrationGuid'], $form['id']); 152 } 153 } else { 157 154 // Profiler failed. Send the failure email. 158 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']['profiler_erroremailaddress']); 159 160 } else { 161 // Store the Integration ID as meta so we can use it later 162 if(isset($pfResponse['dataArray']['id'])) 163 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['id'], $form['id']); 155 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']["profiler".$this->gffield_legacyname."_erroremailaddress"]); 164 156 } 165 166 157 } 167 158 -
profiler-donations-gravityforms/tags/2.5.0/index.php
r3136560 r3211366 1 1 <?php 2 2 /* 3 Plugin Name: Profiler Donations - Gravity FormsAdd-On3 Plugin Name: Gravity Forms + Profiler Add-On 4 4 Plugin URI: https://mediarealm.com.au/ 5 5 Description: Integrates Gravity Forms with Profiler, enabling donation data and more to be sent directly to Profiler. 6 Version: 2. 4.36 Version: 2.5.0 7 7 8 8 Author: Media Realm … … 66 66 //GFAddOn::register('GFProfilerEvents'); 67 67 68 // This is a settings screen to list all Profiler feeds in the system 69 require_once('class-feedlist-gfaddon.php'); 70 GFAddOn::register('GF_Profiler_FeedList'); 71 68 72 // Include some random helper functions 69 73 require_once(plugin_dir_path(__FILE__) . '/shortcodes.php'); -
profiler-donations-gravityforms/tags/2.5.0/readme.txt
r3136560 r3211366 22 22 23 23 == Changelog == 24 25 = 2.5.0 = 26 27 This is a substantial update. Please backup your site before upgrading, and test all your integrations thoroughly after upgrading this plugin. 28 29 * Use the new Profiler Core API for Donations/payments. This removes the UDF field config and automates it within Profiler. 30 * Create 'Profiler Feed List' setting screen, for quick access to all configured feeds on your site 31 * Remove Profiler Logs fields, and move these to an entry metabox. 32 * Donation Feed: Add Extra Comments field 33 * Donation Feed: Automatic formatting of Australian phone numbers 34 * Add Profiler icon to all Feeds 35 * Donation Feed: Add new fields for gender, interactions, roles, membership mapping and payment split text. 36 * Membership Feed: Hide manual payment fields if Profiler-driven payments have been disabled 24 37 25 38 = 2.4.3 = -
profiler-donations-gravityforms/tags/2.5.0/sync_users.php
r2750662 r3211366 232 232 233 233 if(empty($options['auth_apikey']) || empty($options['auth_apipass']) || empty($options['pf_database']) || empty($options['pf_domain'])) { 234 $this->log("Profiler Users not configured correctly");235 234 return; 236 235 } -
profiler-donations-gravityforms/tags/2.5.0/woocommerce/integration.php
r2984822 r3211366 23 23 $this->dbname = $this->get_option( 'dbname' ); 24 24 $this->apikey = $this->get_option( 'apikey' ); 25 26 // Upgrade config to new domain 27 $this->instancedomainname = str_replace(".profilersystem.com", ".profilersoftware.com", $this->instancedomainname); 25 28 26 29 // Actions. … … 54 57 'title' => 'Profiler Instance Domain Name', 55 58 'type' => 'text', 56 'description' => 'e.g. example.profilers ystem.com',59 'description' => 'e.g. example.profilersoftware.com', 57 60 'desc_tip' => true, 58 61 'default' => '', … … 85 88 'desc_tip' => true, 86 89 'default' => '' 87 ),88 'udf_sourcecode' => array(89 'title' => 'UDF: Donation Source Code',90 'type' => 'select',91 'description' => '',92 'desc_tip' => true,93 'default' => '',94 'options' => $this->options_udf(),95 ),96 'udf_clientip' => array(97 'title' => 'UDF: Client IP Address',98 'type' => 'select',99 'description' => '',100 'desc_tip' => true,101 'default' => '',102 'options' => $this->options_udf(),103 ),104 'udf_transactionid' => array(105 'title' => 'UDF: Gateway Transaction ID',106 'type' => 'select',107 'description' => '',108 'desc_tip' => true,109 'default' => '',110 'options' => $this->options_udf(),111 90 ), 112 91 ); … … 204 183 205 184 // Build API payload 206 $url = 'https://' . $this->instancedomainname . '/ProfilerAPI/ Legacy/';185 $url = 'https://' . $this->instancedomainname . '/ProfilerAPI/RapidEndpoint/'; 207 186 $profiler_data = array( 208 'DB' => $this->dbname, 209 'apikey' => $this->apikey, 210 'apipass' => $this->get_option('apipass'), 211 'method' => 'integration.send', 187 'apiuser' => $this->apikey, 188 'apipassword' => $this->get_option('apipass'), 212 189 'datatype' => 'OLDON', 213 190 214 191 'amount' => $total, 215 'donation amount' => $total,216 ' sourcecode' => $this->get_option('sourcecode'),192 'donationAmount' => $total, 193 'donationSourceCode' => $this->get_option('sourcecode'), 217 194 'status' => 'Approved', 218 195 219 196 'clientname' => $first_name . ' ' . $last_name, 220 'first name' => $first_name,197 'firstName' => $first_name, 221 198 'surname' => $last_name, 222 199 … … 233 210 ); 234 211 235 if($this->get_option('udf_sourcecode') != '') { 236 // Source code as a UDF 237 $profiler_data['userdefined' . $this->get_option('udf_sourcecode')] = $this->get_option('sourcecode'); 238 } 212 // Source code as a UDF 213 $profiler_data['donationSourceCode'] = $this->get_option('sourcecode'); 239 214 240 215 if($order->needs_payment()) { … … 243 218 } 244 219 245 if($this->get_option('udf_clientip') != '') { 246 // Client IP Address 247 $profiler_data['userdefined' . $this->get_option('udf_clientip')] = $this->get_client_ip_address(); 248 } 249 250 if($this->get_option('udf_transactionid') != '') { 251 // Payment Gateway Transaction ID 252 $profiler_data['userdefined' . $this->get_option('udf_transactionid')] = $order->get_transaction_id(); 253 } 220 // Client IP Address 221 $profiler_data['requestIPAddress'] = $this->get_client_ip_address(); 222 223 // Payment Gateway Transaction ID 224 $profiler_data['gatewayResponseId'] = $order->get_transaction_id(); 254 225 255 226 // Push data to Profiler … … 350 321 351 322 $ch = curl_init(); 352 curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit')));323 curl_setopt($ch, CURLOPT_URL, $url); 353 324 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 354 curl_setopt($ch, CURLOPT_ HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query))));355 curl_setopt($ch, CURLOPT_ POSTFIELDS, http_build_query($profiler_query));325 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($profiler_query)); 326 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 356 327 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 357 328 … … 386 357 "dataSent" => $profiler_query, 387 358 "data" => $result, 388 "dataXML" => simplexml_load_string($result), 389 "dataArray" => json_decode(json_encode((array)simplexml_load_string($result)), 1), 359 "dataArray" => json_decode($result, true), 390 360 "cURLError" => $cURL_error, 391 361 "cURL_SSL_Mode" => $ssl_mode, 392 362 ); 393 }394 395 private function options_udf() {396 $fields = array("0" => "");397 398 for($i = 1; $i <= 99; $i++) {399 $fields[$i] = "User Defined Field " . $i;400 }401 402 return $fields;403 363 } 404 364 -
profiler-donations-gravityforms/trunk/README.md
r2698068 r3211366 15 15 * [Gravity Forms](http://www.gravityforms.com) 16 16 * Payment Gateway integration with Gravity Forms (must be pre-existing and use standard Gravity Forms payment hooks and database fields) 17 * For Australian non-profits, we recommend the official Gravity Forms Stripe plugin17 * We recommend the official Gravity Forms Stripe plugin 18 18 * Full administrative access to Profiler 19 19 * CURL and XML Enabled on Web Server -
profiler-donations-gravityforms/trunk/class-profilercommon.php
r3136560 r3211366 7 7 protected $_title = "Profiler / Gravity Forms - Integration Feed"; 8 8 9 protected $api_type = "form"; // form or json 10 protected $api_domain = "profilersystem.com"; 9 11 protected $apifield_apikey = "apikey"; 10 12 protected $apifield_apipass = "apipass"; … … 27 29 add_filter('gform_stripe_charge_description', array($this, 'stripe_payment_description'), 10, 5); 28 30 add_filter('gform_stripe_payment_element_initial_payment_information', array($this, 'stripe_elements_setup'), 10, 3); 29 } 31 32 // Metabox for Profiler Logs 33 add_filter('gform_entry_detail_meta_boxes', array($this, 'meta_box_entry'), 10, 3); 34 } 35 36 public function get_menu_icon() { 37 //return 'dashicons-admin-generic'; 38 return plugins_url('icon-profiler.png', __FILE__); 39 } 30 40 31 41 public function feed_settings_fields() { … … 65 75 "name" => "profiler".$this->gffield_legacyname."_instancedomainname", 66 76 "required" => true, 67 "tooltip" => "Your Instance Domain Name can be found in your login URL: e.g. 'https://instance.profiler.net.au/' is 'instance.profiler.net.au'", 68 ); 69 70 $fields[] = array( 71 "label" => 'Profiler Database Name', 72 "type" => "text", 73 "name" => "profiler".$this->gffield_legacyname."_dbname", 74 "required" => true, 75 ); 77 "tooltip" => "Your Instance Domain Name can be found in your login URL: e.g. 'https://instance.profilersystem.com/' is 'instance.profilesystem.com'", 78 ); 79 80 if($this->api_type !== 'json') { 81 $fields[] = array( 82 "label" => 'Profiler Database Name', 83 "type" => "text", 84 "name" => "profiler".$this->gffield_legacyname."_dbname", 85 "required" => true, 86 ); 87 } 76 88 77 89 $fields[] = array( … … 138 150 // Loop over mailing list fields 139 151 152 if($this->api_type !== 'json') { 153 $fields[] = array( 154 "label" => 'Mailing List #'.$i.': UDF', 155 "type" => "select", 156 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf", 157 "required" => false, 158 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing", 159 "choices" => $userdefinedfields, 160 ); 161 } 162 140 163 $fields[] = array( 141 "label" => 'Mailing List #'.$i.': UDF', 142 "type" => "select", 143 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf", 144 "required" => false, 145 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing", 146 "choices" => $userdefinedfields, 147 ); 148 149 $fields[] = array( 150 "label" => 'Mailing List #'.$i.': UDF Text', 164 "label" => ($this->api_type == 'json' ? 'Mailing List #'.$i.': Mailing Type Code' : 'Mailing List #'.$i.': UDF Text'), 151 165 "type" => "text", 152 166 "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext", 153 167 "required" => false, 154 "tooltip" => "Enter the string Profiler is expecting in this UDF",168 "tooltip" => ($this->api_type == 'json' ? "Enter the Profiler Mailing Type Code" : "Enter the string Profiler is expecting in this UDF") . ". This field also accept post meta merge fields in this format: {postmeta:meta_field_name}", 155 169 ); 156 170 157 171 $fields[] = array( 158 172 "label" => 'Mailing List #'.$i.': Field', … … 161 175 "tooltip" => 'Link it to a checkbox field - when checked, the mailing will be sent', 162 176 "required" => false, 163 "choices" => $checkboxFields177 "choices" => array_merge($checkboxRadioFields, array(array("value" => "always", "label" => "Always Subscribe"))), 164 178 ); 165 179 } … … 203 217 204 218 $fields[] = array( 205 "label" => 'Profiler Logs',206 "type" => "select",207 "name" => "profiler".$this->gffield_legacyname."_logs",208 "tooltip" => 'Link it to a Hidden field that will hold Profiler Response Logs',209 "required" => false,210 "choices" => $hiddenFields211 );212 213 $fields[] = array(214 219 "label" => 'SSL Mode', 215 220 "type" => "select", … … 259 264 $postData = array(); 260 265 261 $postData['DB'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_dbname']; 266 if($this->api_type !== 'json') { 267 $postData['DB'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_dbname']; 268 } 262 269 $postData[$this->apifield_apikey] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apikey']; 263 270 $postData[$this->apifield_apipass] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apipass']; … … 265 272 if(empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname']) && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'])) { 266 273 // Respect the setting from when we only accepted the first part of the domain name 267 $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'] . ".profiler .net.au";274 $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'] . ".profilersystem.com"; 268 275 } 269 276 … … 282 289 if(isset($field['pf_apifield']) && $this->get_field_value($form, $entry, $feed['meta'][$field['name']]) != '') { 283 290 $postData[$field['pf_apifield']] = trim($this->get_field_value($form, $entry, $feed['meta'][$field['name']])); 291 292 // Auto formatting for phone fields 293 if(isset($field['auto_format']) && $field['auto_format'] == "phone") { 294 $postData[$field['pf_apifield']] = $this->auto_format_phone($postData[$field['pf_apifield']]); 295 } 284 296 } 285 297 } … … 301 313 if($this->apifield_formurl === true && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl'])) { 302 314 $postData['userdefined' . $feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl']] = $entry['source_url']; 315 } else if($this->apifield_formurl !== false) { 316 $postData[$this->apifield_formurl] = $entry['source_url']; 303 317 } 304 318 … … 322 336 } 323 337 324 if( $feed['meta']['profilerdonation_userdefined_gatewaycustomerid'] !== "" &&isset($payment_intent)) {338 if(isset($payment_intent)) { 325 339 // Gateway Customer ID 326 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycustomerid']] = $payment_intent->customer;327 } 328 329 if( $feed['meta']['profilerdonation_userdefined_gatewaycardtoken'] !== "" &&isset($payment_intent)) {340 $postData['paymentGatewayCustomerId'] = $payment_intent->customer; 341 } 342 343 if(isset($payment_intent)) { 330 344 // Gateway Card Token 331 345 try { 332 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycardtoken']] = $payment_intent->charges->data[0]->payment_method;346 $postData['gatewayCardToken'] = $payment_intent->charges->data[0]->payment_method; 333 347 } catch(Exception $e) { 334 348 error_log("STRIPE/PROFILER CARD TOKEN ERROR: " . print_r($e, true)); … … 338 352 339 353 // PayFURL-supplied Gateway Token 340 if( $feed['meta']['profilerdonation_userdefined_gatewaycardtoken'] !== "" &&isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider'])) {354 if(isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider'])) { 341 355 $payfurl_provider_token = $_POST['payfurl_payment_details']['captured_payment']['payfurl_payment_method_id_provider']; 342 356 343 357 if(!empty($payfurl_provider_token)) { 344 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycardtoken']] = $payfurl_provider_token;358 $postData['gatewayCardToken'] = $payfurl_provider_token; 345 359 } 346 360 } … … 349 363 if($this->supports_custom_fields === true && !empty($feed['meta']['profiler_customfields_count'])) { 350 364 for($i = 1; $i <= $feed['meta']['profiler_customfields_count']; $i++) { 351 $postData["userdefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"])); 365 366 $value = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"])); 367 368 if($this->api_type == 'json') { 369 if(!isset($postData['userDefinedFields'])) { 370 $postData['userDefinedFields'] = array(); 371 } 372 373 $postData['userDefinedFields']["userDefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = $value; 374 375 } else { 376 $postData["userdefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = $value; 377 } 378 379 352 380 } 353 381 } … … 358 386 // Loop over mailing list fields 359 387 $mailingFieldValue = $this->get_field_value($form, $entry, $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"]); 360 $udf = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf"];361 388 $udfText = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext"]; 362 389 363 if(!empty($udf) && !empty($udfText) && !empty($mailingFieldValue)) { 364 $postData['userdefined' . $udf] = $udfText; 365 } 366 390 // Allow merging post meta fields into $udfText 391 if(isset($entry['post_id']) && !empty($entry['post_id'])) { 392 $post_id = $entry['post_id']; 393 } else { 394 global $post; 395 if(isset($post)) { 396 $post_id = $post->ID; 397 } 398 } 399 400 if(isset($post_id)) { 401 preg_match_all("/{postmeta:(.*?)}/", $udfText, $matches); 402 403 if(is_array($matches) && isset($matches[1])) { 404 foreach($matches[1] as $match) { 405 $post_meta = get_post_meta($post_id, $match, true); 406 $udfText = str_replace("{postmeta:".$match."}", $post_meta, $udfText); 407 } 408 } 409 } 410 411 if($this->api_type == 'json') { 412 413 if(!isset($postData['mailingList'])) { 414 $postData['mailingList'] = ''; 415 } 416 417 if(!empty($udfText) && (!empty($mailingFieldValue) || $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"] == 'always')) { 418 $postData['mailingList'] .= (!empty($postData['mailingList']) ? ',' : '') . $udfText; 419 } 420 421 } else { 422 $udf = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf"]; 423 424 if(!empty($udf) && !empty($udfText) && (!empty($mailingFieldValue) || $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"] == 'always')) { 425 $postData['userdefined' . $udf] = $udfText; 426 } 427 } 367 428 } 368 429 } … … 386 447 $postData = apply_filters('profiler_integration_api_request_data', $postData, $form, $entry, $this->apifield_endpoint); 387 448 449 // Update URL for newer APIs 450 if($this->api_domain !== 'profilersystem.com') { 451 $API_URL = str_replace(".profilersystem.com", "." . $this->api_domain, $API_URL); 452 } 453 388 454 // Send data to Profiler 389 455 $pfResponse = $this->sendDataToProfiler($API_URL, $postData, $feed['meta']['profiler'.$this->gffield_legacyname.'_sslmode']); … … 391 457 if($fromValidatorProcessPFGateway === false) { 392 458 // Save Profiler response data back to the form entry 393 $logsToStore = json_encode($pfResponse );459 $logsToStore = json_encode($pfResponse, JSON_PRETTY_PRINT); 394 460 $logsToStore = str_replace($postData['cardnumber'], "--REDACTED--", $logsToStore); 395 461 $logsToStore = str_replace($postData[$this->apifield_apikey], "--REDACTED--", $logsToStore); 396 462 $logsToStore = str_replace($postData[$this->apifield_apipass], "--REDACTED--", $logsToStore); 397 $entry[$feed['meta']['profiler'.$this->gffield_legacyname.'_logs']] = htmlentities($logsToStore); 398 GFAPI::update_entry($entry); 463 gform_add_meta($entry["id"], "profiler_logs", $logsToStore, $form['id']); 399 464 400 465 if(method_exists($this, 'process_feed_success')) { 401 466 $this->process_feed_success($feed, $entry, $form, $pfResponse, $postData); 402 } 467 } 468 403 469 } else { 404 470 return $pfResponse; … … 651 717 } 652 718 719 if(isset($profiler_query['DB'])) { 720 $url .= '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit')); 721 } 722 653 723 $ch = curl_init(); 654 curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit'))); 724 curl_setopt($ch, CURLOPT_URL, $url); 725 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 655 726 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 656 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query)))); 657 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($profiler_query)); 658 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 659 727 660 728 if($ssl_mode == "bundled_ca") { 661 729 // Use the CA Cert bundled with this plugin … … 669 737 } 670 738 739 if($this->api_type === 'json') { 740 // JSON POST 741 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($profiler_query)); 742 curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 743 744 } else { 745 // FORM POST 746 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query)))); 747 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($profiler_query)); 748 } 749 671 750 $result = curl_exec($ch); 672 751 $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 673 752 674 753 if(curl_error($ch)) { 675 754 $cURL_error = curl_error($ch); … … 677 756 $cURL_error = null; 678 757 } 679 758 680 759 curl_close($ch); 681 760 761 if($this->api_type === 'json') { 762 $data_decoded = json_decode($result, true); 763 } else { 764 $data_decoded = json_decode(json_encode((array)simplexml_load_string($result)), true); 765 } 766 682 767 return array( 683 768 "httpstatus" => $status_code, 769 "url" => $url, 684 770 "dataSent" => $profiler_query, 685 771 "data" => $result, 686 "dataXML" => simplexml_load_string($result), 687 "dataArray" => json_decode(json_encode((array)simplexml_load_string($result)), 1), 772 "dataArray" => $data_decoded, 688 773 "cURLError" => $cURL_error, 689 774 "cURL_SSL_Mode" => $ssl_mode, 775 "api_type" => $this->api_type, 690 776 ); 691 777 } … … 707 793 708 794 foreach($pfResponse['dataSent'] as $key => $val) { 709 if($key == "apikey" || $key == "apipass" || $key == " cardnumber" || $key == "api_user" || $key == "api_pass" || $key == $this->apifield_apikey || $key == $this->apifield_apipass) {795 if($key == "apikey" || $key == "apipass" || $key == "apipassword" || $key == "cardnumber" || $key == "api_user" || $key == "api_pass" || $key == $this->apifield_apikey || $key == $this->apifield_apipass) { 710 796 $val = "--REDACTED--"; 711 797 } … … 1023 1109 1024 1110 } 1111 1112 public function meta_box_entry($meta_boxes, $entry, $form) { 1113 // Custom Metabox 1114 1115 if($this->get_active_feeds($form['id'])) { 1116 1117 $profiler_logs_meta = gform_get_meta($entry['id'], 'profiler_logs'); 1118 1119 if(!empty($profiler_logs_meta)) { 1120 $meta_boxes[$this->_slug] = array( 1121 'title' => 'Profiler API', 1122 'callback' => array($this, 'meta_box_entry_render'), 1123 'context' => 'side', 1124 'callback_args' => array($entry, $form), 1125 ); 1126 } 1127 } 1128 1129 return $meta_boxes; 1130 } 1131 1132 public function meta_box_entry_render($data) { 1133 // Render the Custom Metabox 1134 $html = ''; 1135 1136 $meta_fields = array( 1137 "profiler_integrationid" => "Integration ID", 1138 "profiler_integration_guid" => "Integration GUID", 1139 "profiler_logs" => "Profiler API Logs", 1140 ); 1141 1142 foreach($meta_fields as $field_name => $field_title) { 1143 1144 $meta_value = gform_get_meta($data['entry']['id'], $field_name); 1145 1146 if(!empty($meta_value)) { 1147 $html .= '<p><strong>'.$field_title.'</strong>:<br /><pre style="width: 100%; overflow-x: scroll;">'.esc_html($meta_value).'</pre></p>'; 1148 } 1149 } 1150 1151 echo $html; 1152 } 1153 1154 private function auto_format_phone($phone_number_original) { 1155 // This function auto-formats a phone number into an Australian format (0000 000 000 or 00 0000 0000) 1156 1157 // Remove certain characters 1158 $phone_number = str_replace(array(" ", "-", "(", ")"), array("", "", "", ""), $phone_number_original); 1159 1160 // Remove +61 prefix 1161 if(substr($phone_number, 0, 3) == "+61") { 1162 $phone_number = substr($phone_number, 3); 1163 1164 if(strlen($phone_number) === 9) { 1165 $phone_number = "0" . $phone_number; 1166 } 1167 } 1168 1169 // International number. Return as-is 1170 if(substr($phone_number, 0, 1) == "+") { 1171 return $phone_number; 1172 } 1173 1174 // Probably an Australian number 1175 if(strlen($phone_number) == 10) { 1176 // 0000 000 000 1177 if(substr($phone_number, 0, 2) == "04") { 1178 $phone_number = substr($phone_number, 0, 4) . " " . substr($phone_number, 4, 3) . " " . substr($phone_number, 7); 1179 return $phone_number; 1180 } 1181 1182 // 00 0000 0000 1183 $phone_number = substr($phone_number, 0, 2) . " " . substr($phone_number, 2, 4) . " " . substr($phone_number, 6); 1184 return $phone_number; 1185 } 1186 1187 // Probably Australian landline with no area prefix 1188 if(strlen($phone_number) == 8) { 1189 // Adjust to 0000 0000 format 1190 $phone_number = substr($phone_number, 0, 4) . " " . substr($phone_number, 4); 1191 } 1192 1193 return $phone_number; 1194 } 1025 1195 } 1026 1196 -
profiler-donations-gravityforms/trunk/class-profilerdonate-gfaddon.php
r3136560 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/Legacy/"; 13 protected $apifield_apikey = "apikey"; 14 protected $apifield_apipass = "apipass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "donation"; 18 20 protected $supports_custom_fields = true; … … 129 131 "required" => false, 130 132 "choices" => $field_settings, 131 "tooltip" => "The value of this field must be set to ' monthly' or 'yearly'. This field will be used if 'Donation Type' is set to 'regular'."133 "tooltip" => "The value of this field must be set to 'weekly', 'monthly' or 'yearly'. This field will be used if 'Donation Type' is set to 'regular'." 132 134 ); 133 135 … … 139 141 "choices" => $product_field_settings, 140 142 "tooltip" => "This amount field will be used if Donation Type is set to 'regular'.", 141 );142 143 $fields[] = array(144 "label" => 'UDF: Pledge Type ID',145 "type" => "select",146 "name" => "profilerdonation_userdefined_pledgetypeid",147 "required" => false,148 "tooltip" => "Pick the Profiler User Defined Field you wish the Pledge Type ID to be sent to",149 "choices" => $userdefinedfields,150 143 ); 151 144 … … 182 175 "required" => false, 183 176 "choices" => $field_settings, 184 "pf_apifield" => "first name",177 "pf_apifield" => "firstName", 185 178 ); 186 179 … … 193 186 "pf_apifield" => "surname", 194 187 ); 188 189 $fields[] = array( 190 "label" => 'Client: Gender', 191 "type" => "select", 192 "name" => "profilerdonation_clientgender", 193 "required" => false, 194 "choices" => $field_settings, 195 "pf_apifield" => "clientGender", 196 "tooltip" => "Gender values are defined in Profiler in Setup > Client > Gender.", 197 ); 195 198 196 199 $fields[] = array( … … 263 266 "required" => false, 264 267 "choices" => $field_settings, 265 "pf_apifield" => "phone ah",266 ); 267 268 "pf_apifield" => "phoneAH", 269 ); 270 268 271 $fields[] = array( 269 272 "label" => 'Client: Business Phone', … … 272 275 "required" => false, 273 276 "choices" => $field_settings, 274 "pf_apifield" => "phonebus", 275 ); 276 277 "pf_apifield" => "phoneBus", 278 "auto_format" => "phone", 279 ); 280 277 281 $fields[] = array( 278 282 "label" => 'Client: Mobile Phone', … … 281 285 "required" => false, 282 286 "choices" => $field_settings, 283 "pf_apifield" => "phonemobile", 284 ); 285 287 "pf_apifield" => "phoneMobile", 288 "auto_format" => "phone", 289 ); 290 291 $fields[] = array( 292 "label" => 'Client: Phone', 293 "type" => "select", 294 "name" => "profilerdonation_clientphonemobile", 295 "required" => false, 296 "choices" => $field_settings, 297 "pf_apifield" => "phoneMobile", 298 "auto_format" => "phone", 299 ); 300 286 301 $fields[] = array( 287 302 "label" => 'Client: Website', … … 323 338 "required" => false, 324 339 "choices" => $field_settings, 325 "pf_apifield" => "comments", 326 ); 327 328 $fields[] = array( 329 "label" => 'UDF: Receipt Name', 330 "type" => "select", 331 "name" => "profilerdonation_userdefined_receiptname", 332 "required" => false, 333 "tooltip" => "Pick the Profiler User Defined Field you wish the donation receipt name to be sent to", 334 "choices" => $userdefinedfields, 340 ); 341 342 $fields[] = array( 343 "label" => 'Extra Comments Text', 344 "type" => "textarea", 345 "name" => "profilerdonation_commentsextra", 346 "required" => false, 347 "class" => "merge-tag-support", 348 "tooltip" => "This is extra text to be sent to Profiler in the Comments field. Youc an include Gravity Forms Merge Fields in this textarea to accept additional user input.", 349 ); 350 351 $fields[] = array( 352 "label" => 'Interaction: Type', 353 "type" => "select", 354 "name" => "profilerdonation_interaction_type", 355 "required" => false, 356 "choices" => $field_settings, 357 "pf_apifield" => "interactionType", 358 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Type here, and your Interaction Text below. This is separate to the 'Comments' field above.", 359 ); 360 361 $fields[] = array( 362 "label" => 'Interaction: Text', 363 "type" => "select", 364 "name" => "profilerdonation_interaction_text", 365 "required" => false, 366 "choices" => $field_settings, 367 "pf_apifield" => "interactionText", 368 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text here, and your Interaction Type above. This is separate to the 'Comments' field above.", 369 ); 370 371 $fields[] = array( 372 "label" => 'Interaction: Tag', 373 "type" => "select", 374 "name" => "profilerdonation_interaction_tag", 375 "required" => false, 376 "choices" => $field_settings, 377 "pf_apifield" => "interactionTag", 378 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text and Interaction Type above, and your Interaction Tag here. This is separate to the 'Comments' field above.", 379 ); 380 381 $fields[] = array( 382 "label" => 'Interaction: Sub-Tag', 383 "type" => "select", 384 "name" => "profilerdonation_interaction_subtag", 385 "required" => false, 386 "choices" => $field_settings, 387 "pf_apifield" => "interactionSubTag", 388 "tooltip" => "If you wish to setup an Interaction, specify your Interaction Text and Interaction Type above, and your Interaction Sub-Tag here. This is separate to the 'Comments' field above.", 389 ); 390 391 $fields[] = array( 392 "label" => 'Role: Add Role By Role Name', 393 "type" => "select", 394 "name" => "profilerdonation_role_name", 395 "required" => false, 396 "choices" => $field_settings, 397 "pf_apifield" => "roleName", 398 "tooltip" => "If you wish to add a Role to a Client by Role Name, enter the Role Name here.", 399 ); 400 401 $fields[] = array( 402 "label" => 'Role: Add Role By Role ID', 403 "type" => "select", 404 "name" => "profilerdonation_role_id", 405 "required" => false, 406 "choices" => $field_settings, 407 "pf_apifield" => "roleId", 408 "tooltip" => "If you wish to add a Role to a Client by Role ID, enter the Role ID here.", 335 409 ); 336 410 … … 341 415 "required" => false, 342 416 "choices" => $field_settings, 343 ); 344 345 $fields[] = array( 346 "label" => 'UDF: Donation Source Code', 347 "type" => "select", 348 "name" => "profilerdonation_userdefined_sourcecode", 349 "required" => false, 350 "tooltip" => "Pick the Profiler User Defined Field you wish the donation source code to be sent to", 351 "choices" => $userdefinedfields, 352 ); 353 417 "pf_apifield" => "receiptName", 418 ); 419 354 420 $fields[] = array( 355 421 "label" => 'Donation Source Code - Default Value', … … 374 440 + self::$_instance->formFields("Form Field: "), 375 441 ); 376 377 $fields[] = array( 378 "label" => 'UDF: Pledge Source Code', 379 "type" => "select", 380 "name" => "profilerdonation_userdefined_pledgesourcecode", 381 "required" => false, 382 "tooltip" => "Pick the Profiler User Defined Field you wish the pledge source code to be sent to", 383 "choices" => $userdefinedfields, 384 ); 385 442 386 443 $fields[] = array( 387 444 "label" => 'Pledge Source Code - Default Value', … … 406 463 + self::$_instance->formFields("Form Field: "), 407 464 ); 408 409 $fields[] = array( 410 "label" => 'UDF: Pledge Acquisition Code', 411 "type" => "select", 412 "name" => "profilerdonation_userdefined_pledgeacquisitioncode", 413 "required" => false, 414 "tooltip" => "Pick the Profiler User Defined Field you wish the pledge acquisition code to be sent to", 415 "choices" => $userdefinedfields, 416 ); 417 465 418 466 $fields[] = array( 419 467 "label" => 'Pledge Acquisition Code - Default Value', … … 425 473 426 474 $fields[] = array( 427 "label" => 'UDF: Client Acquisition',428 "type" => "select",429 "name" => "profilerdonation_userdefined_clientacquisitioncode",430 "required" => false,431 "tooltip" => "Pick the Profiler User Defined Field you wish the client acquisition code to be sent to.",432 "choices" => $userdefinedfields,433 );434 435 $fields[] = array(436 475 "label" => 'Client Acquisition Field', 437 476 "type" => "select", … … 441 480 "choices" => $field_settings 442 481 ); 443 444 $fields[] = array(445 "label" => 'UDF: Donation Purpose',446 "type" => "select",447 "name" => "profilerdonation_userdefined_donationpurposecode",448 "required" => false,449 "tooltip" => "Pick the Profiler User Defined Field you wish the donation's purpose code to be sent to",450 "choices" => $userdefinedfields,451 );452 482 453 483 $fields[] = array( … … 461 491 462 492 $fields[] = array( 463 "label" => 'UDF: Donation Tag',464 "type" => "select",465 "name" => "profilerdonation_userdefined_donationtagcode",466 "required" => false,467 "tooltip" => "Pick the Profiler User Defined Field you wish the donation's tag code to be sent to. Do not set this up if you use Tag Automation within Profiler.",468 "choices" => $userdefinedfields,469 );470 471 $fields[] = array(472 493 "label" => 'Donation Tag Field', 473 494 "type" => "select", … … 479 500 480 501 $fields[] = array( 481 "label" => 'UDF: Client Preferred Contact Method', 482 "type" => "select", 483 "name" => "profilerdonation_userdefined_clientpreferredcontactmethod", 484 "required" => false, 485 "tooltip" => "Pick the Profiler User Defined Field you wish the client's preferred contact method to be sent to", 486 "choices" => $userdefinedfields, 487 ); 488 502 "label" => 'Interaction: Membership/Regular Mapping Text', 503 "type" => "select", 504 "name" => "profilerdonation_membership_mapping_text", 505 "required" => false, 506 "choices" => $field_settings, 507 "pf_apifield" => "membershipMappingText", 508 "tooltip" => "If you configure a 'Membership/Regular Type Map' in Profiler, you can use this field to perform the Mapping.", 509 ); 510 511 $fields[] = array( 512 "label" => 'Payment Split-Out Text', 513 "type" => "select", 514 "name" => "profilerdonation_payment_split_out_text", 515 "required" => false, 516 "choices" => $field_settings, 517 "pf_apifield" => "splitOutText", 518 "tooltip" => "In Profiler, you can setup a text mapping for a Split / Breakdown Payment. If configured, it uses the text in this field to perform the split. For example, a Payment comes in for 100 and split is setup in Profiler for word POSTAGE, the payment recorded in Profiler will have separate amounts for two source codes.", 519 ); 520 489 521 $fields[] = array( 490 522 "label" => 'Client Preferred Contact Method Field', … … 497 529 498 530 $fields[] = array( 499 "label" => 'UDF: Client Privacy Preference',500 "type" => "select",501 "name" => "profilerdonation_userdefined_clientprivacypreference",502 "required" => false,503 "tooltip" => "Pick the Profiler User Defined Field you wish the client's privacy preference (true/false) to be sent to",504 "choices" => $userdefinedfields,505 );506 507 $fields[] = array(508 531 "label" => 'Client Privacy Preference Field', 509 532 "type" => "select", … … 512 535 "tooltip" => "If this checkbox is true, this client will be marked as 'private'.", 513 536 "choices" => $checkboxFields 514 );515 516 $fields[] = array(517 "label" => 'UDF: Client IP Address',518 "type" => "select",519 "name" => "profilerdonation_userdefined_clientip",520 "required" => false,521 "tooltip" => "Pick the Profiler User Defined Field you wish the client's IP address to be sent to",522 "choices" => $userdefinedfields,523 );524 525 $fields[] = array(526 "label" => 'UDF: Gateway Transaction ID / Gateway Response',527 "type" => "select",528 "name" => "profilerdonation_userdefined_gatewaytransactionid",529 "required" => false,530 "tooltip" => "Pick the Profiler User Defined Field you wish the gateway transaction ID to be sent to (certain gateways only)",531 "choices" => $userdefinedfields,532 );533 534 $fields[] = array(535 "label" => 'UDF: Payment Gateway ID Used',536 "type" => "select",537 "name" => "profilerdonation_userdefined_paymentgatewayidused",538 "required" => false,539 "tooltip" => "Pick the Profiler User Defined Field you wish the payment gateway ID to be sent to",540 "choices" => $userdefinedfields,541 537 ); 542 538 … … 558 554 "choices" => $field_settings 559 555 ); 560 561 if(function_exists('gf_stripe') || class_exists('GF_PayFURL')) {562 // Stripe & PayFURL only fields563 $fields[] = array(564 "label" => 'UDF: Payment Gateway Card Token',565 "type" => "select",566 "name" => "profilerdonation_userdefined_gatewaycardtoken",567 "required" => false,568 "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Card Token to",569 "choices" => $userdefinedfields,570 );571 }572 573 if(function_exists('gf_stripe')) {574 // Stripe only fields575 $fields[] = array(576 "label" => 'UDF: Payment Gateway Customer ID',577 "type" => "select",578 "name" => "profilerdonation_userdefined_gatewaycustomerid",579 "required" => false,580 "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Customer ID to",581 "choices" => $userdefinedfields,582 );583 }584 556 585 557 … … 620 592 } else { 621 593 // Profiler will just record integration data 622 $postData['method'] = "integration.send"; 623 $postData['datatype'] = "OLDON"; 594 $postData['dataType'] = "OLDON"; 624 595 } 625 596 … … 634 605 $postData['pledgeamount'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_amount']); 635 606 } 636 637 $postData['clientname'] = $postData['firstname'] . ' ' . $postData['surname'];638 607 639 608 // Credit card fields: … … 645 614 $postData['ccv'] = $cardDetails['ccv']; 646 615 647 if($feed['meta']['profilerdonation_userdefined_receiptname'] !== "") { 648 // Receipt Name 649 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_receiptname']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_receiptname']); 650 } 651 652 if($feed['meta']['profilerdonation_userdefined_paymentgatewayidused'] !== "") { 653 // Payment Gateway ID Used 654 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentgatewayidused']); 655 656 if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']])) { 657 // Use default value 658 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $feed['meta']['profilerdonation_paymentgatewayidused_default']; 659 } 660 } 661 616 // Payment Gateway ID Used 617 $postData['paymentGatewayIdUsed'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentgatewayidused']); 618 619 if(empty($postData['paymentGatewayIdUsed'])) { 620 // Use default value 621 $postData['paymentGatewayIdUsed'] = $feed['meta']['profilerdonation_paymentgatewayidused_default']; 622 } 662 623 663 624 // Source codes … … 671 632 } 672 633 673 $postData['sourcecode'] = $donationSourceCode; 674 675 if($feed['meta']['profilerdonation_userdefined_sourcecode'] !== "") { 676 // Donation Source Code 677 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']] = $donationSourceCode; 678 } 679 680 if($feed['meta']['profilerdonation_userdefined_pledgesourcecode'] !== "") { 681 // Pledge Source Code 682 683 if(isset($feed['meta']['profilerdonation_pledgesourcecodemode']) && $feed['meta']['profilerdonation_pledgesourcecodemode'] !== "normal") { 684 // The source code is a value of a specified field 685 $pledgeSourceCode = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgesourcecodemode']); 686 687 } else { 688 // Regular behaviour 689 $pledgeSourceCode = $this->getDonationCode($feed, 'pledgesourcecode', $form); 690 } 691 692 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgesourcecode']] = $pledgeSourceCode; 693 } 694 695 if($feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode'] !== "") { 696 // Pledge Acqusition code 697 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode']] = $this->getDonationCode($feed, 'pledgeacquisitioncode', $form); 698 } 699 700 if($feed['meta']['profilerdonation_userdefined_pledgetypeid'] !== "") { 701 // Pledge Type ID 702 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgetypeid']); 703 704 if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']])) { 705 // Default value if above field is empty 706 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $feed['meta']['profilerdonation_pledgetypeid_default']; 707 } 708 } 709 710 if($feed['meta']['profilerdonation_userdefined_clientacquisitioncode'] !== "" && $feed['meta']['profilerdonation_clientacquisitioncode'] !== "") { 634 $postData['donationSourceCode'] = $donationSourceCode; 635 636 // Pledge Source Code 637 638 if(isset($feed['meta']['profilerdonation_pledgesourcecodemode']) && $feed['meta']['profilerdonation_pledgesourcecodemode'] !== "normal") { 639 // The source code is a value of a specified field 640 $pledgeSourceCode = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgesourcecodemode']); 641 642 } else { 643 // Regular behaviour 644 $pledgeSourceCode = $this->getDonationCode($feed, 'pledgesourcecode', $form); 645 } 646 647 $postData['regularSourceCode'] = $pledgeSourceCode; 648 649 // Pledge Acqusition code 650 $postData['regularAcquiredReason'] = $this->getDonationCode($feed, 'pledgeacquisitioncode', $form); 651 652 // Pledge Type ID 653 $postData['regularType'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgetypeid']); 654 655 if(empty($postData['regularType'])) { 656 // Default value if above field is empty 657 $postData['regularType'] = $feed['meta']['profilerdonation_pledgetypeid_default']; 658 } 659 660 if($feed['meta']['profilerdonation_clientacquisitioncode'] !== "") { 711 661 // Client Acqusition code 712 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_clientacquisitioncode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientacquisitioncode']);713 714 } else if ($feed['meta']['profilerdonation_userdefined_clientacquisitioncode'] !== ""){715 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_clientacquisitioncode']] = $this->getDonationCode($feed, 'clientacquisitioncode', $form);716 } 717 718 if($feed['meta']['profilerdonation_ userdefined_donationpurposecode'] !== "" && $feed['meta']['profilerdonation_donationpurposecode'] !== "") {719 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_donationpurposecode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationpurposecode']);720 } 721 722 if($feed['meta']['profilerdonation_ userdefined_donationtagcode'] !== "" && $feed['meta']['profilerdonation_donationtagcode'] !== "") {723 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_donationtagcode']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtagcode']);724 } 725 726 if( $feed['meta']['profilerdonation_userdefined_gatewaytransactionid'] !== "" &&isset($entry['transaction_id'])) {662 $postData['clientAcquiredReason'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientacquisitioncode']); 663 664 } else { 665 $postData['clientAcquiredReason'] = $this->getDonationCode($feed, 'clientacquisitioncode', $form); 666 } 667 668 if($feed['meta']['profilerdonation_donationpurposecode'] !== "") { 669 $postData['paymentPupose'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationpurposecode']); 670 } 671 672 if($feed['meta']['profilerdonation_donationtagcode'] !== "") { 673 $postData['paymentTag'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtagcode']); 674 } 675 676 if(isset($entry['transaction_id'])) { 727 677 // Gateway transaction id 728 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaytransactionid']] = $entry['transaction_id'];729 } 730 731 if( $feed['meta']['profilerdonation_userdefined_gatewaytransactionid'] !== "" &&isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id'])) {678 $postData['gatewayResponseId'] = $entry['transaction_id']; 679 } 680 681 if(isset($_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id'])) { 732 682 // PayFURL-supplied Gateway Response 733 683 $payfurl_gateway_response = $_POST['payfurl_payment_details']['captured_payment']['payfurl_transaction_id']; 734 684 735 685 if(!empty($payfurl_gateway_response)) { 736 $postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaytransactionid']] = $payfurl_gateway_response;686 $postData['gatewayResponseId'] = $payfurl_gateway_response; 737 687 } 738 688 } … … 743 693 } 744 694 745 if($feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod'] !== "") { 746 // Client Preferred Contact Method 747 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientpreferredcontactmethod']); 748 } 749 750 if($feed['meta']['profilerdonation_userdefined_clientprivacypreference'] !== "") { 751 // Client Privacy Preference 752 753 $privacy_field_value = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientprivacypreference']); 754 755 if(!empty($privacy_field_value)) { 756 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_clientprivacypreference']] = 'true'; 757 } 758 } 695 // Client Preferred Contact Method 696 $postData['clientPreferredContactMethod'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientpreferredcontactmethod']); 697 698 // Client Privacy Preference 699 $privacy_field_value = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientprivacypreference']); 700 if(!empty($privacy_field_value)) { 701 $postData['clientPrivacyPreference'] = 'true'; 702 } 703 704 // Comments field 705 $comments = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_comments']); 706 707 if(!empty($feed['meta']['profilerdonation_commentsextra'])) { 708 // Extra text to append to comments field 709 $comments .= GFCommon::replace_variables($feed['meta']['profilerdonation_commentsextra'], $form, $entry, false, true, false, 'text'); 710 } 711 712 $comments = html_entity_decode($comments); 713 714 // Only allow ASCII printable characters. 715 // This is a work-around to the API endpoint not allowing some characters 716 $comments = preg_replace('/[^\x20-\x7E]/','', $comments); 717 718 // Comments 719 $postData['comments'] = $comments; 759 720 760 721 if($this->get_field_value($form, $entry, $feed['meta']['profilerdonation_donationtype']) == "regular") { 761 722 // Recurring donation 762 $postData['data type'] = "PLG";763 $postData['pledge type'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgefreq']);764 765 if(empty($postData['pledge type'])) {723 $postData['dataType'] = "PLG"; 724 $postData['pledgeType'] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgefreq']); 725 726 if(empty($postData['pledgeType'])) { 766 727 // We assume a monthly pledge if no frequency is specified 767 $postData['pledge type'] = "monthly";728 $postData['pledgeType'] = "monthly"; 768 729 } 769 730 770 if($feed['meta']['profilerdonation_userdefined_sourcecode'] !== "") { 771 // If it's recurring, the donation gets the pledge source code instead of the donation code 772 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']] = $this->getDonationCode($feed, 'pledgesourcecode', $form); 773 } 731 // If it's recurring, the donation gets the pledge source code instead of the donation code 732 $postData['donationSourceCode'] = $this->getDonationCode($feed, 'pledgesourcecode', $form); 774 733 775 734 // Store the donation type 776 gform_add_meta($entry["id"], "profiler_type", "regular", $form _id);735 gform_add_meta($entry["id"], "profiler_type", "regular", $form['id']); 777 736 778 737 } elseif($useAsGateway == false) { … … 786 745 787 746 unset($postData['pledgeamount']); 788 unset($postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode']]);789 unset($postData[' userdefined' . $feed['meta']['profilerdonation_userdefined_pledgesourcecode']]);747 unset($postData['regularAcquiredReason']); 748 unset($postData['regularSourceCode']); 790 749 791 750 } else { … … 810 769 unset($postData['cardexpiry']); 811 770 812 $postData['b ankaccountname'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountname"]);813 $postData['b ankbsb'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_bsb"]);814 $postData['b ankaccountnumber'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountnumber"]);771 $postData['bsbAccName'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountname"]); 772 $postData['bsb'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_bsb"]); 773 $postData['bsbAccNum'] = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_bankdebit_accountnumber"]); 815 774 816 775 } elseif($this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentmethod']) == "paypal") { … … 829 788 public function process_feed_success($feed, $entry, $form, $pfResponse, $postData) { 830 789 831 if(!isset($pfResponse['dataArray']['status']) || $pfResponse['dataArray']['status'] != "Pass") { 790 if(isset($pfResponse['dataArray']['success']) && $pfResponse['dataArray']['success'] === true) { 791 // Store the Integration ID as meta so we can use it later 792 if(isset($pfResponse['dataArray']['integrationId'])) { 793 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['integrationId'], $form['id']); 794 gform_add_meta($entry["id"], "profiler_integration_guid", $pfResponse['dataArray']['integrationGuid'], $form['id']); 795 gform_add_meta($entry["id"], "profiler_sourcecode", $postData['donationSourceCode'], $form['id']); 796 } 797 } else { 832 798 // Profiler failed. Send the failure email. 833 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']['profiler_erroremailaddress']); 834 835 } else { 836 // Store the Integration ID as meta so we can use it later 837 if(isset($pfResponse['dataArray']['id'])) { 838 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['id'], $form['id']); 839 gform_add_meta($entry["id"], "profiler_sourcecode", $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_sourcecode']], $form['id']); 840 } 841 } 842 799 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']["profiler".$this->gffield_legacyname."_erroremailaddress"]); 800 } 843 801 } 844 802 -
profiler-donations-gravityforms/trunk/class-profilermembership-gfaddon.php
r2750662 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/Legacy/"; 13 protected $apifield_apikey = "apikey"; 14 protected $apifield_apipass = "apipass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "membership"; 18 20 … … 43 45 $fields = parent::feed_settings_fields_custom(); 44 46 45 foreach($fields as $fieldKey => $fieldVal) { 46 if($fieldVal['label'] == "Use Profiler As A Gateway?") { 47 $fields[$fieldKey]['choices'][] = array( 48 'label' => 'Manual - Profiler will Process Payments, manually later on via a Pledge', 49 'value' => 'manual', 50 ); 47 if(apply_filters('profiler_integration_allow_profiler_gateway', true) == true) { 48 // This filter allows us to disable the Profiler Gateway feature on a site 49 50 foreach($fields as $fieldKey => $fieldVal) { 51 if($fieldVal['label'] == "Use Profiler As A Gateway?") { 52 $fields[$fieldKey]['choices'][] = array( 53 'label' => 'Manual - Profiler will Process Payments, manually later on via a Pledge', 54 'value' => 'manual', 55 ); 56 } 51 57 } 58 59 $fields[] = array( 60 "label" => 'UDF: Stored Card Number', 61 "type" => "select", 62 "name" => "profilerdonation_userdefined_storedcard_number", 63 "required" => false, 64 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card number in", 65 "choices" => $userdefinedfields, 66 ); 67 68 $fields[] = array( 69 "label" => 'UDF: Stored Card Expiry', 70 "type" => "select", 71 "name" => "profilerdonation_userdefined_storedcard_expiry", 72 "required" => false, 73 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card expiry in", 74 "choices" => $userdefinedfields, 75 ); 76 77 $fields[] = array( 78 "label" => 'UDF: Stored Card CCV', 79 "type" => "select", 80 "name" => "profilerdonation_userdefined_storedcard_ccv", 81 "required" => false, 82 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card CCV in", 83 "choices" => $userdefinedfields, 84 ); 85 86 $fields[] = array( 87 "label" => 'UDF: Stored Card Name', 88 "type" => "select", 89 "name" => "profilerdonation_userdefined_storedcard_name", 90 "required" => false, 91 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card name in", 92 "choices" => $userdefinedfields, 93 ); 94 52 95 } 53 54 $fields[] = array(55 "label" => 'UDF: Stored Card Number',56 "type" => "select",57 "name" => "profilerdonation_userdefined_storedcard_number",58 "required" => false,59 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card number in",60 "choices" => $userdefinedfields,61 );62 63 $fields[] = array(64 "label" => 'UDF: Stored Card Expiry',65 "type" => "select",66 "name" => "profilerdonation_userdefined_storedcard_expiry",67 "required" => false,68 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card expiry in",69 "choices" => $userdefinedfields,70 );71 72 $fields[] = array(73 "label" => 'UDF: Stored Card CCV',74 "type" => "select",75 "name" => "profilerdonation_userdefined_storedcard_ccv",76 "required" => false,77 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card CCV in",78 "choices" => $userdefinedfields,79 );80 81 $fields[] = array(82 "label" => 'UDF: Stored Card Name',83 "type" => "select",84 "name" => "profilerdonation_userdefined_storedcard_name",85 "required" => false,86 "tooltip" => "Pick the Profiler User Defined Field you wish to store the card name in",87 "choices" => $userdefinedfields,88 );89 96 90 97 return $fields; -
profiler-donations-gravityforms/trunk/class-profilerpostdonate-gfaddon.php
r2750662 r3211366 10 10 protected static $_instance = null; 11 11 12 protected $apifield_endpoint = "/ProfilerAPI/LegacyPost/"; 13 protected $apifield_apikey = "api_user"; 14 protected $apifield_apipass = "api_pass"; 15 protected $apifield_ipaddress = 'udf'; 16 protected $apifield_formurl = true; 12 protected $api_type = "json"; 13 protected $api_domain = "profilersoftware.com"; 14 protected $apifield_endpoint = "/ProfilerAPI/RapidEndpoint/"; 15 protected $apifield_apikey = "apiuser"; 16 protected $apifield_apipass = "apipassword"; 17 protected $apifield_ipaddress = 'requestIPAddress'; 18 protected $apifield_formurl = 'pageURL'; 17 19 protected $gffield_legacyname = "donation"; 18 20 protected $supports_custom_fields = true; … … 59 61 60 62 $fields[] = array( 61 "label" => 'UDF: Comments',62 "type" => "select",63 "name" => "profilerdonation_userdefined_comments",64 "required" => false,65 "tooltip" => "Pick the Profiler User Defined Field you wish to use for the Comments field",66 "choices" => $userdefinedfields,67 );68 69 $fields[] = array(70 63 "label" => 'Extra Comments Text', 71 64 "type" => "textarea", 72 65 "name" => "profilerdonation_commentsextra", 73 "required" => true,66 "required" => false, 74 67 "class" => "merge-tag-support", 75 68 "tooltip" => "This is extra text to be sent to Profiler as an Interaction. Protip: Include Gravity Forms Merge Fields in this textarea to accept user input.", … … 109 102 public function process_feed_custom($feed, $entry, $form, $postData, $fromValidatorProcessPFGateway = false) { 110 103 111 $postData['method'] = "integration.send";112 104 $postData['datatype'] = "OLDON"; 113 105 … … 123 115 // Comments 124 116 $postData['comments'] = $comments; 125 $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_comments']] = $comments; 126 117 127 118 $gfEntryId = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_gfentryid']); 128 119 $pfIntegrationId = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_profilerid']); … … 147 138 148 139 // This is the ID of the actual donation entry 149 $postData[' HoldingID'] = $pfIntegrationId;140 $postData['holdingId'] = $pfIntegrationId; 150 141 151 142 return $postData; … … 154 145 public function process_feed_success($feed, $entry, $form, $pfResponse, $postData) { 155 146 156 if(!isset($pfResponse['dataArray']['status']) || $pfResponse['dataArray']['status'] != "Pass") { 147 if(isset($pfResponse['dataArray']['success']) && $pfResponse['dataArray']['success'] === true) { 148 // Store the Integration ID as meta so we can use it later 149 if(isset($pfResponse['dataArray']['integrationId'])) { 150 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['integrationId'], $form['id']); 151 gform_add_meta($entry["id"], "profiler_integration_guid", $pfResponse['dataArray']['integrationGuid'], $form['id']); 152 } 153 } else { 157 154 // Profiler failed. Send the failure email. 158 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']['profiler_erroremailaddress']); 159 160 } else { 161 // Store the Integration ID as meta so we can use it later 162 if(isset($pfResponse['dataArray']['id'])) 163 gform_add_meta($entry["id"], "profiler_integrationid", $pfResponse['dataArray']['id'], $form['id']); 155 $this->sendFailureEmail($entry, $form, $pfResponse, $feed['meta']["profiler".$this->gffield_legacyname."_erroremailaddress"]); 164 156 } 165 166 157 } 167 158 -
profiler-donations-gravityforms/trunk/index.php
r3136560 r3211366 1 1 <?php 2 2 /* 3 Plugin Name: Profiler Donations - Gravity FormsAdd-On3 Plugin Name: Gravity Forms + Profiler Add-On 4 4 Plugin URI: https://mediarealm.com.au/ 5 5 Description: Integrates Gravity Forms with Profiler, enabling donation data and more to be sent directly to Profiler. 6 Version: 2. 4.36 Version: 2.5.0 7 7 8 8 Author: Media Realm … … 66 66 //GFAddOn::register('GFProfilerEvents'); 67 67 68 // This is a settings screen to list all Profiler feeds in the system 69 require_once('class-feedlist-gfaddon.php'); 70 GFAddOn::register('GF_Profiler_FeedList'); 71 68 72 // Include some random helper functions 69 73 require_once(plugin_dir_path(__FILE__) . '/shortcodes.php'); -
profiler-donations-gravityforms/trunk/readme.txt
r3136560 r3211366 22 22 23 23 == Changelog == 24 25 = 2.5.0 = 26 27 This is a substantial update. Please backup your site before upgrading, and test all your integrations thoroughly after upgrading this plugin. 28 29 * Use the new Profiler Core API for Donations/payments. This removes the UDF field config and automates it within Profiler. 30 * Create 'Profiler Feed List' setting screen, for quick access to all configured feeds on your site 31 * Remove Profiler Logs fields, and move these to an entry metabox. 32 * Donation Feed: Add Extra Comments field 33 * Donation Feed: Automatic formatting of Australian phone numbers 34 * Add Profiler icon to all Feeds 35 * Donation Feed: Add new fields for gender, interactions, roles, membership mapping and payment split text. 36 * Membership Feed: Hide manual payment fields if Profiler-driven payments have been disabled 24 37 25 38 = 2.4.3 = -
profiler-donations-gravityforms/trunk/sync_users.php
r2750662 r3211366 232 232 233 233 if(empty($options['auth_apikey']) || empty($options['auth_apipass']) || empty($options['pf_database']) || empty($options['pf_domain'])) { 234 $this->log("Profiler Users not configured correctly");235 234 return; 236 235 } -
profiler-donations-gravityforms/trunk/woocommerce/integration.php
r2984822 r3211366 23 23 $this->dbname = $this->get_option( 'dbname' ); 24 24 $this->apikey = $this->get_option( 'apikey' ); 25 26 // Upgrade config to new domain 27 $this->instancedomainname = str_replace(".profilersystem.com", ".profilersoftware.com", $this->instancedomainname); 25 28 26 29 // Actions. … … 54 57 'title' => 'Profiler Instance Domain Name', 55 58 'type' => 'text', 56 'description' => 'e.g. example.profilers ystem.com',59 'description' => 'e.g. example.profilersoftware.com', 57 60 'desc_tip' => true, 58 61 'default' => '', … … 85 88 'desc_tip' => true, 86 89 'default' => '' 87 ),88 'udf_sourcecode' => array(89 'title' => 'UDF: Donation Source Code',90 'type' => 'select',91 'description' => '',92 'desc_tip' => true,93 'default' => '',94 'options' => $this->options_udf(),95 ),96 'udf_clientip' => array(97 'title' => 'UDF: Client IP Address',98 'type' => 'select',99 'description' => '',100 'desc_tip' => true,101 'default' => '',102 'options' => $this->options_udf(),103 ),104 'udf_transactionid' => array(105 'title' => 'UDF: Gateway Transaction ID',106 'type' => 'select',107 'description' => '',108 'desc_tip' => true,109 'default' => '',110 'options' => $this->options_udf(),111 90 ), 112 91 ); … … 204 183 205 184 // Build API payload 206 $url = 'https://' . $this->instancedomainname . '/ProfilerAPI/ Legacy/';185 $url = 'https://' . $this->instancedomainname . '/ProfilerAPI/RapidEndpoint/'; 207 186 $profiler_data = array( 208 'DB' => $this->dbname, 209 'apikey' => $this->apikey, 210 'apipass' => $this->get_option('apipass'), 211 'method' => 'integration.send', 187 'apiuser' => $this->apikey, 188 'apipassword' => $this->get_option('apipass'), 212 189 'datatype' => 'OLDON', 213 190 214 191 'amount' => $total, 215 'donation amount' => $total,216 ' sourcecode' => $this->get_option('sourcecode'),192 'donationAmount' => $total, 193 'donationSourceCode' => $this->get_option('sourcecode'), 217 194 'status' => 'Approved', 218 195 219 196 'clientname' => $first_name . ' ' . $last_name, 220 'first name' => $first_name,197 'firstName' => $first_name, 221 198 'surname' => $last_name, 222 199 … … 233 210 ); 234 211 235 if($this->get_option('udf_sourcecode') != '') { 236 // Source code as a UDF 237 $profiler_data['userdefined' . $this->get_option('udf_sourcecode')] = $this->get_option('sourcecode'); 238 } 212 // Source code as a UDF 213 $profiler_data['donationSourceCode'] = $this->get_option('sourcecode'); 239 214 240 215 if($order->needs_payment()) { … … 243 218 } 244 219 245 if($this->get_option('udf_clientip') != '') { 246 // Client IP Address 247 $profiler_data['userdefined' . $this->get_option('udf_clientip')] = $this->get_client_ip_address(); 248 } 249 250 if($this->get_option('udf_transactionid') != '') { 251 // Payment Gateway Transaction ID 252 $profiler_data['userdefined' . $this->get_option('udf_transactionid')] = $order->get_transaction_id(); 253 } 220 // Client IP Address 221 $profiler_data['requestIPAddress'] = $this->get_client_ip_address(); 222 223 // Payment Gateway Transaction ID 224 $profiler_data['gatewayResponseId'] = $order->get_transaction_id(); 254 225 255 226 // Push data to Profiler … … 350 321 351 322 $ch = curl_init(); 352 curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query(array("DB" => $profiler_query['DB'], "Call" => 'submit')));323 curl_setopt($ch, CURLOPT_URL, $url); 353 324 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 354 curl_setopt($ch, CURLOPT_ HTTPHEADER, array('Content-Length: ' . strlen(http_build_query($profiler_query))));355 curl_setopt($ch, CURLOPT_ POSTFIELDS, http_build_query($profiler_query));325 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($profiler_query)); 326 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 356 327 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 357 328 … … 386 357 "dataSent" => $profiler_query, 387 358 "data" => $result, 388 "dataXML" => simplexml_load_string($result), 389 "dataArray" => json_decode(json_encode((array)simplexml_load_string($result)), 1), 359 "dataArray" => json_decode($result, true), 390 360 "cURLError" => $cURL_error, 391 361 "cURL_SSL_Mode" => $ssl_mode, 392 362 ); 393 }394 395 private function options_udf() {396 $fields = array("0" => "");397 398 for($i = 1; $i <= 99; $i++) {399 $fields[$i] = "User Defined Field " . $i;400 }401 402 return $fields;403 363 } 404 364
Note: See TracChangeset
for help on using the changeset viewer.