agileware / gf-civicrm

Extends Gravity Forms to get option lists and defaults from linked CiviCRM Form Processors
GNU General Public License v3.0
5 stars 2 forks source link

Remote CiviCRM? #1

Open davidjosephhayes opened 2 years ago

davidjosephhayes commented 2 years ago

Hello! This looks super cool. I installed on a test site this evening to try it out, but immediatly got an error: Call to undefined function GFCiviCRM\\civicrm_initialize(). Obviously, the plugin is currently intended for local CiviCRM installs but I was going to attempt a remote form submit.

Looks like development is happening fast. Would you be interested in some pull requests to add remote CiviCRM support?

agileware-justin commented 2 years ago

@davidjosephhayes yes, go for it!

If you want to submit some documentation PRs as well, that would be super too.

davidjosephhayes commented 2 years ago

Awesome! I'll circle back around as my project comes together. Thanks!

davidjosephhayes commented 2 years ago

Speaking of documentation, I am a big confused how the webhook works with the settings detailed on #11 .

With the explanation given, I am seeing the webhook request body in the debugger as json similar to:

Array
(
    [body] => {"first_name":"John","last_name":"Doe","email":"jdoe@example.com"}
    [method] => POST
    [headers] => Array
        (
            [Authorization] => Bearer **API_KEY**
            [X-Civi-Key] => **SITE_KEY**
            [X-Requested-With] => XMLHttpRequest
            [Content-Type] => application/json
        )

    [sslverify] => 1
)

And receiving an error response from CiviCRM.

{
  "fields": ["email", "first_name","last_name"],
  "error_code":"mandatory_missing",
  "entity":"FormProcessor",
  "action":"newsletter_subscribe",
  "is_error":1,
  "error_message":"Mandatory key(s) missing from params array: email, first_name, last_name"
} 

I am not too familiar with Form Processor specifically, but the API Explorer seems to indicate that it would like the json nested under a json variable in the request body. Similar to:

json=%7B%22first_name%22%3A%22John%22%2C%22last_name%22%3A%22Doe%22%2C%22email%22%3A%22jdoe%40example.com%22%7D

I can make a pull request to fix this if it is an issue, but I want to make sure I am not missing anything obvious first.

Thoughts?

agileware-justin commented 2 years ago

@davidjosephhayes so I don't think a PR is required, because this works. It's more like the documentation is wrong or the example for form processor is wrong. They were based on a working environment, so should be OK.

Did you check that all the steps were done as per https://github.com/agileware/gf-civicrm/blob/main/README.md#setting-up-a-newsletter-subscription-form-using-gravity-forms-and-civicrm

And in particular, make sure the request URL in Gravity Forms, Web Form is correct.