Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
integration:craftcms [2014/08/10 08:37] – [HMAC Encryption] adamintegration:craftcms [2019/01/22 14:14] (current) – [Webhooks] adam
Line 94: Line 94:
 Now navigate to 'Settings > Sections', and create a new section. Give it a name of "Product", handle of "products" and a section type of "Channel". Also set the Entry URL Format to "store/{slug}" and the Entry Template to "store/_product". Now navigate to 'Settings > Sections', and create a new section. Give it a name of "Product", handle of "products" and a section type of "Channel". Also set the Entry URL Format to "store/{slug}" and the Entry Template to "store/_product".
  
-Once that is created, click on the 'Edit entry type' that appears next to it's listing in the "Sections" page and then the "Product" option that appears. Uncheck the "Show title fields" checkbox and enter "{heading}" in the Title Format text box that appears. Down the bottom, create two tabs in the "Design your field layout" section. Name the first tab 'Default' and place in there the "Heading" and "Body" fields. Then name the second tab "Product" and add in any product fields you created in the previous step - making the "Name", "Price" and "Code" fields required by clicking on the cog icon next to their labels.+Once that is created, click on the 'Edit entry type' that appears next to it's listing in the "Sections" page and then the "Product" option that appears. Uncheck the "Show title fields" checkbox and enter "{heading}" in the Title Format text box that appears. Down the bottom, create two tabs in the "Design your field layout" section. Name the first tab 'Default' and place in there the "Heading" and "Body" fields. Then name the second tab "Product" and add in any product fields you created in the previous step - making the "Heading", "Name", "Price" and "Code" fields required by clicking on the cog icon next to their labels.
  
 Save those changes. Save those changes.
Line 185: Line 185:
 ===== Other Plugin Features ===== ===== Other Plugin Features =====
  
-==== HMAC Encryption ====+==== Link/Form Validation ====
  
-If you'd like to make use of our [[static:redirect:price_validation|link and form encryption]] to prevent possible tampering, you simply need to wrap your links and forms, or the whole page, within ''{% hmac %}'' and ''{% endhmac %}'' tags. Note that you also need to enable this option on the 'advanced' settings page of your store's FoxyCart administration. Taking the ''_product.html'' template from before:+If you'd like to make use of our [[static:redirect:price_validation|link and form validation]] to prevent possible tampering, you simply need to wrap your links and forms, or the whole page, within ''{% hmac %}'' and ''{% endhmac %}'' tags. Note that you also need to enable this option on the 'advanced' settings page of your store's FoxyCart administration. Taking the ''_product.html'' template from before:
    
 <code html>{% extends "_layout" %} <code html>{% extends "_layout" %}
Line 231: Line 231:
 Navigate to the FoxyCart Craft plugin's settings page and copy the webhooks action URL from the lower section of the page, and set that within the 'advanced' settings section of your store's FoxyCart administration. Navigate to the FoxyCart Craft plugin's settings page and copy the webhooks action URL from the lower section of the page, and set that within the 'advanced' settings section of your store's FoxyCart administration.
  
-If you need to perform custom actions with that data (for example, you may need to subscribe a customer to a mailing list), you can make use of the ''foxyCart.onProcessWebhook'' event. The event contains two parameters, ''xml'' which contains the decrypted XML from the webhook payload and ''feedType'' which will either be ''transaction'' or ''subscription'' dependant on the type of webhook that has been triggered. If you don't have an existing custom plugin for your custom Craft code, we recommend utilising the [[https://github.com/lindseydiloreto/craft-businesslogic|Business Logic plugin]].+If you need to perform custom actions with that data (for example, you may need to subscribe a customer to a mailing list), you can make use of the ''foxyCart.onProcessWebhook'' event. The event contains two parameters, ''xml'' which contains the decrypted XML from the webhook payload and ''type'' which will either be ''transaction'' or ''subscription'' dependant on the type of webhook that has been triggered. If you don't have an existing custom plugin for your custom Craft code, we recommend utilising the [[https://github.com/lindseydiloreto/craft-businesslogic|Business Logic plugin]].
  
 +<code php>
 +craft()->on('foxyCart.onProcessWebhook', function(Event $event) {
 +    $xml = $event->params['xml']; // The decrypted XML payload
 +    $feedType = $event->params['type']; // "transaction" or "subscription"
 +    
 +    // .. your code
 +});
 +</code>
 +
 +For an example of the payload you'll receive, you can review those on their respective wiki pages - [[v:2.0:transaction_xml_datafeed|transaction datafeed]] and [[v:2.0:subscription_xml_datafeed|subscription datafeed]].
 ==== Single Sign-On ==== ==== Single Sign-On ====
  

Site Tools