问题与PayPal JavaScript SDK客户端JS有关
https://developer.paypal.com/docs/checkout/reference/server-integration/capture-transaction/#on-the-server。
fetch
功能如何工作?
根据官方文档,客户端类似于:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
onApprove: function( data, actions ) {
return actions.order.capture().then( function(details) {
//alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the transaction
//console.log('Transaction completed' ); alert(details);
console.log( 'data.orderID = ' + data.orderID );
document.getElementById('orderID').value = data.orderID;
console.log('data'); console.log(data);
console.log('Transaction completed by ' + details.payer.name.given_name );
//return fetch('/paypal-transaction-complete', {
return fetch( 'https://domain.biz/pay/ppal_1025/EN/pay', {
method: 'POST',
body: JSON.stringify({
orderID: data.orderID,
submitPpal: 1 //imitation of submit button
})
}); // return fetch( 'https://typejoy.biz/pay/ppal_1025/EN/pay
}); // return actions.order.capture().then( function(details
} // onApprove: function(data, actions
}).render('#payPp');
我不了解其工作原理:
return fetch( 'https://domain.biz/pay/ppal_1025/EN/pay', { <... > } )
我在与网址https://domain.biz/pay/ppal_1025/EN/pay
相关的文件中看不到任何POST结果
空POST记录为URL out.php
的{{1}}
https://domain.biz/pay/ppal_1025/EN/pay
PayBundle \ Resources \ actions \ ppal \ action.php
file_put_contents( __DIR__'/out.php', json_encode( $_POST ) .' from '.__FILE__ );