SDKs & Libraries
Accelerate your development with our official Software Development Kits (SDKs) and libraries.
To make integrating with CashPay APIs as seamless as possible, we offer official SDKs for popular programming languages. These libraries handle boilerplate code, authentication, and error handling, allowing you to focus on your application's core logic.
Official SDKs
@cashpay/payment
Installation
cURL
npm install @cashpay/payment@cashpay/sms
Installation
cURL
npm install @cashpay/smsComing soon.
@cashpay/hsm
Installation
cURL
npm install @cashpay/hsmComing soon.
@cashpay/cards
Installation
cURL
npm install @cashpay/cardsComing soon.
@cashpay/ui
Installation
cURL
npm install @cashpay/uiComing soon.
Example Usage (@cashpay/payment)
Here's a conceptual example of how to create a hosted checkout session using our Payment SDK on a server.
JavaScript
import { CashPayPayment } from '@cashpay/payment';
// This would typically be in a server action or API route
async function redirectToCheckout() {
// Initialize the client with your API key from environment variables
const cashpay = new CashPayPayment({
apiKey: process.env.CASHPAY_API_KEY!,
environment: 'sandbox' // or 'production'
});
try {
const response = await cashpay.createHostedCheckout({
amount: 120.50,
currency: 'USD',
reference: 'ORDER-XYZ-123',
description: 'Purchase of 2x T-Shirt',
redirectUrl: 'https://yourshop.com/payment/complete'
});
console.log('Redirecting user to:', response.payment_url);
// In a real app (like Next.js), you would perform a server-side redirect:
// redirect(response.payment_url);
return response.payment_url;
} catch (error) {
console.error('Failed to create checkout session:', error.message);
}
}
// Call the function
redirectToCheckout();