Giter VIP home page Giter VIP logo

foxy_sync's Introduction

FoxySync

A gem to synchronize your Ruby application with FoxyCart.

It encapsulates the FoxyCart SSO, Datafeed, and cart validation protocols and abstracts the entire FoxyCart API.

Installation

If you use Bundler just add gem 'foxy_sync' to your Gemfile and then run bundle install. Otherwise you can gem install foxy_sync manually.

Setup

You'll need to configure FoxySync. In particular you need to make known your FoxyCart API key and store URL.

FoxySync.setup do |config|
  config.api_key = 'YOUR API KEY HERE'
  config.store_url = 'YOUR STORE URL HERE'
end

You should do this in an application startup file. In Rails it's best to put it in a file config/initializers/foxy_sync.rb

Cart validation

FoxySync provides methods to help with FoxyCart's cart validation service. To create a hidden input like this:

<input type="hidden" value="mai" name="code||5651608dde5a2abeb51fad7099fbd1a026690a7ddbd93a1a3167362e2f611b53"/>

You would include FoxySync::CartValidation and output your hidden field with a name whose value is cart_input_name 'code', 'mai', 'mai'

Single sign on

FoxySync provides methods for helping with FoxyCart's single sign on service.

To create the URL that FoxyCart expects your server to redirect to just include FoxySync::Sso and redirect_to sso_url(params, user). The params argument should be something that responds to [] and holds the 'fcsid' and 'timestamp' parameters given by the FoxyCart SSO request (in Rails that's the params object). The user argument should be the currently logged in user, if any.

XML datafeeds

FoxySync provides methods for helping with FoxyCart's datafeeds. Typically done in a controller you would include FoxySync::Datafeed and, in the method that handles the datafeed request, parse the request parameter and read the XML:

  receipt = []
  xml = datafeed_unwrap params
  receipt << xml.customer_first_name
  receipt << xml.customer_last_name
  receipt << xml.receipt_url
  # ... etc ....

params should respond to [] and hold the 'FoxyData' parameter that FoxyCart sends (in Rails that's the params object). xml would be a FoxySync::Xml::Transaction. FoxyCart expects a particular reply when responding to its datafeed requests. The reply can be sent using the datafeed_response method.

FoxyCart API

You can access any part of the FoxyCart API via the FoxySync::Api::Messenger class. To use it create a new instance and then send it a message that corresponds to the FoxyCart API. All messages return an instance of FoxySync::Xml::Document through which you can access FoxyCart's XML response. For Example:

    api = FoxySync::Api::Messenger.new
    reply = api.customer_get :customer_email => '[email protected]'
    reply.customer_id # is the customer's FoxyCart id

Messenger instances respond to every API call in FoxyCart v1.0.

foxy_sync's People

Contributors

pix0r avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.