Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/payments/bank-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default Component.extend({
classNameBindings: ['statusClass'],
classNames: ['bank-account', 'account-setup__section'],

accountNumber: '000123456789',
routingNumber: '110000000',
accountNumber: null,
routingNumber: null,

status: computed.alias('stripeConnectAccount.bankAccountStatus'),

Expand Down
41 changes: 13 additions & 28 deletions app/components/payments/funds-recipient/details-form.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
import Ember from 'ember';

const {
assign,
Component,
computed: { equal },
get,
getProperties,
set
} = Ember;

const BUSINESS_PROPERTIES = ['businessName', 'businessEin'];

const INDIVIDUAL_PROPERTIES = [
'recipientType',
'firstName', 'lastName',
'dobDay', 'dobMonth', 'dobYear',
'address1', 'address2', 'city', 'state', 'zip', 'country',
'ssnLast4'
];

export default Component.extend({
classNames: ['details-form'],
tagName: 'section',

isBusiness: equal('recipientType', 'business'),
isIndividual: equal('recipientType', 'individual'),
isBusiness: equal('stripeConnectAccount.legalEntityType', 'business'),
isIndividual: equal('stripeConnectAccount.legalEntityType', 'individual'),

init() {
let recipientType = get(this, 'stripeConnnectAccount.recipientType') || 'individual';
set(this, 'recipientType', recipientType);
this._super(...arguments);
let stripeConnectAccount = get(this, 'stripeConnectAccount');
if (get(stripeConnectAccount, 'legalEntityType') === null) {
set(this, 'stripeConnectAccount.legalEntityType', 'individual');
}
},

actions: {
submit() {
let details = this._collectIndividualProperties();
let stripeConnectAccount = get(this, 'stripeConnectAccount');

if (get(this, 'isBusiness')) {
assign(details, this._collectBusinessProperties());
if (get(this, 'isIndividual')) {
stripeConnectAccount.setProperties({
legalEntityBusinessName: null,
legalEntityBusinessTaxId: null
});
}

let onSubmit = get(this, 'onSubmit');
onSubmit(details);
onSubmit();
}
},

_collectBusinessProperties() {
return getProperties(this, ...BUSINESS_PROPERTIES);
},

_collectIndividualProperties() {
return getProperties(this, ...INDIVIDUAL_PROPERTIES);
}
});
48 changes: 31 additions & 17 deletions app/controllers/project/settings/donations/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ import Ember from 'ember';
import FriendlyError from 'code-corps-ember/utils/friendly-error';

const {
computed: { alias },
Controller,
get,
inject: { service },
RSVP,
set,
setProperties
set
} = Ember;

const ACCOUNT_CREATION_ERROR = 'There was a problem with creating your account. Please check your input and try again.';
const ACCOUNT_UPDATE_ERROR = 'There was a problem with your account information. Please check your input and try again.';
const BANK_ACCOUNT_TOKEN_CREATION_ERROR = 'There was a problem in using your bank account information. Please check your input and try again.';
const BANK_ACCOUNT_ADDING_ERROR = 'There was a problem submitting your bank account information.';
const PERSONAL_ID_NUMBER_TOKEN_CREATION_ERROR = 'There was a problem in using your personal ID number. Please check your input and try again.';
const VERIFICATION_DOCUMENT_ERROR = 'There was a problem with attaching your document. Please try again.';

export default Controller.extend({
currentUser: service(),
store: service(),
stripe: service(),

stripeConnectAccount: alias('project.organization.stripeConnectAccount'),

actions: {
onCreateStripeConnectAccount(country) {
set(this, 'isBusy', true);
Expand All @@ -31,11 +34,11 @@ export default Controller.extend({
.finally(() => set(this, 'isBusy', false));
},

onRecipientDetailsSubmitted(recipientInformation) {
onRecipientDetailsSubmitted() {
set(this, 'isBusy', true);

get(this, 'stripeConnectAccount')
.then((stripeConnectAccount) => this._updateRecipientDetails(stripeConnectAccount, recipientInformation))
.then((stripeConnectAccount) => this._updateRecipientDetails(stripeConnectAccount))
.catch((reason) => this._handleError(reason))
.finally(() => set(this, 'isBusy', false));
},
Expand Down Expand Up @@ -63,13 +66,18 @@ export default Controller.extend({
.finally(() => set(this, 'isBusy', false));
},

onPersonalIdNumberSubmitted(personalIdNumber) {
onLegalEntityPersonalIdNumberSubmitted(legalEntityPersonalIdNumber) {
set(this, 'isBusy', true);

get(this, 'stripeConnectAccount')
.then((account) => this._assignPersonalIdNumber(account, personalIdNumber))
.catch((response) => this._handleError(response))
.finally(() => set(this, 'isBusy', false));
let promises = {
tokenData: this._createPersonalIdNumberToken(legalEntityPersonalIdNumber),
stripeConnectAccount: get(this, 'stripeConnectAccount')
};

RSVP.hash(promises)
.then(({ tokenData, stripeConnectAccount }) => this._assignLegalEntityPersonalIdNumber(tokenData, stripeConnectAccount))
.catch((response) => this._handleError(response))
.finally(() => set(this, 'isBusy', false));
}
},

Expand All @@ -85,9 +93,7 @@ export default Controller.extend({

// udating recipient info

_updateRecipientDetails(stripeConnectAccount, recipientDetails) {
setProperties(stripeConnectAccount, recipientDetails);

_updateRecipientDetails(stripeConnectAccount) {
return stripeConnectAccount
.save()
.then(RSVP.resolve)
Expand All @@ -97,7 +103,7 @@ export default Controller.extend({
// uploading and assigning an id verification document

_assignIdentityVerificationDocument(stripeConnectAccount, stripeFileUploadId) {
set(stripeConnectAccount, 'identityDocumentId', stripeFileUploadId);
set(stripeConnectAccount, 'legalEntityVerificationDocument', stripeFileUploadId);

return stripeConnectAccount
.save()
Expand All @@ -107,24 +113,32 @@ export default Controller.extend({

// assigning a personal id number

_assignPersonalIdNumber(stripeConnectAccount, personalIdNumber) {
set(stripeConnectAccount, 'personalIdNumber', personalIdNumber);
_assignLegalEntityPersonalIdNumber(tokenData, stripeConnectAccount) {
set(stripeConnectAccount, 'legalEntityPersonalIdNumber', tokenData.id);

return stripeConnectAccount
.save()
.then(RSVP.resolve)
.catch(() => this._wrapError(ACCOUNT_UPDATE_ERROR));
},

_createPersonalIdNumberToken(personalIdNumber) {
let stripe = get(this, 'stripe');

return stripe.piiData.createToken({ personalIdNumber })
.then((stripeResponse) => RSVP.resolve(stripeResponse))
.catch(() => this._wrapError(PERSONAL_ID_NUMBER_TOKEN_CREATION_ERROR));
},

// bank account - token step

_createAccountToken(accountNumber, routingNumber) {
let stripe = get(this, 'stripe');
let params = this._bankAccountTokenParams(accountNumber, routingNumber);

return stripe.bankAccount.createToken(params)
.then((stripeResponse) => RSVP.resolve(stripeResponse))
.catch(() => this._wrapError(BANK_ACCOUNT_TOKEN_CREATION_ERROR));
.then((stripeResponse) => RSVP.resolve(stripeResponse))
.catch(() => this._wrapError(BANK_ACCOUNT_TOKEN_CREATION_ERROR));
},

_bankAccountTokenParams(accountNumber, routingNumber) {
Expand Down
64 changes: 48 additions & 16 deletions app/models/stripe-connect-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,65 @@ import attr from 'ember-data/attr';
import { belongsTo } from 'ember-data/relationships';

export default Model.extend({
address1: attr(),
address2: attr(),
businessEin: attr(),
bankAccountStatus: attr(),
businessName: attr(),
businessType: attr(),
businessUrl: attr(),
canAcceptDonations: attr(),
chargesEnabled: attr(),
city: attr(),
country: attr(),
defaultCurrency: attr(),
detailsSubmitted: attr(),
displayName: attr(),
dobDay: attr(),
dobMonth: attr(),
dobYear: attr(),
email: attr(),
firstName: attr(),
identityDocumentId: attr(),
idFromStripe: attr(),
externalAccount: attr(),
insertedAt: attr(),
lastName: attr(),
legalEntityAddressCity: attr(),
legalEntityAddressCountry: attr(),
legalEntityAddressLine1: attr(),
legalEntityAddressLine2: attr(),
legalEntityAddressPostalCode: attr(),
legalEntityAddressState: attr(),
legalEntityBusinessName: attr(),
legalEntityBusinessTaxId: attr(),
legalEntityBusinessTaxIdProvided: attr(),
legalEntityBusinessVatId: attr(),
legalEntityBusinessVatIdProvided: attr(),
legalEntityDobDay: attr('number'),
legalEntityDobMonth: attr('number'),
legalEntityDobYear: attr('number'),
legalEntityFirstName: attr(),
legalEntityLastName: attr(),
legalEntityGender: attr(),
legalEntityMaidenName: attr(),
legalEntityPersonalAddressCity: attr(),
legalEntityPersonalAddressCountry: attr(),
legalEntityPersonalAddressLine1: attr(),
legalEntityPersonalAddressLine2: attr(),
legalEntityPersonalAddressPostalCode: attr(),
legalEntityPersonalAddressState: attr(),
legalEntityPhoneNumber: attr(),
legalEntityPersonalIdNumber: attr(),
legalEntityPersonalIdNumberProvided: attr(),
legalEntitySsnLast4: attr(),
legalEntitySsnLast4Provided: attr(),
legalEntityType: attr(),
legalEntityVerificationDetails: attr(),
legalEntityVerificationDetailsCode: attr(),
legalEntityVerificationDocument: attr(),
legalEntityVerificationStatus: attr(),
idFromStripe: attr(),
managed: attr(),
personalIdNumberStatus: attr(),
recipientStatus: attr(),
recipientType: attr(),
ssnLast4: attr(),
state: attr(),
supportEmail: attr(),
supportPhone: attr(),
supportUrl: attr(),
transfersEnabled: attr(),
updatedAt: attr(),
verificationDisabledReason: attr(),
verificationDocumentStatus: attr(),
verificationDueBy: attr(),
verificationFieldsNeeded: attr(),
zip: attr(),

organization: belongsTo('organization', { async: true })
});
8 changes: 8 additions & 0 deletions app/serializers/stripe-connect-account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend({
attrs: {
legalEntitySsnLast4: { key: 'legal-entity-ssn-last-4' },
legalEntitySsnLast4Provided: { key: 'legal-entity-ssn-last-4-provided' }
}
});
2 changes: 1 addition & 1 deletion app/styles/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $calendar: 20px 20px $spriteURL -42px -268px $spritex2URL;
$task-small: 16px 16px $spriteURL 0px -288px $spritex2URL;
$issue-small: 16px 16px $spriteURL -16px -288px $spritex2URL;
$idea-small: 16px 16px $spriteURL -32px -288px $spritex2URL;
$tick-green-large: 20px 24px $spriteURL 0px -304px $spritex2URL;
$tick-green-large: 24px 20px $spriteURL 0px -304px $spritex2URL;

.box-icon {
@include sprite($box);
Expand Down
4 changes: 4 additions & 0 deletions app/styles/components/payments/account-setup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
background-color: $light-green-background;
border-color: $green;

p {
color: $green;
}

aside h1:before {
content: "";
display: block;
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/payments/account-setup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

{{payments/funds-recipient
isBusy=isBusy
onLegalEntityPersonalIdNumberSubmitted=(action onLegalEntityPersonalIdNumberSubmitted)
onRecipientDetailsSubmitted=(action onRecipientDetailsSubmitted)
onVerificationDocumentSubmitted=(action onVerificationDocumentSubmitted)
onPersonalIdNumberSubmitted=(action onPersonalIdNumberSubmitted)
stripeConnectAccount=stripeConnectAccount
}}

Expand Down
13 changes: 8 additions & 5 deletions app/templates/components/payments/funds-recipient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,27 @@
{{payments/funds-recipient/verification-document
isBusy=isBusy
onVerificationDocumentSubmitted=(action onVerificationDocumentSubmitted)
stripeConnectAccount=stripeConnectAccount}}
stripeConnectAccount=stripeConnectAccount
}}

{{payments/funds-recipient/personal-id-number
isBusy=isBusy
stripeConnectAccount=stripeConnectAccount
submit=(action onPersonalIdNumberSubmitted)}}
submit=(action onLegalEntityPersonalIdNumberSubmitted)
}}
{{/if}}

{{#if (eq status 'verified')}}
<section>
<div class="funds-recipient__individual-name">
<label>Name</label>
<p>{{stripeConnectAccount.individualName}}</p>
<p>{{stripeConnectAccount.legalEntityFirstName}} {{stripeConnectAccount.legalEntityLastName}}</p>
</div>

{{#if (eq stripeConnectAccount.recipientType 'business')}}
{{#if (eq stripeConnectAccount.legalEntityType 'business')}}
<div class="funds-recipient__business-name">
<label>Business Name</label>
<p>{{stripeConnectAccount.businessName}}</p>
<p>{{stripeConnectAccount.legalEntityBusinessName}}</p>
</div>
{{/if}}
</section>
Expand Down
Loading