paymongo-cli 1.4.4 → 1.4.7
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/.github/copilot-instructions.md +95 -95
- package/CHANGELOG.md +85 -1
- package/LICENSE +20 -20
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/config.js +30 -15
- package/dist/commands/dev/logs.js +3 -3
- package/dist/commands/dev/status.js +2 -2
- package/dist/commands/dev/stop.js +3 -3
- package/dist/commands/dev.js +9 -8
- package/dist/commands/env.js +6 -6
- package/dist/commands/generate/templates/checkout-page/index.js +520 -520
- package/dist/commands/generate/templates/payment-intent/javascript.js +68 -68
- package/dist/commands/generate/templates/payment-intent/typescript.js +92 -92
- package/dist/commands/generate/templates/webhook-handler/javascript.js +192 -147
- package/dist/commands/generate/templates/webhook-handler/typescript.js +147 -117
- package/dist/commands/generate.js +43 -37
- package/dist/commands/init.js +25 -8
- package/dist/commands/login.js +56 -19
- package/dist/commands/payments.js +9 -8
- package/dist/commands/team/index.js +11 -9
- package/dist/commands/trigger.js +58 -18
- package/dist/commands/webhooks.js +8 -7
- package/dist/index.js +9 -2
- package/dist/services/analytics/service.js +24 -19
- package/dist/services/api/client.js +16 -16
- package/dist/services/config/manager.js +6 -8
- package/dist/services/dev/process-manager.js +30 -32
- package/dist/services/dev/server.js +45 -39
- package/dist/services/team/service.js +4 -1
- package/dist/types/schemas.js +38 -9
- package/dist/utils/bulk.js +36 -4
- package/dist/utils/constants.js +11 -1
- package/dist/utils/errors.js +6 -0
- package/dist/utils/validator.js +10 -9
- package/dist/utils/webhook-store.js +18 -15
- package/eslint.config.ts +70 -70
- package/package.json +2 -2
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -281
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -281
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -5053
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/dist/commands/config.d.ts +0 -21
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -16
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/env.d.ts +0 -4
- package/dist/commands/env.d.ts.map +0 -1
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/init.d.ts +0 -15
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/login.d.ts +0 -20
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/payments.d.ts +0 -41
- package/dist/commands/payments.d.ts.map +0 -1
- package/dist/commands/payments.js.map +0 -1
- package/dist/commands/team/index.d.ts +0 -4
- package/dist/commands/team/index.d.ts.map +0 -1
- package/dist/commands/team/index.js.map +0 -1
- package/dist/commands/trigger.d.ts +0 -4
- package/dist/commands/trigger.d.ts.map +0 -1
- package/dist/commands/trigger.js.map +0 -1
- package/dist/commands/webhooks.d.ts +0 -23
- package/dist/commands/webhooks.d.ts.map +0 -1
- package/dist/commands/webhooks.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/services/analytics/service.d.ts +0 -35
- package/dist/services/analytics/service.d.ts.map +0 -1
- package/dist/services/analytics/service.js.map +0 -1
- package/dist/services/api/client.d.ts +0 -26
- package/dist/services/api/client.d.ts.map +0 -1
- package/dist/services/api/client.js.map +0 -1
- package/dist/services/api/rate-limiter.d.ts +0 -64
- package/dist/services/api/rate-limiter.d.ts.map +0 -1
- package/dist/services/api/rate-limiter.js.map +0 -1
- package/dist/services/api/undici-client.d.ts +0 -39
- package/dist/services/api/undici-client.d.ts.map +0 -1
- package/dist/services/api/undici-client.js +0 -288
- package/dist/services/api/undici-client.js.map +0 -1
- package/dist/services/config/manager.d.ts +0 -16
- package/dist/services/config/manager.d.ts.map +0 -1
- package/dist/services/config/manager.js.map +0 -1
- package/dist/services/dev/process-manager.d.ts +0 -50
- package/dist/services/dev/process-manager.d.ts.map +0 -1
- package/dist/services/dev/process-manager.js.map +0 -1
- package/dist/services/github/auth.d.ts +0 -15
- package/dist/services/github/auth.d.ts.map +0 -1
- package/dist/services/github/auth.js +0 -79
- package/dist/services/github/auth.js.map +0 -1
- package/dist/services/github/client.d.ts +0 -95
- package/dist/services/github/client.d.ts.map +0 -1
- package/dist/services/github/client.js +0 -130
- package/dist/services/github/client.js.map +0 -1
- package/dist/services/github/sync.d.ts +0 -26
- package/dist/services/github/sync.d.ts.map +0 -1
- package/dist/services/github/sync.js +0 -203
- package/dist/services/github/sync.js.map +0 -1
- package/dist/services/payments/simulator.d.ts +0 -28
- package/dist/services/payments/simulator.d.ts.map +0 -1
- package/dist/services/payments/simulator.js.map +0 -1
- package/dist/services/team/service.d.ts +0 -44
- package/dist/services/team/service.d.ts.map +0 -1
- package/dist/services/team/service.js.map +0 -1
- package/dist/services/web/server.d.ts +0 -31
- package/dist/services/web/server.d.ts.map +0 -1
- package/dist/services/web/server.js +0 -206
- package/dist/services/web/server.js.map +0 -1
- package/dist/types/paymongo.d.ts +0 -204
- package/dist/types/paymongo.d.ts.map +0 -1
- package/dist/types/paymongo.js.map +0 -1
- package/dist/types/schemas.d.ts +0 -80
- package/dist/types/schemas.d.ts.map +0 -1
- package/dist/types/schemas.js.map +0 -1
- package/dist/utils/bulk.d.ts +0 -62
- package/dist/utils/bulk.d.ts.map +0 -1
- package/dist/utils/bulk.js.map +0 -1
- package/dist/utils/cache.d.ts +0 -22
- package/dist/utils/cache.d.ts.map +0 -1
- package/dist/utils/cache.js.map +0 -1
- package/dist/utils/constants.d.ts +0 -32
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -34
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -20
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/spinner.d.ts +0 -17
- package/dist/utils/spinner.d.ts.map +0 -1
- package/dist/utils/spinner.js.map +0 -1
- package/dist/utils/validator.d.ts +0 -10
- package/dist/utils/validator.d.ts.map +0 -1
- package/dist/utils/validator.js.map +0 -1
- package/dist/utils/webhook-store.d.ts +0 -22
- package/dist/utils/webhook-store.d.ts.map +0 -1
- package/dist/utils/webhook-store.js.map +0 -1
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
export function getPaymentIntentTemplate(methods) {
|
|
2
|
-
return `const axios = require('axios');
|
|
3
|
-
|
|
4
|
-
// PayMongo API credentials
|
|
5
|
-
const PAYMONGO_SECRET_KEY = process.env.PAYMONGO_SECRET_KEY;
|
|
6
|
-
const PAYMONGO_PUBLIC_KEY = process.env.PAYMONGO_PUBLIC_KEY;
|
|
7
|
-
|
|
8
|
-
async function createPaymentIntent(amount, currency = 'PHP', description = '') {
|
|
9
|
-
try {
|
|
10
|
-
const response = await axios.post(
|
|
11
|
-
'https://api.paymongo.com/v1/payment_intents',
|
|
12
|
-
{
|
|
13
|
-
data: {
|
|
14
|
-
attributes: {
|
|
15
|
-
amount: amount, // Amount in centavos (e.g., 10000 = ₱100.00)
|
|
16
|
-
currency: currency,
|
|
17
|
-
description: description,
|
|
18
|
-
payment_method_allowed: ${JSON.stringify(methods)},
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
headers: {
|
|
24
|
-
'Authorization': \`Basic \${Buffer.from(PAYMONGO_SECRET_KEY + ':').toString('base64')}\`,
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const paymentIntent = response.data.data;
|
|
31
|
-
|
|
32
|
-
console.log('Payment Intent created:', paymentIntent.id);
|
|
33
|
-
console.log('Client Key:', paymentIntent.attributes.client_key);
|
|
34
|
-
console.log('Amount:', (paymentIntent.attributes.amount / 100).toFixed(2), paymentIntent.attributes.currency);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
id: paymentIntent.id,
|
|
38
|
-
clientKey: paymentIntent.attributes.client_key,
|
|
39
|
-
amount: paymentIntent.attributes.amount,
|
|
40
|
-
currency: paymentIntent.attributes.currency,
|
|
41
|
-
status: paymentIntent.attributes.status
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Error creating payment intent:', error.response?.data || error.message);
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Example usage
|
|
51
|
-
async function example() {
|
|
52
|
-
try {
|
|
53
|
-
const paymentIntent = await createPaymentIntent(
|
|
54
|
-
10000, // ₱100.00
|
|
55
|
-
'PHP',
|
|
56
|
-
'Sample payment'
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
console.log('Use this client key in your frontend:', paymentIntent.clientKey);
|
|
60
|
-
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error('Failed to create payment intent');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = { createPaymentIntent };
|
|
67
|
-
|
|
68
|
-
if (require.main === module) {
|
|
69
|
-
example();
|
|
2
|
+
return `const axios = require('axios');
|
|
3
|
+
|
|
4
|
+
// PayMongo API credentials
|
|
5
|
+
const PAYMONGO_SECRET_KEY = process.env.PAYMONGO_SECRET_KEY;
|
|
6
|
+
const PAYMONGO_PUBLIC_KEY = process.env.PAYMONGO_PUBLIC_KEY;
|
|
7
|
+
|
|
8
|
+
async function createPaymentIntent(amount, currency = 'PHP', description = '') {
|
|
9
|
+
try {
|
|
10
|
+
const response = await axios.post(
|
|
11
|
+
'https://api.paymongo.com/v1/payment_intents',
|
|
12
|
+
{
|
|
13
|
+
data: {
|
|
14
|
+
attributes: {
|
|
15
|
+
amount: amount, // Amount in centavos (e.g., 10000 = ₱100.00)
|
|
16
|
+
currency: currency,
|
|
17
|
+
description: description,
|
|
18
|
+
payment_method_allowed: ${JSON.stringify(methods)},
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
headers: {
|
|
24
|
+
'Authorization': \`Basic \${Buffer.from(PAYMONGO_SECRET_KEY + ':').toString('base64')}\`,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const paymentIntent = response.data.data;
|
|
31
|
+
|
|
32
|
+
console.log('Payment Intent created:', paymentIntent.id);
|
|
33
|
+
console.log('Client Key:', paymentIntent.attributes.client_key);
|
|
34
|
+
console.log('Amount:', (paymentIntent.attributes.amount / 100).toFixed(2), paymentIntent.attributes.currency);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id: paymentIntent.id,
|
|
38
|
+
clientKey: paymentIntent.attributes.client_key,
|
|
39
|
+
amount: paymentIntent.attributes.amount,
|
|
40
|
+
currency: paymentIntent.attributes.currency,
|
|
41
|
+
status: paymentIntent.attributes.status
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error creating payment intent:', error.response?.data || error.message);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Example usage
|
|
51
|
+
async function example() {
|
|
52
|
+
try {
|
|
53
|
+
const paymentIntent = await createPaymentIntent(
|
|
54
|
+
10000, // ₱100.00
|
|
55
|
+
'PHP',
|
|
56
|
+
'Sample payment'
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
console.log('Use this client key in your frontend:', paymentIntent.clientKey);
|
|
60
|
+
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Failed to create payment intent');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { createPaymentIntent };
|
|
67
|
+
|
|
68
|
+
if (require.main === module) {
|
|
69
|
+
example();
|
|
70
70
|
}`;
|
|
71
71
|
}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
export function getPaymentIntentTemplate(methods) {
|
|
2
|
-
return `import axios from 'axios';
|
|
3
|
-
|
|
4
|
-
interface PaymentIntent {
|
|
5
|
-
id: string;
|
|
6
|
-
clientKey: string;
|
|
7
|
-
amount: number;
|
|
8
|
-
currency: string;
|
|
9
|
-
status: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface PayMongoPaymentIntentResponse {
|
|
13
|
-
data: {
|
|
14
|
-
id: string;
|
|
15
|
-
attributes: {
|
|
16
|
-
amount: number;
|
|
17
|
-
currency: string;
|
|
18
|
-
description: string;
|
|
19
|
-
status: string;
|
|
20
|
-
client_key: string;
|
|
21
|
-
payment_method_allowed: string[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// PayMongo API credentials
|
|
27
|
-
const PAYMONGO_SECRET_KEY = process.env.PAYMONGO_SECRET_KEY!;
|
|
28
|
-
const PAYMONGO_PUBLIC_KEY = process.env.PAYMONGO_PUBLIC_KEY!;
|
|
29
|
-
|
|
30
|
-
export async function createPaymentIntent(
|
|
31
|
-
amount: number,
|
|
32
|
-
currency: string = 'PHP',
|
|
33
|
-
description: string = ''
|
|
34
|
-
): Promise<PaymentIntent> {
|
|
35
|
-
try {
|
|
36
|
-
const response = await axios.post<PayMongoPaymentIntentResponse>(
|
|
37
|
-
'https://api.paymongo.com/v1/payment_intents',
|
|
38
|
-
{
|
|
39
|
-
data: {
|
|
40
|
-
attributes: {
|
|
41
|
-
amount: amount, // Amount in centavos (e.g., 10000 = ₱100.00)
|
|
42
|
-
currency: currency,
|
|
43
|
-
description: description,
|
|
44
|
-
payment_method_allowed: ${JSON.stringify(methods)},
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
headers: {
|
|
50
|
-
'Authorization': \`Basic \${Buffer.from(PAYMONGO_SECRET_KEY + ':').toString('base64')}\`,
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const paymentIntent = response.data.data;
|
|
57
|
-
|
|
58
|
-
console.log('Payment Intent created:', paymentIntent.id);
|
|
59
|
-
console.log('Client Key:', paymentIntent.attributes.client_key);
|
|
60
|
-
console.log('Amount:', (paymentIntent.attributes.amount / 100).toFixed(2), paymentIntent.attributes.currency);
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
id: paymentIntent.id,
|
|
64
|
-
clientKey: paymentIntent.attributes.client_key,
|
|
65
|
-
amount: paymentIntent.attributes.amount,
|
|
66
|
-
currency: paymentIntent.attributes.currency,
|
|
67
|
-
status: paymentIntent.attributes.status
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
} catch (error: any) {
|
|
71
|
-
console.error('Error creating payment intent:', error.response?.data || error.message);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Example usage
|
|
77
|
-
async function example(): Promise<void> {
|
|
78
|
-
try {
|
|
79
|
-
const paymentIntent = await createPaymentIntent(
|
|
80
|
-
10000, // ₱100.00
|
|
81
|
-
'PHP',
|
|
82
|
-
'Sample payment'
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
console.log('Use this client key in your frontend:', paymentIntent.clientKey);
|
|
86
|
-
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('Failed to create payment intent');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (require.main === module) {
|
|
93
|
-
example();
|
|
2
|
+
return `import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
interface PaymentIntent {
|
|
5
|
+
id: string;
|
|
6
|
+
clientKey: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
status: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface PayMongoPaymentIntentResponse {
|
|
13
|
+
data: {
|
|
14
|
+
id: string;
|
|
15
|
+
attributes: {
|
|
16
|
+
amount: number;
|
|
17
|
+
currency: string;
|
|
18
|
+
description: string;
|
|
19
|
+
status: string;
|
|
20
|
+
client_key: string;
|
|
21
|
+
payment_method_allowed: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// PayMongo API credentials
|
|
27
|
+
const PAYMONGO_SECRET_KEY = process.env.PAYMONGO_SECRET_KEY!;
|
|
28
|
+
const PAYMONGO_PUBLIC_KEY = process.env.PAYMONGO_PUBLIC_KEY!;
|
|
29
|
+
|
|
30
|
+
export async function createPaymentIntent(
|
|
31
|
+
amount: number,
|
|
32
|
+
currency: string = 'PHP',
|
|
33
|
+
description: string = ''
|
|
34
|
+
): Promise<PaymentIntent> {
|
|
35
|
+
try {
|
|
36
|
+
const response = await axios.post<PayMongoPaymentIntentResponse>(
|
|
37
|
+
'https://api.paymongo.com/v1/payment_intents',
|
|
38
|
+
{
|
|
39
|
+
data: {
|
|
40
|
+
attributes: {
|
|
41
|
+
amount: amount, // Amount in centavos (e.g., 10000 = ₱100.00)
|
|
42
|
+
currency: currency,
|
|
43
|
+
description: description,
|
|
44
|
+
payment_method_allowed: ${JSON.stringify(methods)},
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
headers: {
|
|
50
|
+
'Authorization': \`Basic \${Buffer.from(PAYMONGO_SECRET_KEY + ':').toString('base64')}\`,
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const paymentIntent = response.data.data;
|
|
57
|
+
|
|
58
|
+
console.log('Payment Intent created:', paymentIntent.id);
|
|
59
|
+
console.log('Client Key:', paymentIntent.attributes.client_key);
|
|
60
|
+
console.log('Amount:', (paymentIntent.attributes.amount / 100).toFixed(2), paymentIntent.attributes.currency);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
id: paymentIntent.id,
|
|
64
|
+
clientKey: paymentIntent.attributes.client_key,
|
|
65
|
+
amount: paymentIntent.attributes.amount,
|
|
66
|
+
currency: paymentIntent.attributes.currency,
|
|
67
|
+
status: paymentIntent.attributes.status
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} catch (error: any) {
|
|
71
|
+
console.error('Error creating payment intent:', error.response?.data || error.message);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Example usage
|
|
77
|
+
async function example(): Promise<void> {
|
|
78
|
+
try {
|
|
79
|
+
const paymentIntent = await createPaymentIntent(
|
|
80
|
+
10000, // ₱100.00
|
|
81
|
+
'PHP',
|
|
82
|
+
'Sample payment'
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
console.log('Use this client key in your frontend:', paymentIntent.clientKey);
|
|
86
|
+
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('Failed to create payment intent');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (require.main === module) {
|
|
93
|
+
example();
|
|
94
94
|
}`;
|
|
95
95
|
}
|