dodopayments-cli 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -7
- package/build-binaries.ts +27 -4
- package/dist/index.js +22 -22
- package/package.json +3 -3
- package/dodo-webhooks/functions/generate-dispute-data.ts +0 -123
- package/dodo-webhooks/functions/generate-licence-data.ts +0 -39
- package/dodo-webhooks/functions/generate-payment-data.ts +0 -101
- package/dodo-webhooks/functions/generate-refund-data.ts +0 -44
- package/dodo-webhooks/functions/generate-subscription-data.ts +0 -153
- package/dodo-webhooks/functions/supported-events.ts +0 -24
- package/dodo-webhooks/index.ts +0 -207
- package/dodo-webhooks/types/baseArgs.ts +0 -9
- package/index.ts +0 -490
- package/utils/currency-to-symbol-map.ts +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dodopayments-cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A CLI for Dodo Payments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dodopayments",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dodopayments": "dist/index.js"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "bun build ./index.ts --minify --target node --outfile ./dist/index.js",
|
|
26
|
+
"build": "bun build ./src/index.ts --minify --target node --outfile ./dist/index.js",
|
|
27
27
|
"build-native": "bun run build-binaries.ts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"dodopayments": "^2.
|
|
30
|
+
"dodopayments": "^2.19.0",
|
|
31
31
|
"inquirer": "^13.2.2",
|
|
32
32
|
"open": "^11.0.0"
|
|
33
33
|
},
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { type baseArgs } from "../types/baseArgs";
|
|
2
|
-
|
|
3
|
-
const genBaseDisputeData = ({
|
|
4
|
-
business_id = 'bus_test'
|
|
5
|
-
}: baseArgs) => {
|
|
6
|
-
return {
|
|
7
|
-
"business_id": business_id,
|
|
8
|
-
"data": {
|
|
9
|
-
"amount": 400,
|
|
10
|
-
"business_id": business_id,
|
|
11
|
-
"created_at": new Date().toISOString(),
|
|
12
|
-
"currency": "USD",
|
|
13
|
-
"customer": {
|
|
14
|
-
"customer_id": "cus_test",
|
|
15
|
-
"email": "test@acme.com",
|
|
16
|
-
"name": "Test user",
|
|
17
|
-
"phone_number": "+447700900123"
|
|
18
|
-
},
|
|
19
|
-
"dispute_id": "dp_test",
|
|
20
|
-
"dispute_stage": "dispute",
|
|
21
|
-
"dispute_status": "dispute_opened",
|
|
22
|
-
"payload_type": "Dispute",
|
|
23
|
-
"payment_id": "pay_test",
|
|
24
|
-
"reason": "testing dispute",
|
|
25
|
-
"remarks": null
|
|
26
|
-
},
|
|
27
|
-
"timestamp": new Date().toISOString(),
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const genDisputeOpened = (args: baseArgs) => {
|
|
32
|
-
const baseData = genBaseDisputeData(args);
|
|
33
|
-
return {
|
|
34
|
-
...baseData,
|
|
35
|
-
"type": "dispute.opened",
|
|
36
|
-
data: {
|
|
37
|
-
...baseData.data,
|
|
38
|
-
dispute_status: "dispute_opened"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const genDisputeExpired = (args: baseArgs) => {
|
|
44
|
-
const baseData = genBaseDisputeData(args);
|
|
45
|
-
return {
|
|
46
|
-
...baseData,
|
|
47
|
-
"type": "dispute.expired",
|
|
48
|
-
data: {
|
|
49
|
-
...baseData.data,
|
|
50
|
-
dispute_status: "dispute_expired"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const genDisputeAccepted = (args: baseArgs) => {
|
|
56
|
-
const baseData = genBaseDisputeData(args);
|
|
57
|
-
return {
|
|
58
|
-
...baseData,
|
|
59
|
-
"type": "dispute.accepted",
|
|
60
|
-
data: {
|
|
61
|
-
...baseData.data,
|
|
62
|
-
dispute_status: "dispute_accepted"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const genDisputeCancelled = (args: baseArgs) => {
|
|
68
|
-
const baseData = genBaseDisputeData(args);
|
|
69
|
-
return {
|
|
70
|
-
...baseData,
|
|
71
|
-
"type": "dispute.cancelled",
|
|
72
|
-
data: {
|
|
73
|
-
...baseData.data,
|
|
74
|
-
dispute_status: "dispute_cancelled"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const genDisputeChallenged = (args: baseArgs) => {
|
|
80
|
-
const baseData = genBaseDisputeData(args);
|
|
81
|
-
return {
|
|
82
|
-
...baseData,
|
|
83
|
-
"type": "dispute.challenged",
|
|
84
|
-
data: {
|
|
85
|
-
...baseData.data,
|
|
86
|
-
dispute_status: "dispute_challenged"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const genDisputeWon = (args: baseArgs) => {
|
|
92
|
-
const baseData = genBaseDisputeData(args);
|
|
93
|
-
return {
|
|
94
|
-
...baseData,
|
|
95
|
-
"type": "dispute.won",
|
|
96
|
-
data: {
|
|
97
|
-
...baseData.data,
|
|
98
|
-
dispute_status: "dispute_won"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const genDisputeLost = (args: baseArgs) => {
|
|
104
|
-
const baseData = genBaseDisputeData(args);
|
|
105
|
-
return {
|
|
106
|
-
...baseData,
|
|
107
|
-
"type": "dispute.lost",
|
|
108
|
-
data: {
|
|
109
|
-
...baseData.data,
|
|
110
|
-
dispute_status: "dispute_lost"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export {
|
|
116
|
-
genDisputeOpened,
|
|
117
|
-
genDisputeExpired,
|
|
118
|
-
genDisputeAccepted,
|
|
119
|
-
genDisputeCancelled,
|
|
120
|
-
genDisputeChallenged,
|
|
121
|
-
genDisputeWon,
|
|
122
|
-
genDisputeLost
|
|
123
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type baseArgs } from "../types/baseArgs";
|
|
2
|
-
|
|
3
|
-
const genBaseLicenceData = ({
|
|
4
|
-
business_id = 'bus_test',
|
|
5
|
-
product_id = 'pdt_test',
|
|
6
|
-
subscription_id
|
|
7
|
-
}: baseArgs) => {
|
|
8
|
-
return {
|
|
9
|
-
"business_id": business_id,
|
|
10
|
-
"data": {
|
|
11
|
-
"activations_limit": null,
|
|
12
|
-
"business_id": business_id,
|
|
13
|
-
"created_at": new Date().toISOString(),
|
|
14
|
-
"customer_id": "cus_test",
|
|
15
|
-
"expires_at": null,
|
|
16
|
-
"id": "lic_test",
|
|
17
|
-
"instances_count": 0,
|
|
18
|
-
"key": "db44b22c-fe9b-4a68-bf0d-b0e0d6c6c8c0",
|
|
19
|
-
"payload_type": "LicenseKey",
|
|
20
|
-
"payment_id": "pay_test",
|
|
21
|
-
"product_id": product_id,
|
|
22
|
-
"status": "active",
|
|
23
|
-
"subscription_id": subscription_id
|
|
24
|
-
},
|
|
25
|
-
"timestamp": new Date().toISOString()
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const genLicenceCreated = (args: baseArgs) => {
|
|
31
|
-
return {
|
|
32
|
-
...genBaseLicenceData(args),
|
|
33
|
-
"type": "license_key.created"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
genLicenceCreated
|
|
39
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type baseArgs } from "../types/baseArgs";
|
|
2
|
-
|
|
3
|
-
// For payment events
|
|
4
|
-
const genBasePaymentData = ({
|
|
5
|
-
business_id = 'bus_test',
|
|
6
|
-
product_id = 'pdt_test',
|
|
7
|
-
qty = 1
|
|
8
|
-
}: baseArgs) => {
|
|
9
|
-
return {
|
|
10
|
-
"business_id": business_id,
|
|
11
|
-
"data": {
|
|
12
|
-
"billing": {
|
|
13
|
-
"city": "New York",
|
|
14
|
-
"country": "US",
|
|
15
|
-
"state": "New York",
|
|
16
|
-
"street": "New York, New York",
|
|
17
|
-
"zipcode": "12345"
|
|
18
|
-
},
|
|
19
|
-
"brand_id": business_id,
|
|
20
|
-
"business_id": business_id,
|
|
21
|
-
"card_issuing_country": "GB",
|
|
22
|
-
"card_last_four": "4242",
|
|
23
|
-
"card_network": "VISA",
|
|
24
|
-
"card_type": "CREDIT",
|
|
25
|
-
"checkout_session_id": "cks_123",
|
|
26
|
-
"created_at": new Date().toISOString(),
|
|
27
|
-
"currency": "USD",
|
|
28
|
-
"customer": {
|
|
29
|
-
"customer_id": "cus_test",
|
|
30
|
-
"email": "test@acme.com",
|
|
31
|
-
"metadata": {},
|
|
32
|
-
"name": "Test user",
|
|
33
|
-
"phone_number": "+15555550100"
|
|
34
|
-
},
|
|
35
|
-
"digital_products_delivered": false,
|
|
36
|
-
"discount_id": null,
|
|
37
|
-
"disputes": [],
|
|
38
|
-
"error_code": null,
|
|
39
|
-
"error_message": null,
|
|
40
|
-
"invoice_id": "inv_test",
|
|
41
|
-
"metadata": {},
|
|
42
|
-
"payload_type": "Payment",
|
|
43
|
-
"payment_id": "pay_test",
|
|
44
|
-
"payment_link": "https://test.checkout.dodopayments.com/cbq",
|
|
45
|
-
"payment_method": "card",
|
|
46
|
-
"payment_method_type": "card",
|
|
47
|
-
"product_cart": [
|
|
48
|
-
{
|
|
49
|
-
"product_id": product_id,
|
|
50
|
-
"quantity": qty
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"refunds": [],
|
|
54
|
-
"settlement_amount": 400,
|
|
55
|
-
"settlement_currency": "USD",
|
|
56
|
-
"settlement_tax": null,
|
|
57
|
-
"status": "succeeded",
|
|
58
|
-
"subscription_id": null,
|
|
59
|
-
"tax": null,
|
|
60
|
-
"total_amount": 400,
|
|
61
|
-
"updated_at": null
|
|
62
|
-
},
|
|
63
|
-
"timestamp": new Date().toISOString()
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const genPaymentSuccess = (args: baseArgs) => {
|
|
68
|
-
return {
|
|
69
|
-
...genBasePaymentData(args),
|
|
70
|
-
"type": "payment.succeeded"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const genPaymentFailed = (args: baseArgs) => {
|
|
75
|
-
return {
|
|
76
|
-
...genBasePaymentData(args),
|
|
77
|
-
"type": "payment.failed"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const genPaymentProcessing = (args: baseArgs) => {
|
|
82
|
-
return {
|
|
83
|
-
...genBasePaymentData(args),
|
|
84
|
-
"type": "payment.processing"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const genPaymentCancelled = (args: baseArgs) => {
|
|
89
|
-
return {
|
|
90
|
-
...genBasePaymentData(args),
|
|
91
|
-
"type": "payment.cancelled"
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
genPaymentSuccess,
|
|
98
|
-
genPaymentFailed,
|
|
99
|
-
genPaymentProcessing,
|
|
100
|
-
genPaymentCancelled
|
|
101
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type baseArgs } from "../types/baseArgs"
|
|
2
|
-
|
|
3
|
-
const genBaseRefundData = ({
|
|
4
|
-
business_id = 'bus_test'
|
|
5
|
-
}: baseArgs) => {
|
|
6
|
-
return {
|
|
7
|
-
"business_id": business_id,
|
|
8
|
-
"data": {
|
|
9
|
-
"amount": 400,
|
|
10
|
-
"business_id": business_id,
|
|
11
|
-
"created_at": new Date().toISOString(),
|
|
12
|
-
"currency": "USD",
|
|
13
|
-
"customer": {
|
|
14
|
-
"customer_id": "cus_test",
|
|
15
|
-
"email": "test@acme.com",
|
|
16
|
-
"name": "Test user",
|
|
17
|
-
"phone_number": null
|
|
18
|
-
},
|
|
19
|
-
"is_partial": false,
|
|
20
|
-
"payload_type": "Refund",
|
|
21
|
-
"payment_id": "pay_test",
|
|
22
|
-
"reason": "Testing success refund",
|
|
23
|
-
"refund_id": "ref_test",
|
|
24
|
-
"status": "succeeded"
|
|
25
|
-
},
|
|
26
|
-
"timestamp": new Date().toISOString(),
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const genRefundSuccess = (args: baseArgs) => {
|
|
31
|
-
return {
|
|
32
|
-
...genBaseRefundData(args),
|
|
33
|
-
"type": "refund.succeeded"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const genRefundFailed = (args: baseArgs) => {
|
|
38
|
-
return {
|
|
39
|
-
...genBaseRefundData(args),
|
|
40
|
-
"type": "refund.failed"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { genRefundSuccess, genRefundFailed }
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { type baseArgs } from '../types/baseArgs';
|
|
2
|
-
|
|
3
|
-
// For subscription data
|
|
4
|
-
const genBaseSubscriptionData = ({
|
|
5
|
-
business_id = 'bus_test',
|
|
6
|
-
product_id = 'pdt_test',
|
|
7
|
-
subscription_id = 'sub_test',
|
|
8
|
-
qty = 1,
|
|
9
|
-
metadata
|
|
10
|
-
}: baseArgs) => {
|
|
11
|
-
return {
|
|
12
|
-
"business_id": business_id,
|
|
13
|
-
"data": {
|
|
14
|
-
"addons": [],
|
|
15
|
-
"billing": {
|
|
16
|
-
"city": "New York",
|
|
17
|
-
"country": "US",
|
|
18
|
-
"state": "New York",
|
|
19
|
-
"street": "11th Main",
|
|
20
|
-
"zipcode": "12345"
|
|
21
|
-
},
|
|
22
|
-
"cancel_at_next_billing_date": false,
|
|
23
|
-
"cancelled_at": null,
|
|
24
|
-
"created_at": new Date().toISOString(),
|
|
25
|
-
"currency": "USD",
|
|
26
|
-
"customer": {
|
|
27
|
-
"customer_id": "cus_123456",
|
|
28
|
-
"email": "test@acme.com",
|
|
29
|
-
"name": "Test user",
|
|
30
|
-
"phone_number": null
|
|
31
|
-
},
|
|
32
|
-
"discount_cycles_remaining": null,
|
|
33
|
-
"discount_id": null,
|
|
34
|
-
"expires_at": null,
|
|
35
|
-
"metadata": metadata,
|
|
36
|
-
"meters": [],
|
|
37
|
-
"next_billing_date": new Date(new Date().setMonth(new Date().getMonth() + 1)),
|
|
38
|
-
"on_demand": false,
|
|
39
|
-
"payload_type": "Subscription",
|
|
40
|
-
"payment_frequency_count": 1,
|
|
41
|
-
"payment_frequency_interval": "Month",
|
|
42
|
-
"previous_billing_date": new Date().toISOString(),
|
|
43
|
-
"product_id": product_id,
|
|
44
|
-
"quantity": qty,
|
|
45
|
-
"recurring_pre_tax_amount": 400,
|
|
46
|
-
"status": "active",
|
|
47
|
-
"subscription_id": subscription_id,
|
|
48
|
-
"subscription_period_count": 10,
|
|
49
|
-
"subscription_period_interval": "Year",
|
|
50
|
-
"tax_inclusive": false,
|
|
51
|
-
"trial_period_days": 0
|
|
52
|
-
},
|
|
53
|
-
"timestamp": new Date().toISOString()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const genSubscriptionActive = (args: baseArgs) => {
|
|
58
|
-
return {
|
|
59
|
-
...genBaseSubscriptionData(args),
|
|
60
|
-
"type": "subscription.active"
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const genSubscriptionUpdated = (args: baseArgs) => {
|
|
65
|
-
const base = genBaseSubscriptionData(args);
|
|
66
|
-
return {
|
|
67
|
-
...base,
|
|
68
|
-
"type": "subscription.updated",
|
|
69
|
-
data: {
|
|
70
|
-
...base.data,
|
|
71
|
-
status: "active"
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const genSubscriptionOnHold = (args: baseArgs) => {
|
|
77
|
-
const base = genBaseSubscriptionData(args);
|
|
78
|
-
return {
|
|
79
|
-
...base,
|
|
80
|
-
"type": "subscription.on_hold",
|
|
81
|
-
data: {
|
|
82
|
-
...base.data,
|
|
83
|
-
status: "on_hold"
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const genSubscriptionRenewed = (args: baseArgs) => {
|
|
89
|
-
return {
|
|
90
|
-
...genBaseSubscriptionData(args),
|
|
91
|
-
"type": "subscription.renewed"
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const genSubscriptionPlanChanged = (args: baseArgs) => {
|
|
96
|
-
const base = genBaseSubscriptionData(args);
|
|
97
|
-
return {
|
|
98
|
-
...base,
|
|
99
|
-
"type": "subscription.plan_changed",
|
|
100
|
-
data: {
|
|
101
|
-
...base.data,
|
|
102
|
-
status: "active"
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const genSubscriptionCancelled = (args: baseArgs) => {
|
|
108
|
-
const base = genBaseSubscriptionData(args);
|
|
109
|
-
return {
|
|
110
|
-
...base,
|
|
111
|
-
"type": "subscription.cancelled",
|
|
112
|
-
data: {
|
|
113
|
-
...base.data,
|
|
114
|
-
cancel_at_next_billing_date: true,
|
|
115
|
-
status: 'cancelled'
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const genSubscriptionFailed = (args: baseArgs) => {
|
|
121
|
-
const base = genBaseSubscriptionData(args);
|
|
122
|
-
return {
|
|
123
|
-
...base,
|
|
124
|
-
"type": "subscription.failed",
|
|
125
|
-
data: {
|
|
126
|
-
...base.data,
|
|
127
|
-
status: "failed"
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const genSubscriptionExpired = (args: baseArgs) => {
|
|
133
|
-
const base = genBaseSubscriptionData(args);
|
|
134
|
-
return {
|
|
135
|
-
...base,
|
|
136
|
-
"type": "subscription.expired",
|
|
137
|
-
data: {
|
|
138
|
-
...base.data,
|
|
139
|
-
status: "expired"
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export {
|
|
145
|
-
genSubscriptionActive,
|
|
146
|
-
genSubscriptionUpdated,
|
|
147
|
-
genSubscriptionOnHold,
|
|
148
|
-
genSubscriptionRenewed,
|
|
149
|
-
genSubscriptionPlanChanged,
|
|
150
|
-
genSubscriptionCancelled,
|
|
151
|
-
genSubscriptionFailed,
|
|
152
|
-
genSubscriptionExpired
|
|
153
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const supportedEvents: string[] = [
|
|
2
|
-
"subscription.active",
|
|
3
|
-
"subscription.updated",
|
|
4
|
-
"subscription.on_hold",
|
|
5
|
-
"subscription.renewed",
|
|
6
|
-
"subscription.plan_changed",
|
|
7
|
-
"subscription.cancelled",
|
|
8
|
-
"subscription.failed",
|
|
9
|
-
"subscription.expired",
|
|
10
|
-
"payment.success",
|
|
11
|
-
"payment.failed",
|
|
12
|
-
"payment.processing",
|
|
13
|
-
"payment.cancelled",
|
|
14
|
-
"licence.created",
|
|
15
|
-
"refund.success",
|
|
16
|
-
"refund.failed",
|
|
17
|
-
"dispute.opened",
|
|
18
|
-
"dispute.expired",
|
|
19
|
-
"dispute.accepted",
|
|
20
|
-
"dispute.cancelled",
|
|
21
|
-
"dispute.challenged",
|
|
22
|
-
"dispute.won",
|
|
23
|
-
"dispute.lost"
|
|
24
|
-
];
|