@coin-voyage/paykit
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
22 lines (21 loc) • 1.24 kB
JavaScript
import usePayContext from "../components/contexts/pay";
/** Returns the current payment, or undefined if there is none.
*
* Status values:
* - `PENDING` - the user has not paid yet
* - `AWAITING_PAYMENT` - the user has requested payment details but not yet executed the payment.
* - `AWAITING_CONFIRMATION` - the user has paid & payment is in progress. This status
* typically lasts a few seconds.
* - `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.
* - `EXECUTING_ORDER` - the payment is confirmed and the order is being executed. This status typically lasts a few seconds.
* - `COMPLETED` - the payOrder is finalized and succeeded
* - `EXPIRED` - the payOrder expired before the user paid
* - `REFUNDED` - the payment was refunded to the payment's configured refund address on the destination chain.
*/
export function usePayStatus() {
const { paymentState } = usePayContext();
if (!paymentState || !paymentState.payOrder) {
return undefined;
}
return { paymentId: paymentState.payOrder.id, status: paymentState.payOrder.status };
}