UNPKG

@moneygraph/sdk

Version:

AI-native SDK for global payouts powered by StratosPay

122 lines (121 loc) 4.19 kB
"use strict"; /** * MoneyGraph SDK * * AI-native SDK for global payouts powered by StratosPay. * * @example * ```typescript * import { MoneyGraph } from '@moneygraph/sdk'; * * const mg = new MoneyGraph({ apiKey: 'sk_test_...' }); * * // Create a customer * const customer = await mg.onboard.createCustomer({ * account_type: 'personal', * first_name: 'John', * last_name: 'Doe', * email: 'john@example.com', * phone: '2025551234', * phone_iso2: 'US', * country: 'US', * }); * * // Get an FX quote * const quote = await mg.liquidity.getQuote({ * from: 'USD', * to: 'NGN', * amount: 100, * }); * * // Confirm the quote * const confirmation = await mg.liquidity.confirmQuote(quote.id); * * // Send payout (requires KYC approval) * const payout = await mg.payouts.send({ * quote_id: quote.id, * customer_id: customer.id, * recipient: { * name: 'Jane Doe', * bank_code: '058', * account_number: '0123456789', * }, * }); * ``` */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TEST_CARDS = exports.MoneyGraphError = exports.MoneyGraph = void 0; const client_1 = require("./api/client"); const onboard_1 = require("./modules/onboard"); const liquidity_1 = require("./modules/liquidity"); const payouts_1 = require("./modules/payouts"); const reference_1 = require("./modules/reference"); const payments_1 = require("./modules/payments"); class MoneyGraph { constructor(options) { this.client = new client_1.ApiClient(options); this.publicKey = options.publicKey || ''; this.onboard = new onboard_1.OnboardModule(this.client); this.liquidity = new liquidity_1.LiquidityModule(this.client); this.payouts = new payouts_1.PayoutsModule(this.client, this.onboard); this.reference = new reference_1.ReferenceModule(this.client); this.payments = new payments_1.PaymentsModule(this.client, this.publicKey, this.client.mode); } /** Current API mode (sandbox or live) */ get mode() { return this.client.mode; } /** Whether currently in sandbox mode */ get isSandbox() { return this.client.isSandbox; } /** Whether currently in live mode */ get isLive() { return this.client.isLive; } /** * Complete payout flow helper * Combines quote, confirm, and send into a single call */ async sendPayout(params) { // Step 1: Get quote const quote = await this.liquidity.getQuote({ from: params.from, to: params.to, amount: params.amount, }); // Step 2: Confirm quote await this.liquidity.confirmQuote(quote.id); // Step 3: Send payout (KYC check happens here) return this.payouts.send({ quote_id: quote.id, customer_id: params.customerId, recipient: params.recipient, reference: params.reference, narration: params.narration, }); } } exports.MoneyGraph = MoneyGraph; // Re-export all types __exportStar(require("./types"), exports); var client_2 = require("./api/client"); Object.defineProperty(exports, "MoneyGraphError", { enumerable: true, get: function () { return client_2.MoneyGraphError; } }); var payments_2 = require("./modules/payments"); Object.defineProperty(exports, "TEST_CARDS", { enumerable: true, get: function () { return payments_2.TEST_CARDS; } }); // Default export exports.default = MoneyGraph;