test transfer
This commit is contained in:
@@ -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"});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,9 @@ import Bvn from "../model/bvnModel.js";
|
|||||||
|
|
||||||
export const fetch = async (req, res)=>{
|
export const fetch = async (req, res)=>{
|
||||||
try{
|
try{
|
||||||
|
console.log("BVN REQ-----------------------------------------");
|
||||||
|
console.log(req.body);
|
||||||
|
console.log("BVN REQ=========================================");
|
||||||
let config = {
|
let config = {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`,
|
'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`,
|
||||||
@@ -17,7 +19,8 @@ export const fetch = async (req, res)=>{
|
|||||||
"lastname":"Doe",
|
"lastname":"Doe",
|
||||||
"dob":"04-04-1944"
|
"dob":"04-04-1944"
|
||||||
};
|
};
|
||||||
|
//22349419550 real live
|
||||||
|
//10000000001 test
|
||||||
axios.post(
|
axios.post(
|
||||||
`${process.env.VERIFY_ME_ENDPOINT}/10000000001`,
|
`${process.env.VERIFY_ME_ENDPOINT}/10000000001`,
|
||||||
bodyParameters
|
bodyParameters
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const verifyEmployer = async (req, res)=>{
|
|||||||
to: signatory_email, // list of receivers
|
to: signatory_email, // list of receivers
|
||||||
bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers
|
bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers
|
||||||
subject: "Verify Loan Application ✔", // Subject line
|
subject: "Verify Loan Application ✔", // Subject line
|
||||||
text: "Hello world?", // plain text body
|
text: "Hello "+signatory_name+"?", // plain text body
|
||||||
html: mainHtml, // html body
|
html: mainHtml, // html body
|
||||||
});
|
});
|
||||||
console.log("Message sent: %s", info.messageId);
|
console.log("Message sent: %s", info.messageId);
|
||||||
|
|||||||
@@ -4,10 +4,20 @@ import bodyParser from "body-parser"
|
|||||||
import dotenv from "dotenv"
|
import dotenv from "dotenv"
|
||||||
import route from "./routes/userRoute.js"
|
import route from "./routes/userRoute.js"
|
||||||
import verify_route from "./routes/verifyRoute.js"
|
import verify_route from "./routes/verifyRoute.js"
|
||||||
|
import payment_route from "./routes/paymentRoute.js";
|
||||||
|
|
||||||
|
import nodemailer from "nodemailer";
|
||||||
|
|
||||||
const app = express();
|
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();
|
dotenv.config();
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
const MONGOURL = process.env.MONGO_URL;
|
const MONGOURL = process.env.MONGO_URL;
|
||||||
@@ -24,6 +34,8 @@ console.log(error);
|
|||||||
});
|
});
|
||||||
app.use("/api/user", route);
|
app.use("/api/user", route);
|
||||||
app.use("/api/verify", verify_route);
|
app.use("/api/verify", verify_route);
|
||||||
|
app.use("/api/payment",payment_route);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -33,10 +33,10 @@ const bvnSchema = new mongoose.Schema({
|
|||||||
type:String,
|
type:String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
nationality:{
|
// nationality:{
|
||||||
type:String,
|
// type:String,
|
||||||
required: true
|
// required: true
|
||||||
},
|
// },
|
||||||
photo:{
|
photo:{
|
||||||
type:String,
|
type:String,
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user