UNPKG

@oxyhq/services

Version:

Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀

62 lines (57 loc) • 1.45 kB
"use strict"; /** * Payment Methods Mixin * * Provides methods for payment processing and management */ import { CACHE_TIMES } from './mixinHelpers'; export function OxyServicesPaymentMixin(Base) { return class extends Base { constructor(...args) { super(...args); } /** * Create a payment * @param data - Payment data * @returns Created payment object */ async createPayment(data) { try { return await this.makeRequest('POST', '/api/payments', data, { cache: false }); } catch (error) { throw this.handleError(error); } } /** * Get payment by ID * @param paymentId - The payment ID * @returns Payment object */ async getPayment(paymentId) { try { return await this.makeRequest('GET', `/api/payments/${paymentId}`, undefined, { cache: true, cacheTTL: CACHE_TIMES.LONG }); } catch (error) { throw this.handleError(error); } } /** * Get user payments * @returns Array of user payments */ async getUserPayments() { try { return await this.makeRequest('GET', '/api/payments/user', undefined, { cache: false // Don't cache user payments - always get fresh data }); } catch (error) { throw this.handleError(error); } } }; } //# sourceMappingURL=OxyServices.payment.js.map