Announcement

Collapse
No announcement yet.

Post Order Information to External Source via WebService

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Post Order Information to External Source via WebService

    Hi all,

    As part of my sites integration, I need to pass order information once an order is complete to an external system for use in their processing. With the help of Miva, I was pointed to mvt:call

    http://www.miva.com/videos/articles/...-documentation

    Using this, I am trying a simple POST by adding this to the invoice.html page. I have tried it everywhere (ex. template, header, footer, order contents, customer information, etc.), but it never triggers/I don't see it while I log the communications that occur in my browser.

    <mvt:assign name="g.url" value="'http://myvendorsapi.net/orders'" />

    <mvt:call action="g.url" method="'POST'" fields="'name=kelly,ordernum=31'">
    <mvt:eval expr="s.callvalue" />
    </mvt:call>

    My goal is to email order information, including a custom order field, to my external system.

    Thanks!

    K.

    #2
    Re: Post Order Information to External Source via WebService

    If the reply is XML, your browser might not show anything on the screen. Try looking at the HTML source of the invoice page; or modify your code to use encodeentities() on the returned data, e.g. <mvt:eval expr="encodeentities(s.callvalue)" /> .

    HTH --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Re: Post Order Information to External Source via WebService

      Also, your SMT statement is incorrect:

      <mvt:assign name="g.url" value="'http://myvendorsapi.net/orders'" />

      <mvt:call action="g.url" method="'POST'" fields="'name=kelly,ordernum=31'">
      <mvt:eval expr="s.callvalue" />
      </mvt:call>

      Should be

      <mvt:assign name="g.url" value="'http://myvendorsapi.net/orders'" />

      <mvt:call action="g.url" method="'POST'" fields="name,ordernum">
      <mvt:eval expr="s.callvalue" />
      </mvt:call>

      The 'fields' entry should be a List of Variables whose value and name are passed to the target.
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment


        #4
        Re: Post Order Information to External Source via WebService

        Thanks all!

        Originally posted by Bruce - PhosphorMedia View Post
        Also, your SMT statement is incorrect:

        <mvt:assign name="g.url" value="'http://myvendorsapi.net/orders'" />

        <mvt:call action="g.url" method="'POST'" fields="'name=kelly,ordernum=31'">
        <mvt:eval expr="s.callvalue" />
        </mvt:call>

        Should be

        <mvt:assign name="g.url" value="'http://myvendorsapi.net/orders'" />

        <mvt:call action="g.url" method="'POST'" fields="name,ordernum">
        <mvt:eval expr="s.callvalue" />
        </mvt:call>

        The 'fields' entry should be a List of Variables whose value and name are passed to the target.

        Comment


          #5
          Re: Post Order Information to External Source via WebService

          Originally posted by Bruce - PhosphorMedia View Post
          Also, your SMT statement is incorrect:
          The 'fields' entry should be a List of Variables whose value and name are passed to the target.
          Actually, KRusk's original code was correct. The mvt:call element will accept a set of name=value pairs, instead of variable names, in the FIELDS attribute. It was a surprise to me; I had to check the documentation:
          http://www.miva.com/videos/articles/...-documentation
          The description is a little scrambled; a few words are missing from the relevant sentence. But looking at the examples, it's clear that the name-value format is allowed.
          Kent Multer
          Magic Metal Productions
          http://TheMagicM.com
          * Web developer/designer
          * E-commerce and Miva
          * Author, The Official Miva Web Scripting Book -- available on-line:
          http://www.amazon.com/exec/obidos/IS...icmetalproducA

          Comment


            #6
            Re: Post Order Information to External Source via WebService

            Thanks, in the end, we had an IP block on the system I was trying to POST. Once we whitelisted Miva's IP, it resolved the basic POST.

            Originally posted by Kent Multer View Post
            Actually, KRusk's original code was correct. The mvt:call element will accept a set of name=value pairs, instead of variable names, in the FIELDS attribute. It was a surprise to me; I had to check the documentation:
            http://www.miva.com/videos/articles/...-documentation
            The description is a little scrambled; a few words are missing from the relevant sentence. But looking at the examples, it's clear that the name-value format is allowed.

            Comment


              #7
              Re: Post Order Information to External Source via WebService

              ah yes commas can be important as important distinctions can be lost :)

              (Note, you can apparently also use the mivascript form of just listing the variable names:

              Note: Here the fields list is a comma separated list of name value pairs. You can also pass in variables, and they will
              be automatically converted into name value pairs
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment

              Working...
              X