Plugin Directory

Changeset 2618947


Ignore:
Timestamp:
10/24/2021 06:58:21 AM (4 years ago)
Author:
anthonyeden
Message:

Version 2.1.0

Location:
profiler-donations-gravityforms
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • profiler-donations-gravityforms/trunk/class-profilercommon.php

    r2319643 r2618947  
    1414    protected $gffield_legacyname = "";
    1515    protected $supports_custom_fields = false;
     16    protected $supports_mailinglists = false;
    1617
    1718    public function init() {
    1819        parent::init();
     20
     21        // Stripe - force Customer creation
     22        add_filter('gform_stripe_customer_id',              array($this, 'stripe_customer_id'), 10, 4);
     23        add_action('gform_stripe_customer_after_create',    array($this, 'stripe_customer_id_save'), 10, 4);
     24        add_filter('gform_stripe_charge_pre_create',        array($this, 'stripe_payment_intent'), 10, 5);
    1925    }
    2026
     
    2834        $hiddenFields = $this->hiddenFields();
    2935        $checkboxRadioFields = $this->checkboxRadioFields();
     36        $checkboxFields = $this->checkboxFields();
    3037        $userdefinedfields = $this->userDefinedFields();
    31         $customfields = $this->custom_fields_get();
    3238
    3339        $numbers = array();
     
    112118        }
    113119
     120        // Mailing list support
     121        if($this->supports_mailinglists === true) {
     122            $fields[] = array(
     123                "label" => 'Number of Mailing Lists',
     124                "type" => "select",
     125                "name" => "profiler".$this->gffield_legacyname."_mailinglist_count",
     126                "required" => false,
     127                "tooltip" => "Select a quantity of Mailing Lists, save this page, and then configure them. You will need to refresh this page after saving to see the extra fields.",
     128                "choices" => $numbers,
     129                "default" => 0,
     130            );
     131
     132            for($i = 1; $i <= $feed['meta']['profiler'.$this->gffield_legacyname.'_mailinglist_count']; $i++) {
     133                // Loop over mailing list fields
     134
     135                $fields[] = array(
     136                    "label" => 'Mailing List #'.$i.': UDF',
     137                    "type" => "select",
     138                    "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf",
     139                    "required" => false,
     140                    "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing",
     141                    "choices" => $userdefinedfields,
     142                );
     143
     144                $fields[] = array(
     145                    "label" => 'Mailing List #'.$i.': UDF Text',
     146                    "type" => "text",
     147                    "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext",
     148                    "required" => false,
     149                    "tooltip" => "Enter the string Profiler is expecting in this UDF",
     150                );
     151
     152                $fields[] = array(
     153                    "label" => 'Mailing List #'.$i.': Field',
     154                    "type" => "select",
     155                    "name" => "profiler".$this->gffield_legacyname."_mailinglist_".$i."_field",
     156                    "tooltip" => 'Link it to a checkbox field - when checked, the mailing will be sent',
     157                    "required" => false,
     158                    "choices" => $checkboxFields
     159                );
     160            }
     161        }
     162
    114163        if($this->supports_custom_fields === true) {
    115164            $fields[] = array(
     
    118167                "name" => "profiler_customfields_count",
    119168                "required" => false,
    120                 "tooltip" => "How many custom fields do you want to send back to Profiler?",
     169                "tooltip" => "How many custom fields do you want to send back to Profiler? You will need to refresh this page after saving to see the extra fields.",
    121170                "choices" => $numbers,
    122171            );
     
    126175
    127176                $fields[] = array(
    128                     "label" => 'Custom Field #'.$i.': Profiler Field',
     177                    "label" => 'Custom Field #'.$i.': UDF',
    129178                    "type" => "select",
    130179                    "name" => "profiler_customfield_".$i."_pffield",
    131180                    "required" => false,
    132                     "tooltip" => "Pick the field in Profiler you wish to use",
    133                     "choices" => $customfields,
     181                    "tooltip" => "Pick the UDF field in Profiler you wish to use",
     182                    "choices" => $userdefinedfields,
    134183                );
    135184
     
    234283        }
    235284
    236         if($this->apifield_formurl === true && !empty($feed['meta']['profiler_userdefined_clientip'])) {
    237             $postData['userdefined' . $feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_clientip']] = $entry['source_url'];
     285        if($this->apifield_formurl === true && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl'])) {
     286            $postData['userdefined' . $feed['meta']['profiler'.$this->gffield_legacyname.'_userdefined_formurl']] = $entry['source_url'];
     287        }
     288
     289        if(substr($entry['transaction_id'], 0, 3) == "pi_") {
     290            // Stripe Payment - find the Customer ID and Card ID, and pass it to the PF API
     291
     292            try {
     293                if ( ! class_exists( '\Stripe\Stripe' ) ) {
     294                    require_once( plugin_dir_path( __DIR__ ) . 'gravityformsstripe/includes/autoload.php' );
     295                }
     296
     297                // Set Stripe API key.
     298                $stripe_options = get_option('gravityformsaddon_gravityformsstripe_settings');
     299                \Stripe\Stripe::setApiKey( $stripe_options[$stripe_options['api_mode'] . '_secret_key'] );
     300               
     301                // Get the Payment Intent
     302                $payment_intent = \Stripe\PaymentIntent::retrieve($entry['transaction_id']);
     303
     304            } catch(Exception $e) {
     305                error_log("STRIPE/PROFILER SETUP ERROR: " . print_r($e, true));
     306            }
     307
     308            if($feed['meta']['profilerdonation_userdefined_gatewaycustomerid'] !== "" && isset($payment_intent)) {
     309                // Gateway Customer ID
     310                $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycustomerid']] = $payment_intent->customer;
     311            }
     312
     313            if($feed['meta']['profilerdonation_userdefined_gatewaycardtoken'] !== "" && isset($payment_intent)) {
     314                // Gateway Card Token
     315                try {
     316                    $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_gatewaycardtoken']] = $payment_intent->charges->data[0]->payment_method;
     317                } catch(Exception $e) {
     318                    error_log("STRIPE/PROFILER CARD TOKEN ERROR: " . print_r($e, true));
     319                }
     320            }
    238321        }
    239322
     
    241324        if($this->supports_custom_fields === true && !empty($feed['meta']['profiler_customfields_count'])) {
    242325            for($i = 1; $i <= $feed['meta']['profiler_customfields_count']; $i++) {
    243                 $postData["custom_" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"]));
     326                $postData["userdefined" . $feed['meta']["profiler_customfield_".$i."_pffield"]] = trim($this->get_field_value($form, $entry, $feed['meta']["profiler_customfield_".$i."_gffield"]));
     327            }
     328        }
     329
     330        // Calculate mailing list subscriptions
     331        if($this->supports_mailinglists === true && isset($feed['meta']['profiler'.$this->gffield_legacyname.'_mailinglist_count']) && is_numeric($feed['meta']['profiler'.$this->gffield_legacyname.'_mailinglist_count'])) {
     332            for($i = 1; $i <= $feed['meta']['profiler'.$this->gffield_legacyname.'_mailinglist_count']; $i++) {
     333                // Loop over mailing list fields
     334                $mailingFieldValue = $this->get_field_value($form, $entry, $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_field"]);
     335                $udf = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udf"];
     336                $udfText = $feed['meta']["profiler".$this->gffield_legacyname."_mailinglist_".$i."_udftext"];
     337
     338                if(!empty($udf) && !empty($udfText) && !empty($mailingFieldValue)) {
     339                    $postData['userdefined' . $udf] = $udfText;
     340                }
     341
    244342            }
    245343        }
     
    392490    }
    393491
     492    protected function checkboxFields() {
     493        // Returns an array of checkbox fields
     494
     495        $form = $this->get_current_form();
     496        $fields = $form['fields'];
     497
     498        // An array holding all the hidden fields on the form - will be returned
     499        $formfields = array(
     500            array(
     501                "value" => "",
     502                "label" => ""
     503            )
     504        );
     505
     506        foreach ($fields as $key => $field) {
     507            if ($field['type'] == 'checkbox') {
     508                foreach($field['inputs'] as $input) {
     509                    $formfields[] = array(
     510                        "value" => $input['id'],
     511                        "label" => "Field #" . $input['id'] . " - " . $field['label'] . " / " . $input['label']
     512                    );
     513                }
     514            }
     515        }
     516
     517        return $formfields;
     518    }
     519
    394520    protected function selectFields() {
    395521        // Returns an array of checkbox and radio fields
     
    584710        $result = parent::save_feed_settings($feed_id, $form_id, $settings);
    585711
    586         $this->custom_fields_cache();
    587 
    588712        return $result;
    589 
    590     }
    591 
    592     private function custom_fields_cache() {
    593         // Call this function to update the cached list of custom fields
    594 
    595         if($this->supports_custom_fields !== true) {
    596             return false;
    597         }
    598 
    599         // Data from Profiler is stored in here
    600         $data = array();
    601 
    602         $feed = $this->get_current_feed();
    603 
    604         // All the POST data for Profiler gets stored in this variable
    605         $postData = array();
    606 
    607         $postData['DB'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_dbname'];
    608         $postData[$this->apifield_apikey] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apikey'];
    609         $postData[$this->apifield_apipass] = $feed['meta']['profiler'.$this->gffield_legacyname.'_apipass'];
    610 
    611         if(empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname']) && !empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'])) {
    612             // Respect the setting from when we only accepted the first part of the domain name
    613             $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] = $feed['meta']['profiler'.$this->gffield_legacyname.'_instancename'] . ".profiler.net.au";
    614         }
    615 
    616         if(empty($postData['DB']) || empty($postData[$this->apifield_apikey]) || empty($postData[$this->apifield_apipass]) || empty($feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'])) {
    617             return false;
    618         }
    619 
    620         // Build the URL for this API call
    621         $API_URL = "https://" . $feed['meta']['profiler'.$this->gffield_legacyname.'_instancedomainname'] . '/ProfilerAPI/system/customfields/';
    622 
    623         // Send request to Profiler
    624         $pfResponse = $this->sendDataToProfiler($API_URL, $postData, $feed['meta']['profiler_sslmode']);
    625 
    626         // Loop over all the returned fields and pop them into the array of data to be saved
    627         if(isset($pfResponse['dataArray']['field']) && count($pfResponse['dataArray']['field']) > 0) {
    628             foreach($pfResponse['dataArray']['field'] as $field) {
    629                 $data[] = array(
    630                     'id' => $field['id'],
    631                     'field_name' => $field['field_name'],
    632                     'friendly_name' => $field['friendly_name'],
    633                     'field_category' => $field['field_category'],
    634                     'sortorder' => $field['sortorder'],
    635                 );
    636             }
    637 
    638             // Update the cached data
    639             update_option('profilergf_'.$this->get_current_feed_id().'_customfields', $data);
    640         }
    641 
    642     }
    643 
    644     protected function custom_fields_get() {
    645         // Returns a list of all custom fields (from the cache)
    646 
    647         if($this->supports_custom_fields !== true) {
    648             return false;
    649         }
    650 
    651         $fields = get_option('profilergf_'.$this->get_current_feed_id().'_customfields', array());
    652 
    653         $formfields = array(
    654             array(
    655                 "value" => "",
    656                 "label" => ""
    657             )
    658         );
    659 
    660         foreach($fields as $field) {
    661             $formfields[] = array(
    662                 "value" => $field['id'],
    663                 "label" => $field['field_name'] . ": " . $field['friendly_name'],
    664             );
    665         }
    666 
    667         return $formfields;
    668713
    669714    }
     
    774819    }
    775820
    776     protected function enable_creditcard($is_enabled) {
     821    public function enable_creditcard($is_enabled) {
    777822        return true;
    778823    }
     
    822867    }
    823868
     869    public function stripe_customer_id($customer_id, $feed, $entry, $form) {
     870        // Create a new customer in Stripe
     871
     872        // Find email address field
     873        foreach($form['fields'] as &$field) {
     874            if($field->type == "email") {
     875                $email = $this->get_field_value($form, $entry, $field->id);
     876            }
     877        }
     878
     879        // Find name field on form
     880        $name = '';
     881        foreach($form['fields'] as $fieldKey => $field) {
     882            if($field->type == "name") {
     883                $name = $entry[$field->id . '.3'] . ' ' . $entry[$field->id . '.6'];
     884            }
     885        }
     886
     887        if(!isset($email)) {
     888            return $customer_id;
     889        }
     890
     891        if(class_exists('\Stripe\Customer')) {
     892            // Find an existing customer by email
     893            $stripe_all_customers = \Stripe\Customer::all(array(
     894                'email' => $email,
     895                'limit' => 1
     896            ));
     897
     898            if(isset($stripe_all_customers['data'][0]['id'])) {
     899                // Update the name of the customer
     900                if(!empty($name)) {
     901                    $update = \Stripe\Customer::update(
     902                        $stripe_all_customers['data'][0]['id'],
     903                        array(
     904                            'name' => $name
     905                        )
     906                    );
     907                }
     908
     909                // Return existing customer ID
     910                return $stripe_all_customers['data'][0]['id'];
     911            }
     912        }
     913
     914        // Create a new customer
     915        $customer_meta = array();
     916        $customer_meta['description'] = $email_address . ' ' . $name;
     917        $customer_meta['name'] = $name;
     918        $customer_meta['email'] = $email_address;
     919
     920        $customer = gf_stripe()->create_customer($customer_meta, $feed, $entry, $form);
     921        return $customer->id;
     922    }
     923
     924    public function stripe_customer_id_save($customer, $feed, $entry, $form) {
     925        // Get the new Stripe Customer ID and save for later use
     926        gform_update_meta($entry['id'], 'stripe_customer_id', $customer->id);
     927        return $customer;
     928    }
     929
     930    public function stripe_payment_intent($charge_meta, $feed, $submission_data, $form, $entry) {
     931        $charge_meta['setup_future_usage'] = 'off_session';
     932        return $charge_meta;
     933    }
    824934}
    825935
  • profiler-donations-gravityforms/trunk/class-profilerdonate-gfaddon.php

    r2319642 r2618947  
    1616    protected $apifield_formurl = true;
    1717    protected $gffield_legacyname = "donation";
     18    protected $supports_custom_fields = true;
     19    protected $supports_mailinglists = true;
    1820
    1921    public static function get_instance() {
     
    6365        $checkboxRadioFields = self::$_instance->checkboxRadioFields();
    6466        $userdefinedfields = self::$_instance->userDefinedFields();
    65 
    66         $mailingnumbers = array();
    67         for($i = 0; $i <= 99; $i++) {
    68             $mailingnumbers[] = array(
    69                 "value" => $i,
    70                 "label" => $i
    71             );
    72         }
    7367
    7468        // All the fields to add to the feed:
     
    137131            "tooltip" => "This amount field will be used if Donation Type is set to 'regular'.",
    138132        );
    139        
     133
     134        $fields[] = array(
     135            "label" => 'UDF: Pledge Type ID',
     136            "type" => "select",
     137            "name" => "profilerdonation_userdefined_pledgetypeid",
     138            "required" => false,
     139            "tooltip" => "Pick the Profiler User Defined Field you wish the Pledge Type ID to be sent to",
     140            "choices" => $userdefinedfields,
     141        );
     142
     143        $fields[] = array(
     144            "label" => 'Pledge Type ID',
     145            "type" => "select",
     146            "name" => "profilerdonation_pledgetypeid",
     147            "required" => false,
     148            "choices" => $field_settings,
     149            "tooltip" => "Set this field to the Pledge Type ID"
     150        );
     151
     152        $fields[] = array(
     153            "label" => 'Pledge Type ID (Default)',
     154            "type" => "text",
     155            "name" => "profilerdonation_pledgetypeid_default",
     156            "required" => false,
     157            "tooltip" => "Set a default Pledge Type ID, in case the above field isn't set"
     158        );
     159
    140160        $fields[] = array(
    141161            "label" => 'Client: Title',
     
    450470
    451471        $fields[] = array(
     472            "label" => 'UDF: Client Preferred Contact Method',
     473            "type" => "select",
     474            "name" => "profilerdonation_userdefined_clientpreferredcontactmethod",
     475            "required" => false,
     476            "tooltip" => "Pick the Profiler User Defined Field you wish the client's preferred contact method to be sent to",
     477            "choices" => $userdefinedfields,
     478        );
     479       
     480        $fields[] = array(
     481            "label" => 'Client Preferred Contact Method Field',
     482            "type" => "select",
     483            "name" => "profilerdonation_clientpreferredcontactmethod",
     484            "required" => false,
     485            "tooltip" => "This field's value should match one of these codes: E = Email; P = Post; T = Phone; S = SMS; N = No Contact Preferred",
     486            "choices" => $field_settings
     487        );
     488
     489        $fields[] = array(
    452490            "label" => 'UDF: Client IP Address',
    453491            "type" => "select",
     
    477515
    478516        $fields[] = array(
    479             "label" => 'Payment Gateway ID Used',
     517            "label" => 'Payment Gateway ID Used (Field)',
    480518            "type" => "select",
    481519            "name" => "profilerdonation_paymentgatewayidused",
     
    486524
    487525        $fields[] = array(
    488             "label" => 'Number of Mailing Lists',
    489             "type" => "select",
    490             "name" => "profilerdonation_mailinglist_count",
    491             "required" => false,
    492             "tooltip" => "Select a quantity of Mailing Lists, save this page, and then configure them. You may need to refresh this page after saving to see the extra fields.",
    493             "choices" => $mailingnumbers,
    494             "default" => 0,
    495         );
    496 
    497         for($i = 1; $i <= $feed['meta']['profilerdonation_mailinglist_count']; $i++) {
    498             // Loop over mailing list fields
    499 
     526            "label" => 'Payment Gateway ID Used (Default)',
     527            "type" => "text",
     528            "name" => "profilerdonation_paymentgatewayidused_default",
     529            "required" => false,
     530            "tooltip" => "Specify a default Payment Gateway ID to send through to Profiler",
     531            "choices" => $field_settings
     532        );
     533
     534        if(function_exists('gf_stripe')) {
     535            // Stripe only fields
    500536            $fields[] = array(
    501                 "label" => 'Mailing List #'.$i.': UDF',
     537                "label" => 'UDF: Payment Gateway Card Token',
    502538                "type" => "select",
    503                 "name" => "profilerdonation_mailinglist_".$i."_udf",
     539                "name" => "profilerdonation_userdefined_gatewaycardtoken",
    504540                "required" => false,
    505                 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing",
     541                "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Card Token to",
    506542                "choices" => $userdefinedfields,
    507543            );
    508 
     544   
    509545            $fields[] = array(
    510                 "label" => 'Mailing List #'.$i.': UDF Text',
    511                 "type" => "text",
    512                 "name" => "profilerdonation_mailinglist_".$i."_udftext",
     546                "label" => 'UDF: Payment Gateway Customer ID',
     547                "type" => "select",
     548                "name" => "profilerdonation_userdefined_gatewaycustomerid",
    513549                "required" => false,
    514                 "tooltip" => "Enter the string Profiler is expecting in this UDF",
     550                "tooltip" => "Pick the Profiler User Defined Field you wish to send the payment gateway Customer ID to",
     551                "choices" => $userdefinedfields,
    515552            );
    516 
    517             $fields[] = array(
    518                 "label" => 'Mailing List #'.$i.': Field',
    519                 "type" => "select",
    520                 "name" => "profilerdonation_mailinglist_".$i."_field",
    521                 "tooltip" => 'Link it to a checkbox field - when checked, the mailing will be sent',
    522                 "required" => false,
    523                 "choices" => $checkboxFields
    524             );
    525         }
    526 
     553        }
    527554
    528555
     
    531558    }
    532559
    533     public function process_feed_custom($feed, $entry, $form, $postData, $fromValidatorProcessPFGateway = false) {
     560    public function process_feed_custom($feed, $entry, $form, $postData, $fromValidatorProcessPFGateway = false, $forceSendCard = false) {
    534561        // Processes the feed and prepares to send it to Profiler
    535562        // This can either do a gateway payment, or just an integration
     
    591618            // Payment Gateway ID Used
    592619            $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_paymentgatewayidused']);
     620
     621            if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']])) {
     622                // Use default value
     623                $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_paymentgatewayidused']] = $feed['meta']['profilerdonation_paymentgatewayidused_default'];
     624            }
    593625        }
    594626
     
    631663        }
    632664
     665        if($feed['meta']['profilerdonation_userdefined_pledgetypeid'] !== "") {
     666            // Pledge Type ID
     667            $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_pledgetypeid']);
     668
     669            if(empty($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']])) {
     670                // Default value if above field is empty
     671                $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgetypeid']] = $feed['meta']['profilerdonation_pledgetypeid_default'];
     672            }
     673        }
     674
    633675        if($feed['meta']['profilerdonation_userdefined_clientacquisitioncode'] !== "" && $feed['meta']['profilerdonation_clientacquisitioncode'] !== "") {
    634676            // Client Acqusition code
     
    652694        }
    653695
    654         // Calculate mailing list subscriptions
    655         if(isset($feed['meta']['profilerdonation_mailinglist_count']) && is_numeric($feed['meta']['profilerdonation_mailinglist_count'])) {
    656             for($i = 1; $i <= $feed['meta']['profilerdonation_mailinglist_count']; $i++) {
    657                 // Loop over mailing list fields
    658                 $mailingFieldValue = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_mailinglist_".$i."_field"]);
    659                 $udf = $feed['meta']["profilerdonation_mailinglist_".$i."_udf"];
    660                 $udfText = $feed['meta']["profilerdonation_mailinglist_".$i."_udftext"];
    661 
    662                 if(!empty($udf) && !empty($udfText) && !empty($mailingFieldValue)) {
    663                     $postData['userdefined' . $udf] = $udfText;
    664                 }
    665 
    666             }
     696        if($feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod'] !== "") {
     697            // Client Preferred Contact Method
     698            $postData['userdefined' . $feed['meta']['profilerdonation_userdefined_clientpreferredcontactmethod']] = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_clientpreferredcontactmethod']);
    667699        }
    668700       
     
    687719        } elseif($useAsGateway == false) {
    688720            // Once-off donation (not using Profiler as the gateway)
    689             $postData['cardnumber'] = "4444333322221111"; //PF expects a card number and expiry even for once-offs which have already been processed
    690             $postData['cardexpiry'] = date("m") . " " . date("Y");
    691             $postData['ccv'] = "";
     721           
     722            if($forceSendCard == false) {
     723                $postData['cardnumber'] = "4444333322221111"; //PF expects a card number and expiry even for once-offs which have already been processed
     724                $postData['cardexpiry'] = date("m") . " " . date("Y");
     725                $postData['ccv'] = "";
     726            }
     727
    692728            unset($postData['pledgeamount']);
    693729            unset($postData['userdefined' . $feed['meta']['profilerdonation_userdefined_pledgeacquisitioncode']]);
  • profiler-donations-gravityforms/trunk/class-profilerinteraction-gfaddon.php

    r2319642 r2618947  
    1111
    1212    protected $apifield_endpoint = "/ProfilerAPI/interaction/";
    13     protected $apifield_apikey = "apiuser";
     13    protected $apifield_apikey = "apikey";
    1414    protected $apifield_apipass = "apipass";
    1515    protected $apifield_ipaddress = 'udf';
    1616    protected $apifield_formurl = true;
    1717    protected $gffield_legacyname = "interaction";
     18    protected $supports_custom_fields = true;
     19    protected $supports_mailinglists = true;
    1820
    1921    public static function get_instance() {
     
    5961        );
    6062
    61         $mailingnumbers = array();
    62         for($i = 0; $i <= 99; $i++) {
    63             $mailingnumbers[] = array(
    64                 "value" => $i,
    65                 "label" => $i
    66             );
    67         }
    68 
    6963        // All the fields to add to the feed:
    7064        $fields = array();
  • profiler-donations-gravityforms/trunk/class-profilerlists-gfaddon.php

    r2319643 r2618947  
    1313    protected $apifield_apikey = "apikey";
    1414    protected $apifield_apipass = "apipass";
     15    protected $supports_custom_fields = true;
    1516
    1617    public static function get_instance() {
  • profiler-donations-gravityforms/trunk/class-profilerpostdonate-gfaddon.php

    r2319642 r2618947  
    1616    protected $apifield_formurl = true;
    1717    protected $gffield_legacyname = "donation";
     18    protected $supports_custom_fields = true;
     19    protected $supports_mailinglists = true;
    1820
    1921    public static function get_instance() {
     
    4345        $userdefinedfields = self::$_instance->userDefinedFields();
    4446
    45         $mailingnumbers = array();
    46         for($i = 0; $i <= 99; $i++) {
    47             $mailingnumbers[] = array(
    48                 "value" => $i,
    49                 "label" => $i
    50             );
    51         }
    52 
    5347        // All the fields to add to the feed:
    5448        $fields = array();
     
    7266
    7367        $fields[] = array(
    74             "label" => 'Number of Mailing Lists',
    75             "type" => "select",
    76             "name" => "profilerdonation_mailinglist_count",
    77             "required" => false,
    78             "tooltip" => "Select a quantity of Mailing Lists, save this page, and then configure them. You may need to refresh this page after saving to see the extra fields.",
    79             "choices" => $mailingnumbers,
    80             "default" => 0,
     68            "label" => 'Extra Comments Text',
     69            "type" => "textarea",
     70            "name" => "profilerdonation_commentsextra",
     71            "required" => true,
     72            "class" => "merge-tag-support",
     73            "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.",
    8174        );
    82 
    83         for($i = 1; $i <= $feed['meta']['profilerdonation_mailinglist_count']; $i++) {
    84             // Loop over mailing list fields
    85 
    86             $fields[] = array(
    87                 "label" => 'Mailing List #'.$i.': UDF',
    88                 "type" => "select",
    89                 "name" => "profilerdonation_mailinglist_".$i."_udf",
    90                 "required" => false,
    91                 "tooltip" => "Pick the Profiler User Defined Field you wish to use for this mailing",
    92                 "choices" => $userdefinedfields,
    93             );
    94 
    95             $fields[] = array(
    96                 "label" => 'Mailing List #'.$i.': UDF Text',
    97                 "type" => "text",
    98                 "name" => "profilerdonation_mailinglist_".$i."_udftext",
    99                 "required" => false,
    100                 "tooltip" => "Enter the string Profiler is expecting in this UDF",
    101             );
    102 
    103             $fields[] = array(
    104                 "label" => 'Mailing List #'.$i.': Field',
    105                 "type" => "select",
    106                 "name" => "profilerdonation_mailinglist_".$i."_field",
    107                 "tooltip" => 'Link it to a checkbox field - when checked, the mailing will be sent',
    108                 "required" => false,
    109                 "choices" => $checkboxRadioFields
    110             );
    111         }
    11275
    11376        $fields[] = array(
     
    147110        $postData['datatype'] = "OLDON";
    148111
     112        $comments = $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_comments']);
     113
     114        $comments .= GFCommon::replace_variables($feed['meta']['profilerdonation_commentsextra'], $form, $entry, false, true, false, 'text');
     115        $comments = html_entity_decode($comments);
     116
    149117        // Only allow ASCII printable characters.
    150118        // This is a work-around to the API endpoint not allowing some characters
    151         $comments = preg_replace('/[^\x20-\x7E]/','', $this->get_field_value($form, $entry, $feed['meta']['profilerdonation_comments']));
     119        $comments = preg_replace('/[^\x20-\x7E]/','', $comments);
    152120
    153121        // Comments
     
    179147        $postData['HoldingID'] = $pfIntegrationId;
    180148
    181         // Calculate mailing list subscriptions
    182         for($i = 1; $i <= $feed['meta']['profilerdonation_mailinglist_count']; $i++) {
    183             // Loop over mailing list fields
    184             $mailingFieldValue = $this->get_field_value($form, $entry, $feed['meta']["profilerdonation_mailinglist_".$i."_field"]);
    185             $udf = $feed['meta']["profilerdonation_mailinglist_".$i."_udf"];
    186             $udfText = $feed['meta']["profilerdonation_mailinglist_".$i."_udftext"];
    187 
    188             if(!empty($udf) && !empty($udfText) && !empty($mailingFieldValue)) {
    189                 $postData['userdefined' . $udf] = $udfText;
    190             }
    191 
    192         }
    193 
    194149        return $postData;
    195150    }
  • profiler-donations-gravityforms/trunk/index.php

    r2319642 r2618947  
    44Plugin URI: http://mediarealm.com.au/
    55Description: Integrates Gravity Forms with Profiler, enabling donation data and more to be sent directly to Profiler.
    6 Version: 2.0.0
     6Version: 2.1.0
    77
    88Author: Media Realm
     
    3030class ProfilerDonation_GF_Launch {
    3131    public static function ProfilerDonation_load() {
    32        
     32
    3333        if (!class_exists('GFForms') || !method_exists('GFForms', 'include_payment_addon_framework')) {
    3434            return;
     
    5757        GFAddOn::register('GFProfilerListsBasic');
    5858
     59        require_once('class-profilermembership-gfaddon.php');
     60        GFAddOn::register('GFProfilerMembership');
     61
     62        require_once('class-profilerupdate-gfaddon.php');
     63        GFAddOn::register('GFProfilerUpdate');
     64
    5965        //require_once('class-profilerevents-gfaddon.php');
    6066        //GFAddOn::register('GFProfilerEvents');
    61        
     67
    6268        // Include some random helper functions
    63         require_once('shortcodes.php');
    64         require_once('states_australia.php');
    65         require_once('cardprocess.php');
     69        require_once(plugin_dir_path(__FILE__) . '/shortcodes.php');
     70        require_once(plugin_dir_path(__FILE__) . '/states_australia.php');
     71        require_once(plugin_dir_path(__FILE__) . '/cardprocess.php');
     72
     73        // Feature to allow importing user accounts from Profiler
     74        require_once(plugin_dir_path(__FILE__) . '/sync_users.php');
     75
     76        // Feature to allow importing Organisations from Profiler
     77        require_once(plugin_dir_path(__FILE__) . '/sync_orgtype.php');
    6678       
    6779        if(isset($_POST['gform_submit'])) {
  • profiler-donations-gravityforms/trunk/readme.txt

    r2319642 r2618947  
    33Tags: gravity-forms, fundraising, crm, donation, profiler
    44Requires at least: 5.0
    5 Tested up to: 5.4.1
     5Tested up to: 5.8.1
    66Stable tag: trunk
    7 Requires PHP: 7.0.0
     7Requires PHP: 7.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2222
    2323== Changelog ==
     24
     25= 2.1.0 =
     26
     27* CAUTION: This is a major update. Please take a backup before upgrading, and test your forms thoroughly after performing the update.
     28* New Feature: Import Profiler Subscribers as Wordpress Users
     29* New Feature: Import Organisation to a CPT, in order to create a Directory of organisations
     30* New Feature: Membership Sign-ups & Renewals
     31* New Feature: Update Details for existing Profiler Clients
     32* New Feature: Send Custom Fields to Profiler UDFs in many types of data feeds
     33* New Feature: Stripe Customer & Card compatibility
     34* Various bug fixes and minor changes
    2435
    2536= 2.0.0 =
Note: See TracChangeset for help on using the changeset viewer.