Skip to content

Commit

Permalink
chore: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
altaywtf committed Jan 8, 2024
1 parent 35c77b3 commit 7d53781
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: .node-version
registry-url: https://registry.npmjs.org/
- run: yarn install
- run: yarn lint
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
name: Lint, test, and build the package

on: [push]
on: push

jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
name: Build, lint, and test

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['18.16.0']
os: [ubuntu-latest]
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version-file: .node-version

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.10.0
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

52 changes: 22 additions & 30 deletions src/resources/Payment/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
IUserPaymentInfoResponse,
IVoucherInfoResponse,
INanoPaymentRequestResponse,
IOpenNodeChargeResponse,
IPaymentOptionsResponse,
IChangePlanResponse,
} from './types'

export default class Payment {
Expand Down Expand Up @@ -54,7 +56,7 @@ export default class Payment {
})
}

public GetPlanChangeUrls({
public ChangePlan({
planPath,
paymentType,
couponCode,
Expand All @@ -65,19 +67,18 @@ export default class Payment {
couponCode?: string
confirmationCode?: string
}) {
return this.client.post(`/payment/change_plan/${planPath}`, {
data: {
payment_type: paymentType,
confirmation_code: confirmationCode,
},
params: {
coupon_code: couponCode,
return this.client.post<IChangePlanResponse>(
`/payment/change_plan/${planPath}`,
{
data: {
payment_type: paymentType,
confirmation_code: confirmationCode,
},
params: {
coupon_code: couponCode,
},
},
})
}

public ChangePlan(args: any) {
return this.GetPlanChangeUrls(args)
)
}

public CreateNanoPaymentRequest({ planCode }: { planCode: string }) {
Expand All @@ -91,20 +92,15 @@ export default class Payment {
)
}

public CreateCoinbaseCharge(path: string) {
return this.client.post('/payment/methods/coinbase/charge', {
data: {
plan_fs_path: path,
},
})
}

public CreateCoinbaseCheckout(path: string) {
return this.client.post('/payment/methods/coinbase/checkout', {
data: {
plan_fs_path: path,
public CreateOpenNodeCharge({ planPath }: { planPath: string }) {
return this.client.post<IOpenNodeChargeResponse>(
'/payment/methods/opennode/charge',
{
data: {
plan_fs_path: planPath,
},
},
})
)
}

public CancelSubscription() {
Expand All @@ -121,10 +117,6 @@ export default class Payment {
return this.client.post(`/payment/redeem_voucher/${code}`)
}

public VerifyFastspringPayment(reference: string) {
return this.client.get(`/payment/fs-confirm/${reference}`)
}

public Report(paymentIds = []) {
return this.client.post('/payment/report', {
data: {
Expand Down
50 changes: 48 additions & 2 deletions src/resources/Payment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,61 @@ export interface INanoPaymentRequestResponse {
}
}

export interface IOpenNodeChargeResponse {
opennode: {
checkout_url: string
}
}

export type PaymentOption = {
name: string
disabled: boolean
suitable_plan_types: (PlanType | 'trial')[]
default?: boolean
discount_percent: Number
banned_countries: string[]
discount_percent: number
}

export interface IPaymentOptionsResponse {
options: PaymentOption[]
}

type PaymentProvider_Paddle = {
plan_id: number
provider: 'Paddle'
type: 'credit-card'
vendor_id: number
}

type PaymentProvider_Fastspring = {
provider: 'Fastspring'
type: 'credit-card'
url: string
}

type PaymentProvider_OpenNode = {
provider: 'OpenNode'
type: 'cryptocurrency'
}

type PaymentProvider_AcceptNano = {
amount: string
api_host: string
currency: 'USD'
provider: 'AcceptNano'
state: string
type: 'nano'
}

export type PaymentProviderOption =
| PaymentProvider_AcceptNano
| PaymentProvider_Fastspring
| PaymentProvider_OpenNode
| PaymentProvider_Paddle

export type PaymentProvider = PaymentProviderOption['provider']

export type PaymentType = PaymentProviderOption['type']

export interface IChangePlanResponse {
urls: PaymentProviderOption[]
}

0 comments on commit 7d53781

Please sign in to comment.