@domdanao/magpiepay-sdk-typescript
v1.0.1
Published
OpenAPI client for @domdanao/magpiepay-sdk-typescript
Maintainers
Readme
@domdanao/magpiepay-sdk-typescript
The official TypeScript/Node.js library for the MagpiePay API.
Installation
Install the package via npm:
npm install @domdanao/magpiepay-sdk-typescriptUsage
Configuration
Initialize the Configuration object with your API key.
import { Configuration, PaymentsApi } from '@domdanao/magpiepay-sdk-typescript';
const config = new Configuration({
username: process.env.MAGPIEPAY_API_KEY, // Use your API Key as the username
password: '', // Leave password empty
});
const paymentsApi = new PaymentsApi(config);Custom Base URL
You can override the base URL for local development:
const config = new Configuration({
username: process.env.MAGPIEPAY_API_KEY,
password: '',
basePath: process.env.MAGPIEPAY_BASE_URL || 'https://api.magpiepay.com',
});Examples
List Payments
try {
const response = await paymentsApi.listPayments();
console.log(response.data);
} catch (error) {
console.error(error);
}Create a Payout
import { PayoutsApi, PayoutCreateRequest } from '@domdanao/magpiepay-sdk-typescript';
const payoutsApi = new PayoutsApi(config);
const payoutRequest: PayoutCreateRequest = {
amount: 1000,
currency: 'PHP',
description: 'Test Payout',
// ... other fields
};
try {
const response = await payoutsApi.createPayout(payoutRequest);
console.log(response.data);
} catch (error) {
console.error(error);
}API Resources
License
Unlicense
