Skip to content

Instantly share code, notes, and snippets.

@alaingoldman
Created August 8, 2013 07:07
Show Gist options
  • Select an option

  • Save alaingoldman/6182239 to your computer and use it in GitHub Desktop.

Select an option

Save alaingoldman/6182239 to your computer and use it in GitHub Desktop.
class BankacctsController < ApplicationController
def addbank
@account_uri = (params['account_uri'])
current_user.customer_uri = @account_uri
current_user.save!
end
end
var requestBinURL = 'http://requestb.in/15x60eq1';
var marketplaceUri = '/v1/marketplaces/TEST-MPg9bCIQUZMBoiPMnvWkQJW'; // this is my marketplace URI
balanced.init(marketplaceUri);
function responseCallbackHandler(response) {
switch (response.status) {
case 400:
console.log(response.error);
break;
case 201:
$.ajax({ url: '#{addbank_bankaccts_path}',
type: 'POST',
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', '#{form_authenticity_token}')},
dataType: "json",
data: 'account_uri=' + response.data.uri,
success: function(response) {
console.log("This works!");
},
error: function(){
console.log("uhoh!!");}
}); break;}}
var tokenizeInstrument = function(e) {
e.preventDefault();
var $form = $('#bank-account-form');
var bankAccountData = {
name: $form.find('.ba-name').val(),
account_number: $form.find('.ba-an').val(),
bank_code: $form.find('.ba-rn').val(),
type: $form.find('select').val()
};
balanced.bankAccount.create(bankAccountData, responseCallbackHandler);
};
$('#bank-account-form').submit(tokenizeInstrument);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment