systopia / de.systopia.twingle

CiviCRM Twingle Integration
Other
4 stars 2 forks source link

Do not use `user_country` as the only address parameter for XCM #47

Closed MarcMichalsky closed 2 years ago

MarcMichalsky commented 3 years ago

The user_country parameter gets submitted by Twingle with every call on TwingleDonation.submit. Because the user_country is passed to the XCM, it gets interpreted as an address information what can lead to an overwriting of existing address information.

One way to prevent this is to not check the "Change Primary Detail?" option in the XCM profile. But maybe one wants to update primary address information by the newer information from the Twingle call. With this solution, this would not be possible any more.

It would be preferable to do not use the user_country as address parameter if it's the only address information submitted.

This enhancement can be done with a few lines of code, I think.

mariav0 commented 3 years ago

I can verify this works. Thanks, @MarcMichalsky!

MarcMichalsky commented 2 years ago

Hello everyone,

this problem still exists and we are addressing it by disabling the "Change Primary Detail?" option. This leads to the result that sometimes when a contact donates without requesting a donation receipt, their address details only contain the country. If the same contact then donates again but requests a donation receipt, the submitted address information is not included in the contact and we run into problems when we try to send the donation receipt without an address.

We should really fix that.

mariav0 commented 2 years ago

Hey there, I have tested this again and now it does not work anymore. I use @MarcMichalsky's fix. It does not matter if I have "Change Primary Detail" enabled or not: If there is no address of this type already, then there is an address added without any data. It just shows an empty address. If there is an address of this type already, it does not change the address. Tested on CiviCRM 5.47.4, Twingle 1.3-alpha1, XCM 1.8

MarcMichalsky commented 2 years ago

Hi @mariav0, did you already try my issue/47 branch? It adds a setting to the profile to define which address components must be present to overwrite the existing address.

The most common use case would be to define street, postal code, city and country as required address components and set the XCM to change primary details.

mariav0 commented 2 years ago

Hi @MarcMichalsky, I have tried your branch and I am still having this issue when I create a new contact that the address shows up empty:

image

This happens always - no matter if "Change Primary Detail" is enabled or disabled. But an empty address never overwrites an existing one which is good!

MarcMichalsky commented 2 years ago

@mariav0 could you specify what you mean by »when I create a new contact«?

MarcMichalsky commented 2 years ago

@mariav0 And could you check your XCM profile settings to let it fill the right fields and create addresses? Screenshot 2022-04-22 at 08-41-26 Xtended Contact Matcher Profile CiviCRM forumZFD

mariav0 commented 2 years ago

@MarcMichalsky Sorry, I meant when a new contact is created via Twingle (non-existing in CiviCRM before)

And yes, it looks very similar. I only do not have "Neues Kontaktdetail primär" enabled. But I have also tested it when checked and it did not make a difference either. It also does not set the new address to primary which it should?

grafik

MarcMichalsky commented 2 years ago

@mariav0 are you sure that this XCM profile is selected in the Twingle API profile? And does it work that incoming donations containing complete addresses overwrite the old existing addresses?

MarcMichalsky commented 2 years ago

What about these fields in the Twingle API profile? Which ones have you selected? Screenshot 2022-04-22 at 16-20-25 Edit Twingle API profile default CiviCRM forumZFD

mariav0 commented 2 years ago

@mariav0 are you sure that this XCM profile is selected in the Twingle API profile? And does it work that incoming donations containing complete addresses overwrite the old existing addresses?

Yes, I am sure: grafik Nope, incoming donations containing complete addresses does NOT overwrite the old existing addresses.

What about these fields in the Twingle API profile? Which ones have you selected? Screenshot 2022-04-22 at 16-20-25 Edit Twingle API profile default CiviCRM forumZFD

I have those selected: grafik

MarcMichalsky commented 2 years ago

Hi @mariav0, thanks for the feedback! Because we would like to merge my issue/47 branch soon into main to ship it with version 1.3 it is important for us to understand and solve your problem.

I published my collection of Twingle API calls for Postman.

If you are familiar with Postman, you could try to import that collection, configure your environment variables and test the APIs. Especially the output of the TwingleDonation.create request would be helpful.

mariav0 commented 2 years ago

Hi @MarcMichalsky, I am not quite familiar with Postman but I have tried to do a submit and have a response json now. But I guess you want me to use create as an action instead of submit, right? I am just not sure what to enter for

id {{twingle_form_id}}
url {{rand_form_url}}

Could you give me a hint from where I can get this information and should I post the response json from the submit here as well? Thanks in advance!

MarcMichalsky commented 2 years ago

Hi @mariav0, my fault, I meant TwingleDonation.submit of course. Actually you don't need to replace any of the {{variables}}. In Postman you can create an environment where you can set all variables that will be used in the parentheses. You need to set api_key, site_key, url (e.g. https://civicrm.my-awesome-ngo.org), and api_endpoint (either /civicrm/ajax/rest in Drupal 9 or /sites/all/modules/civicrm/extern/rest.php in Drupal 7). All other variables are generated by the pre-request scripts.

You could try to send the Static TwingleDonation.submit request once, change the trxn_id and send it again. The contact address should change after the second call. Then you could try to delete some required address components from the request parameters and send another request (don't forget to change the trxn_id). If the address did not change, everything works like expected.

If you need help with this, I will be happy to help you. You can contact me via the CiviCRM Mattermost (@marc_michalsky) or via email michalsky@forumZFD.de. We could also meet via BigBlueButton.

MarcMichalsky commented 2 years ago

Hello @mariav0,

the XCM indeed creates empty addresses when no address data is submitted. The problem should be solved as soon as XCM version 1.9 is released.

Thanks for your patience!

bjendres commented 2 years ago

The problem should be solved as soon as XCM version 1.9 is released.

Should I tag an alpha version for you?

MarcMichalsky commented 2 years ago

The problem should be solved as soon as XCM version 1.9 is released.

Should I tag an alpha version for you?

This could be helpful, but since it mainly concerns this repository, I think @jensschuppe should respond to that question.

bjendres commented 2 years ago

I meant an alpha version of XCM

MarcMichalsky commented 2 years ago

I meant an alpha version of XCM

Yes. But the fix affects the outcome of TwingleDonation.create. So he should decide how to proceed here.

bjendres commented 2 years ago

Then let's wait for @jensschuppe's opinion

jensschuppe commented 2 years ago

Thanks @MarcMichalsky, @mariav0 and @bjendres!

jensschuppe commented 2 years ago

Released with 1.3-beta1.