英文:
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 '@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 !!!');
// Cloud Function
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>
<!-- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论