Romain

Joined

3,360 Experience
33 Lessons Completed
0 Questions Solved

Activity

Hey Chris,
What should we do if we just want to authorize payments without attaching a card to a user?
Maybe we could simply delete the card after the payment but I don't even see a way to properly delete a card from a user in Stripe documentation. With Payment Intent it seems that we can just detach it but not delete it.

Also do you have any advices to add another Payment Provider to this gem in addition to the github Wiki page? There are other providers like MangoPay out there that don't charge anything for a refund unlike Stripe.

Posted in How do I add a new input to a form using AJAX

Hello!

I'm trying to replace a Flatpickr input in a form using AJAX.
I have to do this because Flatpickr does not currently support dynamic update of its attributes

I can't find a way to pass the form object to the partial in my show.js.erb file and I don't even know if it's possible to do that.

Replacing the entire form could be a solution, however if the user has started filling in some entries, then triggering the AJAX call would reset everything.
I could also store the filled entries values before I replace the whole form and then spread them into the new form instance, but that seems odd to me.

Any hints? :)

My show.js.erb:

    document.querySelector(".timepicker").remove();
    document.querySelector("#booking-form").append(document.createRange().createContextualFragment("<%= j render(partial: 'timepicker', locals: { form: form, interval: @interval }) %>"));

The partial that I would like to render:

    = form.text_field :time,
                    class: "form-control timepicker",
                                    data: { controller: "flatpickr",
                                                    flatpickr_no_calendar: true,
                                                    flatpickr_enable_time: true,
                                                    flatpickr_date_format: "H:i",,
                                                    flatpickr_min_time: interval[:start_time]
                                                    flatpickr_max_time: interval[:end_time] }