A modern, fully-typed TypeScript SDK for the Rapyd payment platform API (unofficial).
β¨ What makes this SDK special:
π Lightweight & Efficient β Optimized for performance with minimal dependencies.
π TypeScript-Powered β Enjoy strong typing, autocompletion, and better developer experience.
π³ Seamless Rapyd Integration β Easily interact with Rapydβs fintech APIs for payments, wallets, and more.
π Built-in Request Signing β Secure HMAC authentication is handled automatically.
π‘ Developer-Friendly β Clean, well-structured code with intuitive service methods.
π οΈ Extensible β Designed for easy customization and future enhancements.
π Detailed request and response typing
npm install rapyd-ts-sdk
import { RapydClient } from 'rapyd-typescript-sdk';
const client = new RapydClient(
'your_access_key',
'your_secret_key'
);
// Get payment method field requirements
const fieldRequirements = await client.PaymentMethodsService.getFieldRequirements('us_debit_card'), // bank_tranfer = us_ach_bank , etc ;
console.log(fieldRequirements);
// Get payment methods by country
const paymentMethods = await client.PaymentMethodsService.getPaymentMethodsByCountry('US');
console.log(`Found ${paymentMethods.payment_methods.length} payment methods for ${paymentMethods.country}`);
//you could pick this option or choose the snippet below on how to create payment
// Create a payment
const payment = await client.createPayment({
amount: 100,
currency: 'USD',
payment_method: 'us_debit_card'
});
// CREATE PAYMENT
// you could use the sdk custom types in your project
import { RapydClient, PaymentService, CreatePaymentRequest } from 'rapyd-payments-sdk';
// Initialize the client
const rapydClient = new RapydClient({
accessKey: 'your-access-key',
secretKey: 'your-secret-key',
baseURL: 'https://sandboxapi.rapyd.net' // or production URL
});
const paymentService = new PaymentService(rapydClient); // just call the method based of the rapydClient class
// Create a payment
async function makePayment() {
try {
const paymentRequest: CreatePaymentRequest = {
amount: 101,
currency: 'USD',
description: 'Payment method token',
payment_method: 'other_7f991f72a4c14c5cd79627ebc21241de',
ewallets: [{
ewallet: 'ewallet_1290eef66d0b84ece177a3f5bd8fb0c8',
percentage: 100
}],
metadata: {
merchant_defined: true
}
};
const paymentResponse = await paymentService.createPayment(paymentRequest);
console.log('Payment created:', paymentResponse.data.id);
return paymentResponse;
} catch (error) {
console.error('Payment failed:', error);
throw error;
}
}
// UPDATE PAYMENT
// Update a payment using the client (which delegates to PaymentService)
const paymentId = 'payment_36724a4ea01b438fd24ac3ab00b29150';
// Method 1: Update general payment information
await rapydClient.updatePayment(paymentId, {
receipt_email: 'customer@example.com',
description: 'Updated payment description'
});
// Method 2: Update just the address
const address = {
name: 'John Doe',
line_1: '123 Main St',
city: 'Anytown',
country: 'US'
};
await rapydClient.updatePaymentAddress(paymentId, address);
// Method 3: Update just metadata
const metadata = {
order_id: '12345',
customer_type: 'premium'
};
await rapydClient.updatePaymentMetadata(paymentId, metadata);
// Method 4: Cancel escrow
await rapydClient.cancelEscrow(paymentId);
// CAPTURE PAYMENT IN FULL OR PARTIALY
// Capture full payment
rapydClient.captureFullPayment('payment_19e3edad1e9102cd24006a34c52c9a0b')
.then(response => console.log(response))
.catch(error => console.error(error));
// Capture partial payment
rapydClient.capturePayment('payment_19e3edad1e9102cd24006a34c52c9a0b', {
amount: 50.00,
receipt_email: 'customer@example.com',
statement_descriptor: 'Your Store Name'
})
.then(response => console.log(response))
.catch(error => console.error(error));
// Create wallet
const wallet = await client.createWallet({
first_name: 'John',
last_name: 'Doe',
email: 'john@example.com',
ewallet_reference_id: 'john-doe-001'
});
// Get balance
const balance = await client.getWalletBalance('wallet_id');
const payout = await client.createPayout({
beneficiary: 'beneficiary_id',
payout_method_type: 'us_bank_transfer',
amount: 100,
currency: 'USD'
});
const account = await client.createVirtualAccount({
country: 'US',
currency: 'USD',
description: 'Business Account'
});
try {
const payment = await client.createPayment({
amount: 100,
currency: 'USD',
payment_method: 'us_debit_card'
});
} catch (error) {
console.error('Payment failed:', error.message);
}
- Fork the repository
- Create your branch (
git checkout -b feature/amazing
) - Commit changes (
git commit -m 'Add feature'
) - Push (
git push origin feature/amazing
) - Open a Pull Request
- Issues: GitHub Issues
- Email: nobudev20@gmail.com
- Documentation: Wiki
MIT Β© LICENSE
Built with β€οΈ by Awuah, Hunt