https://github.com/xct007/midtrans-client
Unofficial Midtrans Payment API Client | https://midtrans.com
https://github.com/xct007/midtrans-client
midtrans midtrans-nodejs payment-gateway payment-integration payments
Last synced: 9 months ago
JSON representation
Unofficial Midtrans Payment API Client | https://midtrans.com
- Host: GitHub
- URL: https://github.com/xct007/midtrans-client
- Owner: xct007
- License: mit
- Created: 2024-10-24T18:52:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-09T13:33:43.000Z (9 months ago)
- Last Synced: 2025-06-19T10:07:39.237Z (9 months ago)
- Topics: midtrans, midtrans-nodejs, payment-gateway, payment-integration, payments
- Language: TypeScript
- Homepage:
- Size: 464 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unofficial Midtrans Client Library
An unofficial Midtrans Payment API Client Library for Node.js.
[](https://www.npmjs.com/package/@xct007/midtrans-client)
[](https://github.com/xct007/midtrans-client/blob/master/LICENSE)
[](https://github.com/xct007/midtrans-client/actions/workflows/nodejs-ci.yml)
## Installation
```bash
npm install @xct007/midtrans-client
```
## Usage
### **import the library**
```javascript
// CommonJS
const MidtransClient = require("@xct007/midtrans-client").default;
// ES Modules
import MidtransClient from "@xct007/midtrans-client";
```
### **Initialize the client**
```javascript
const { Core, Snap, Iris } = new MidtransClient({
sandbox: true, // Set to false for production
clientKey: "YOUR_CLIENT_KEY",
serverKey: "YOUR_SERVER_KEY",
throwHttpErrors: true,
});
```
### **Core API Example**
```javascript
Core.charge({
payment_type: "bank_transfer",
transaction_details: {
order_id: "order-id-" + new Date().getTime(),
gross_amount: 10000,
},
bank_transfer: {
bank: "bca",
},
})
.then((response) => {
console.log("Charge Response:", response);
})
.catch((error) => {
console.error("Charge Error:", error);
});
```
Explore more Core API methods on [examples/core](examples/core).
### **Snap API Example**
```javascript
Snap.create({
transaction_details: {
order_id: "order-id-" + new Date().getTime(),
gross_amount: 10000,
},
})
.then((response) => {
console.log("Snap Token:", response.token);
console.log("Redirect URL:", response.redirect_url);
})
.catch((error) => {
console.error("Snap Error:", error);
});
```
Explore more Snap API methods on [examples/snap](examples/snap).
### **Iris API Example**
```javascript
Iris.ping()
.then((response) => {
console.log("Ping Response:", response);
})
.catch((error) => {
console.error("Ping Error:", error);
});
```
Explore more Iris API methods on [examples/iris](examples/iris).
## Documentation
For hands-on examples, please refer to the [examples](examples) directory.
For detailed API documentation, please refer to the [Midtrans API Documentation](https://docs.midtrans.com/reference).
## Contributing
Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/xct007/midtrans-client).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- This library is unofficial and maintained by [xct007](https://github.com/xct007).
- This library is inspired by the official [Midtrans Node.js Client](https://github.com/midtrans/midtrans-nodejs-client?tab=readme-ov-file#midtrans-client---node-js)
- Special thanks to [Midtrans](https://midtrans.com) team.