1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-29 07:59:42 +01:00

adjust storage with payment intent/method handling

This commit is contained in:
Kyle Spearrin 2019-08-10 13:00:07 -04:00
parent a4571a2617
commit 80c5dff5ad
3 changed files with 14 additions and 3 deletions

2
jslib

@ -1 +1 @@
Subproject commit e28e820286870df0111bd4feb8a219a3ae360ba7 Subproject commit de9bcac0ec9f4429c17af4b952f58a2054aad02e

View File

@ -27,3 +27,4 @@
</small> </small>
</div> </div>
</form> </form>
<app-payment [showMethods]="false"></app-payment>

View File

@ -3,6 +3,7 @@ import {
EventEmitter, EventEmitter,
Input, Input,
Output, Output,
ViewChild,
} from '@angular/core'; } from '@angular/core';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
@ -13,6 +14,10 @@ import { I18nService } from 'jslib/abstractions/i18n.service';
import { StorageRequest } from 'jslib/models/request/storageRequest'; import { StorageRequest } from 'jslib/models/request/storageRequest';
import { PaymentResponse } from 'jslib/models/response/paymentResponse';
import { PaymentComponent } from './payment.component';
@Component({ @Component({
selector: 'app-adjust-storage', selector: 'app-adjust-storage',
templateUrl: 'adjust-storage.component.html', templateUrl: 'adjust-storage.component.html',
@ -25,8 +30,10 @@ export class AdjustStorageComponent {
@Output() onAdjusted = new EventEmitter<number>(); @Output() onAdjusted = new EventEmitter<number>();
@Output() onCanceled = new EventEmitter(); @Output() onCanceled = new EventEmitter();
@ViewChild(PaymentComponent) paymentComponent: PaymentComponent;
storageAdjustment = 0; storageAdjustment = 0;
formPromise: Promise<any>; formPromise: Promise<PaymentResponse>;
constructor(private apiService: ApiService, private i18nService: I18nService, constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService) { } private analytics: Angulartics2, private toasterService: ToasterService) { }
@ -44,7 +51,10 @@ export class AdjustStorageComponent {
} else { } else {
this.formPromise = this.apiService.postOrganizationStorage(this.organizationId, request); this.formPromise = this.apiService.postOrganizationStorage(this.organizationId, request);
} }
await this.formPromise; const result = await this.formPromise;
if (result != null && result.paymentIntentClientSecret != null) {
await this.paymentComponent.handleStripeCardPayment(result.paymentIntentClientSecret, null);
}
this.analytics.eventTrack.next({ action: this.add ? 'Added Storage' : 'Removed Storage' }); this.analytics.eventTrack.next({ action: this.add ? 'Added Storage' : 'Removed Storage' });
this.toasterService.popAsync('success', null, this.toasterService.popAsync('success', null,
this.i18nService.t('adjustedStorage', request.storageGbAdjustment.toString())); this.i18nService.t('adjustedStorage', request.storageGbAdjustment.toString()));