@profullstack/coinpay 0.6.4 → 0.6.6

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 (2) hide show
  1. package/bin/coinpay.js +218 -0
  2. package/package.json +1 -1
package/bin/coinpay.js CHANGED
@@ -208,6 +208,15 @@ ${colors.cyan}Commands:${colors.reset}
208
208
  status <swap-id> Check swap status
209
209
  history Swap history
210
210
 
211
+ ${colors.bright}card${colors.reset}
212
+ create Create a card payment via Stripe
213
+ get <id> Get card payment status
214
+ list List card payments
215
+ connect onboard <id> Create Stripe onboarding link
216
+ connect status <id> Check Stripe account status
217
+ escrow release <id> Release card escrow funds
218
+ escrow refund <id> Refund card escrow
219
+
211
220
  ${colors.bright}escrow${colors.reset}
212
221
  create Create a new escrow
213
222
  get <id> Get escrow status
@@ -1994,6 +2003,211 @@ async function handleReputation(subcommand, args, flags) {
1994
2003
  }
1995
2004
  }
1996
2005
 
2006
+ /**
2007
+ * Card (Stripe) commands
2008
+ */
2009
+ async function handleCard(subcommand, args, flags) {
2010
+ const client = createClient();
2011
+
2012
+ switch (subcommand) {
2013
+ case 'create': {
2014
+ const { 'business-id': businessId, amount, currency = 'usd', description } = flags;
2015
+ const escrowMode = flags['escrow'] === true || flags['escrow-mode'] === true;
2016
+
2017
+ if (!businessId || !amount) {
2018
+ print.error('Required: --business-id, --amount (in cents)');
2019
+ print.info('Example: coinpay card create --business-id biz_123 --amount 5000 --description "Order #123"');
2020
+ return;
2021
+ }
2022
+
2023
+ const payment = await client.createCardPayment({
2024
+ businessId,
2025
+ amount: parseInt(amount, 10),
2026
+ currency,
2027
+ description,
2028
+ metadata: flags.metadata ? JSON.parse(flags.metadata) : undefined,
2029
+ successUrl: flags['success-url'],
2030
+ cancelUrl: flags['cancel-url'],
2031
+ escrowMode,
2032
+ });
2033
+
2034
+ print.success('Card payment created');
2035
+ if (payment.checkout_url) {
2036
+ print.info(`Checkout URL: ${payment.checkout_url}`);
2037
+ }
2038
+ if (payment.checkout_session_id) {
2039
+ print.info(`Session ID: ${payment.checkout_session_id}`);
2040
+ }
2041
+ if (flags.json) print.json(payment);
2042
+ break;
2043
+ }
2044
+
2045
+ case 'get': {
2046
+ const id = args[0];
2047
+ if (!id) {
2048
+ print.error('Payment ID required');
2049
+ print.info('Usage: coinpay card get <id>');
2050
+ return;
2051
+ }
2052
+
2053
+ // Card payments use Stripe account status endpoint for now
2054
+ // or we can query the stripe_transactions table via the API
2055
+ const result = await client.request(`/stripe/payments/${id}`);
2056
+ print.json(result);
2057
+ break;
2058
+ }
2059
+
2060
+ case 'list': {
2061
+ const { 'business-id': businessId, status, limit } = flags;
2062
+
2063
+ if (!businessId) {
2064
+ print.error('Required: --business-id');
2065
+ return;
2066
+ }
2067
+
2068
+ const params = new URLSearchParams({ businessId });
2069
+ if (status) params.append('status', status);
2070
+ if (limit) params.append('limit', limit);
2071
+
2072
+ const result = await client.request(`/stripe/payments?${params.toString()}`);
2073
+ print.json(result);
2074
+ break;
2075
+ }
2076
+
2077
+ case 'connect': {
2078
+ const connectSubcommand = args[0];
2079
+ const merchantId = args[1];
2080
+
2081
+ if (!connectSubcommand) {
2082
+ print.error('Usage: coinpay card connect <onboard|status> <merchantId>');
2083
+ return;
2084
+ }
2085
+
2086
+ switch (connectSubcommand) {
2087
+ case 'onboard': {
2088
+ if (!merchantId) {
2089
+ print.error('Merchant ID required');
2090
+ print.info('Usage: coinpay card connect onboard <merchantId>');
2091
+ return;
2092
+ }
2093
+
2094
+ const result = await client.createStripeOnboardingLink(merchantId, {
2095
+ email: flags.email,
2096
+ country: flags.country,
2097
+ });
2098
+
2099
+ print.success('Onboarding link created');
2100
+ if (result.onboarding_url) {
2101
+ print.info(`Onboarding URL: ${result.onboarding_url}`);
2102
+ }
2103
+ if (result.stripe_account_id) {
2104
+ print.info(`Stripe Account: ${result.stripe_account_id}`);
2105
+ }
2106
+ if (flags.json) print.json(result);
2107
+ break;
2108
+ }
2109
+
2110
+ case 'status': {
2111
+ if (!merchantId) {
2112
+ print.error('Merchant ID required');
2113
+ print.info('Usage: coinpay card connect status <merchantId>');
2114
+ return;
2115
+ }
2116
+
2117
+ const result = await client.getStripeAccountStatus(merchantId);
2118
+
2119
+ print.info(`Stripe Account Status for ${merchantId}:`);
2120
+ if (result.onboarding_complete) {
2121
+ print.success('Onboarding complete — can accept card payments');
2122
+ } else {
2123
+ print.warn('Onboarding incomplete');
2124
+ }
2125
+ print.info(` Charges enabled: ${result.charges_enabled}`);
2126
+ print.info(` Payouts enabled: ${result.payouts_enabled}`);
2127
+ print.info(` Details submitted: ${result.details_submitted}`);
2128
+ if (result.requirements_due?.length > 0) {
2129
+ print.info(` Requirements due: ${result.requirements_due.join(', ')}`);
2130
+ }
2131
+ if (flags.json) print.json(result);
2132
+ break;
2133
+ }
2134
+
2135
+ default:
2136
+ print.error(`Unknown connect command: ${connectSubcommand}`);
2137
+ print.info('Available: onboard, status');
2138
+ process.exit(1);
2139
+ }
2140
+ break;
2141
+ }
2142
+
2143
+ case 'escrow': {
2144
+ const escrowSubcommand = args[0];
2145
+ const escrowId = args[1];
2146
+
2147
+ if (!escrowSubcommand) {
2148
+ print.error('Usage: coinpay card escrow <release|refund> <id>');
2149
+ return;
2150
+ }
2151
+
2152
+ switch (escrowSubcommand) {
2153
+ case 'release': {
2154
+ if (!escrowId) {
2155
+ print.error('Escrow ID required');
2156
+ print.info('Usage: coinpay card escrow release <id> [--reason "..."]');
2157
+ return;
2158
+ }
2159
+
2160
+ const result = await client.releaseCardEscrow(escrowId, flags.reason);
2161
+
2162
+ print.success(`Card escrow ${escrowId} released`);
2163
+ if (result.transfer_id) {
2164
+ print.info(`Transfer ID: ${result.transfer_id}`);
2165
+ }
2166
+ if (result.amount_transferred) {
2167
+ print.info(`Amount: $${(result.amount_transferred / 100).toFixed(2)}`);
2168
+ }
2169
+ if (flags.json) print.json(result);
2170
+ break;
2171
+ }
2172
+
2173
+ case 'refund': {
2174
+ if (!escrowId) {
2175
+ print.error('Escrow ID required');
2176
+ print.info('Usage: coinpay card escrow refund <id> [--reason "..."] [--amount <cents>]');
2177
+ return;
2178
+ }
2179
+
2180
+ const result = await client.refundCardPayment(escrowId, {
2181
+ amount: flags.amount ? parseInt(flags.amount, 10) : undefined,
2182
+ reason: flags.reason,
2183
+ });
2184
+
2185
+ print.success(`Card escrow ${escrowId} refunded`);
2186
+ if (result.refund_id) {
2187
+ print.info(`Refund ID: ${result.refund_id}`);
2188
+ }
2189
+ if (result.amount_refunded) {
2190
+ print.info(`Amount refunded: $${(result.amount_refunded / 100).toFixed(2)}`);
2191
+ }
2192
+ if (flags.json) print.json(result);
2193
+ break;
2194
+ }
2195
+
2196
+ default:
2197
+ print.error(`Unknown card escrow command: ${escrowSubcommand}`);
2198
+ print.info('Available: release, refund');
2199
+ process.exit(1);
2200
+ }
2201
+ break;
2202
+ }
2203
+
2204
+ default:
2205
+ print.error(`Unknown card command: ${subcommand}`);
2206
+ print.info('Available: create, get, list, connect, escrow');
2207
+ process.exit(1);
2208
+ }
2209
+ }
2210
+
1997
2211
  /**
1998
2212
  * Main entry point
1999
2213
  */
@@ -2044,6 +2258,10 @@ async function main() {
2044
2258
  await handleWebhook(subcommand, args, flags);
2045
2259
  break;
2046
2260
 
2261
+ case 'card':
2262
+ await handleCard(subcommand, args, flags);
2263
+ break;
2264
+
2047
2265
  case 'reputation':
2048
2266
  await handleReputation(subcommand, args, flags);
2049
2267
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/coinpay",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "CoinPay SDK & CLI — Accept cryptocurrency payments (BTC, ETH, SOL, POL, BCH, USDC) with wallet and swap support",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",