Created
August 8, 2013 07:07
-
-
Save alaingoldman/6182239 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BankacctsController < ApplicationController | |
| def addbank | |
| @account_uri = (params['account_uri']) | |
| current_user.customer_uri = @account_uri | |
| current_user.save! | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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