icone-pay-sdk
v1.0.1
Published
A TypeScript SDK for icone pay payment API integration
Downloads
189
Maintainers
Readme
Icone Pay SDK
A lightweight TypeScript SDK for the Icone Pay payment service. It validates payloads with zod before reaching the API so you get actionable errors early.
Installation
npm install icone-pay-sdk zodQuick Start
import { IconePaySDK } from "icone-pay-sdk";
const client = new IconePaySDK("YOUR_API_KEY");
const result = await client.initPayment({
action: "checkout",
successUrl: "https://merchant.app/success",
cancelUrl: "https://merchant.app/cancel",
currency: "usd",
amount: 100,
referenceId: "INV-001",
items: [
{
name: "T-shirt",
quantity: 1,
unitPrice: 100,
},
],
});
if (result.error) {
console.error(result.message);
} else {
console.log("Redirect customer to:", result.url);
}API
new IconePaySDK(apiKey: string, options?: { baseUrl?: string; fetchFn?: typeof fetch })
Creates a client. Supply a customfetchFnif your runtime does not providefetch.initPayment(payload)
Validatespayloadwith theinitPaymentSchemaand callsPOST /payments/init. Resolves with{ error, message, url }.
Types
initPaymentSchema, InitPaymentParams, and InitPaymentResponse are exported from src/types.
