• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Stripe plugin questions

lcollong

FabriKant d'applications web
Hi,

We try to make the stripe plugin suitable for our needs.
1/ On the first tab 'payments', the condition seems to no work. I used "return false;" in this field. But the plugin is always triggered.

2/ it seems that some part of the plugin is run "onLoad" as the messages are displayed on form load (text on new / Text on edit). But we'd like the condition being related to a field on the form itself. Actually we have a drop down to choose between wire transfer, checks or CC. In case the customer does not choose "CC", the stripe plugin should not being triggered at all.

3/ we have a lot of post-payment process to deal with. More than just store the transaction ID. Would it be possible to add a php plugin run onAfterProcess which would be able to check on the success or not of the payment and, ideally, catch some date from the charge process. Or, is it possible to add a "hook" on the stripe plugin to run our own post-processing code ? We have to be sure all the "stripe's stuff" has been made before actually do our own (including several list update and several emails to send).

The idea is to "stick" on the fabrik plugin whereas to develop our own.

Thanks,

Laurent
 
1/ On the first tab 'payments', the condition seems to no work. I used "return false;" in this field. But the plugin is always triggered.

Ooops.

https://github.com/Fabrik/fabrik/commit/aabebd9e71fd6bc21dbc46a23b4c094110c90823

2/ it seems that some part of the plugin is run "onLoad" as the messages are displayed on form load (text on new / Text on edit). But we'd like the condition being related to a field on the form itself. Actually we have a drop down to choose between wire transfer, checks or CC. In case the customer does not choose "CC", the stripe plugin should not being triggered at all.

Yes, there's a lot of stuff currently happens on load. Like figuring out the cost and item details, and the appropriate footer text to load, which for existing customers involves talking to the Stripe API (to get the last 4 of the CC, etc). I guess that could be either be converted to run in response to an AJAX call, or (simpler) you could override the layouts, wrap that footer text in a div with display=none, then have some JS on your dropdown element to show / hide the div accordingly.

The harder part would be preventing us from running the Stripe checkout process when submitting. I'd have to add something to the plugin JS to check a variable you could set. Actually, I'll do that now ...

https://github.com/Fabrik/fabrik/commit/800707fa5f73937bc1820f1ecdd7629195050886

... so in the same place you handle the logic for hiding / showing the bottom content div, you can set the form's useCheckout option, like ...

this.form.options.useCheckout = false;

('this' would only be in context if the code was directly in the element's JS event code, refering to the element object. If running somewhere else, it'd be Fabrik.getBlock('form_X').options.useCheckout)

3/ we have a lot of post-payment process to deal with. More than just store the transaction ID. Would it be possible to add a php plugin run onAfterProcess which would be able to check on the success or not of the payment and, ideally, catch some date from the charge process. Or, is it possible to add a "hook" on the stripe plugin to run our own post-processing code ? We have to be sure all the "stripe's stuff" has been made before actually do our own (including several list update and several emails to send).

Sure, I can add that as an option in the plugin settings.

We actually run the charge onBeforeStore, and if it fails, we fail the form submission.

We then have an onAfterProcess, which will only run if the charge succeeded and the form has submitted, which updates the charge object in Stripe to include the rowid in the metadata - we store the list, form, row and user IDs with the Stripe charge object, so any charge in Stripe can be matched to the associated table and row.

So I think the best place to run custom code would be in the onAfterProcess handling, where we know the charge succeeded, and the Stripe charge object is available.

https://github.com/Fabrik/fabrik/commit/71f81175127a823f419b9d68167a66917a533bc3

As per the tooltip on the new option, the Stripe charge object is in $this->charge, form data is in $this->data, etc.

Your code will be running as the last thing to happen. If $this->charge is not set, then the charge wasn't run (your condition code returned false).

-- hugh
 
Almost there.

1/ The onAfterProcess hook looks good and seems to fit ideally the situation as per my first test. I'll keep you inform after everything being set.

2/ The condition is still not checked but I think you forgot to change stripe_conditon to stripe_condition in stripe.php around line 70 :
PHP:
        $formModel  = $this->getModel();
        $listModel  = $formModel->getListModel();
        $input      = $this->app->input;
        $this->data = $this->getProcessData();
        JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fabrik/tables');

        if (!$this->shouldProcess('stripe_condition', null, $params))
        {
            return true;
        }

3/ regarding the div display:none in case CC is not selected in the dropdown : indeed, it's a good solution easy to go.

4/ I can't make the useCheckout working. I take a look on the stripe.js and put some console.log. I have the feeling we are not using the same object. When my code is :

JavaScript:
var p = this.get('value');
console.log("p :"+p);
if (p == 'cb'){
  this.form.options.useCheckout = true;
}else{
  this.form.options.useCheckout = false; 
}

Is sounds like the object against which useCheckout is tested in stripe.js is a Stripe object, not a Form one. It is always set to "true" (class construct) whatever I set in my code. So, I've tried to change the test in stripe.js to (this.form.options instead of this.options in lines 114 and 147) :

JavaScript:
            if (this.form.options.useCheckout) {

But the result is not stable depends if the choice is made "onLoad" or after dropdown has been modified (however the same code below is on both events).

5/ ideally, would be nice to have the "Dialog Name" being parsed for placeholders as, in our case, it's not a constant.
 
2/ I've fixed the condition thing ... although it should have worked before, as the names matched (I didn't notice that the both had the same typo). I just tested, return false, and it works, the plugin doesn't run. The for submission completes, just without the Stripe plugin running.

https://github.com/Fabrik/fabrik/commit/70d7ce4b48c52b6deb581b2242ffd4775536fa82

4/ And yeah, sorry, should be stripe.options.useCheckout. We assign the stripe form plugin object to that global variable (we should probably stick it somewhere in the main Fabrik object, but for now it is what it is).

5/ Done

https://github.com/Fabrik/fabrik/commit/89462ee84973e6ee46870593318f9af33b6c9337

-- hugh
 
Thanks for the (5). Perfect !

I just can't reach useCheckout ! I've try all the variations I could imagine from :
JavaScript:
var form = Fabrik.getBlock('form_70');
console.log(form.stripe);

ie stripe or Stripe
form.stripe, form.options.stripe, stripe alone .....

always answer "undefined"....

And when I output only "form", I can't find "stripe" anywhere.

The element from which I try to output (actually set) the useCheckout var is a dropdown belonging to a group which is joined to the main one.
 
Hmm, OK, yeah, scope issue.

I'm going to have to tweak the main form.js class, to do the same thing the list class does, and add the form plugins as an object during init. We do that with the list plugins because we have a need to access those from "outside" (for filtering), but we've never had a need before to access individual form plugins from "outside".

I've got it going locally, need to do a little more testing (and modify every other form plugin, as they now need to return their init code slightly differently).

Probably commit later today.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top