问题描述
我无法在我的 C# .net 核心项目中集成 Paytm 网关。我正在接受一些处理并得到这个
Cannot POST /payment
@H_404_4@
我做了以下编码
在Paymnt-gateway.component.html我有一个简单的按钮
<button type="button" (click)="submitForm()">PAY Now</button>
@H_404_4@
在 Paymnt-gateway.component.ts 文件中我有这个代码
export class PaymentGatewayComponent implements OnInit {
paytm: any;
ngOnInit(): void {
}
submitForm() {
submitForm() {
// I will do API call and will get CHECKSUMHASH.
//this.http.post('https://myAPI.com/createchecksum',this.paytm)
// .subscribe((res: any) => {
// // As per my backend i will get checksumhash under res.data
// this.paytm['CHECKSUMHASH'] = res.data;
// // than i will create form
// this.createPaytmForm();
// });
debugger;
let userId = localStorage.getItem('u-id');
let method = "payment/" + userId;
let data = "";
this.dataservice.postFeed(method,JSON.stringify(data)).subscribe(result => {
debugger;
if (result.body.success == false) {
}
else {
let userId = localStorage.getItem('u-id');
this.paytm = {
MID: "my MID here",// paytm provide
WEBSITE: "WEBSTAGING",// paytm provide
INDUSTRY_TYPE_ID: "Retail",// paytm provide
CHANNEL_ID: "WEB",// paytm provide
ORDER_ID: "AWS10007",// Math.floor(10000000000 + Math.random() * 90000000000),CUST_ID: userId,// customer id
MOBILE_NO: "9809234011",// customer mobile number
EMAIL: userId,// customer email
TXN_AMOUNT: "1.00",// transaction amount
CHECKSUMHASH: result.body.data,CALLBACK_URL: "http://localhost:4200/paymentstatus",// Call back URL that i want to redirect after payment fail or success
};
//this.paytm['CHECKSUMHASH'] = result.body.data;
//this.paytm = result.body.data;
this.createPaytmForm();
}
});
}
}
createPaytmForm() {
const my_form: any = document.createElement('form');
my_form.name = 'paytm_form';
my_form.method = 'post';
my_form.action = 'https://securegw-stage.paytm.in/order/process';
const myParams = Object.keys(this.paytm);
for (let i = 0; i < myParams.length; i++) {
const key = myParams[i];
let my_tb: any = document.createElement('input');
my_tb.type = 'hidden';
my_tb.name = key;
my_tb.value = this.paytm[key];
my_form.appendChild(my_tb);
};
document.body.appendChild(my_form);
my_form.submit();
}
@H_404_4@
在后端服务 api 中,我有代码来生成 checksumhash 像这样
[HttpPost("{uid}")]
[ProducesResponseType(typeof(int),200)]
[ProducesResponseType(typeof(int),400)]
[ProducesResponseType(typeof(string),500)]
public async Task<IActionResult> Post(string uid)
{
string body = @"{'\mid\':'\MID here\','\orderId\':'\AWS10007\'}";
string paytmChecksum = Paytm.Checksum.generateSignature(body,"%my key here");
response.Data = paytmChecksum;
@H_404_4@
使用这里的响应假设像 checksumhash
我在这里做错了什么?
解决方法
您似乎正在集成已弃用的 Paytm 重定向流,我们建议集成 js 结帐解决方案。文档可在 paytm 开发者门户上找到。