Skip to content

Instantly share code, notes, and snippets.

@AlannaBurke
Last active October 19, 2015 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlannaBurke/1a6edb8cf9ce5bee6aef to your computer and use it in GitHub Desktop.
Save AlannaBurke/1a6edb8cf9ce5bee6aef to your computer and use it in GitHub Desktop.

Setup changes

  • Uses public key instead of transparent post.
  • Call recurly.configure($publickey) instead of passing a whole mess of options.
    • Good! But leaves me figuring out what to do with those options.
    • Some can be discarded.
      • Unneeded options, settings
      • everything was json-encoded and sent to recurly, not needed
      • can discard a lot of code used to clean up field names and change them
      • ~150 lines of code less in the module file now

Forms

  • super simple, need the data-recurly attribute.
<form>
 <input type="text" data-recurly="routing_number">
 <input type="text" data-recurly="account_number">
 <input type="text" data-recurly="account_number_confirmation">
 <input type="text" data-recurly="account_type">
 <input type="text" data-recurly="name_on_account">
 <input type="hidden" name="recurly-token" data-recurly="token">
 <button>submit</button>
</form>

Tokens

  • how v3 authenticates
  • the form submit is interrupted to get a token.
  • get the token, continue with the submit.
recurly.token(this, function (err, token) {

   // send any errors to the error function below
  if (err) error(err);

  // Otherwise we continue with the form submission
  else form.submit();

});

Challenges

  • the existing module is pretty complex. Recurlyjs v3 is pretty simple.
  • Working between drupal forms & recurlyjs forms, wrestling the form API
  • figuring out what isn't needed anymore
  • figuring out why the old code was needed without the old API (most of the links are broken). This is one of the biggest ones for me.

Realizations

  • I had to think of the whole project in layers/steps -

    • make array of fields/values
    • display user facing form in tpls
    • put user values into the array
    • format the needed values for the drupal subscription & account objects, save
    • format the values for recurly, create a billingInfo object, submit.
  • Figure out which of these steps and which fields are needed for:

    • new subscribers
    • updating billing information for existing subscribers
  • Use form callbacks to process fields.

  • Some functions in the recurlyjs module are using the php functions - decide which of these are necessary, or should all calls use recurlyjs in this module? what's faster/more efficient?

Todo

  • Re-do billing info update form
  • styling
  • test ALL the things!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment