javascript - 是否真的需要服务器端 Paypal 支付验证?
问题描述
简而言之,问题是是否需要服务器端的Paypal支付验证?
更长的故事,我有后端 Scala Play 和前端 Angular7,它们使用 Paypal 客户端 API 触发支付,使用以下客户端支付模式示例作为基线:
<!DOCTYPE html>
<head>
<!-- Add meta tags for mobile and IE -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body>
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=USD"></script>
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
// >>>>>>>>>>>>>>>>>>>> IS THIS NECESSARY? <<<<<<<<<<<<<<<<<<<<<<<<
// use data.orderID to verify the payment on the server-side
myPaypalPaymentRemoteAppServiceImpl.verifyPayment(data.orderID);
// add payment verification result code here
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
</body>
orderID
那么问题是使用 Paypal REST API 在我的服务器端抓取并仔细检查付款确实成功完成并且付款金额确实是预期的(没有潜在的恶意客户端入侵)是否有意义可能会改变价格或尝试其他形式的破坏)。
解决方案
推荐阅读
- javascript - Cognito 用户池“用户名”显示为 id 而不是电子邮件,如何解决?
- .net-core - 任何将 STEP 文件转换为 glTF 文件格式的开源库?
- microsoft-graph-api - 通过 Graph API 检索嵌套分发列表的邮件地址
- c# - 如何构造数据模型以绑定到具有 XML 列的 SQL 表
- python - 伪代码 Python 概念
- android - Kotlin - 如何将非空对象值设置为空?
- java - Combobox 上的 ZK 框架 onCreate 事件
- c# - 如何在 MacOS 中使用 C# 获取鼠标在屏幕上的位置?
- linux - 在 Linux 上执行自建的 ghostscript 二进制文件的问题
- python - 为实例设置类属性就是为所有实例设置它