Next revision | Previous revision |
v:0.7.0:advanced:transaction_xml_datafeed [2010/08/19 20:57] – created foxybrett | v:0.7.0:advanced:transaction_xml_datafeed [2017/04/26 07:02] (current) – external edit 127.0.0.1 |
---|
In order to allow the flexibility and integration options that you need, FoxyCart can be configured to send encrypted XML to a URL of your choosing. This allows you to integrate FoxyCart without duplicating data across applications. | In order to allow the flexibility and integration options that you need, FoxyCart can be configured to send encrypted XML to a URL of your choosing. This allows you to integrate FoxyCart without duplicating data across applications. |
| |
When you configure it for your store, it will send you an encrypted XML data via a ''POST'' of your new transactions immediately upon a successful transaction. You can use this to update inventory, create users or manage user permissions for a paid subscription site, or add users to your mailing list on a 3rd party email service provider's system. There are [[http://wiki.foxycart.com/integration|many examples]]. | When you configure it for your store, it will send you an encrypted XML data via a ''POST'' of your new transactions immediately upon a successful transaction. You can use this to update inventory, create users or manage user permissions for a paid subscription site, or add users to your mailing list on a 3rd party email service provider's system. There are [[:integration|many examples]]. |
| |
Please note that FoxyCart's XML datafeeds do //not// include credit card information (number, CSC, date, etc.). | Please note that FoxyCart's XML datafeeds do //not// include credit card information (number, CSC, date, etc.). |
| |
==== Testing ==== | ==== Testing ==== |
When you're testing your custom XML integration, don't run transactions through FoxyCart. This is both time consuming (as you have to add-to-cart, checkout, then wait up to a minute to receive the XML), but it also doesn't give you any indication of what's actually going wrong. | When you're testing your custom XML integration, don't run transactions through FoxyCart. This is both time consuming (as you have to add-to-cart and checkout), but it also doesn't give you any indication of what's actually going wrong. |
| |
A much better method is to use the [[integration:foxycart:test_xml_post|XML Test Post]] script or [[integration:foxycart:test_xml_post_with_csharp|application (C#)]]. This effectively mimics what FoxyCart is actually doing when sending the XML to your server in the first place. **Make sure you update the test XML** in the script to the appropriate version (below). | A much better method is to use the [[:integration:foxycart:test_xml_post|XML Test Post]] script or [[:integration:foxycart:test_xml_post_with_csharp|application (C#)]]. This effectively mimics what FoxyCart is actually doing when sending the XML to your server in the first place. **Make sure you update the test XML** in the script to the appropriate version (below). |
| |
If you'd like to test using real data from your store, you can run a test transaction and [[integration:foxycart:test_xml_write_to_file|write the datafeed to a file]], then copy it out and put it in the Test Post script. | If you'd like to test using real data from your store, you can run a test transaction and [[:integration:foxycart:test_xml_write_to_file|write the datafeed to a file]], then copy it out and put it in the Test Post script. |
| |
If you're struggling to just get started with //reading// the feed, try this: on your script page, capture all the POST data and write it to a file. Test it by posting a simple form to this page just to ensure that it works, and then you can run a //single// FoxyCart transaction to capture its data. You should end up with an array with a key of 'FoxyData' and pages of url-encrypted data, e.g. "%EBrV%8C%E9...". After you've saved this to a file, you can work out the other details of your script, e.g. decoding the XML and routing it to your database or 3rd party applications (e.g. MailChimp). | If you're struggling to just get started with //reading// the feed, try this: on your script page, capture all the POST data and write it to a file. Test it by posting a simple form to this page just to ensure that it works, and then you can run a //single// FoxyCart transaction to capture its data. You should end up with an array with a key of 'FoxyData' and pages of url-encrypted data, e.g. "%EBrV%8C%E9...". After you've saved this to a file, you can work out the other details of your script, e.g. decoding the XML and routing it to your database or 3rd party applications (e.g. MailChimp). |
==== Best Practices ==== | ==== Best Practices ==== |
* Test according to the above method. | * Test according to the above method. |
* If you're doing complicated stuff, you may want to [[integration:mysql|backup the XML to a database]]. This allows you to re-process things at a later date (like if you change mailing list service providers, add a new member functionality, etc.). | * If you're doing complicated stuff, you may want to [[:integration:mysql|backup the XML to a database]]. This allows you to re-process things at a later date (like if you change mailing list service providers, add a new member functionality, etc.). |
* Don't make assumptions about the data structure. Rather than just accessing a node and assuming the value is there, test first. This can prevent errors down the road. | * Don't make assumptions about the data structure. Rather than just accessing a node and assuming the value is there, test first. This can prevent errors down the road. |
| |
| |
===== Notes ===== | ===== Notes ===== |
* The transaction XML datafeed comes with a ''POST'' name of ''FoxyData''. This is different than the [[:docs:subscription_datafeed|subscription XML datafeed]], which has a ''POST'' name of ''FoxySubscriptionData''. | * The transaction XML datafeed comes with a ''POST'' name of ''FoxyData''. This is different than the [[subscription_xml_datafeed|Subscription XML Datafeeds]], which has a ''POST'' name of ''FoxySubscriptionData''. |
* FoxyCart v0.5.1+ sends the XML datafeed immediately, in between the checkout and receipt. Previous version send it once a minute. | |
| |
| |
=== Country Codes === | === Country Codes === |
For compatibility, FoxyCart uses ISO country codes in our XML: | For compatibility, FoxyCart uses ISO country codes in our XML: |
* http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm | * [[http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm|ISO.org]] |
* http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Decoding_table | * [[wp>ISO_3166-1_alpha-2#Decoding_table|Wikipedia]] |
| |
| |
<subscription_nextdate><![CDATA[0000-00-00]]></subscription_nextdate> | <subscription_nextdate><![CDATA[0000-00-00]]></subscription_nextdate> |
<subscription_enddate><![CDATA[0000-00-00]]></subscription_enddate> | <subscription_enddate><![CDATA[0000-00-00]]></subscription_enddate> |
| <is_future_line_item>0</is_future_line_item> |
<shipto><![CDATA[]]></shipto> | <shipto><![CDATA[]]></shipto> |
<category_description><![CDATA[Discount: Price: Percentage]]></category_description> | <category_description><![CDATA[Discount: Price: Percentage]]></category_description> |
<subscription_nextdate><![CDATA[2010-09-19]]></subscription_nextdate> | <subscription_nextdate><![CDATA[2010-09-19]]></subscription_nextdate> |
<subscription_enddate><![CDATA[2013-01-01]]></subscription_enddate> | <subscription_enddate><![CDATA[2013-01-01]]></subscription_enddate> |
| <is_future_line_item>0</is_future_line_item> |
<shipto><![CDATA[Me]]></shipto> | <shipto><![CDATA[Me]]></shipto> |
<category_description><![CDATA[Default for all products]]></category_description> | <category_description><![CDATA[Default for all products]]></category_description> |