zaus / forms-3rdparty-xpost

Converts external submission from [Forms: 3rdparty Integration](http://wordpress.org/plugins/forms-3rdparty-integration/) plugin to XML post; optionally can add custom headers (to allow SOAP submissions).
4 stars 2 forks source link

XML by Field Name #10

Closed RSpecianJr closed 8 years ago

RSpecianJr commented 9 years ago

Hey Zaus,

I've run into another small problem again. I'm working on getting multiple forms set up to send XML data based on forms origin page. It requires me to have a form for each page, but the XML submission code should be static.

Using Ninja Forms, I duplicate a form with identical field names (but different they have different field IDs). The issue I'm having is that I need to map the field names to the XML fields, but it only takes the field ID.

I've gone through the process for https://github.com/zaus/forms-3rdparty-integration/issues/35 and it works on the form submission but does not translate to the XML. Must be missing something somewhere.

Thanks,

Robert

zaus commented 9 years ago

What's your debug email look like?

RSpecianJr commented 9 years ago

Hey Zaus,

Thanks for the quick reply as always. This is a killer plugin and I've got some great mileage out of it thus far. I've *'d out information that is sensitive. I'll play with it a little more after I get some sleep, but the issue is that it isn't matching the name of the field to the ID of the active form.

Thanks,

Robert

*** Service ***
Array
(
    [name] => Tenstreet
    [url] => https://dashboard.tenstreet.com/post
    [forms] => Array
        (
            [0] => njn_8
            [1] => njn_6
            [2] => njn_10
            [3] => njn_11
            [4] => njn_13
            [5] => njn_14
        )

    [success] =>
    [failure] =>
    [timeout] => 10
    [hook] => true
    [as-xpost] => true
    [xpost-wrapper] => TenstreetData
    [xpost-header] =>
    [mapping] => Array
        (
            [0] => Array
                (
                    [val] => 1
                    [lbl] => Mode
                    [src] => Prod
                    [3rd] => Mode
                )

            [1] => Array
                (
                    [val] => 1
                    [lbl] => Source
                    [src] => RightPost
                    [3rd] => Source
                )

            [2] => Array
                (
                    [val] => 1
                    [lbl] => ClientId
                    [src] => **
                    [3rd] => Authentication/ClientId
                )

            [3] => Array
                (
                    [val] => 1
                    [lbl] => Password
                    [src] => ******************************
                    [3rd] => Authentication/Password
                )

            [4] => Array
                (
                    [val] => 1
                    [lbl] => Service
                    [src] => subject_upload
                    [3rd] => Authentication/Service
                )

            [5] => Array
                (
                    [val] => 1
                    [lbl] => CompanyId
                    [src] => ***
                    [3rd] => CompanyId
                )

            [6] => Array
                (
                    [val] => 1
                    [lbl] => CompanyName
                    [src] => *******
                    [3rd] => CompanyName
                )

            [7] => Array
                (
                    [lbl] => First Name
                    [src] => First Name
                    [3rd] => PersonalData/PersonName/GivenName
                )

            [8] => Array
                (
                    [lbl] => Last Name
                    [src] => Last Name
                    [3rd] => PersonalData/PersonName/FamilyName
                )

            [9] => Array
                (
                    [lbl] => Email Address
                    [src] => Email
                    [3rd] => PersonalData/ContactData/InternetEmailAddress
                )

            [10] => Array
                (
                    [lbl] => Phone Number
                    [src] => Phone Number
                    [3rd] => PersonalData/ContactData/PrimaryPhone
                )

            [11] => Array
                (
                    [lbl] => City
                    [src] => City
                    [3rd] => PersonalData/PostalAddress/Municipality
                )

            [12] => Array
                (
                    [lbl] => State
                    [src] => State
                    [3rd] => PersonalData/PostalAddress/Region
                )

            [13] => Array
                (
                    [lbl] => Zip
                    [src] => Zip / Post Code
                    [3rd] => PersonalData/PostalAddress/PostalCode
                )

            [14] => Array
                (
                    [lbl] => Referrer
                    [src] => Hidden Field
                    [3rd] => ApplicationData/AppReferrer
                )

        )

    [separator] =>
)

*** Post (Form) ***
*************************************
Array
(
    [45] => dave
    [46] => test
    [47] => ************
    [48] => (555) 555-5555
    [49] => Cosby
    [50] => TN
    [51] => 37722
    [52] =>
    [53] => Indeed OO
)

*** Post (to Service) ***
Array
(
    [timeout] => 10
    [body] => <?xml version="1.0"?>
<TenstreetData><Authentication><ClientId>**</ClientId><Password>******************************</Password><Service>subject_upload</Service></Authentication><Mode>Prod</Mode><Source>RightPost</Source><CompanyId>***</CompanyId><CompanyName>******</CompanyName></TenstreetData>

    [headers] => Array
        (
            [Content-Type] => application/xml
        )

)

*** Response ***
Array
(
    [headers] => Array
        (
            [date] => Tue, 28 Apr 2015 14:32:02 GMT
            [server] => Apache
            [content-length] => 474
            [connection] => close
            [content-type] => text/html; charset=UTF-8
        )

    [body] => <?xml version="1.0" encoding="UTF-8"?>
<TenstreetResponse><Version>1.1</Version><SourceIpAddress>***.***.***.***</SourceIpAddress><CompanyPostedToId>***</CompanyPostedToId><CompanyPostedToName>*******</CompanyPostedToName><DateTime>2015-04-28 9:32:02</DateTime><Mode>PROD</Mode><SSN></SSN><DriverId></DriverId><DriverName> </DriverName><Status>REJECTED</Status><Description>Error 1: First Name is required.  Error 2: Last Name is required.  </Description></TenstreetResponse>
zaus commented 9 years ago

So it's only setting the 'Is Value' mappings, but not extracting your named fields. Are you saying that it works if you turn off xpost? If so, I wonder if the problem might be the priority of the xpost hook conflicting with your hook? Any chance you can share your code?

RSpecianJr commented 9 years ago

Hey Zaus,

Yea, in the data above, you can see that the fields work for third party integration, they just dont translate over to xpost. I haven't done any modifications to the code, so the code should be what you can install from the wordpress plugins page. If you want me to upload it I can.

I don't have custom hooks.

Thanks,

Robert

zaus commented 9 years ago

Sorry, maybe I misunderstood when you referenced the 'name remap' issue:

I've gone through the process for zaus/forms-3rdparty-integration#35 and it works on the form submission but does not translate to the XML.

I thought you had written something to get it to map on name vs id. If you haven't, then that's why it's not working -- all of your src fields should correspond to something in the "Post (Form)" section of the debug email, which are numerical ids for Ninja Forms, not field names like you currently have mapped.

I originally wrote this plugin for Contact Form 7, where you have control over the field id/names, which makes it really easy to share services across forms (since you can name all the fields the same). But when I added support for Gravity Forms and Ninja Forms, everyone found out that they're not as great in that regard. Issue 35 is a wishlist to address that, but I haven't actually done anything for it.

zaus commented 8 years ago

Implemented as native functionality per referenced commit v1.6.6 to core plugin F3i.