import Auth from './apis/Auth'; import Bank from './apis/Bank'; import Wallet from './apis/Wallet'; import Order from './apis/Order'; import Transaction from './apis/Transaction'; import User from './apis/User'; import SubMerchant from './apis/Submerchant'; import Upi from './apis/Upi'; import Addresses from './apis/Addresses'; import { IInitializeCheckoutOptions } from './interfaces/CheckoutConfig'; import App from './apis/App'; import CheckoutUtils from './apis/CheckoutUtils'; import Payments from './apis/Payments'; import Offer from './apis/Offer'; import Emi from './apis/Emi'; import Card from './apis/Card'; /** * ``` * The Checkout class is the main module of an SDK that provides access to different APIs related to checkout and payment processing. It contains methods for authentication, working with banks, payment processing, order management, and more. The class constructor takes a configuration object of type CheckoutOptions. This object contains various properties, such as access key, access secret, host, order ID, and more. These properties are used to configure the different APIs that the Checkout class provides access to. The class has several properties, each of which represents a different API. These properties are defined using the typeof operator and refer to methods of various classes that are imported from the @apis module. The generatePublicKey, generateToken, and verifyDomain methods are related to authentication and are part of the Auth class. The getBanks, getBinData, and getCardOffers methods are related to working with banks and are part of the Bank class. The getTransactionStatus and updateTransactionFrontend methods are related to payment processing and are part of the Payment class. The getSubmerchant method is related to sub-merchants and is part of the SubMerchant class. The validateVpa method is related to UPI payments and is part of the Upi class. The getPaymentModes method is related to checkout resources and is part of the CheckoutResources class. The initPayment and makePayment methods are related to payment processing and are part of the InitPayment class. The resendOtp method is related to resending OTPs and is part of the ResendOtp class. The listOfWallets method is related to listing wallets and is part of the ListOfWallets class. The getOrder and updateOrder methods are related to order management and are part of the Order class. Each method is assigned to the corresponding property of the Checkout class, making them accessible from an instance of the Checkout class. Overall, the Checkout class provides a convenient way to access different APIs related to payment processing and order management, all from a single module. ``` * To use the `Checkout` class, create an instance of it with a `CheckoutOptions` * object, then call methods on the instance to interact with various APIs. * * Example usage: * * ```typescript * const checkout = new Checkout({ * access_key: 'my_access_key', * host: 'api.mysite.com', * order_id: '1234', * }); * * const publicKey = checkout.generatePublicKey(); * console.log(publicKey); * ``` * * @remarks * This class requires a `CheckoutOptions` object to be passed to the constructor, which contains * configuration settings such as the access key, access secret, host, and other parameters. * * ```ts * interface CheckoutOptions { // access_key for the merchant access_key: string; // the host server to which all request will be served // change this to point to any sandbox environment @default "https://api.nimbbl.tech" host?: string; // nimbbl order_id generated which was generated by the merchant order_id: string; } * ``` * @public */ declare class Checkout { /** * Asynchronously returns an object with public key used for RSA encryption. * * @returns {Promise>} * A promise that resolves to an object containing public key. */ getPublicKey: typeof Auth.prototype.getPublicKey; /** * Asynchronously retrieves a list of banks based on the provided parameters. * * @param {GetListOfBanksParams | undefined} params - Optional parameters for fetching the list of banks. * @returns {Promise>} * A promise that resolves to an object containing the list of banks. */ getListOfBanks: typeof Bank.prototype.getListOfBanks; /** * Asynchronously retrieves BIN (Bank Identification Number) data based on the provided parameters. * * @param {GetBinParams} params - Parameters for fetching BIN data. * @returns {Promise>} * A promise that resolves to an object containing BIN data. */ getBin: typeof Card.prototype.getBin; /** * Asynchronously retrieves payment modes based on the provided parameters. * * @param {GetPaymentModesParams | undefined} [params] - Optional parameters for fetching payment modes. * - `order_id` (string, optional): Custom order ID to use instead of the one from config * - `os` (string, optional): Operating system (e.g., 'android', 'ios') * - `upi_app_package_names` (string[], optional): Array of UPI app package names * @returns {Promise>} * A promise that resolves to an object containing processed payment modes with additional computed fields. * * @example * ```typescript * // Basic usage with default order_id from config * const paymentModes = await checkout.getPaymentModes(); * * // With custom order_id * const paymentModes = await checkout.getPaymentModes({ * order_id: 'custom_order_123' * }); * * // With OS parameter * const paymentModes = await checkout.getPaymentModes({ * os: 'android' * }); * * // With UPI app package names * const paymentModes = await checkout.getPaymentModes({ * upi_app_package_names: [ * 'com.phonepe.app', * 'com.google.android.apps.nbu.paisa.user', * 'com.whatsapp' * ] * }); * * // With all parameters * const paymentModes = await checkout.getPaymentModes({ * order_id: 'custom_order_123', * os: 'ios', * upi_app_package_names: [ * 'com.phonepe.app', * 'com.google.android.apps.nbu.paisa.user' * ] * }); * ``` */ getPaymentModes: typeof CheckoutUtils.prototype.getPaymentModes; /** * Asynchronously retrieves the payload for a callback based on the provided parameters. * * @param {ICallbackParams} [callbackParams] - Optional parameters for retrieving the callback payload. * - `order_id` (string, optional): The order ID to get callback payload for * - `transaction_id` (string, optional): The transaction ID to get callback payload for * @returns {Promise>} * A promise that resolves to an object containing the callback payload. * * @example * ```typescript * // Get callback payload for an order * const callbackPayload = await checkout.getCallbackPayload({ * order_id: 'order_123' * }); * * // Get callback payload for a transaction * const callbackPayload = await checkout.getCallbackPayload({ * transaction_id: 'txn_456' * }); * * console.log('Callback payload:', callbackPayload.data); * ``` */ getCallbackPayload: typeof CheckoutUtils.prototype.getCallbackPayload; /** * Asynchronously retrieves offers based on provided parameters. * * @param {GetOfferParams} offerParams - The parameters for fetching the offer. * @returns {Promise>} * A promise that resolves to an object containing all available offers. */ getOffer: typeof Offer.prototype.getOffer; /** * Asynchronously retrieves a specific offer by its ID. * * @param {string} offerId - The unique identifier of the offer to retrieve. * @returns {Promise>} * A promise that resolves to an object containing the specific offer details. * * @example * ```typescript * const offer = await checkout.getOfferById('offer_123'); * console.log('Offer details:', offer.data); * ``` */ getOfferById: typeof Offer.prototype.getOfferById; /** * Asynchronously retrieves order details based on the provided parameters. * * @param {GetOrderParams | undefined} params - Optional parameters for fetching order details. * @returns {Promise>} * A promise that resolves to an object containing order details. */ getOrder: typeof Order.prototype.getOrder; /** * Asynchronously updates order details based on the provided data. * * @param {UpdateOrderParams} orderData - The data for updating order details. * @returns {Promise>} * A promise that resolves to an object containing updated order details. */ updateOrder: typeof Order.prototype.updateOrder; /** * Asynchronously retrieves all addresses for the current user. * * @returns {Promise>} * A promise that resolves to an object containing all user addresses with their details. * * @example * ```typescript * const addresses = await checkout.getAddresses(); * * // Access address details * addresses.data.addresses.forEach(address => { * console.log('Address:', address.address_details); * console.log('Amount:', address.amount); * console.log('Currency:', address.currency); * }); * ``` */ getAddresses: typeof Addresses.prototype.getAddresses; /** * Initiates a payment based on the provided parameters. * * @param {IInitiationParams} initiationParams - The parameters required for initiating the payment. * @returns {Promise>} * A promise that resolves to an object containing payment initiation details. */ initiatePayment: typeof Payments.prototype.initiatePayment; /** * Initiates a payment based on the provided parameters. * * @param {MakePaymentParams} paymentParams - The parameters required for initiating the payment. * @returns {Promise>} * A promise that resolves to an object containing payment initiation details. */ makePayment: typeof Payments.prototype.makePayment; /** * Asynchronously deletes a saved card for the user. * * @param {string} cardId - The unique identifier of the saved card to delete. * @returns {Promise>} * A promise that resolves when the card is successfully deleted. * * @example * ```typescript * await checkout.deleteSavedCard('card_123'); * console.log('Card deleted successfully'); * ``` */ deleteSavedCard: typeof Card.prototype.deleteSavedCard; /** * Initiates the process to resend the OTP for a payment. * * @param {ResendPaymentOtpParams} resendOtpParams - The parameters required for resending the OTP. * @returns {Promise>} * A promise that resolves to an object containing details about the OTP resend. */ resendPaymentOtp: typeof Payments.prototype.resendPaymentOtp; /** * Asynchronously resolves user details based on the provided parameters. * * @param {ResolveUserParams} userParams - The parameters for resolving user details. * @returns {Promise>} * A promise that resolves to an object containing user details. */ resolveUser: typeof User.prototype.resolveUser; /** * Asynchronously re-sends the user's one-time password (OTP). * * @returns {Promise>} * A promise that resolves to an object containing the status of the OTP resend operation. */ resendUserOtp: typeof User.prototype.resendUserOtp; /** * Opens the checkout interface in a new window or iframe. * * @param {OpenOptions} [options] - Optional configuration for opening the checkout. * - `mode` (string, optional): The display mode ('popup', 'iframe', 'redirect') * - `width` (number, optional): Width of the popup window * - `height` (number, optional): Height of the popup window * @returns {void} * Opens the checkout interface based on the provided options. * * @example * ```typescript * // Open in popup mode * checkout.open({ mode: 'popup', width: 800, height: 600 }); * * // Open in iframe mode * checkout.open({ mode: 'iframe' }); * * // Open with default settings * checkout.open(); * ``` */ open: typeof App.prototype.open; /** * Asynchronously retrieves a list of available wallets. * * @returns {Promise>} * A promise that resolves to an object containing the list of available wallets. * * @example * ```typescript * const wallets = await checkout.getListOfWallets(); * console.log('Available wallets:', wallets.data.wallets); * ``` */ getListOfWallets: typeof Wallet.prototype.getListOfWallets; /** * Asynchronously validates a UPI Virtual Payment Address (VPA). * * @param {string} vpa - The UPI VPA to validate (e.g., 'user@upi'). * @returns {Promise>} * A promise that resolves to an object containing VPA validation details. * * @example * ```typescript * const validation = await checkout.validateVpa('user@upi'); * console.log('VPA valid:', validation.data.is_valid); * ``` */ validateVpa: typeof Upi.prototype.validateVpa; /** * Asynchronously retrieves a list of VPA handles for the user. * * @returns {Promise>} * A promise that resolves to an object containing the list of VPA handles. * * @example * ```typescript * const vpaList = await checkout.getVpaList(); * console.log('VPA handles:', vpaList.data.vpa_handles); * ``` */ getVpaList: typeof Upi.prototype.getVpaList; /** * Asynchronously retrieves a list of available UPI apps. * * @returns {Promise>} * A promise that resolves to an object containing the list of available UPI apps. * * @example * ```typescript * const upiApps = await checkout.getUpiAppList(); * console.log('UPI apps:', upiApps.data.upi_apps); * ``` */ getUpiAppList: typeof Upi.prototype.getUpiAppList; /** * Asynchronously retrieves the status of a transaction. * * @param {IGetTransactionProps} params - Either transaction_id or order_id (or both) must be provided. * @returns {Promise>} * A promise that resolves to an object containing transaction status details. * * @example * ```typescript * // Using transaction_id only * const status = await checkout.getTransactionStatus({ transaction_id: 'txn_123' }); * * // Using order_id only * const status = await checkout.getTransactionStatus({ order_id: 'order_456' }); * * // Using both parameters * const status = await checkout.getTransactionStatus({ * transaction_id: 'txn_123', * order_id: 'order_456' * }); * ``` */ getTransactionStatus: typeof Transaction.prototype.getTransactionStatus; /** * Asynchronously cancels a transaction. * * @param {string} transactionId - The unique identifier of the transaction to cancel. * @returns {Promise>} * A promise that resolves to an object containing cancellation details. * * @example * ```typescript * const cancellation = await checkout.cancelTransaction('txn_123'); * console.log('Cancellation status:', cancellation.data.status); * ``` */ cancelTransaction: typeof Transaction.prototype.cancelTransaction; /** * Asynchronously retrieves submerchant details. * * @returns {Promise>} * A promise that resolves to an object containing submerchant information. * * @example * ```typescript * const submerchant = await checkout.getSubmerchant(); * console.log('Submerchant details:', submerchant.data); * ``` */ getSubmerchant: typeof SubMerchant.prototype.getSubmerchant; /** * Asynchronously retrieves emi list based on provided parameters. * * @param {GetEmiList} emiParams - The parameters for fetching the emi. * @returns {Promise>} * A promise that resolves to an object containing all available emis. */ getEmiList: typeof Emi.prototype.getEmiList; /** * Asynchronously retrieves all addresses for the user. * * @returns {Promise>} * A promise that resolves to an object containing all addresses. */ /** * Asynchronously creates new addresses. * * @param {IAddressParams} params - The parameters for creating addresses (array of addresses with amount and currency). * @returns {Promise>} * A promise that resolves to an array of created address responses. */ createAddress: typeof Addresses.prototype.createAddress; /** * Asynchronously updates an existing address. * * @param {IUpdateAddressParams} params - The parameters for updating the address. * @returns {Promise>} * A promise that resolves to an object containing the updated address. */ updateAddress: typeof Addresses.prototype.updateAddress; /** * Asynchronously deletes an address. * * @param {string} addressId - The ID of the address to delete. * @returns {Promise>} * A promise that resolves when the address is deleted. */ deleteAddress: typeof Addresses.prototype.deleteAddress; /** * Asynchronously fetches address from a provider. * * @param {IFetchAddressRequest} fetchAddressParams - The parameters for fetching the address. * @param {ILinkAddressParams} linkAddressParams - The parameters for linking the address. * @returns {Promise>} * A promise that resolves to an object containing the fetched address. */ fetchAddress: typeof Addresses.prototype.fetchAddress; /** * Asynchronously links an address to the user's account. * * @param {ILinkAddressParams} linkAddressParams - The parameters for linking the address. * - `address_id` (string): The ID of the address to link * - `user_id` (string): The ID of the user to link the address to * @returns {Promise>} * A promise that resolves to an object containing the linked address details. * * @example * ```typescript * const linkedAddress = await checkout.linkAddress({ * address_id: 'addr_123', * user_id: 'user_456' * }); * console.log('Address linked:', linkedAddress.data); * ``` */ linkAddress: typeof Addresses.prototype.linkAddress; /** * Asynchronously checks eligibility for shipping based on pincode. * * @param {ICheckEligibilityParams} params - The parameters for checking eligibility (pincode). * @returns {Promise>} * A promise that resolves to an object containing eligibility information. */ checkEligibility: typeof Addresses.prototype.checkEligibility; private checkoutConfig; constructor(config: IInitializeCheckoutOptions); } export default Checkout;