Java Razoray支付在windows服务器上不起作用
代码在本地计算机上运行良好。给我“https://www.abdc.com/createPayment 500(内部服务器错误)未捕获类型错误:无法读取未定义的属性“statusCode” 在我的jsp页面上的htmlButtoneElement.document.getElementById.onclick(rozorpayreq:1759)“错误,其中“createPayment”是我的ajax url,statusCode是我从createPayment ajax调用返回的属性 下面是java代码Java Razoray支付在windows服务器上不起作用,java,ajax,spring-boot,windows-server-2008,razorpay,Java,Ajax,Spring Boot,Windows Server 2008,Razorpay,代码在本地计算机上运行良好。给我“https://www.abdc.com/createPayment 500(内部服务器错误)未捕获类型错误:无法读取未定义的属性“statusCode” 在我的jsp页面上的htmlButtoneElement.document.getElementById.onclick(rozorpayreq:1759)“错误,其中“createPayment”是我的ajax url,statusCode是我从createPayment ajax调用返回的属性 下面是ja
@RequestMapping(value="/createPayment", method=RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> createOrder(@RequestBody Customer customer,HttpServletRequest req) {
System.out.println("customer=="+customer.toString());
try {
System.out.println(1);
Order order = createRazorPayOrder( customer.getAmount() );
//System.out.println("id data=="+order.get("id"));
System.out.println("createRazorPayOrder data=="+order.toString());
RazorPay razorPay = getRazorPay((String)order.get("id"), customer);
System.out.println("getRazorPay data=="+razorPay.toString());
return new ResponseEntity<String>(gson.toJson(getResponse(razorPay, 200)),
HttpStatus.OK);
} catch (RazorpayException e) {
System.out.println("IN CTCH");
e.printStackTrace();
}
System.out.println(3);
return new ResponseEntity<String>(gson.toJson(getResponse(new RazorPay(), 500)),
HttpStatus.EXPECTATION_FAILED);
}
private Response getResponse(RazorPay razorPay, int statusCode) {
Response response = new Response();
response.setStatusCode(statusCode);
response.setRazorPay(razorPay);
return response;
}
private RazorPay getRazorPay(String orderId, Customer customer) {
RazorPay razorPay = new RazorPay();
razorPay.setApplicationFee(convertRupeeToPaise(customer.getAmount()));
razorPay.setCustomerName(customer.getCustomerName());
razorPay.setCustomerEmail(customer.getEmail());
razorPay.setMerchantName("PURCHASE DEMO");
razorPay.setPurchaseDescription("ABCD");
razorPay.setRazorpayOrderId(orderId);
razorPay.setSecretKey(SECRET_ID);
razorPay.setImageURL("pay.png");
razorPay.setTheme("#F37254");
razorPay.setNotes("notes"+orderId);
return razorPay;
}
private Order createRazorPayOrder(String amount) throws RazorpayException {
JSONObject options = new JSONObject();
options.put("amount", convertRupeeToPaise(amount));
options.put("currency", "INR");
options.put("receipt", "txn_123456");
options.put("payment_capture", 1); // You can enable this if you want to do Auto Capture.
return client.Orders.create(options);
}
private String convertRupeeToPaise(String paise) {
BigDecimal b = new BigDecimal(paise);
BigDecimal value = b.multiply(new BigDecimal("100"));
return value.setScale(0, RoundingMode.UP).toString();
}
由于所有文件都在本地计算机上工作,而不是在我的windows服务器上,我不知道该怎么做需要有价值的指导
document.getElementById('rzp-button1').onclick = function(e){
customerName = document.getElementById('customerName').value;
email = document.getElementById('email').value;
phoneNo = document.getElementById('phoneNo').value;
SHIPPING_ADDRESS = document.getElementById('SHIPPING_ADDRESS').value;
var reqObject = $('#msform').serializeArray();
var indexedReqObj = {};
$.map(reqObject, function(n, i){
indexedReqObj[n['name']] = n['value'];
});
resp = doPost("createPayment", JSON.stringify(indexedReqObj), false);
alert(resp.statusCode);
alert("applicationFee="+resp.razorPay.applicationFee);
alert("razorpayOrderId="+resp.razorPay.razorpayOrderId);
alert("secretKey="+resp.razorPay.secretKey);
alert("paymentId="+resp.razorPay.paymentId);
alert("notes="+resp.razorPay.notes);
alert("imageURL="+resp.razorPay.imageURL);
alert("theme="+resp.razorPay.theme);
alert("merchantName="+resp.razorPay.merchantName);
alert("merchantName="+resp.razorPay.purchaseDescription);
alert("customerName="+resp.razorPay.customerName);
alert("customerEmail="+resp.razorPay.customerEmail);
alert("customerContact="+resp.razorPay.customerContact);
if(resp.statusCode == 200) {
options.key = resp.razorPay.secretKey;
options.order_id = resp.razorPay.razorpayOrderId;
options.amount = resp.razorPay.applicationFee; //paise
options.name = resp.razorPay.merchantName;
options.description = resp.razorPay.purchaseDescription;
options.image = resp.razorPay.imageURL;
options.prefill.name = resp.razorPay.customerName;
options.prefill.email = resp.razorPay.customerEmail;
options.notes.address = resp.razorPay.notes;
options.theme.color = resp.razorPay.theme;
var rzp1 = new Razorpay(options);
rzp1.open();
e.preventDefault();
} else {
//do something else
}
}