new payment api changes

This commit is contained in:
Kyle Spearrin 2019-08-09 23:56:55 -04:00
parent 393f6c9c20
commit e28e820286
3 changed files with 34 additions and 6 deletions

View File

@ -78,6 +78,7 @@ import {
OrganizationUserDetailsResponse,
OrganizationUserUserDetailsResponse,
} from '../models/response/organizationUserResponse';
import { PaymentResponse } from '../models/response/paymentResponse';
import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
@ -118,7 +119,7 @@ export abstract class ApiService {
getAccountRevisionDate: () => Promise<number>;
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
postRegister: (request: RegisterRequest) => Promise<any>;
postPremium: (data: FormData) => Promise<any>;
postPremium: (data: FormData) => Promise<PaymentResponse>;
postReinstatePremium: () => Promise<any>;
postCancelPremium: () => Promise<any>;
postAccountStorage: (request: StorageRequest) => Promise<any>;
@ -241,7 +242,7 @@ export abstract class ApiService {
postOrganizationLicenseUpdate: (id: string, data: FormData) => Promise<any>;
postOrganizationApiKey: (id: string, request: PasswordVerificationRequest) => Promise<ApiKeyResponse>;
postOrganizationRotateApiKey: (id: string, request: PasswordVerificationRequest) => Promise<ApiKeyResponse>;
postOrganizationUpgrade: (id: string, request: OrganizationUpgradeRequest) => Promise<any>;
postOrganizationUpgrade: (id: string, request: OrganizationUpgradeRequest) => Promise<PaymentResponse>;
postOrganizationSeat: (id: string, request: SeatRequest) => Promise<any>;
postOrganizationStorage: (id: string, request: StorageRequest) => Promise<any>;
postOrganizationPayment: (id: string, request: PaymentRequest) => Promise<any>;
@ -263,6 +264,7 @@ export abstract class ApiService {
getHibpBreach: (username: string) => Promise<BreachAccountResponse[]>;
postBitPayInvoice: (request: BitPayInvoiceRequest) => Promise<string>;
postSetupPayment: () => Promise<string>;
getActiveBearerToken: () => Promise<string>;
fetch: (request: Request) => Promise<Response>;

View File

@ -0,0 +1,18 @@
import { BaseResponse } from './baseResponse';
import { ProfileResponse } from './profileResponse';
export class PaymentResponse extends BaseResponse {
userProfile: ProfileResponse;
paymentIntentClientSecret: string;
success: boolean;
constructor(response: any) {
super(response);
const userProfile = this.getResponseProperty('UserProfile');
if (userProfile != null) {
this.userProfile = new ProfileResponse(userProfile);
}
this.paymentIntentClientSecret = this.getResponseProperty('PaymentIntentClientSecret');
this.success = this.getResponseProperty('Success');
}
}

View File

@ -85,6 +85,7 @@ import {
OrganizationUserDetailsResponse,
OrganizationUserUserDetailsResponse,
} from '../models/response/organizationUserResponse';
import { PaymentResponse } from '../models/response/paymentResponse';
import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
@ -253,8 +254,9 @@ export class ApiService implements ApiServiceAbstraction {
return this.send('POST', '/accounts/register', request, false, false);
}
postPremium(data: FormData): Promise<any> {
return this.send('POST', '/accounts/premium', data, true, false);
async postPremium(data: FormData): Promise<PaymentResponse> {
const r = await this.send('POST', '/accounts/premium', data, true, true);
return new PaymentResponse(r);
}
postReinstatePremium(): Promise<any> {
@ -780,8 +782,9 @@ export class ApiService implements ApiServiceAbstraction {
return new ApiKeyResponse(r);
}
postOrganizationUpgrade(id: string, request: OrganizationUpgradeRequest): Promise<any> {
return this.send('POST', '/organizations/' + id + '/upgrade', request, true, false);
async postOrganizationUpgrade(id: string, request: OrganizationUpgradeRequest): Promise<PaymentResponse> {
const r = await this.send('POST', '/organizations/' + id + '/upgrade', request, true, true);
return new PaymentResponse(r);
}
postOrganizationSeat(id: string, request: SeatRequest): Promise<any> {
@ -881,6 +884,11 @@ export class ApiService implements ApiServiceAbstraction {
return r as string;
}
async postSetupPayment(): Promise<string> {
const r = await this.send('POST', '/setup-payment', null, true, true);
return r as string;
}
// Helpers
async getActiveBearerToken(): Promise<string> {