WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms eWAY
[resolved] Send specific field information to eWAY (9 posts)

  1. mycustom
    Member
    Posted 1 year ago #

    Hi,
    I'm trying to get a single text field that I have named "invoice number" to reflect information when a transaction has been processed into the eWAY database in the specific eWAY field called "Reference Number" and or "Invoice Description"
    Can anyone advise how this is acheived?

    Thanks,
    Gary

    http://wordpress.org/extend/plugins/gravityforms-eway/

  2. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Gary.

    There's a filter 'gfeway_invoice_desc' for the invoice description, and a filter 'gfeway_invoice_ref' for the invoice reference. One-off payments also have 'gfeway_invoice_option1' (and 2, 3) filters whereas recurring payments have 'gfeway_invoice_cust_comments'.

    You use them like this (example for invoice description):

    add_filter('gfeway_invoice_desc', 'my_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function my_gfeway_invoice_desc($desc, $form) {
        // set by form ID
        switch ($form['id']) {
            case 1:
                $desc = 'Donate form';
                break;
    
            case 6:
                $desc = 'Recurring payment form';
                break;
        }
    
        // set by specified field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Description') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }

    Put that code into a simple plugin, or add to your theme's functions.php file.

    cheers,
    Ross

  3. mycustom
    Member
    Posted 1 year ago #

    Hi Ross,

    Awesome thanks for the quick reply.

    I have added the fuction.php to my child theme and all seems to be in working order. However the Reference and invoice details are not displaying in the required fields with eWAY.

    Refere to this link http://www.yatessecurity.com.au/Customer Details.docx you can see the sections I have highlighted in Bold Red. The Invoice description is being taken from somewere else that I am not sure of but the Reference is N/A.
    Thanks,
    Gary

  4. mycustom
    Member
    Posted 1 year ago #

    Sorry link should be
    Regards,
    Gary

  5. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Gary,

    I've tested the filters, and they do set the invoice description and invoice reference in the Customer Details section.

    I've just added a new filter for setting the invoice transaction reference in the Transaction Details section: "gfeway_invoice_trans_number".

    NB: this field is limited to only 16 characters (eWAY intends it to hold an invoice number or similar), so you probably want to use "gfeway_invoice_ref" anyway as that can hold up to 255 characters.

    Here's some code that sets all three, from fields in the form:

    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_desc($desc, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Description') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }
    
    add_filter('gfeway_invoice_desc', 'test_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice reference for a Gravity Form post
    * @param string $ref the reference before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_ref($ref, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Reference') {
                $ref = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $ref;
    }
    
    add_filter('gfeway_invoice_ref', 'test_gfeway_invoice_ref', 10, 2);
    
    /**
    * filter the eWAY invoice transaction no. for a Gravity Form post
    * @param string $ref the trans no. before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_trans_number($transNumber, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Transaction Number') {
                $transNumber = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $transNumber;
    }
    
    add_filter('gfeway_invoice_trans_number', 'test_gfeway_invoice_trans_number', 10, 2);

    cheers,
    Ross

  6. mycustom
    Member
    Posted 1 year ago #

    Thanks Ross,
    All works great now.
    Regards,
    Gary

  7. thefutureisbright
    Member
    Posted 8 months ago #

    Do you have to enter the form and field Id in the above example to get it to work?

  8. webaware
    Member
    Plugin Author

    Posted 8 months ago #

    G'day Paul,

    For your use, you'd need to use the name of the field with the description in it, e.g.

    add_filter('gfeway_invoice_desc', 'my_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function my_gfeway_invoice_desc($desc, $form) {
        // set by specified field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'What would you like to donate to') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }

    cheers,
    Ross

  9. kharlow
    Member
    Posted 7 months ago #


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic