【问题标题】:Custom paypal checkout button showing inside iframe显示在 iframe 内的自定义贝宝结帐按钮
【发布时间】:2021-08-26 00:57:35
【问题描述】:

我想在我的 iframe 中保持信用卡表单 UI 保持打开状态。但有时它会在里面打开,有时会打开新窗口。我怎样才能让它只在我的 iframe 中打开?

代码如下:

loadScript({
    "client-id": content['client_id'],
    "data-client-token": content['client_token'],
    "currency": "JPY",
    "data-order-id": this.order_id,
    "locale": 'ja_JP'
}).then((paypal) => {
    paypal.Buttons({
      // eslint-disable-next-line no-unused-vars
      createOrder: (data, actions) => {
        this.cancelDisabled = true;
        return Promise.resolve(this.order_id);
      },
      onApprove: (data, actions) => {
        // eslint-disable-next-line no-unused-vars
       return actions.order.capture().then((details) => {
         this.$api.fetch(`/payment-sessions/${this.paymentSession.id}/send_request/?request=payment-capture-done&to=operator,payer`)
       });
      },
      onError: (err) => {
        this.cancelDisabled = false;
        console.error(err);
      },
      // eslint-disable-next-line no-unused-vars
      onCancel: (data, actions) => {
        this.cancelDisabled = false;
      }
    }).render("#paypal-button-container")
    .then(() => {
      let btn = document.getElementById('paypal-button-container')
      btn.style.display = 'unset';
    });

【问题讨论】:

    标签: javascript paypal


    【解决方案1】:

    这可能是由代码中某处的目标引用引起的问题。尝试添加此代码以检查此问题是否是由窗口或选项卡重定向引起的。请注意,这不是一种解决方案,而是一种用于识别您的问题的调试方法。

    $('a[target="_blank"]').removeAttr('target');
    

    【讨论】:

    • 我没有在我的代码中找到目标为空白的标签。问题是使用信用卡按钮(Paypal 生成的按钮)单击付款时有时会在单独的窗口中打开。所以我认为这不是我的问题。
    • 这很奇怪 1 建议是禁用来自您页面的任何新窗口重定向。但它并不是真正的解决方案
    猜你喜欢
    • 2021-06-01
    • 1970-01-01
    • 2016-01-23
    • 2014-06-30
    • 2020-07-21
    • 2015-01-05
    • 2019-03-16
    • 2021-11-17
    • 2013-05-07
    相关资源
    最近更新 更多