简体   繁体   English

paypal 智能按钮集成问题

[英]Issue with paypal smart buttons integration

I've already setup a paypal payments flow.我已经设置了 paypal 付款流程。 In which if a user were to click to 'pay with PayPal', a pop up opens up which asks the user the sign in to their paypal account and then make the payment from there.其中,如果用户单击“使用 PayPal 付款”,则会打开一个弹出窗口,要求用户登录其 paypal 帐户,然后从那里进行付款。 This flow works as it is.此流程按原样工作。 The issue I'm facing is with the 'pay with credit or debit card' button which the PayPal smart button JavaScript SDK provides.我面临的问题是 PayPal 智能按钮 JavaScript SDK 提供的“使用信用卡或借记卡付款”按钮。 When clicking on this button, it does not open a pop up like it does for the 'pay with PayPal' button.单击此按钮时,它不会像“使用 PayPal 付款”按钮那样打开弹出窗口。 Instead it opens an inline form.相反,它会打开一个内联表单。 I've seen sites where clicking on the 'pay with credit or debit card' button opens a pop up where the form is rendered.我见过一些网站,点击“使用信用卡或借记卡付款”按钮会打开一个弹出窗口,其中会显示表单。 What am I missing?我错过了什么? I've gone through their Smart Buttons API docs and they have not mentioned how to switch between rendering things inline and a pop up.我浏览了他们的 Smart Buttons API 文档,他们没有提到如何在内联渲染和弹出渲染之间切换。 This is the how I've configured the SDK:这是我配置 SDK 的方式:

paypal.Buttons({
    enableStandardCardFields: true,
    locale: 'en_US',
    commit: true,
    style: {
      label: 'pay',
      layout: 'vertical',
      fundingicons: 'true'
    },
    funding: {
      allowed: [ paypal.FUNDING.CARD ]
    },
    onInit: function(data, actions) {
      actions.enable()
    },
    createOrder: function() {
      $('div.loading-container').append('<h2>Processing your payment...</h2>')
      return fetch('/create_order', {
        method: 'post',
        headers: {
          'content-type': 'application/json'
        }
      }).then(function(res) {
        return res.json();
      }).then(function(data) {
        return data.table.id;
      });
    },
    onCancel: function(data) {
      $('div.loading-container').empty()
      return;
    },
    onApprove: function(data) {
      return fetch('/capture_order', {
        method: 'post',
        headers: {
          'content-type': 'application/json'
        },
        body: JSON.stringify({
          orderID: data.orderID
        })
      }).then(function(res) {
        return res.json();
      }).then(function(details) {
        if (details.status == 400) {
          window.location.reload();
          return;
        }
        window.history.pushState({ urlPath:'/orders/thanks' }, "" , '/orders/thanks' );
        window.location.reload();
      })
    }
  }).render('div.paypal_container');

Note: You can find the expected behaviour in this link注意:您可以在此链接中找到预期的行为

You can use this workaround to force the popup:您可以使用此解决方法来强制弹出窗口:

//Changes credit/debit button behavior to "old" version
onShippingChange: function(data,actions){
    //if not needed do nothing..
    return actions.resolve();
},

see also Paypal Smart Payment buttons bug另见Paypal 智能支付按钮错误

The black Debit or Credit Card button always renders inline (exception: a few countries it isn't enabled for).黑色的借记卡或信用卡按钮始终内联呈现(例外:一些国家/地区未启用)。 Most people want this, and consider it nice.大多数人都想要这个,并认为它很好。

There's no way to make that black button open a window. You can disable the black button, leaving only the normal PayPal button, which has the other behavior.没有办法让那个黑色按钮打开 window。您可以禁用黑色按钮,只留下正常的 PayPal 按钮,它具有其他行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM