我已经在MERN堆栈中创建了一个基于电子商务的应用程序,后端托管在AWS EC2中,前端托管在Vercel中。所以我的问题是在AWS EC2中托管后端后,我看到我无法打开支付网关。我猜测可能是AWS本身阻止了支付URL访问。在我的Chrome浏览器的网络选项卡中,它显示504 gateway timeout
错误,strict-origin-when-cross-origin
。但在AWS托管之前,我也尝试了OnRender平台在那里托管,它工作得很好。
我在获取超时错误时所做的事情-在AWS中,我将安全组中的出站规则设置为http和https,并且还有入站规则ssh,https和http。但我仍然无法访问支付网关。我使用Eazebuzz支付getway。
我正在共享路由和控制器
我的路由是本地透视http://localhost:5000/API/schemes/:id/initiate_payment
控制器
export const initiatePaymentWithEazebuzz = expressAsyncHandler(async (req, res) => {
const response = await GenSchema.findById({ _id: process.env.GEN_CONFIG_CONFIGURATION_ID });
const scheme = await Scheme.findOne({ "schemeData._id": req.params.id }, { "schemeData.$": 1, status: 1, user: 1 });
if (scheme.status !== "active") {
return res.status(400).json({ error: "This Scheme isn't active anymore. You can't make a payment." });
}
const user = await User.findById(scheme.user);
const amount = scheme.schemeData[0].amount.toFixed(2);
const phone = user.mobile_number.slice(3);
const firstname = user.name.split(" ")[0];
const productinfo = scheme.schemeData[0].month_name;
const email = user.email;
const key = response.eazebuzz_merchant_key;
const salt = response.eazebuzz_salt;
// const key = process.env.EASEBUZZ_KEY;
// const salt = process.env.EAZEBUZZ_SALT;
const txnid = crypto.randomBytes(10).toString("hex");
const hashSequence = generateHashForEazeBuzz({ key, txnid, amount, productinfo, firstname, email, salt });
const url = `${process.env.BASE_URL}/payment_result`;
const formData = {
key,
txnid,
amount,
email,
phone,
firstname,
hash: hashSequence,
productinfo,
furl: url,
surl: url,
};
const eazebuzz_env = process.env.EAZEBUZZ_ENV;
const geturl = (env) => {
let url_link;
if (env === "test") {
url_link = "https://testpay.easebuzz.in/";
} else if (env === "prod") {
url_link = "https://pay.easebuzz.in/";
} else {
url_link = "https://testpay.easebuzz.in/";
}
return url_link;
};
let payment_url = geturl(eazebuzz_env);
let call_url = payment_url + "payment/initiateLink";
const options = {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
};
try {
const { data } = await axios.post(call_url, formData, options);
if (data.status === 1) {
await Scheme.findOneAndUpdate(
{ "schemeData._id": req.params.id },
{
$set: {
"schemeData.$.txnid": txnid,
},
}
);
return res.json({ access_url: data.data, key, env: eazebuzz_env });
}
} catch (error) {
return res.json({ message: error.message });
}
});
字符串
这里是NGINX sites-availability config我做的,如果任何事情chnage需要启动付款.
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name jewellerymine.jewellerskart.in;
ssl_certificate /etc/nginx/ssl/client-certificate.crt;
ssl_certificate_key /etc/nginx/ssl/private-ssl.key;
location /api {
rewrite ^\/api\/(.*)$ /api/$1 break;
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
型
1条答案
按热度按时间kx7yvsdv1#
我已经找到了解决方案经过一些研究,我发现,有一些参数需要激活eazebuzz支付网关,这是在我的环境变量,不幸的是,我忘记了发送特定的变量到生产,我也看到了错误来自cors的起源,所以我添加了eazebuzz支付网址在我的cors设置允许的起源,因此问题解决了。