@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/dist/index.d.cts CHANGED
@@ -4663,18 +4663,59 @@ declare class DelopayAuthenticationError extends DelopayError {
4663
4663
  });
4664
4664
  }
4665
4665
 
4666
+ /**
4667
+ * The payload of a webhook event, tagged by kind.
4668
+ *
4669
+ * Mirrors the backend's `{ "type": …, "object": … }` envelope: `type` names the
4670
+ * payload shape and `object` carries it. Narrow on `content.type` to get a
4671
+ * fully-typed `object`:
4672
+ *
4673
+ * ```typescript
4674
+ * if (event.content.type === 'payment_details') {
4675
+ * event.content.object.payment_id; // typed as PaymentResponse
4676
+ * }
4677
+ * ```
4678
+ */
4679
+ type WebhookContent = {
4680
+ type: 'payment_details';
4681
+ object: PaymentResponse;
4682
+ } | {
4683
+ type: 'refund_details';
4684
+ object: RefundResponse;
4685
+ } | {
4686
+ type: 'dispute_details';
4687
+ object: DisputeResponse;
4688
+ } | {
4689
+ type: 'mandate_details';
4690
+ object: MandateResponse;
4691
+ } | {
4692
+ type: 'payout_details';
4693
+ object: PayoutResponse;
4694
+ } | {
4695
+ type: 'subscription_details';
4696
+ object: ConfirmSubscriptionResponse;
4697
+ };
4666
4698
  /**
4667
4699
  * A parsed and verified Delopay webhook event.
4668
4700
  *
4669
- * The `type` field identifies the event (e.g. `'payment_succeeded'`).
4670
- * Specific event payload shapes are nested under `data`.
4701
+ * Matches the signed wire body exactly:
4702
+ * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.
4703
+ *
4704
+ * - `event_type` identifies the event, e.g. `'payment_succeeded'`.
4705
+ * - `content.type` tags the payload kind, e.g. `'payment_details'`.
4706
+ * - `content.object` is the payload; narrow on `content.type` to type it.
4671
4707
  */
4672
4708
  interface WebhookEvent {
4709
+ /** ID of the merchant that owns this event. */
4710
+ merchant_id: string;
4711
+ /** Unique ID for this event (stable across delivery retries). */
4712
+ event_id: string;
4673
4713
  /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */
4674
- type: string;
4675
- /** Event payload. Shape depends on `type`. */
4676
- data: Record<string, unknown>;
4677
- [key: string]: unknown;
4714
+ event_type: EventType;
4715
+ /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */
4716
+ content: WebhookContent;
4717
+ /** ISO 8601 timestamp at which the webhook was sent. */
4718
+ timestamp: string;
4678
4719
  }
