A partial implementation of the spreedly API in ColdFusion.
ColdFusion
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
readme.md
spreedly.cfc

readme.md

Spreedly + ColdFusion

This is a partial implementation of the Spreedly API for ColdFusion. Using this component is rather simple. For example:

<cfscript>
  // create a new spreedly user
  var SP = CreateObject("component", "Spreedly").init();
  var newbie = {
    "customer-id":person.id,
    "screen-name":person.name
  };
  SP.create(data=newbie);
  // assign them a free trial plan
  SP.free_trial(id=person.id,data={"id":"7533"});
</cfscript>

If you are using a CFML engine that doesn't support shorthand JSON-style object creation syntax, try this example instead:

<cfscript>
  // create a new spreedly user
  SP = CreateObject("component", "Spreedly").init();
  newbie = StructNew();
  newbie["customer-id"] = person.id;
  newbie["screen-name"] = person.name;
  SP.create(data=newbie);
  // assign them a free trial plan
  free_trial_data = StructNew();
  free_trial_data["id"] = "7533";
  SP.free_trial(id=person.id,data=free_trial_data);
</cfscript>

Creating an invoice

var data = structNew();
data["subscription-plan-id"] = plan.spreedly_id;
data["subscriber"] = structNew();
data["subscriber"]["customer-id"] = userAccount.id;
data["subscriber"]["screen-name"] = userAccount.username;
data["subscriber"]["email"] = userAccount.email;
data["subscriber"]["billing-first-name"] = userAccount.firstname;
data["subscriber"]["billing-last-name"] = userAccount.lastname;
invoice = getMyPlugin("Spreedly").invoice( data=data );

Paying an invoice:

var pdata = structNew();
pdata["credit-card"] = structNew();
pdata["credit-card"]["number"] = "4222222222222";
pdata["credit-card"]["card-type"] = "visa";
pdata["credit-card"]["verification-value"] = 234;
pdata["credit-card"]["month"] = 1;
pdata["credit-card"]["year"] = 2013;
pdata["credit-card"]["first-name"] = ...;
pdata["credit-card"]["last-name"] = ...;
pdata["credit-card"]["address1"] = ...;
pdata["credit-card"]["address2"] = ...;
pdata["credit-card"]["city"] = ...;
pdata["credit-card"]["state"] = ...;
pdata["credit-card"]["zip"] = ...;
pdata["credit-card"]["country"] = ...;
getMyPlugin("Spreedly").pay( invoice_id=<token>, data=data );

Changing the plan:

var data = structNew();
data.id = <new_plan_id>;
getMyPlugin("Spreedly").change_subscription_plan( customer_id=..., data=data );

Notes

Has only been tested with Railo 3. Will probably work with CF8+ as well.