結帳與支付
Payment types
// asset
enum BuyStatus {
SUCCESS = 'SUCCESS',
WAIT_PAYMENT = 'WAIT_PAYMENT',
FAILED = 'FAILED',
}
interface PayCallbackInput {
successRedirectUrl: string;
failureRedirectUrl: string;
pendingRedirectUrl: string;
}
buyAssetAndCreateCheckout
購買 NFT 並產生結帳連結 URL
async function buyAssetAndCreateCheckout(
assetBuyInput: AssetBuyInput,
options?: AssetBuyOptions,
): Promise<AssetBuyResponse | null>;
interface AssetBuyInput {
requestId: string;
asset: AssetSaleInput;
payCallback: PayCallbackInput;
test?: boolean; // default false
option?: AssetBuyOptionInput;
}
interface AssetSaleInput {
assetVariantId: string;
quantity: number;
price: string;
currency: CurrencyForAsset;
}
enum CurrencyForAsset {
ETH = 'ETH',
TWD = 'TWD',
MATIC = 'MATIC',
}
interface AssetBuyOptionInput {
beGift?: boolean;
privateSaleCode?: string;
}
interface AssetBuyOptions {
locale?: PaymentLocale;
}
interface AssetBuyResponse {
assetBuy: AssetBuyInfo;
}
enum CheckoutPaymentType {
UNSELECTED = 'UNSELECTED',
FREE = 'FREE',
CREDIT_CARD = 'CREDIT_CARD',
TRANSFER = 'TRANSFER',
CRYPTO = 'CRYPTO',
}
enum UnavailablePaymentReason {
GAS_PRICE_SURGE
PAYMENT_LIMIT_EXCEEDED
EXCHANGE_PRICE_FAILED
PAYMENT_MAINTENANCE
}
type UnavailablePayment {
type: CheckoutPaymentType!
reason: UnavailablePaymentReason!
}
interface AssetBuyInfo {
status: BuyStatus;
orderId: string;
paymentUrl: string;
paymentTypes: [CheckoutPaymentType!]!
unavailablePayments: [UnavailablePayment!]!
}
Example
const response = await qubicConnect.buyAssetAndCreateCheckout(assetBuyInput, { locale: 'zh' });
window.location.href = response.assetBuy.paymentUrl;
Last updated