Skip to content

Commit

Permalink
refactor: update payment types
Browse files Browse the repository at this point in the history
  • Loading branch information
altaywtf committed Jan 18, 2024
1 parent 1a61d11 commit 1b4b31c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
52 changes: 25 additions & 27 deletions src/resources/Payment/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,33 @@ export default class Payment {
return this.client.get('/payment/invites')
}

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 = {
GET: (params: IChangePlanRequestParams) => {
return this.client.get<IChangePlanGetResponse>(
`/payment/change_plan/${params.plan_path}`,
{
params: {
payment_type: params.payment_type,
coupon_code: params.coupon_code,
},
)
},

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,
},
},
)
},

POST: (params: IChangePlanRequestParams) => {
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
15 changes: 8 additions & 7 deletions src/resources/Payment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ export interface IChangePlanRequestParams {
}

export interface IChangePlanGetResponse {
amount: string
current_plan: {
plan_type?: PlanType
subscription_payment_provider?: PaymentProviderName
}
target_plan: {
price: number
price: string
plan_type: PlanType
period_days: number
plan_code: PlanCode
Expand All @@ -148,19 +149,19 @@ export interface IChangePlanGetResponse {
subscription_trial_period?: number
}
Paddle: {
charge_amount: number
charge_amount: string
currency: string
next_billing_date: string
}
Fastspring: {
prorated_amount: number
refund_amount: number
charge_amount: number
prorated_amount: string
refund_amount: string
charge_amount: string
currency: string
}
new_remaining_days: number
prorated: number
credit: number
prorated: string
credit: string
charge_amount: boolean
currency: string
is_product_change: boolean
Expand Down

0 comments on commit 1b4b31c

Please sign in to comment.