Support » Plugin: Stripe For WooCommerce » Recomend update to codes requiring order_id from webhooks and redirect

  • Resolved isaac2017

    (@isaac2017)


    Hi

    I really like this plugin and it seems to be covering a lot of areas that I needed to use with stripe. Though I needed to make some adjustments to 2 of your files in regards to order_id that is being used to retrieve order objects within the webhook and redirect processes.

    The amendments are in the files
    1. class-wc-stripe-redirect-handler.php
    line 42.
    2. wc-stripe-webhook-functions.php
    Line 14
    LIne 50
    line 98
    line 130

    in which I added an apply_filter to the source, charge and intent processes.
    eg. apply_filters( ‘wc_stripe_clean_order_id’, $charge->metadata[ ‘order_id’ ] )

    So that I can clean up the order_id that is returned from stripe.
    The reason why I need to do this is because the order_id that I pass to stripe to process is actually my formatted order number eg “ABC123456” instead of the order_id in the saved in the database.

    Am sorry I could not contribute directly to SVN, as I am not sure if I should or not.
    So I am putting it here so that you could take it as a suggestion for change.

    Again. Thanks for creating such a useful plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author mr.clayton

    (@mrclayton)

    Hi @isaac2017,

    Thank you for the suggestion regarding the order ID. Instead of using the filters to change the order ID did you consider adding an extra metadata field that contained your formatted order ID?

    That way you don’t need to alter any plugin files and it will be update safe.

    Kind regards,

    isaac2017

    (@isaac2017)

    Hi Clayton,

    Yeah, we did but the title of the payment is easier to read when its with the formatted id. Another reason is that we did not want to expose the internal ID’s to our third party vendors (which included stripe) so that all communications between customer, vendor and us are based on a common “friendly” information.

    Do you think you could add this filter or something similar so that ID’s like we use be compatible? Or if you have other ideas that can help me address this concern, I would appreciate it.

    Thank you.

    Plugin Author mr.clayton

    (@mrclayton)

    Hi @isaac2017,

    I don’t see an issue with adding a filter to the sections of code that instantiate a WC_Order object using the source’s metadata. There are some other ways but I believe your suggestion of a filter is the most elegant. I will make a note to add that to the next release.

    I will most likely name the filter wc_stripe_filter_order_id and it will be wrapped in a function to cut down on code duplication of the filter.

    Example:

    function wc_stripe_filter_order_id($order_id, $object){
        return wc_get_order(apply_filter('wc_stripe_filter_order_id', $order_id, $object));
    }

    I don’t have a targeted release date for the next version but I imagine it will be in the next one to two weeks.

    If you’re liking the plugin we always appreciate a positive review on our review page.

    Kind Regards,

    isaac2017

    (@isaac2017)

    Hi Clayton,

    Thanks a million.
    Will wait for your update and make the appropriate changes from my side.

    Will leave a review soon.
    Thank you for getting back to me on this so promptly.

    Plugin Author mr.clayton

    (@mrclayton)

    @isaac2017

    Version 3.1.3 released which includes a filter for the order ID.

    Kind regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.