Is there a way to update Custom fields when accepting donations through the donations API?

Options

Is this possible? Has anyone had any success using the Donations API in conjunction with the Constituent API to perform this function through a donation?

Tagged:

Comments

  • This is totally possible, but not as a client-side function. You'll have to set up a server-side proxy because updates can't be run via the client-side API (unless you make them log in first, which will reduce conversions considerably, so pretend it's impossible client-side). This is easy or hard or impossible depending on your infrastructure........

    Keep in mind that to avoid some odd data intregrity issues, you're probably better off embedding as many as you can in the donation page. Remember using the Donation API, you don't have to SHOW every field on your custom form that you show on your shadow form, just remember to populate any fields you hide that are required.... But, if you have something like doubleclicker as a field, and then embed a JavaScript that detects the person weirdly double clicks everything instead of single clicks, you could make that field hidden, then populate it with a true via script.

    Now, say that field can't be submitted with the donation transaction for whatever reason. And, say you're able to set up a server-side proxy to allow for record updates without require the user be logged in.

    You might give this a test:

    1. Donor fills out data, hidden field gets populated.

    2. Donor clicks submit.

    3. Via AJAX (or similar technology -- Flash remoting or whatever), you construct TWO posts at the same time. One is the Donation API post (needs to be a POST and needs to be SSL), the other, which files at the same time, is the Cons API post that takes the email address (primary_email) and the field/value pair and updates the user's record with the createOrUpdate method (new donors, and it's all Async so you don't know which call will be processed by Convio first).

    4. Ignore the ConsAPI return, you can't do anything if it fails without making a big fuss unless you want to actually stop the donation (then, you would want to serialize these calls and only submit the donation if the ConsAPI update worked). Basically, you fire-and-forget this update, it's all AJAX so there isn't any waiting to continue anyway.

    5. DO pay attention to the returns for the donation of course so you know what response message to display to the user.

    You can do this without as much AJAX use too, but some measure of JavaScript will be required because you'll have to trap the submit event (or button press event) and kick the update call off BEFORE the browser transition off the page. Remember, you don't care what the response is, so as long as you kick the request over to the ConsAPI, you should be OK.

    By the way, your milage may vary, I just came up with this off the top of my head just now. I'd invite others to shoot holes in what I've written above I'm sure there are enough already.....

  • When designing the form pages and layout for the donation form ("Design Donor Pages" action, IIRC), create a custom data element, selecting a constituent field to which to map it. When you put it on the form, you can either show it or make it hidden as needed. In the API call, the name of the parameter is the name you gave the custom data element except it is all lower case and spaces are changed to underscores. As an example, if you named it "Willing to Volunteer" then the parameter name would be "willing_to_volunteer".

Categories