diff --git a/app/components/donation/credit-card.js b/app/components/donation/credit-card.js index 8ac896308..58118038a 100644 --- a/app/components/donation/credit-card.js +++ b/app/components/donation/credit-card.js @@ -2,11 +2,71 @@ import Ember from 'ember'; const { Component, - computed: { not } + computed, + computed: { and, not }, + inject: { service } } = Ember; export default Component.extend({ classNames: ['credit-card-form'], - canDonate: true, - cannotDonate: not('canDonate') + month: '', + months: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'], + year: '', + years: [], + + /** + @property stripe + @type Ember.Service + */ + stripe: service(), + + cannotDonate: not('canDonate'), + + cannotSubmit: not('canSubmit'), + + canSubmit: and('isCardValid', 'isCVCValid', 'isExpiryValid'), + + date: computed('month', 'year', function() { + let month = this.get('month'); + let year = this.get('year'); + return `${month} ${year}`; + }), + + isCardValid: computed('cardNumber', function() { + let stripe = this.get('stripe'); + let cardNumber = this.get('cardNumber'); + return stripe.card.validateCardNumber(cardNumber); + }), + + isCVCValid: computed('cvc', function() { + let stripe = this.get('stripe'); + let cvc = this.get('cvc'); + return stripe.card.validateCVC(cvc); + }), + + isExpiryValid: computed('date', function() { + let stripe = this.get('stripe'); + let date = this.get('date'); + return stripe.card.validateExpiry(date); + }), + + init() { + let date = new Date(); + let currentMonth = `0${date.getMonth() + 1}`.slice(-2); + this.set('month', currentMonth); + let currentYear = date.getFullYear(); + this.set('year', currentYear); + let years = this.generateYears(currentYear); + this.set('years', years); + this._super(...arguments); + }, + + generateYears(currentYear) { + let years = []; + let endYear = currentYear + 20; + while (endYear >= currentYear) { + years.push(currentYear++); + } + return years; + } }); diff --git a/app/styles/_forms.scss b/app/styles/_forms.scss index ccf5fdd75..930631b18 100644 --- a/app/styles/_forms.scss +++ b/app/styles/_forms.scss @@ -46,10 +46,14 @@ $outer-border-radius: 4px; .row { display: flex; justify-content: space-between; + } - label { - width: 49%; - position: relative; + label { + span { + display: block; + font-size: $body-font-size-small; + font-weight: 700; + margin-bottom: 3px; } } @@ -186,14 +190,19 @@ form { } } +select { + border: 1px solid $border-default; + font-family: $body-font-family; + font-size: $body-font-size-normal; + height: 41px; + padding: 0 16px; + cursor: pointer; +} + .task-type { select { border: none; - font-family: $body-font-family; - font-size: $body-font-size-normal; height: 34px; - padding: 0 16px; - cursor: pointer; width: 100px; &:focus { diff --git a/app/styles/components/donation-payment.scss b/app/styles/components/donation-payment.scss index 5939b11c3..c486c38b4 100644 --- a/app/styles/components/donation-payment.scss +++ b/app/styles/components/donation-payment.scss @@ -33,25 +33,3 @@ margin-bottom: 15px; } } - -.credit-card-label { - &:before { - @include sprite($credit-card); - } - - .icon-input { - padding-left: 45px; - } -} - -.lock-label { - &:before { - @include sprite($lock); - } -} - -.calendar-label { - &:before { - @include sprite($calendar); - } -} diff --git a/app/templates/components/donation/credit-card.hbs b/app/templates/components/donation/credit-card.hbs index 7c6edcb0c..7e6210266 100644 --- a/app/templates/components/donation/credit-card.hbs +++ b/app/templates/components/donation/credit-card.hbs @@ -8,36 +8,39 @@ diners-club
-
-
- + diff --git a/app/templates/components/donation/donation-container.hbs b/app/templates/components/donation/donation-container.hbs index 1a107a34e..e0c8a52ef 100644 --- a/app/templates/components/donation/donation-container.hbs +++ b/app/templates/components/donation/donation-container.hbs @@ -2,7 +2,6 @@

{{format-currency donationAmount}}

given each month - edit
diff --git a/config/environment.js b/config/environment.js index ddab714b3..98a9ce3f0 100644 --- a/config/environment.js +++ b/config/environment.js @@ -78,6 +78,8 @@ module.exports = function(environment) { sentry: { dsn: 'https://cecdf7d399e74b72bc73dc8e4e62737d@app.getsentry.com/82741' }, + + stripe: {} }; if (environment === 'development') { @@ -92,6 +94,8 @@ module.exports = function(environment) { ENV.sentry.development = true; + ENV.stripe.publishableKey = 'pk_test_hiQ7tWKKdLSw8jJdE98NSW74'; + ENV['ember-cli-mirage'] = { enabled: false }; diff --git a/package.json b/package.json index 6257ce3cc..987ab2f78 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "ember-simple-auth": "1.1.0", "ember-simple-auth-token": "^1.2.0", "ember-sinon": "0.5.1", + "ember-stripe-service": "4.4.2", "ember-tether": "0.3.1", "ember-tooltips": "2.4.0", "ember-truth-helpers": "1.2.0",