diff --git a/src/resources/Payment/Payment.ts b/src/resources/Payment/Payment.ts index ebd7f97..ad189cf 100644 --- a/src/resources/Payment/Payment.ts +++ b/src/resources/Payment/Payment.ts @@ -43,7 +43,7 @@ export default class Payment { public ChangePlan(params: IChangePlanRequestParams) { return { - get: () => { + GET: () => { return this.client.get( `/payment/change_plan/${params.plan_path}`, { @@ -55,7 +55,7 @@ export default class Payment { ) }, - post: () => { + POST: () => { return this.client.post( `/payment/change_plan/${params.plan_path}`, { diff --git a/src/resources/Payment/types.ts b/src/resources/Payment/types.ts index 6905256..ac2d59d 100644 --- a/src/resources/Payment/types.ts +++ b/src/resources/Payment/types.ts @@ -56,7 +56,7 @@ export interface IVoucherInfoResponse { code: PlanCode group_code: PlanGroupCode hd_avail: PlanDiskSize - simulated_expiration: PlanExpirationDate + simulated_expiration?: PlanExpirationDate } new_remaining_days: number } @@ -112,6 +112,17 @@ export type PaymentProviderName = PaymentProvider['provider'] export type PaymentType = PaymentProvider['type'] +export type PaymentOption = { + name: PaymentType + suitable_plan_types: (PlanType | 'trial')[] + default?: boolean + discount_percent: number +} + +export interface IPaymentOptionsResponse { + options: PaymentOption[] +} + export interface IChangePlanRequestParams { plan_path: string payment_type: PaymentType @@ -119,19 +130,66 @@ export interface IChangePlanRequestParams { confirmation_code?: string } -export interface IChangePlanGetResponse {} +export interface IChangePlanGetResponse { + current_plan: { + plan_type?: PlanType + subscription_payment_provider?: PaymentProviderName + } + target_plan: { + price: number + plan_type: PlanType + period_days: number + plan_code: PlanCode + plan_name: PlanName + hd_avail: PlanDiskSize + simulated_expiration?: PlanExpirationDate + new_code: PlanCode + is_trial_subscription: boolean + subscription_trial_period?: number + } + Paddle: { + charge_amount: number + currency: string + next_billing_date: string + } + Fastspring: { + prorated_amount: number + refund_amount: number + charge_amount: number + currency: string + } + new_remaining_days: number + prorated: number + credit: number + charge_amount: boolean + currency: string + is_product_change: boolean + discount?: { + discount: number + type: 'percentage' | 'amount' + } +} -export interface IChangePlanPostResponse { +type ChangePlanURLsResponse = { urls: PaymentProvider[] } -export type PaymentOption = { - name: PaymentType - suitable_plan_types: (PlanType | 'trial')[] - default?: boolean - discount_percent: number +type ChangePlanConfirmationResponse = { + confirmation: true } -export interface IPaymentOptionsResponse { - options: PaymentOption[] +type ChangePlanSubscriptionUpgradeDowngradeResponse = { + charged_amount: string + next_payment: { + amount: string + billing_date: string + } } + +type ChangePlanEmptyResponse = {} + +export type IChangePlanPostResponse = + | ChangePlanURLsResponse + | ChangePlanConfirmationResponse + | ChangePlanSubscriptionUpgradeDowngradeResponse + | ChangePlanEmptyResponse