changed how membership changes are communicated to the backend and fixed a couple of bugs related to that process
parent
df342fe288
commit
e9cd98af88
|
@ -117,7 +117,7 @@ export class ProfileService {
|
|||
}
|
||||
|
||||
updateAccount(accountChanges: any) {
|
||||
return this.http.patch(ACCOUNT_URL, {accountChanges}).pipe(
|
||||
return this.http.patch(ACCOUNT_URL, accountChanges).pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ import { MediaChange, MediaObserver } from '@angular/flex-layout';
|
|||
import { MatBottomSheet } from '@angular/material';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { AccountMembership } from '../../../../../shared/models/account-membership.model';
|
||||
import { MembershipType } from '../../../../../shared/models/membership.model';
|
||||
import { ProfileService } from '../../../../../core/http/profile.service';
|
||||
import { AccountMembership } from '@account/models/account-membership.model';
|
||||
import { MembershipType } from '@account/models/membership.model';
|
||||
import { ProfileService } from '@account/http/profile.service';
|
||||
import { PaymentComponent } from '../../views/payment/payment.component';
|
||||
|
||||
@Component({
|
||||
|
@ -42,20 +42,24 @@ export class MembershipComponent implements OnDestroy {
|
|||
if (selectedMembership) {
|
||||
if (this.accountMembership) {
|
||||
// We have the user's credit card info but they decide to change plans
|
||||
this.profileService.updateAccount({support: {membership: membershipType}});
|
||||
this.profileService.updateAccount(
|
||||
{membership: {paymentMethod: 'Stripe', newMembership: false, membershipType: membershipType}}
|
||||
);
|
||||
} else {
|
||||
// No credit card info. Go to payment screen to collect
|
||||
this.openBottomSheet();
|
||||
this.openBottomSheet(membershipType);
|
||||
}
|
||||
} else {
|
||||
// Membership termination
|
||||
this.profileService.updateAccount({support: {membership: null}});
|
||||
this.profileService.updateAccount(
|
||||
{membership: {paymentMethod: 'Stripe', newMembership: false, membershipType: null}}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
openBottomSheet() {
|
||||
openBottomSheet(membershipType: string) {
|
||||
const bottomSheetConfig = {
|
||||
data: {newAccount: false},
|
||||
data: {newAccount: false, membershipType: membershipType},
|
||||
disableClose: true,
|
||||
restoreFocus: true
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
|
||||
import { ElementOptions, StripeCardComponent, StripeService } from 'ngx-stripe';
|
||||
|
||||
import { ProfileService } from '../../../../../core/http/profile.service';
|
||||
import { ProfileService } from '@account/http/profile.service';
|
||||
import { VerifyCardDialogComponent } from './verify-card-dialog.component';
|
||||
|
||||
const twoSeconds = 2000;
|
||||
|
@ -32,7 +32,6 @@ export class PaymentComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
};
|
||||
private membershipType: string;
|
||||
private dialogRef: MatDialogRef<VerifyCardDialogComponent>;
|
||||
|
||||
constructor(
|
||||
|
@ -57,7 +56,7 @@ export class PaymentComponent implements OnInit {
|
|||
if (configData.newAccount) {
|
||||
this.showStripeSuccess(result.token.id);
|
||||
} else {
|
||||
this.updateAccount(result.token.id);
|
||||
this.updateAccount(configData.membershipType, result.token.id);
|
||||
}
|
||||
} else if (result.error) {
|
||||
this.showStripeError(result.error.message);
|
||||
|
@ -73,10 +72,11 @@ export class PaymentComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
updateAccount(stripeToken: string) {
|
||||
updateAccount(membershipType: string, stripeToken: string) {
|
||||
const newMembership = {
|
||||
support: {
|
||||
membership: this.membershipType,
|
||||
membership: {
|
||||
newMembership: true,
|
||||
membershipType: membershipType,
|
||||
paymentMethod: 'Stripe',
|
||||
paymentToken: stripeToken
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue