Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
altaywtf committed Jan 16, 2024
1 parent 8a4f47c commit c55833e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
67 changes: 29 additions & 38 deletions src/resources/Payment/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
INanoPaymentRequestResponse,
IOpenNodeChargeResponse,
IPaymentOptionsResponse,
IChangePlanResponse,
IChangePlanGetResponse,
IChangePlanPostResponse,
IChangePlanRequestParams,
} from './types'

export default class Payment {
Expand Down Expand Up @@ -39,46 +41,35 @@ export default class Payment {
return this.client.get('/payment/invites')
}

public GetPlanChangeInfo({
planPath,
paymentType,
couponCode,
}: {
planPath: string
paymentType: string
couponCode?: string
}) {
return this.client.get(`/payment/change_plan/${planPath}`, {
params: {
coupon_code: couponCode,
payment_type: paymentType,
public ChangePlan(params: IChangePlanRequestParams) {
return {
get: () => {
return this.client.get<IChangePlanGetResponse>(
`/payment/change_plan/${params.plan_path}`,
{
params: {
payment_type: params.payment_type,
coupon_code: params.coupon_code,
},
},
)
},
})
}

public ChangePlan({
planPath,
paymentType,
couponCode,
confirmationCode,
}: {
planPath: string
paymentType: string
couponCode?: string
confirmationCode?: string
}) {
return this.client.post<IChangePlanResponse>(
`/payment/change_plan/${planPath}`,
{
data: {
payment_type: paymentType,
confirmation_code: confirmationCode,
},
params: {
coupon_code: couponCode,
},
post: () => {
return this.client.post<IChangePlanPostResponse>(
`/payment/change_plan/${params.plan_path}`,
{
data: {
payment_type: params.payment_type,
confirmation_code: params.confirmation_code,
},
params: {
coupon_code: params.coupon_code,
},
},
)
},
)
}
}

public CreateNanoPaymentRequest({ planCode }: { planCode: string }) {
Expand Down
12 changes: 10 additions & 2 deletions src/resources/Payment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,21 @@ export type PaymentProviderName = PaymentProvider['provider']

export type PaymentType = PaymentProvider['type']

export interface IChangePlanResponse {
export interface IChangePlanRequestParams {
plan_path: string
payment_type: PaymentType
coupon_code?: string
confirmation_code?: string
}

export interface IChangePlanGetResponse {}

export interface IChangePlanPostResponse {
urls: PaymentProvider[]
}

export type PaymentOption = {
name: PaymentType
disabled: boolean
suitable_plan_types: (PlanType | 'trial')[]
default?: boolean
discount_percent: number
Expand Down

0 comments on commit c55833e

Please sign in to comment.