gembapay 1.1.0 → 1.2.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # GembaPay
2
2
 
3
- **Unified payment gateway for crypto, cards, and PayPal.**
3
+ **Unified payment gateway for cards and PayPal.**
4
4
 
5
- Accept ETH, BNB, POL, USDC, USDT, credit cards (via Stripe), and PayPal through a single API. Non-custodial crypto payments — funds go directly to your wallet via smart contract.
5
+ Accept credit cards (via Stripe) and PayPal through a single API. Funds settle directly into the merchant's own connected account — GembaPay never holds your money.
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/gembapay)](https://www.npmjs.com/package/gembapay)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -11,11 +11,10 @@ Accept ETH, BNB, POL, USDC, USDT, credit cards (via Stripe), and PayPal through
11
11
 
12
12
  ## Features
13
13
 
14
- - **One API, three payment methods** — Crypto, Stripe (cards/Apple Pay/Google Pay), PayPal
15
- - **Non-custodial crypto** — Payments route directly to your wallet via smart contracts
16
- - **86+ currencies** — Price in any fiat currency, settle in crypto or fiat
17
- - **Multi-chain** — Ethereum, BNB Smart Chain, Polygon
18
- - **Test mode built-in** — Testnets + sandbox environments for development
14
+ - **One API, two payment methods** — Stripe (cards/Apple Pay/Google Pay) and PayPal
15
+ - **Direct settlement** — Payments route straight into your own Stripe or PayPal account
16
+ - **86+ currencies** — Price in any supported currency
17
+ - **Test mode built-in** — Stripe and PayPal sandbox environments for development
19
18
  - **TypeScript support** — Full type definitions included
20
19
  - **Zero dependencies** — Uses only Node.js built-in modules
21
20
 
@@ -46,7 +45,7 @@ console.log(payment.paymentUrl);
46
45
  // → https://payment.gembapay.com/checkout/3f9c1e7a-2b4d-4c8e-9f10-a2b3c4d5e6f7
47
46
 
48
47
  console.log(payment.allowedMethods);
49
- // → ['crypto', 'stripe', 'paypal']
48
+ // → ['stripe', 'paypal']
50
49
  ```
51
50
 
52
51
  ## Usage
@@ -77,6 +76,13 @@ console.log(status.network); // 'bsc', 'stripe', 'paypal', etc.
77
76
 
78
77
  ### Webhook Verification
79
78
 
79
+ > **⚠️ SDK update required.** The live GembaPay backend signs webhooks as **bare hex** (no
80
+ > `sha256=` prefix) over the **raw request body**. The current `verifyWebhook`/`webhookHandler`
81
+ > in this SDK build expect a `sha256=` prefix and hash the parsed body, so they reject genuine
82
+ > webhooks until the SDK is updated. Until then, verify manually against the raw body per
83
+ > [docs/webhooks.md](../../docs/webhooks.md#signature-verification). Subscription cycles arrive as
84
+ > `subscription.payment` (flat payload, no `orderId`), not `payment.completed`.
85
+
80
86
  ```javascript
81
87
  const express = require('express');
82
88
  const app = express();
@@ -112,17 +118,20 @@ app.post('/webhooks/gembapay', express.json(), (req, res) => {
112
118
  ### Transactions & Stats
113
119
 
114
120
  ```javascript
115
- const transactions = await gembapay.listTransactions();
116
121
  const stats = await gembapay.getStats();
122
+ // const transactions = await gembapay.listTransactions(); // see note below
117
123
  ```
118
124
 
125
+ > **Note:** `listTransactions()` currently targets a **dashboard (JWT) endpoint** and returns
126
+ > `401` with an API key. Use `getStats()` / `getPaymentStatus()` programmatically, or view
127
+ > transactions in the dashboard, until the SDK/endpoint is aligned.
128
+
119
129
  ## Test Mode
120
130
 
121
131
  Use test API keys (`gembapay_test_...`) for development. Test mode automatically uses:
122
132
 
123
133
  | Method | Test Environment |
124
134
  |--------|-----------------|
125
- | Crypto | Sepolia, BSC Testnet, Polygon Amoy |
126
135
  | Stripe | Test cards (`4242 4242 4242 4242`) |
127
136
  | PayPal | Sandbox accounts |
128
137
 
@@ -201,7 +210,6 @@ app.listen(3000);
201
210
 
202
211
  | Method | Fee |
203
212
  |--------|-----|
204
- | Crypto (ETH, BNB, POL, USDC, USDT) | 1% |
205
213
  | Stripe (Cards, Apple Pay, Google Pay) | 1% + €0.20 + Stripe fees |
206
214
  | PayPal (Balance, Bank, Pay Later) | 1% + €0.20 + PayPal fees |
207
215
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gembapay",
3
- "version": "1.1.0",
4
- "description": "GembaPay — Unified payment gateway for crypto (ETH, BNB, POL, USDC, USDT), Stripe, and PayPal. Non-custodial payments.",
3
+ "version": "1.2.0",
4
+ "description": "GembaPay \u2014 unified payment gateway for Stripe card payments and PayPal. Funds settle directly to the merchant.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
7
7
  "files": [
@@ -16,39 +16,26 @@
16
16
  "keywords": [
17
17
  "payments",
18
18
  "payment-gateway",
19
- "crypto",
20
- "crypto-payments",
21
- "cryptocurrency",
22
- "bitcoin",
23
- "ethereum",
24
- "eth",
25
- "bnb",
26
- "polygon",
27
- "matic",
28
- "usdc",
29
- "usdt",
30
- "stablecoin",
31
19
  "stripe",
32
20
  "paypal",
21
+ "card-payments",
22
+ "credit-card",
33
23
  "fiat-payments",
34
- "non-custodial",
35
- "web3",
36
- "blockchain",
37
- "smart-contract",
38
- "defi",
39
24
  "payment-processing",
40
25
  "checkout",
26
+ "unified-checkout",
41
27
  "ecommerce",
42
28
  "gateway",
43
- "protocol",
44
- "crypto-protocol",
45
29
  "merchant",
46
- "accept-crypto",
47
30
  "accept-payments",
48
- "unified-checkout",
49
- "multi-chain",
31
+ "payment-links",
32
+ "qr-payments",
33
+ "subscriptions",
34
+ "recurring-billing",
50
35
  "apple-pay",
51
- "google-pay"
36
+ "google-pay",
37
+ "webhooks",
38
+ "sdk"
52
39
  ],
53
40
  "author": {
54
41
  "name": "GEMBA EOOD",
package/src/index.d.ts CHANGED
@@ -28,7 +28,7 @@ declare module 'gembapay' {
28
28
  amountUsd: string;
29
29
  amountOriginal: number;
30
30
  currencyOriginal: string;
31
- allowedMethods: ('crypto' | 'stripe' | 'paypal')[];
31
+ allowedMethods: ('stripe' | 'paypal')[];
32
32
  expiresAt: string;
33
33
  }
34
34
 
@@ -36,8 +36,8 @@ declare module 'gembapay' {
36
36
  orderId: string;
37
37
  status: 'pending' | 'processing' | 'confirmed' | 'completed' | 'failed' | 'expired';
38
38
  amountUsd: string;
39
- network: 'ethereum' | 'bsc' | 'polygon' | 'sepolia' | 'bscTestnet' | 'amoy' | 'stripe' | 'paypal';
40
- paymentProvider: 'crypto' | 'stripe' | 'paypal';
39
+ network: 'stripe' | 'paypal';
40
+ paymentProvider: 'stripe' | 'paypal';
41
41
  payment?: {
42
42
  txHash?: string;
43
43
  tokenSymbol?: string;
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ const https = require('https');
4
4
  const crypto = require('crypto');
5
5
 
6
6
  const BASE_URL = 'https://api.gembapay.com';
7
- const VERSION = '1.1.0';
7
+ const VERSION = '1.1.1';
8
8
 
9
9
  class GembaPayError extends Error {
10
10
  constructor(message, statusCode, code) {
@@ -114,16 +114,21 @@ class GembaPay {
114
114
  throw new GembaPayError('webhookSecret is required for signature verification', null, 'missing_webhook_secret');
115
115
  }
116
116
 
117
- const body = typeof payload === 'string' ? payload : JSON.stringify(payload);
118
- const expected = 'sha256=' + crypto
117
+ // `payload` must be the RAW request body (string or Buffer) — the exact bytes GembaPay
118
+ // signed. If an already-parsed object is passed, we best-effort re-serialize (less reliable;
119
+ // mount the webhook route with express.raw and pass the raw body instead).
120
+ const body = Buffer.isBuffer(payload) || typeof payload === 'string'
121
+ ? payload
122
+ : JSON.stringify(payload);
123
+ const expected = crypto
119
124
  .createHmac('sha256', this.webhookSecret)
120
125
  .update(body)
121
- .digest('hex');
126
+ .digest('hex'); // bare hex — GembaPay does NOT prefix with "sha256="
122
127
 
123
- return crypto.timingSafeEqual(
124
- Buffer.from(signature || ''),
125
- Buffer.from(expected)
126
- );
128
+ const a = Buffer.from(signature || '', 'utf8');
129
+ const b = Buffer.from(expected, 'utf8');
130
+ // Length-guard first: timingSafeEqual throws on unequal-length buffers.
131
+ return a.length === b.length && crypto.timingSafeEqual(a, b);
127
132
  }
128
133
 
129
134
  /**
@@ -133,13 +138,17 @@ class GembaPay {
133
138
  */
134
139
  parseWebhook(req) {
135
140
  const signature = req.headers['x-gembapay-signature'];
136
- const body = req.body;
141
+ // Prefer the RAW body — mount the route with express.raw({ type: 'application/json' }).
142
+ // Falls back to req.rawBody, then a re-serialized parsed body (least reliable).
143
+ const raw = Buffer.isBuffer(req.body) ? req.body
144
+ : (req.rawBody != null ? req.rawBody
145
+ : (typeof req.body === 'string' ? req.body : JSON.stringify(req.body)));
137
146
 
138
- if (!this.verifyWebhook(body, signature)) {
147
+ if (!this.verifyWebhook(raw, signature)) {
139
148
  throw new GembaPayError('Invalid webhook signature', 401, 'invalid_signature');
140
149
  }
141
150
 
142
- return body;
151
+ return (Buffer.isBuffer(raw) || typeof raw === 'string') ? JSON.parse(raw.toString('utf8')) : raw;
143
152
  }
144
153
 
145
154
  // ── Express Middleware ────────────────────────────────