4679
4720
  declare const Webhooks: {
4680
4721
  /**
@@ -4709,7 +4750,7 @@ declare const Webhooks: {
4709
4750
  * req.header('x-webhook-signature-512') ?? '',
4710
4751
  * process.env.DELOPAY_WEBHOOK_SECRET!,
4711
4752
  * );
4712
- * console.log(event.type, event.data);
4753
+ * console.log(event.event_type, event.content.object);
4713
4754
  * res.sendStatus(200);
4714
4755
  * } catch {
4715
4756
  * res.status(400).send('Invalid signature');
package/dist/index.d.ts CHANGED
@@ -4663,18 +4663,59 @@ declare class DelopayAuthenticationError extends DelopayError {
4663
4663
  });
4664
4664
  }
4665
4665
 
4666
+ /**
4667
+ * The payload of a webhook event, tagged by kind.
4668
+ *
4669
+ * Mirrors the backend's `{ "type": …, "object": … }` envelope: `type` names the
4670
+ * payload shape and `object` carries it. Narrow on `content.type` to get a
4671
+ * fully-typed `object`:
4672
+ *
4673
+ * ```typescript
4674
+ * if (event.content.type === 'payment_details') {
4675
+ * event.content.object.payment_id; // typed as PaymentResponse
4676
+ * }
4677
+ * ```
4678
+ */
4679
+ type WebhookContent = {
4680
+ type: 'payment_details';
4681
+ object: PaymentResponse;
4682
+ } | {
4683
+ type: 'refund_details';
4684
+ object: RefundResponse;
4685
+ } | {
4686
+ type: 'dispute_details';
4687
+ object: DisputeResponse;
4688
+ } | {
4689
+ type: 'mandate_details';
4690
+ object: MandateResponse;
4691
+ } | {
4692
+ type: 'payout_details';
4693
+ object: PayoutResponse;
4694
+ } | {
4695
+ type: 'subscription_details';
4696
+ object: ConfirmSubscriptionResponse;
4697
+ };
4666
4698
  /**
4667
4699
  * A parsed and verified Delopay webhook event.
4668
4700
  *
4669
- * The `type` field identifies the event (e.g. `'payment_succeeded'`).
4670
- * Specific event payload shapes are nested under `data`.
4701
+ * Matches the signed wire body exactly:
4702
+ * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.
4703
+ *
4704
+ * - `event_type` identifies the event, e.g. `'payment_succeeded'`.
4705
+ * - `content.type` tags the payload kind, e.g. `'payment_details'`.
4706
+ * - `content.object` is the payload; narrow on `content.type` to type it.
4671
4707
  */
4672
4708
  interface WebhookEvent {
4709
+ /** ID of the merchant that owns this event. */
4710
+ merchant_id: string;
4711
+ /** Unique ID for this event (stable across delivery retries). */
4712
+ event_id: string;
4673
4713
  /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */
4674
- type: string;
4675
- /** Event payload. Shape depends on `type`. */
4676
- data: Record<string, unknown>;
4677
- [key: string]: unknown;
4714
+ event_type: EventType;
4715
+ /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */
4716
+ content: WebhookContent;
4717
+ /** ISO 8601 timestamp at which the webhook was sent. */
4718
+ timestamp: string;
4678
4719
  }
4679
4720
  declare const Webhooks: {
4680
4721
  /**
@@ -4709,7 +4750,7 @@ declare const Webhooks: {
4709
4750
  * req.header('x-webhook-signature-512') ?? '',
4710
4751
  * process.env.DELOPAY_WEBHOOK_SECRET!,
4711
4752
  * );
4712
- * console.log(event.type, event.data);
4753
+ * console.log(event.event_type, event.content.object);
4713
4754
  * res.sendStatus(200);
4714
4755
  * } catch {
4715
4756
  * res.status(400).send('Invalid signature');
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  shadowFor,
50
50
  surfacePadValue,
51
51
  verticalGapValue
52
- } from "./chunk-P45MMRTD.js";
52
+ } from "./chunk-7EHSQIPR.js";
53
53
  export {
54
54
  Analytics,
55
55
  AnalyticsDashboard,
package/dist/internal.cjs CHANGED
@@ -2521,7 +2521,7 @@ var Webhooks = {
2521
2521
  * req.header('x-webhook-signature-512') ?? '',
2522
2522
  * process.env.DELOPAY_WEBHOOK_SECRET!,
2523
2523
  * );
2524
- * console.log(event.type, event.data);
2524
+ * console.log(event.event_type, event.content.object);
2525
2525
  * res.sendStatus(200);
2526
2526
  * } catch {
2527
2527
  * res.status(400).send('Invalid signature');
@@ -4148,6 +4148,35 @@ var AdminPortal = class {
4148
4148
  query: params
4149
4149
  });
4150
4150
  }
4151
+ /**
4152
+ * Full detail for a single transaction of ANY merchant — the same
4153
+ * `PaymentResponse` the merchant `payments.retrieve` returns. Admin-scoped:
4154
+ * the JWT (or admin API key) does not need to belong to the payment's
4155
+ * merchant; the backend resolves the owning merchant and reads it read-only
4156
+ * (no connector sync).
4157
+ */
4158
+ async getTransaction(paymentId) {
4159
+ return this.request("GET", `/admin-portal/transactions/${encodeURIComponent(paymentId)}`);
4160
+ }
4161
+ /**
4162
+ * Per-attempt history (retries across connectors, decline reasons) for a
4163
+ * single transaction of ANY merchant.
4164
+ */
4165
+ async getTransactionAttempts(paymentId) {
4166
+ return this.request(
4167
+ "GET",
4168
+ `/admin-portal/transactions/${encodeURIComponent(paymentId)}/attempts`
4169
+ );
4170
+ }
4171
+ /**
4172
+ * Refunds for a single transaction of ANY merchant.
4173
+ */
4174
+ async getTransactionRefunds(paymentId) {
4175
+ return this.request(
4176
+ "GET",
4177
+ `/admin-portal/transactions/${encodeURIComponent(paymentId)}/refunds`
4178
+ );
4179
+ }
4151
4180
  async analytics(params) {
4152
4181
  return this.request("GET", "/admin-portal/analytics", {
4153
4182
  query: params