Skip to content

Commit

Permalink
simple migration
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre committed Mar 13, 2015
1 parent 0843f22 commit 1c8bc41
Show file tree
Hide file tree
Showing 18 changed files with 467 additions and 0 deletions.
66 changes: 66 additions & 0 deletions app/controllers/migrate.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
`import Ember from "ember";`
`import Utils from "balanced-dashboard/lib/utils";`
`import AnalyticsLogger from "balanced-dashboard/utils/analytics_logger";`

Controller = Ember.Controller.extend(
needs: ["notification_center"]

userMarketplaces: Ember.computed.reads("auth.user.user_marketplaces")
marketplaces: Ember.computed.filterBy("userMarketplaces", "production")

isStartingMigration: false

getConnection: (apiKey) ->
require("balanced-dashboard/lib/connections/api-connection").default.create(
apiKey: apiKey
)

createMigration: (marketplace, emailAddress) ->
deferred = Ember.RSVP.defer()
AnalyticsLogger.trackEvent("Stripe migration started",
data_marketplace_id: marketplace.get("id")
data_email_address: emailAddress
)

Ember.$
.ajax("https://api.balancedpayments.com/stripe/",
method: "POST"
data:
email: emailAddress
headers:
Authorization: Utils.encodeAuthorization(marketplace.get("secret"))
)
.done ->
deferred.resolve()
.fail (xhr, error, message) ->
AnalyticsLogger.trackEvent("Stripe migration error",
data_marketplace_id: marketplace.get("id"),
data_email_address: emailAddress,
xhr_text: xhr.responseText
)

deferred.reject(xhr.responseJSON.errors)
deferred.promise

actions:
startMigration: (marketplace, emailAddress, isAccepted) ->
@set "errors", []
@get("controllers.notification_center").clearAlerts()
if marketplace && emailAddress && isAccepted
@set("isStartingMigration", true)
@createMigration(marketplace, emailAddress)
.then =>
marketplace.reload()
.then =>
@transitionTo("migrateSuccess", marketplace)
.catch (errors) =>
for error in errors
error.isStripeUnderwritingError = (error.category_code == "stripe-underwriting-error")
@set("errors", errors)
.finally =>
@set("isStartingMigration", false)
else
@get("controllers.notification_center").alertError("Please fill all of the fields")
)

