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);