我可以在警报屏幕中看到有关付款的详细信息,并且PayPal
沙箱帐户根据收到付款,但是我无法在ASP.NET Core 2.1
代码中捕获这些详细信息以记录在数据库中。
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '@planoPreco'
}
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
alert('Transação completada por ' +
details.payer.email_address + '\n' +
details.id + '\n' +
details.payer.name.given_name + '\n' + "R$ " +
details.purchase_units[0].amount.value)
return fetch('/Anunciantes/Contrato_Selecionado', {
method: 'post',
body: JSON.stringify({
orderID: details.payer.email_address// '50007000'// data.orderID
})
})
});
}
}).render('#paypal-button-container');
</script>
public async Task<IActionResult> OnPostAsync([FromBody] string orderID)
{
Console.Beep();
TempData["Message"] = "Pagamento Salvo";
var user = await UserManager.FindByIdAsync("10");
}