mileston-payments
v0.2.3
Published
Open source Mileston Payment SDK to seamlessly integrate and build crypto (USDC) payment links, invoices and recurring payments into your apps!
Maintainers
Readme
Mileston Payments SDK
The Mileston Payments SDK is a simple and powerful library for managing payments, invoices, and recurring subscriptions. It provides seamless integration with your application, enabling you to create, update, and manage payment workflows effortlessly. Contact [email protected] if you have any issues integrating this.
Want to integrate crypto payment gateway into your application? Head on to https://mileston.co
Features
- Create and manage payment links.
- Generate and update invoices.
- Handle recurring payments with ease.
- Secure and reliable integration.
- Lightweight and developer-friendly.
Installation
Install the SDK using npm:
npm install mileston-paymentsInitialization
To get started, import the SDK and initialize it with your API key, and business ID.
import { PaymentLink, Invoice, RecurringPayment } from 'mileston-payments';
const apiKey = 'your-api-key'; // Your API key
const businessId = 'your-business-id'; // Your business ID
// Initialize PaymentLink, Invoice, or RecurringPayment as needed
const paymentLink = new PaymentLink(apiKey, businessId);
const invoice = new Invoice(apiKey, businessId);
const recurringPayment = new RecurringPayment(apiKey, businessId);Usage Examples
1. Creating a Payment Link
const createPaymentPayload = {
amount: '100.00',
description: 'Purchase of premium subscription',
customerEmail: '[email protected]',
};
const paymentLinkResponse = await paymentLink.create(createPaymentPayload);
console.log('Payment Link:', paymentLinkResponse.paymentLink);2. Generating an Invoice
const createInvoicePayload = {
amount: '200.00',
itemName: 'Service Fee',
customerEmail: '[email protected]',
dueDate: new Date(),
};
const businessName = 'Acme';
const invoiceResponse = await invoice.create(businessName, createInvoicePayload);
console.log('Invoice Link:', invoiceResponse.invoiceLink);3. Handling Recurring Payments
const createRecurringPaymentPayload = {
amount: '50.00',
subscriberFullName: 'John Doe',
subscriberEmail: '[email protected]',
recurringDate: new Date('2025-01-01'),
recurringInterval: 30, // Interval in days
};
const recurringPaymentResponse = await recurringPayment.create(businessName, createRecurringPaymentPayload);
console.log('Recurring Payment Created:', recurringPaymentResponse);4. Updating a Payment Link
const updatePayload = {
amount: '120.00',
description: 'Updated subscription fee',
};
const updatedPaymentLink = await paymentLink.update('paymentLinkId', updatePayload);
console.log('Updated Payment Link:', updatedPaymentLink);API Reference
Classes
PaymentLink
create(payload: CreatePaymentLinkPayload): Promise<CreatePaymentLinkResponse>update(id: string, payload: UpdatePaymentLinkPayload): Promise<UpdatePaymentLinkResponse>get(id: string): Promise<UpdatePaymentLinkResponse>delete(id: string): Promise<DeletePaymentLinkResponse>
Invoice
create(payload: CreateInvoicePayload): Promise<CreateInvoiceResponse>update(id: string, payload: UpdateInvoicePayload): Promise<UpdateInvoiceResponse>get(id: string): Promise<UpdateInvoiceResponse>delete(id: string): Promise<DeleteInvoiceResponse>
RecurringPayment
create(payload: CreateRecurringPaymentPayload): Promise<CreateRecurringPaymentResponse>update(id: string, payload: UpdateRecurringPaymentPayload): Promise<UpdateRecurringPaymentResponse>getAll(): Promise<GetAllRecurringPaymentResponse>
Contributing
We welcome contributions! Feel free to fork this repository and submit pull requests for any improvements or features you'd like to add.
License
This project is licensed under the MIT License. See the LICENSE file for details.
