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.
Files changed (155) hide show
  1. package/.github/copilot-instructions.md +95 -95
  2. package/CHANGELOG.md +85 -1
  3. package/LICENSE +20 -20
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/commands/config.js +30 -15
  6. package/dist/commands/dev/logs.js +3 -3
  7. package/dist/commands/dev/status.js +2 -2
  8. package/dist/commands/dev/stop.js +3 -3
  9. package/dist/commands/dev.js +9 -8
  10. package/dist/commands/env.js +6 -6
  11. package/dist/commands/generate/templates/checkout-page/index.js +520 -520
  12. package/dist/commands/generate/templates/payment-intent/javascript.js +68 -68
  13. package/dist/commands/generate/templates/payment-intent/typescript.js +92 -92
  14. package/dist/commands/generate/templates/webhook-handler/javascript.js +192 -147
  15. package/dist/commands/generate/templates/webhook-handler/typescript.js +147 -117
  16. package/dist/commands/generate.js +43 -37
  17. package/dist/commands/init.js +25 -8
  18. package/dist/commands/login.js +56 -19
  19. package/dist/commands/payments.js +9 -8
  20. package/dist/commands/team/index.js +11 -9
  21. package/dist/commands/trigger.js +58 -18
  22. package/dist/commands/webhooks.js +8 -7
  23. package/dist/index.js +9 -2
  24. package/dist/services/analytics/service.js +24 -19
  25. package/dist/services/api/client.js +16 -16
  26. package/dist/services/config/manager.js +6 -8
  27. package/dist/services/dev/process-manager.js +30 -32
  28. package/dist/services/dev/server.js +45 -39
  29. package/dist/services/team/service.js +4 -1
  30. package/dist/types/schemas.js +38 -9
  31. package/dist/utils/bulk.js +36 -4
  32. package/dist/utils/constants.js +11 -1
  33. package/dist/utils/errors.js +6 -0
  34. package/dist/utils/validator.js +10 -9
  35. package/dist/utils/webhook-store.js +18 -15
  36. package/eslint.config.ts +70 -70
  37. package/package.json +2 -2
  38. package/coverage/base.css +0 -224
  39. package/coverage/block-navigation.js +0 -87
  40. package/coverage/favicon.png +0 -0
  41. package/coverage/index.html +0 -281
  42. package/coverage/lcov-report/base.css +0 -224
  43. package/coverage/lcov-report/block-navigation.js +0 -87
  44. package/coverage/lcov-report/favicon.png +0 -0
  45. package/coverage/lcov-report/index.html +0 -281
  46. package/coverage/lcov-report/prettify.css +0 -1
  47. package/coverage/lcov-report/prettify.js +0 -2
  48. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  49. package/coverage/lcov-report/sorter.js +0 -210
  50. package/coverage/lcov.info +0 -5053
  51. package/coverage/prettify.css +0 -1
  52. package/coverage/prettify.js +0 -2
  53. package/coverage/sort-arrow-sprite.png +0 -0
  54. package/coverage/sorter.js +0 -210
  55. package/dist/commands/config.d.ts +0 -21
  56. package/dist/commands/config.d.ts.map +0 -1
  57. package/dist/commands/config.js.map +0 -1
  58. package/dist/commands/dev.d.ts +0 -16
  59. package/dist/commands/dev.d.ts.map +0 -1
  60. package/dist/commands/dev.js.map +0 -1
  61. package/dist/commands/env.d.ts +0 -4
  62. package/dist/commands/env.d.ts.map +0 -1
  63. package/dist/commands/env.js.map +0 -1
  64. package/dist/commands/init.d.ts +0 -15
  65. package/dist/commands/init.d.ts.map +0 -1
  66. package/dist/commands/init.js.map +0 -1
  67. package/dist/commands/login.d.ts +0 -20
  68. package/dist/commands/login.d.ts.map +0 -1
  69. package/dist/commands/login.js.map +0 -1
  70. package/dist/commands/payments.d.ts +0 -41
  71. package/dist/commands/payments.d.ts.map +0 -1
  72. package/dist/commands/payments.js.map +0 -1
  73. package/dist/commands/team/index.d.ts +0 -4
  74. package/dist/commands/team/index.d.ts.map +0 -1
  75. package/dist/commands/team/index.js.map +0 -1
  76. package/dist/commands/trigger.d.ts +0 -4
  77. package/dist/commands/trigger.d.ts.map +0 -1
  78. package/dist/commands/trigger.js.map +0 -1
  79. package/dist/commands/webhooks.d.ts +0 -23
  80. package/dist/commands/webhooks.d.ts.map +0 -1
  81. package/dist/commands/webhooks.js.map +0 -1
  82. package/dist/index.d.ts +0 -3
  83. package/dist/index.d.ts.map +0 -1
  84. package/dist/index.js.map +0 -1
  85. package/dist/services/analytics/service.d.ts +0 -35
  86. package/dist/services/analytics/service.d.ts.map +0 -1
  87. package/dist/services/analytics/service.js.map +0 -1
  88. package/dist/services/api/client.d.ts +0 -26
  89. package/dist/services/api/client.d.ts.map +0 -1
  90. package/dist/services/api/client.js.map +0 -1
  91. package/dist/services/api/rate-limiter.d.ts +0 -64
  92. package/dist/services/api/rate-limiter.d.ts.map +0 -1
  93. package/dist/services/api/rate-limiter.js.map +0 -1
  94. package/dist/services/api/undici-client.d.ts +0 -39
  95. package/dist/services/api/undici-client.d.ts.map +0 -1
  96. package/dist/services/api/undici-client.js +0 -288
  97. package/dist/services/api/undici-client.js.map +0 -1
  98. package/dist/services/config/manager.d.ts +0 -16
  99. package/dist/services/config/manager.d.ts.map +0 -1
  100. package/dist/services/config/manager.js.map +0 -1
  101. package/dist/services/dev/process-manager.d.ts +0 -50
  102. package/dist/services/dev/process-manager.d.ts.map +0 -1
  103. package/dist/services/dev/process-manager.js.map +0 -1
  104. package/dist/services/github/auth.d.ts +0 -15
  105. package/dist/services/github/auth.d.ts.map +0 -1
  106. package/dist/services/github/auth.js +0 -79
  107. package/dist/services/github/auth.js.map +0 -1
  108. package/dist/services/github/client.d.ts +0 -95
  109. package/dist/services/github/client.d.ts.map +0 -1
  110. package/dist/services/github/client.js +0 -130
  111. package/dist/services/github/client.js.map +0 -1
  112. package/dist/services/github/sync.d.ts +0 -26
  113. package/dist/services/github/sync.d.ts.map +0 -1
  114. package/dist/services/github/sync.js +0 -203
  115. package/dist/services/github/sync.js.map +0 -1
  116. package/dist/services/payments/simulator.d.ts +0 -28
  117. package/dist/services/payments/simulator.d.ts.map +0 -1
  118. package/dist/services/payments/simulator.js.map +0 -1
  119. package/dist/services/team/service.d.ts +0 -44
  120. package/dist/services/team/service.d.ts.map +0 -1
  121. package/dist/services/team/service.js.map +0 -1
  122. package/dist/services/web/server.d.ts +0 -31
  123. package/dist/services/web/server.d.ts.map +0 -1
  124. package/dist/services/web/server.js +0 -206
  125. package/dist/services/web/server.js.map +0 -1
  126. package/dist/types/paymongo.d.ts +0 -204
  127. package/dist/types/paymongo.d.ts.map +0 -1
  128. package/dist/types/paymongo.js.map +0 -1
  129. package/dist/types/schemas.d.ts +0 -80
  130. package/dist/types/schemas.d.ts.map +0 -1
  131. package/dist/types/schemas.js.map +0 -1
  132. package/dist/utils/bulk.d.ts +0 -62
  133. package/dist/utils/bulk.d.ts.map +0 -1
  134. package/dist/utils/bulk.js.map +0 -1
  135. package/dist/utils/cache.d.ts +0 -22
  136. package/dist/utils/cache.d.ts.map +0 -1
  137. package/dist/utils/cache.js.map +0 -1
  138. package/dist/utils/constants.d.ts +0 -32
  139. package/dist/utils/constants.d.ts.map +0 -1
  140. package/dist/utils/constants.js.map +0 -1
  141. package/dist/utils/errors.d.ts +0 -34
  142. package/dist/utils/errors.d.ts.map +0 -1
  143. package/dist/utils/errors.js.map +0 -1
  144. package/dist/utils/logger.d.ts +0 -20
  145. package/dist/utils/logger.d.ts.map +0 -1
  146. package/dist/utils/logger.js.map +0 -1
  147. package/dist/utils/spinner.d.ts +0 -17
  148. package/dist/utils/spinner.d.ts.map +0 -1
  149. package/dist/utils/spinner.js.map +0 -1
  150. package/dist/utils/validator.d.ts +0 -10
  151. package/dist/utils/validator.d.ts.map +0 -1
  152. package/dist/utils/validator.js.map +0 -1
  153. package/dist/utils/webhook-store.d.ts +0 -22
  154. package/dist/utils/webhook-store.d.ts.map +0 -1
  155. 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
  }