在此代码中,我使用razorpay
支付网关 api,其中支付成功完成但在成功 ajax 调用后无法重定向。那么,如何使用window.location.href
订单页面重定向页面?请帮我。
$(document).ready(function() {
$('#buy_now').click(function(e) {
var total_amount = $(".total_amount").val();
var product_id = $(".product_id").map(function() {
return this.id;
}).get().join(",");
var new_uid = $("#new_uid").val();
var user_id = $("#uid").val();
var user_email = $(".user_email").attr("id");
var options = {
"key": "************************",
"amount": (1 * 100), // 2000 paise = INR 20
"name": "MyApp",
"description": "Payment",
"image": "https://www.MyApp.com/img/logo/logo.png",
"handler": function(response) {
$.ajax({
url: '<?php echo base_url() ?>razorPaySuccess',
type: 'post',
dataType: 'json',
data: {
"razorpay_payment_id": response.razorpay_payment_id,
"total_amount": total_amount,
"product_id": product_id,
"new_uid": new_uid,
"user_email": user_email,
"user_id": user_id
},
success: function(data) {
window.location.href = "<?php echo base_url(); ?>order";
}
});
},
"theme": {
"color": "#528FF0"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
e.preventDefault();
});
});