简体   繁体   English

错误:使用 intent=capture 来使用客户端捕获 [Paypal Javascript SDK]

[英]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.

相关问题 如何捕获GEB中的客户端JavaScript错误? - How to capture client side javascript errors in geb? 在客户端 JavaScript 中,是否可以捕获事件并在稍后阶段触发它? - In client-side JavaScript, is it possible to capture an event and fire it at a later stage? PayPal JavaScript SDK - 了解客户端的安全问题 - PayPal JavaScript SDK - understand security problems on the client-side 如何捕获客户端丢失的资源? - How to capture client-side missing resources? 可以将ExactTarget与客户端JavaScript一起使用吗? - Is it possible to use ExactTarget with client-side JavaScript? 将变量从服务器端控制器传递到客户端,以在客户端JavaScript中使用 - Pass variable from server-side controller to client-side to use in client-side JavaScript 在客户端JavaScript中使用我的Flickr API密钥是否安全? - Is it safe to use my Flickr API key in client-side JavaScript? 我应该使用哪个JavaScript库进行客户端连字? - Which JavaScript library should I use for client-side hyphenation? 将 eval 用于客户端 JavaScript 计算器是否安全 - Is it safe to use eval for a client-side JavaScript calculator 在客户端javascript中使用/生成训练有素的机器学习模型? - Use/productionize trained machine learning model in client-side javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM