@coin-voyage/paykit 2.2.0-beta.0 → 2.2.0-beta.1

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.
@@ -1,17 +1,18 @@
1
- import type { PaymentStatus } from "../types";
1
+ import { PayOrderStatus } from "@coin-voyage/shared/common";
2
2
  /** Returns the current payment, or undefined if there is none.
3
3
  *
4
4
  * Status values:
5
- * - `payment_pending` - the user has not paid yet
6
- * - `payment_started` - the user has paid & payment is in progress. This status
5
+ * - `PENDING` - the user has not paid yet
6
+ * - `AWAITING_PAYMENT` - the user has requested payment details but not yet executed the payment.
7
+ * - `AWAITING_CONFIRMATION` - the user has paid & payment is in progress. This status
7
8
  * typically lasts a few seconds.
8
- * - `payment_completed` - the final call or transfer succeeded
9
- * - `payment_bounced` - the final call or transfer reverted. Funds were sent
10
- * - `payment_expired` - the payment expired before the user paid
11
- * - `payment_failed` - the payment failed for some reason
12
- * to the payment's configured refund address on the destination chain.
9
+ * - `OPTIMISTIC_CONFIRMED` - the user has paid and the payment is verified on the blockchain, but not yet confirmed. This status can last from a few seconds to several minutes, depending on the chains transaction speed.
10
+ * - `EXECUTING_ORDER` - the payment is confirmed and the order is being executed. This status typically lasts a few seconds.
11
+ * - `COMPLETED` - the payOrder is finalized and succeeded
12
+ * - `EXPIRED` - the payOrder expired before the user paid
13
+ * - `REFUNDED` - the payment was refunded to the payment's configured refund address on the destination chain.
13
14
  */
14
15
  export declare function usePayStatus(): {
15
16
  paymentId: string;
16
- status: PaymentStatus;
17
+ status: PayOrderStatus;
17
18
  } | undefined;
@@ -1,41 +1,22 @@
1
- import { PayOrderStatus } from "@coin-voyage/shared/common";
2
1
  import usePayContext from "../components/contexts/pay";
3
2
  /** Returns the current payment, or undefined if there is none.
4
3
  *
5
4
  * Status values:
6
- * - `payment_pending` - the user has not paid yet
7
- * - `payment_started` - the user has paid & payment is in progress. This status
5
+ * - `PENDING` - the user has not paid yet
6
+ * - `AWAITING_PAYMENT` - the user has requested payment details but not yet executed the payment.
7
+ * - `AWAITING_CONFIRMATION` - the user has paid & payment is in progress. This status
8
8
  * typically lasts a few seconds.
9
- * - `payment_completed` - the final call or transfer succeeded
10
- * - `payment_bounced` - the final call or transfer reverted. Funds were sent
11
- * - `payment_expired` - the payment expired before the user paid
12
- * - `payment_failed` - the payment failed for some reason
13
- * to the payment's configured refund address on the destination chain.
9
+ * - `OPTIMISTIC_CONFIRMED` - the user has paid and the payment is verified on the blockchain, but not yet confirmed. This status can last from a few seconds to several minutes, depending on the chains transaction speed.
10
+ * - `EXECUTING_ORDER` - the payment is confirmed and the order is being executed. This status typically lasts a few seconds.
11
+ * - `COMPLETED` - the payOrder is finalized and succeeded
12
+ * - `EXPIRED` - the payOrder expired before the user paid
13
+ * - `REFUNDED` - the payment was refunded to the payment's configured refund address on the destination chain.
14
14
  */
15
15
  export function usePayStatus() {
16
16
  const { paymentState } = usePayContext();
17
17
  if (!paymentState || !paymentState.payOrder) {
18
18
  return undefined;
19
19
  }
20
- const order = paymentState.payOrder;
21
- const paymentId = order.id;
22
- if ([PayOrderStatus.EXECUTING_ORDER, PayOrderStatus.COMPLETED].includes(order.status)) {
23
- return { paymentId, status: "payment_completed" };
24
- }
25
- if (order.status === PayOrderStatus.FAILED) {
26
- return { paymentId, status: "payment_failed" };
27
- }
28
- if (order.status === PayOrderStatus.REFUNDED) {
29
- return { paymentId, status: "payment_bounced" };
30
- }
31
- if (order.status === PayOrderStatus.AWAITING_CONFIRMATION) {
32
- return { paymentId, status: "payment_started" };
33
- }
34
- if (order.status === PayOrderStatus.EXPIRED) {
35
- return { paymentId, status: "payment_expired" };
36
- }
37
- if ([PayOrderStatus.AWAITING_PAYMENT, PayOrderStatus.PENDING].includes(order.status)) {
38
- return { paymentId, status: "payment_pending" };
39
- }
20
+ return { paymentId: paymentState.payOrder.id, status: paymentState.payOrder.status };
40
21
  }
41
22
  //# sourceMappingURL=usePayStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"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AI,CAAC,cAAc,CAAC,gBAAgB,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACrF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;IACjD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"usePayStatus.js","sourceRoot":"","sources":["../../src/hooks/usePayStatus.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,4BAA4B,CAAA;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,CAAA;IACxC,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;AACtF,CAAC"}
package/dist/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ReactNode } from "react";
5
5
  import type { Languages as Lang } from "./lib/localizations";
6
6
  export type APIEnvironment = APIEnvironmentShared;
7
7
  export type WalletConfiguration = WalletConfigurationImport;
8
- export type { PayOrder, PayOrderMetadata } from "@coin-voyage/shared/common";
8
+ export type { PayOrder, PayOrderMetadata, PayOrderStatus, PayOrderEvent, WebhookEventType } from "@coin-voyage/shared/common";
9
9
  export type PayKitConfig = {
10
10
  children?: ReactNode;
11
11
  apiKey: string;
@@ -126,5 +126,3 @@ export type PayModalOptions = {
126
126
  /** Automatically reset the payment state after a successful payment. */
127
127
  resetOnSuccess?: boolean;
128
128
  };
129
- /** Payment status. See webhooks and React usePayStatus() hook. */
130
- export type PaymentStatus = "payment_pending" | "payment_started" | "payment_completed" | "payment_bounced" | "payment_expired" | "payment_failed";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coin-voyage/paykit",
3
3
  "description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
4
- "version": "2.2.0-beta.0",
4
+ "version": "2.2.0-beta.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "author": "Lars <lars@coinvoyage.io>",
@@ -88,6 +88,7 @@
88
88
  "release:build": "pnpm clean && pnpm build",
89
89
  "pre:release": "pnpm version prerelease --preid=beta",
90
90
  "pre:publish": "pnpm publish --access public --tag beta --no-git-checks",
91
+ "release": "pnpm publish --access public --no-git-checks",
91
92
  "type-check": "tsc --noEmit"
92
93
  }
93
94
  }