API Docs
JavaScript Examples
Here are some examples of how to use the ZuriPay API with JavaScript.
Initiating a Transaction
JavaScript
const axios = require('axios'); const url = "https://api.zuripay.app/v1/transactions"; const headers = { "Authorization": "Bearer zp_test_26PHem9AhJZvU623DfE1x4sd", "Content-Type": "application/json" }; const data = { "currency": "USD", "amount": 1000, "email": "[email protected]", "mobile_money_number": "254712345678", "payment_method_code": "mpesa", "transaction_reference": "ZURIPAY1234567890" }; axios.post(url, data, { headers }) .then(response => { console.log("Transaction initiated:", response.data); }) .catch(error => { console.error("Error:", error.response.status, error.response.data); });
Listing Wallets
JavaScript
const axios = require('axios'); const url = "https://api.zuripay.app/v1/wallets/list"; const params = { "limit": 100 }; const headers = { "Authorization": "Bearer zp_test_26PHem9AhJZvU623DfE1x4sd", "Content-Type": "application/json" }; axios.get(url, { headers, params }) .then(response => { console.log("Wallet details:", response.data); }) .catch(error => { console.error("Error:", error.response.status, error.response.data); });
Authenticating API Requests
JavaScript
const axios = require('axios'); const url = "https://api.zuripay.app/v1/authenticate"; const headers = { "Authorization": "Bearer undefined_test_26PHem9AhJZvU623DfE1x4sd", "Content-Type": "application/json" }; axios.get(url, { headers }) .then(response => { console.log("Authentication successful:", response.data); }) .catch(error => { console.error("Error:", error.response.status, error.response.data); });
Creating a Wallet
JavaScript
const axios = require('axios'); const url = "https://api.zuripay.app/v1/wallets/create"; const headers = { "Authorization": "Bearer zp_test_26PHem9AhJZvU623DfE1x4sd", "Content-Type": "application/json" }; const data = { "currency": "USD", "balance": 1000 }; axios.post(url, data, { headers }) .then(response => { console.log("Wallet created:", response.data); }) .catch(error => { console.error("Error:", error.response.status, error.response.data); });
Fetching Wallet Balance
JavaScript
const axios = require('axios'); const url = "https://api.zuripay.app/v1/wallets/balance"; const headers = { "Authorization": "Bearer zp_test_26PHem9AhJZvU623DfE1x4sd", "Content-Type": "application/json" }; axios.get(url, { headers }) .then(response => { console.log("Wallet balance:", response.data); }) .catch(error => { console.error("Error:", error.response.status, error.response.data); });