@delopay/sdk 0.50.0 → 0.52.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 +12 -10
- package/dist/{chunk-P45MMRTD.js → chunk-7EHSQIPR.js} +2 -2
- package/dist/chunk-7EHSQIPR.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -7
- package/dist/index.d.ts +48 -7
- package/dist/index.js +1 -1
- package/dist/internal.cjs +30 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +20 -3
- package/dist/internal.d.ts +20 -3
- package/dist/internal.js +30 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-P45MMRTD.js.map +0 -1
package/README.md
CHANGED
|
@@ -324,6 +324,8 @@ tier unchanged.
|
|
|
324
324
|
|
|
325
325
|
Delopay signs each outgoing webhook with HMAC-SHA512 over the raw request body and delivers the hex-encoded digest in the `X-Webhook-Signature-512` header. Use `express.raw()` (not `express.json()`) so the bytes reach the verifier unchanged.
|
|
326
326
|
|
|
327
|
+
The verified event matches the wire body: `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`. `event_type` says what happened (e.g. `'payment_succeeded'`); `content.type` tags the payload kind (e.g. `'payment_details'`) — narrow on it to get a typed `content.object` (the payment/refund/dispute, with `payment_id` etc.).
|
|
328
|
+
|
|
327
329
|
```typescript
|
|
328
330
|
import express from 'express';
|
|
329
331
|
import { Delopay } from '@delopay/sdk';
|
|
@@ -339,16 +341,16 @@ app.post('/webhooks/delopay', express.raw({ type: 'application/json' }), async (
|
|
|
339
341
|
return res.status(400).send('Invalid signature');
|
|
340
342
|
}
|
|
341
343
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
344
|
+
if (event.content.type === 'payment_details') {
|
|
345
|
+
const payment = event.content.object; // typed: PaymentResponse
|
|
346
|
+
switch (event.event_type) {
|
|
347
|
+
case 'payment_succeeded':
|
|
348
|
+
// fulfil order — payment.payment_id, payment.amount, payment.currency
|
|
349
|
+
break;
|
|
350
|
+
case 'payment_failed':
|
|
351
|
+
// notify customer — payment.error_message
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
352
354
|
}
|
|
353
355
|
|
|
354
356
|
res.json({ received: true });
|
|
@@ -2434,7 +2434,7 @@ var Webhooks = {
|
|
|
2434
2434
|
* req.header('x-webhook-signature-512') ?? '',
|
|
2435
2435
|
* process.env.DELOPAY_WEBHOOK_SECRET!,
|
|
2436
2436
|
* );
|
|
2437
|
-
* console.log(event.
|
|
2437
|
+
* console.log(event.event_type, event.content.object);
|
|
2438
2438
|
* res.sendStatus(200);
|
|
2439
2439
|
* } catch {
|
|
2440
2440
|
* res.status(400).send('Invalid signature');
|
|
@@ -4055,4 +4055,4 @@ export {
|
|
|
4055
4055
|
applyBrandingVariables,
|
|
4056
4056
|
shadowFor
|
|
4057
4057
|
};
|
|
4058
|
-
//# sourceMappingURL=chunk-
|
|
4058
|
+
//# sourceMappingURL=chunk-7EHSQIPR.js.map
|