@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
|
|
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
|
-
* - `
|
|
6
|
-
* - `
|
|
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
|
-
* - `
|
|
9
|
-
* - `
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
12
|
-
*
|
|
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:
|
|
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
|
-
* - `
|
|
7
|
-
* - `
|
|
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
|
-
* - `
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
12
|
-
* - `
|
|
13
|
-
*
|
|
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
|
-
|
|
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,"file":"usePayStatus.js","sourceRoot":"","sources":["../../src/hooks/usePayStatus.ts"],"names":[],"mappings":"
|
|
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.
|
|
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
|
}
|