[英]Errors: Use intent=capture to use client-side capture [Paypal Javascript SDK]
I am using the PayPal javascript SDK to create a Paypal subscription button for my web page, the problem resides when testing the button using a sandbox account in which after performing all the payment for the subscription the following error appears: I am using the PayPal javascript SDK to create a Paypal subscription button for my web page, the problem resides when testing the button using a sandbox account in which after performing all the payment for the subscription the following error appears:
Error: Use intent=capture to use client-side capture ...
Here's my HTML script used to show my pay PayPal button这是我的 HTML 脚本,用于显示我的付款 PayPal 按钮
<script src="https://www.paypal.com/sdk/js?client-id=MY_CLIENT_ID&vault=true&intent=subscription&components=buttons"></script>
<div id="paypal-button-container"></div>
Heres my js file which performs the respective handlers depending on the actions and status of the payment:这是我的 js 文件,它根据付款的操作和状态执行相应的处理程序:
paypal.Buttons({
style: {
shape: 'rect',
color: 'black',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
if (discordUser.value === "") {
alert("Introduce tu usuario de discord");
return;
}
slotDecremented = true;
alterSlots();
return actions.subscription.create({
'plan_id': 'P-ID' // here is my plan id
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
sendEmailToken(details.payer.email_address, discordUser.value, data.subscriptionID);
});
},
onCancel: function(data) {
alterSlots(true);
slotDecremented = false;
},
onError: function(data) {
if (!slotDecremented) {
return;
}
alterSlots(true);
slotDecremented = false;
}
}).render('#paypal-button-container');
the alterSlot() function makes an API call with AJAX to my specific endpoint, just extra information if neccesary alterSlot() function 使用 AJAX 对我的特定端点进行 API 调用,如果需要,只需提供额外信息
EDIT:编辑:
The sendEmailToken()
function makes an AJAX request to an API hosted on my server, such that the server performs the correct action and being secure (just metadata for knowing what's going on in that part) sendEmailToken()
function 向托管在我的服务器上的 API 发出 AJAX 请求,以便服务器执行正确的操作并确保安全(只是元数据继续了解该部分的内容)
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
sendEmailToken(details.payer.email_address, discordUser.value, data.subscriptionID);
});
},
actions.order.capture()
is for a client-side one-time payment button. actions.order.capture()
用于客户端一次性付款按钮。 It does not belong in a Subscribe button, as there is no order to capture.它不属于订阅按钮,因为没有要捕获的顺序。
See eg the PayPal Subscriptions documentation, which only has a basic success alert in its onApprove
example: https://developer.paypal.com/docs/subscriptions/integrate/#create-the-subscription请参阅例如 PayPal 订阅文档,该文档在其
onApprove
示例中仅包含基本成功警报: https://developer.paypal.com/docs/subscriptions#create/
Since it appears your intent is to perform a server-side operation such as sending an email after subscription approval, you should be activating said subscription from your server to ensure subscriptions don't become active without your server being correctly being notified of this fact.由于您的意图似乎是执行服务器端操作,例如在订阅批准后发送 email,因此您应该从您的服务器激活所述订阅,以确保在没有正确通知您的服务器的情况下订阅不会激活这一事实。 Here is some information: https://stackoverflow.com/a/65139331/2069605
以下是一些信息: https://stackoverflow.com/a/65139331/2069605
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.