`export default Controller;`
4 changes: 4 additions & 0 deletions app/models/marketplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ var Marketplace = UserMarketplace.extend({
invoices_uri: '/invoices',
disputes_uri: '/disputes',

isMigrationStarted: Ember.computed("meta", function() {
return this.get("meta") && !Ember.isBlank(this.get("meta")["stripe.account_id"]);
}),

populateWithTestTransactions: function() {
// pre-populate marketplace with transactions
var id = this.get('id');
Expand Down
4 changes: 4 additions & 0 deletions app/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Router.map ->
this.route('resetPassword', path: '/password/:token')
this.route('resetPassword', path: '/invite/:token')

this.route("migrate", path: "/migrate")
this.route("migrateConnect", path: "/connect/:marketplace_id")
this.route("migrateSuccess", path: "/migrate/:marketplace_id")

this.route("marketplace-application", path: "/marketplaces/applications/:id")
this.resource 'marketplaces', path: '/marketplaces', ->
this.route('apply')
Expand Down
16 changes: 16 additions & 0 deletions app/routes/migrate-connect.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
`import Ember from "ember";`
`import TitleRoute from "./title";`

Route = TitleRoute.extend(
pageTitle: "Connect Stripe account"

model: (params) ->
@container
.lookupFactory("model:marketplace")
.findById(params.marketplace_id)

setupController: (controller, model) ->
controller.set("model", model)
)

`export default Route;`
20 changes: 20 additions & 0 deletions app/routes/migrate-success.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
`import Ember from "ember";`
`import TitleRoute from "./title";`

SUCCESS_MESSAGE =
"Migration request received: The migration process will take 2-3 business days. You'll receive an email confirmation upon completion."

Route = TitleRoute.extend(
pageTitle: "Migrate"

model: (params) ->
@container
.lookupFactory("model:marketplace")
.findById(params.marketplace_id)

setupController: (controller, model) ->
controller.set("model", model)
@controllerFor("notification_center").alertSuccess(SUCCESS_MESSAGE)
)

`export default Route;`
10 changes: 10 additions & 0 deletions app/routes/migrate.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
`import Ember from "ember";`
`import AuthRoute from "./auth";`

Route = AuthRoute.extend(
pageTitle: "Migrate"
setupController: (controller) ->
@controllerFor("notification_center").clearAlerts()
)

`export default Route;`
2 changes: 2 additions & 0 deletions app/styles/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ dl, dt, dd {

// seperate pages inside our dashboard
@import "./account_security.less";

@import "./migrate.less";
17 changes: 17 additions & 0 deletions app/styles/loading-spinner.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.spin-animation {
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}

@-moz-keyframes fa-spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); }
}
@-webkit-keyframes fa-spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
@keyframes fa-spin {
from {transform:rotate(0deg);}
to {transform:rotate(360deg);}
}
97 changes: 97 additions & 0 deletions app/styles/migrate.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@import "./loading-spinner.less";

.container.column {
margin: 45px auto;
min-width: initial !important;
width: 100% !important;
max-width: 940px !important;

h3 {
font: normal normal normal 16px "Proxima Nova Semi Bold", arial, sans-serif;
}

.group-label {
font: normal normal normal 12px "Proxima Nova Semi Bold", arial, sans-serif;
}

.help-block {
font-size: 12px;
}
.padded-section {
margin: 40px 0;
}

.button-spinner {
text-align: center;
width: 135px;
}

i.icon-loading {
.spin-animation();
background: transparent url("/images/loading.png") center center no-repeat;
display: inline-block;
height: 26px;
overflow: hidden;
width: 26px;
}

.btn.btn-lg {
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
}

label {
font: normal normal normal 15px "Proxima Nova Reg", arial, sans-serif;
&::after {
content: "";
padding: 0;
}

input[type=radio], input[type=checkbox] {
margin: 5px 6px 10px 0;
}
}

.form-item {
margin-bottom: 30px;
}

.alert {
border-radius: 0;
font: normal normal normal 14px "Proxima Nova Semi Bold", arial, sans-serif;
margin: 75px 0;
}

.alert.alert-info {
background-color: #EFF0F1;
border: 1px solid #CBCFD3;
color: #000;
text-align: center;
}
}

.letterhead {
text-align: center;
.logo {
display: inline-block;
}
.logo.logo-dots {
img {
width: 35px
}
}
}

.page-title.title-1 {
color: #000;
font: normal normal normal 44px "Proxima Nova Semi Bold",arial,sans-serif;
letter-spacing: .1em;
line-height: 52px;
margin: 70px 0;
text-align: center;
text-transform: uppercase;
}

.migrate-form {
}
12 changes: 12 additions & 0 deletions app/templates/clean-page-layout.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{render "notification_center"}}
<section class="container column">
<header class="letterhead">
<a class="logo logo-dots" href="https://www.balancedpayments.com">
<img src="/images/logo_3dots.png"/>
</a>
</header>

<div class="contents">
{{yield}}
</div>
</section>
34 changes: 34 additions & 0 deletions app/templates/migrate-connect.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<h1 class="page-title title-1">Stripe migration</h3>

<hr>

<h3>Migration information</h3>
<div class="form-section clearfix col-md-offset-4">
<h4 class="group-label">Migrate production marketplace</h4>
<div class="form-item">
{{model.name}}
{{#if model.isMigrationStarted}}
<strong>(migration started)</strong>
{{/if}}
</div>

<h4 class="group-label">Migrate data</h4>
<p>
Card, bank account, and seller identity data
</p>
</div>
<hr>

<h3>Migration agreement</h3>
<div class="form-section clearfix col-md-offset-4">
<div class="form-item">
By clicking below, you indicate your acceptance of the
<a href="https://www.balancedpayments.com/terms/stripe-migration" target="_blank">Migration Agreement</a>
</div>
</div>
<hr>
<div class="form-section form-footer">
<a {{bind-attr href=view.activateAccountHref}} class="btn btn-info pull-right">
Connect Stripe account
</a>
</div>
13 changes: 13 additions & 0 deletions app/templates/migrate-success.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1 class="page-title title-1">Next step</h3>

<div style="text-align: center;">
<div class="padded-section">
<h3>Activate your stripe account</h3>
</div>
<p>
Provide your personal and business information to obtain process access to stripe.<br/>
You will not be able to process live until you've activated your account.</p>
<div class="padded-section">
<a {{bind-attr href=view.activateAccountHref}} class="btn btn-lg btn-info">Activate Stripe account</a>
</div>
</div>
Loading

0 comments on commit 1c8bc41

Please sign in to comment.