Javascript PayPal onApprove不调用ajax函数
我试图在付款成功时向数据库添加布尔值Javascript PayPal onApprove不调用ajax函数,javascript,ajax,paypal,paypal-sandbox,Javascript,Ajax,Paypal,Paypal Sandbox,我试图在付款成功时向数据库添加布尔值 <script> paypal.Buttons({ createOrder: function(data, actions) { // This function sets up the details of the transaction, including the amount and line item details. return actions.order.create({ purchase_un
<script>
paypal.Buttons({
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
alert('Transaction completed by ' + details.payer.name.given_name);
$.ajax({
url: "includes/payment_db.php",
success: function(data) {
alert('Successfully called');
},
error: function(jqxhr, status, exception) {
alert('Exception:', exception);
}
});
});
}
}).render('#paypal-button-container');
贝宝,按钮({
createOrder:函数(数据、操作){
//此功能设置交易的详细信息,包括金额和行项目详细信息。
return actions.order.create({
购买单位:[{
金额:{
值:“0.01”
}
}]
});
},
onApprove:功能(数据、操作){
//此函数用于捕获交易中的资金。
返回actions.order.capture().then(函数(详细信息){
//此功能向买家显示交易成功消息。
警报('交易由'+详细信息.付款人.名称.给定名称'完成);
$.ajax({
url:“includes/payment_db.php”,
成功:功能(数据){
警报(“成功调用”);
},
错误:函数(jqxhr、状态、异常){
警报(“异常:”,异常);
}
});
});
}
}).render(“#贝宝按钮容器”);
ajax函数不起作用。它不会显示任何错误或成功消息。不应使用这种类型的支付流。不要在客户端捕获信息,然后在数据库中记录信息 相反,请使用直接从服务器捕获的适当服务器端集成,这样您就可以立即获得成功或失败的API响应,并且不依赖于客户端来通知您发生了什么 为此,请在服务器上创建两条路由,一条用于“设置事务”,另一条用于“捕获事务”,如下所示:
为了得到客户的批准,请将以下JavaScript与您创建的上述两个路由配对:我无法理解它是如何实现的。como o queéo quèondeéque vou chamar a minha funèo do php no server integration您需要创建两个新路由<例如,code>includes/create_payment.php和
includes/capture_payment.php?id=xxxxxxxxxxxxxx
或者任何适合您的东西。