PayPalButtons 在桌面上运行正常,但 onApprove() 函数不执行?

huangapple go评论122阅读模式
英文:

PayPalButtons working on desktop but onApprove() function don't run?

问题

我正在使用'@paypal/react-paypal-js'抽象来为React启用网站上的支付功能,在桌面上运行得很顺利,但在Chrome / Safari的iPhone上,onApprove函数不运行,我一直得到无尽的PayPal按钮旋转加载图标,可能是什么原因导致了这个问题?

// Paypal提供者
import { PayPalScriptProvider } from '@paypal/react-paypal-js';
import { PayPalButtons } from '@paypal/react-paypal-js';

<div style={{ margin: 20 }}>
    <PayPalButtons
        style={{
            layout: 'vertical',
            color: 'black',
            shape: 'rect',
            label: 'paypal',
        }}
        createOrder={async (data, actions) => {
            const functions = getFunctions();
            const paypalCreateOrder = httpsCallable(functions, 'paypalCreateOrder');
            paypalCreateOrder(/*Empty*/).then((response: any) => {
                return response.data.id;
            });
        }}
        onApprove={async (data, actions) => {
            alert('Payment Approved !!!');
            // 云函数
            const functions = getFunctions();
            const paypalHandleOrder = httpsCallable(functions, 'paypalHandleOrder');
            await paypalHandleOrder({ orderId: data.orderID })
                .then((response: any) => {
                    _authContext.updatePremiumUntil();
                })
                .catch((error) => {
                    errorHandling(error, 'Payment error has happened', 'BodyPayPal onApprove', dispatch, setSnackBarMsg);
                });

            dispatch(setSnackBarMsg({ bool: true, msg: 'Payment has been accepted' }));
        }}
        onCancel={() => {
            handleCancel();
        }}
        onError={(error) => {
            errorHandling(error, 'Payment error has happened', 'BodyPayPal onError', dispatch, setSnackBarMsg);
        }}
    />
</div>
英文:

I am using '@paypal/react-paypal-js' abstraction for react to enable payments on a website,
the issue is on desktop it works like charm but on chrome / safari iphone the onApprove function doesn't run the I keep getting an endless spinner on the PayPal Btn what could be causing this issue ?

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

// Paypal provider
import { PayPalScriptProvider } from &#39;@paypal/react-paypal-js&#39;;
import { PayPalButtons } from &#39;@paypal/react-paypal-js&#39;;
 
 &lt;div style={{ margin: 20 }}&gt;
          &lt;PayPalButtons
            style={{
              layout: &#39;vertical&#39;,
              color: &#39;black&#39;,
              shape: &#39;rect&#39;,
              label: &#39;paypal&#39;,
            }}
            createOrder={async (data, actions) =&gt; {
              const functions = getFunctions();
              const paypalCreateOrder = httpsCallable(functions, &#39;paypalCreateOrder&#39;);
                paypalCreateOrder(/*Empty*/).then((response: any) =&gt; {
                  return response.data.id;
                });
              }
            }}
            onApprove={async (data, actions) =&gt; {
              alert(&#39;Payment Approved !!!&#39;);
              // Cloud Function
              const functions = getFunctions();
              const paypalHandleOrder = httpsCallable(functions, &#39;paypalHandleOrder&#39;);
              await paypalHandleOrder({ orderId: data.orderID })
                .then((response: any) =&gt; {
                  _authContext.updatePremiumUntil();
                })
                .catch((error) =&gt; {
                  errorHandling(error, &#39;Payment error has happened&#39;, &#39;BodyPayPal onApprove&#39;, dispatch, setSnackBarMsg);
                });

              dispatch(setSnackBarMsg({ bool: true, msg: &#39;Payment has been accepted&#39; }));
            }}
            onCancel={() =&gt; {
              handleCancel();
            }}
            onError={(error) =&gt; {
              errorHandling(error, &#39;Payment error has happened&#39;, &#39;BodyPayPal onError&#39;, dispatch, setSnackBarMsg);
            }}
          /&gt;
        &lt;/div&gt;

<!-- end snippet -->

答案1

得分: 1

不知道是否有关联,但我认为PayPal智能按钮结账存在问题,我几天前向PayPal报告了此问题,因为客户也遇到了相同的问题。请查看此帖子,PayPal已经承认了这个问题。

链接:https://www.paypal-community.com/t5/REST-APIs/Failed-transactions-using-PayPal-Payments-API/m-p/3033825#M8130

英文:

I don’t know if it is connected, but I believe there is a problem with the PayPal smart button checkout, I reported it to PayPal days ago as customers were experiencing the same problem. See this thread for what PayPal have said as they acknowledge there is a. Problem.

https://www.paypal-community.com/t5/REST-APIs/Failed-transactions-using-PayPal-Payments-API/m-p/3033825#M8130

huangapple
  • 本文由 发表于 2023年2月14日 08:30:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75442432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定