onvo-api-client
v1.0.2
Published
ONVOPay API Library
Readme
onvo-api-client
Official Docs
You can see the official docs here. ONVO API Documentation.
ONVOPay API Library
Installation
Install the package via npm:
npm install onvo-api-clientUsage
Import and create a new client instance using your API keys:
import { ONVOClient } from 'onvo-api-client';
const client = new ONVOClient({
PUBLISHABLE_KEY: 'your-publishable-key',
SECRET_KEY: 'your-secret-key'
});Example: Creating a Customer
client.createCustomer({
name: "John Doe",
email: "[email protected]",
phone: "+1234567890",
address: {
line1: "123 Main St",
city: "San Francisco",
state: "CA",
postalCode: "94105",
country: "USA"
}
}).then(customer => {
console.log(customer);
}).catch(error => {
console.error(error);
});Example: Creating a Checkout Session
client.createCheckoutSession({
customerId: "customer_12345",
priceId: "price_67890",
successUrl: "https://example.com/success",
cancelUrl: "https://example.com/cancel"
}).then(session => {
console.log(session);
}).catch(error => {
console.error(error);
});API Reference
The client provides methods to interact with various resources:
Checkout Sessions
createCheckoutSession(data: CheckoutSessionCreateRequest): Promise<CheckoutSession>expireCheckoutSession(id: string): Promise<CheckoutSession>listCheckoutSessions(params?: Record<string, any>): Promise<{ data: CheckoutSession[]; hasMore: boolean }>
Customers
createCustomer(data: CustomerCreateRequest): Promise<Customer>listCustomers(params?: Record<string, any>): Promise<CustomerListResponse>getCustomer(id: string): Promise<Customer>updateCustomer(id: string, updates: CustomerUpdateRequest): Promise<Customer>deleteCustomer(id: string): Promise<{ id: string; deleted: boolean }>
Payment Intents
createPaymentIntent(data: PaymentIntentCreateRequest): Promise<PaymentIntent>listPaymentIntents(params?: Record<string, any>): Promise<PaymentIntentListResponse>getPaymentIntent(id: string): Promise<PaymentIntent>updatePaymentIntent(id: string, data: PaymentIntentUpdateRequest): Promise<PaymentIntent>confirmPaymentIntent(id: string, data: PaymentIntentConfirmRequest): Promise<PaymentIntent>capturePaymentIntent(id: string): Promise<PaymentIntent>
Payment Methods
createPaymentMethod(data: PaymentMethodCreateRequest): Promise<PaymentMethod>listPaymentMethods(params?: Record<string, any>): Promise<PaymentMethodListResponse>getPaymentMethod(id: string): Promise<PaymentMethod>updatePaymentMethod(id: string, data: PaymentMethodUpdateRequest): Promise<PaymentMethod>detachPaymentMethod(id: string): Promise<PaymentMethod>
Prices
createPrice(data: PriceCreateRequest): Promise<Price>listPrices(params?: Record<string, any>): Promise<PriceListResponse>getPrice(id: string): Promise<Price>updatePrice(id: string, data: PriceUpdateRequest): Promise<Price>deletePrice(id: string): Promise<{ id: string; deleted: boolean }>
Products
createProduct(data: ProductCreateRequest): Promise<Product>listProducts(params?: Record<string, any>): Promise<ProductListResponse>getProduct(id: string): Promise<Product>updateProduct(id: string, data: ProductUpdateRequest): Promise<Product>deleteProduct(id: string): Promise<{ id: string; deleted: boolean }>
Refunds
createRefund(data: RefundCreateRequest): Promise<Refund>getRefund(id: string): Promise<Refund>
Shipping Rates
createShippingRate(data: ShippingRateCreateRequest): Promise<ShippingRate>listShippingRates(params?: Record<string, any>): Promise<ShippingRateListResponse>getShippingRate(id: string): Promise<ShippingRate>updateShippingRate(id: string, data: ShippingRateUpdateRequest): Promise<ShippingRate>deleteShippingRate(id: string): Promise<{ id: string; deleted: boolean }>
Subscriptions
createSubscription(data: SubscriptionCreateRequest): Promise<Subscription>listSubscriptions(params?: Record<string, any>): Promise<SubscriptionListResponse>getSubscription(id: string): Promise<Subscription>updateSubscription(id: string, data: SubscriptionUpdateRequest): Promise<Subscription>deleteSubscription(id: string): Promise<{ id: string; deleted: boolean }>confirmSubscription(id: string): Promise<Subscription>addSubscriptionItem(id: string, data: { priceId: string; quantity?: number }): Promise<Subscription>
For complete type definitions and further details, refer to the index.d.ts file.
Contributing
Contributions, bug reports, and feature requests are welcome. Please open an issue or submit a pull request.
License
This project is licensed under the ISC License. See the LICENSE file for details.
