【发布时间】:2020-11-16 07:56:22
【问题描述】:
我的结帐页面上有一个 PayPal 智能按钮。我想在付款被批准后记录交易。 “onApprove”中的警报按预期工作。只有在付款被批准时才会弹出。但是,C# 卡在运行时好像不属于 JS 代码一样。 Here is the PayPal code tutorial.
<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: '@Model.Price'
}
}]
});
},
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);
@{
var userId = UserManager.GetUserId(User);
var transaction = new Transaction
{
Price = Model.Price,
BuyerId = userId,
BuyerName = User.Identity.Name,
SellerId = Model.AuthorId,
SellerName = Model.AuthorName,
TimeOccured = DateTime.Now,
ForumId = Model.ForumId,
ForumName = Model.ForumName
};
await _postService.AddTransaction(transaction);
}
});
},
onCancel: function (data) {
// Show a cancel page, or return to cart
alert('You have canceled the order');
}
}).render('#paypal-button-container');
//This function displays Smart Payment Buttons on your web page.
</script>
【问题讨论】:
标签: javascript c# asp.net paypal