test transfer

This commit is contained in:
CHIEFSOFT\ameye
2024-07-11 09:11:37 -04:00
parent 9efe74efec
commit 0277c1a100
6 changed files with 133 additions and 8 deletions
+102
View File
@@ -0,0 +1,102 @@
import axios from "axios";
import dotenv from "dotenv"
import Bvn from "../model/bvnModel.js";
import https from "https";
export const deposit = async (req, res)=>{
try{
console.log("TRNS** STARTED REQ-----------------------------------------");
// console.log(req.body);
// console.log("BVN REQ=========================================");
const params = JSON.stringify({
"source": "balance",
"reason": "Calm down",
"amount":3794800,
"recipient": "RCP_iycuaxuhxluj8o7"
})
const SECRET = "sk_test_e880ee5f37602e3f5d8703b1a691f3f800fcea68";
const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/transfer',
method: 'POST',
headers: {
Authorization: `Bearer ${SECRET}`,
'Content-Type': 'application/json'
}
}
const req = https.request(options, res => {
let data = ''
res.on('data', (chunk) => {
data += chunk
});
res.on('end', () => {
console.log(JSON.parse(data))
})
}).on('error', error => {
console.error(error)
})
req.write(params)
req.end()
res.status(200).json({result: "Transfer Result"});
}catch(error){
res.status(500).json({error: "Internal Server error"});
}
}
export const recipient = async (req, res)=>{
try{
console.log("TRNS** STARTED REQ-----------------------------------------");
// console.log(req.body);
// console.log("BVN REQ=========================================");
const params = JSON.stringify({
"type": "nuban",
"name": "Tolulope Robert",
"account_number": "0148618731",
"bank_code": "058",
"currency": "NGN"
})
const SECRET = "sk_test_e880ee5f37602e3f5d8703b1a691f3f800fcea68";
const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/transferrecipient',
method: 'POST',
headers: {
Authorization: `Bearer ${SECRET}`,
'Content-Type': 'application/json'
}
}
const req = https.request(options, res => {
let data = ''
res.on('data', (chunk) => {
data += chunk
});
res.on('end', () => {
console.log(JSON.parse(data))
})
}).on('error', error => {
console.error(error)
})
req.write(params)
req.end()
res.status(200).json({result: "Transfer Result"});
}catch(error){
res.status(500).json({error: "Internal Server error"});
}
}
+5 -2
View File
@@ -4,7 +4,9 @@ import Bvn from "../model/bvnModel.js";
export const fetch = async (req, res)=>{
try{
console.log("BVN REQ-----------------------------------------");
console.log(req.body);
console.log("BVN REQ=========================================");
let config = {
headers: {
'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`,
@@ -17,7 +19,8 @@ export const fetch = async (req, res)=>{
"lastname":"Doe",
"dob":"04-04-1944"
};
//22349419550 real live
//10000000001 test
axios.post(
`${process.env.VERIFY_ME_ENDPOINT}/10000000001`,
bodyParameters
+1 -1
View File
@@ -55,7 +55,7 @@ export const verifyEmployer = async (req, res)=>{
to: signatory_email, // list of receivers
bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers
subject: "Verify Loan Application ✔", // Subject line
text: "Hello world?", // plain text body
text: "Hello "+signatory_name+"?", // plain text body
html: mainHtml, // html body
});
console.log("Message sent: %s", info.messageId);
+13 -1
View File
@@ -4,10 +4,20 @@ import bodyParser from "body-parser"
import dotenv from "dotenv"
import route from "./routes/userRoute.js"
import verify_route from "./routes/verifyRoute.js"
import payment_route from "./routes/paymentRoute.js";
import nodemailer from "nodemailer";
const app = express();
app.use(bodyParser.json());
// Enable parsing of URL-encoded data on all routes:
app.use(express.urlencoded({
extended: false, // Whether to use algorithm that can handle non-flat data strutures
limit: 10000, // Limit payload size in bytes
parameterLimit: 2, // Limit number of form items on payload
}));
//app.use(bodyParser.json());
dotenv.config();
const PORT = process.env.PORT || 5000;
const MONGOURL = process.env.MONGO_URL;
@@ -24,6 +34,8 @@ console.log(error);
});
app.use("/api/user", route);
app.use("/api/verify", verify_route);
app.use("/api/payment",payment_route);
+4 -4
View File
@@ -33,10 +33,10 @@ const bvnSchema = new mongoose.Schema({
type:String,
required: true
},
nationality:{
type:String,
required: true
},
// nationality:{
// type:String,
// required: true
// },
photo:{
type:String,
required: true
+8
View File
@@ -0,0 +1,8 @@
import express from "express"
import { deposit ,recipient } from "../controller/paymentController.js"
const payment_route = express.Router();
payment_route.post("/transfer",deposit);
payment_route.post("/recipient",recipient);
export default payment_route;