PayPal createSubscription:必须将vault=true传递给sdk才能使用createSubsc



当尝试将createSubscription与react-paypal-button-v2一起使用时,尽管传递了vault=true,我还是收到了这个错误。

Uncaught Error: Must pass vault=true to sdk to use createSubscription

完全错误

buttons?style.label=paypal&style.layout=vertical&style.color=gold&style.shape=rect&style.tagline=false&style.menuPlacement=below&components.0=buttons&locale.country=US&locale.lang=en&sdkMeta=eyJ1cmwiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3Nkay9qcz9jbGllbnQtaWQ9QVFNVjZVSndXRWxVWXNReWNTRzRJQ1RnUmlLMDdiYTBOLUx4eGJIVHBlZmVZYlViSTd2X3BxQkFqNy1uSGlhTHZMTUZfYmdQOGlqajBHUFUiLCJhdHRycyI6eyJkYXRhLXVpZCI6InVpZF9hd2Vpb21pYnhzc3Z4anppc2V3eXdmcnFjY3lwenMifX0&clientID=AQMV6UJwWElUYsQycSG4ICTgRiK07ba0N-LxxbHTpefeYbUbI7v_pqBAj7-nHiaLvLMF_bgP8ijj0GPU&sdkCorrelationID=f1660485acc9c&storageID=uid_131275b7a3_mdy6mji6mdu&sessionID=uid_b2cb1206b2_mta6mzq6ndg&buttonSessionID=uid_94923624b6_mta6mzu6nta&env=production&buttonSize=medium&fundingEligibility=eyJwYXlwYWwiOnsiZWxpZ2libGUiOnRydWUsInZhdWx0YWJsZSI6ZmFsc2V9LCJwYXlsYXRlciI6eyJlbGlnaWJsZSI6ZmFsc2UsIm1lcmNoYW50Q29uZmlnSGFzaCI6IjZiNThjYWEyNzg5YmQwOWJlOTdiYWMyOTBmYjA0NmIyZWU4M2QwMjEiLCJwcm9kdWN0cyI6eyJwYXlJbjMiOnsiZWxpZ2libGUiOmZhbHNlLCJ2YXJpYW50IjpudWxsfSwicGF5SW40Ijp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH0sInBheWxhdGVyIjp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH19fSwiY2FyZCI6eyJlbGl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mYWxzZX0sInBheXUiOnsiZWxpZ2libGUiOmZhbHNlfSwiYmxpayI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJ0cnVzdGx5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sIm94eG8iOnsiZWxpZ2libGUiOmZhbHNlfSwibWF4aW1hIjp7ImVsaWdpYmxlIjpmYWxzZX0sImJvbGV0byI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJtZXJjYWRvcGFnbyI6eyJlbGlnaWJsZSI6ZmFsc2V9fQ&platform=desktop&experiment.enableVenmo=false&experiment.disablePaylater=false&experiment.enableVenmoAppLabel=false&flow=subscription_setup&currency=USD&intent=capture&commit=true&vault=false&renderedButtons.0=paypal&renderedButtons.1=card&debug=false&applePaySupport=false&supportsPopups=true&supportedNativeBrowser=false&allowBillingPayments=true:1342 Uncaught Error: Must pass vault=true to sdk to use createSubscription
at $n (buttons?style.label=paypal&style.layout=vertical&style.color=gold&style.shape=rect&style.tagline=false&style.menuPlacement=below&components.0=buttons&locale.country=US&locale.lang=en&sdkMeta=eyJ1cmwiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3Nkay9qcz9jbGllbnQtaWQ9QVFNVjZVSndXRWxVWXNReWNTRzRJQ1RnUmlLMDdiYTBOLUx4eGJIVHBlZmVZYlViSTd2X3BxQkFqNy1uSGlhTHZMTUZfYmdQOGlqajBHUFUiLCJhdHRycyI6eyJkYXRhLXVpZCI6InVpZF9hd2Vpb21pYnhzc3Z4anppc2V3eXdmcnFjY3lwenMifX0&clientID=AQMV6UJwWElUYsQycSG4ICTgRiK07ba0N-LxxbHTpefeYbUbI7v_pqBAj7-nHiaLvLMF_bgP8ijj0GPU&sdkCorrelationID=f1660485acc9c&storageID=uid_131275b7a3_mdy6mji6mdu&sessionID=uid_b2cb1206b2_mta6mzq6ndg&buttonSessionID=uid_94923624b6_mta6mzu6nta&env=production&buttonSize=medium&fundingEligibility=eyJwYXlwYWwiOnsiZWxpZ2libGUiOnRydWUsInZhdW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naWJsZSI6ZmFsc2V9LCJpZGVhbCI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJiYW5jb250YWN0Ijp7ImVsaWdpYmxlIjpmYWxzZX0sImdpcm9wYXkiOnsiZWxpZ2libGUiOmZhbHNlfSwiZXBzIjp7ImVsaWdpYmxlIjpmYWxzZX0sInNvZm9ydCI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJteWJhbmsiOnsiZWxpZ2libGUiOmZhbHNlfSwicDI0Ijp7ImVsaWdpYmxlIjpmYWxzZX0sInppbXBsZXIiOnsiZWxpZ2libGUiOmZhbHNlfSwid2VjaGF0cGF5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sInBheXUiOnsiZWxpZ2libGUiOmZhbHNlfSwiYmxpayI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJ0cnVzdGx5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sIm94eG8iOnsiZWxpZ2libGUiOmZhbHNlfSwibWF4aW1hIjp7ImVsaWdpYmxlIjpmYWxzZX0sImJvbGV0byI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJtZXJjYWRvcGFnbyI6eyJlbGlnaWJsZSI6ZmFsc2V9fQ&platform=desktop&experiment.enableVenmo=false&experiment.disablePaylater=false&experiment.enableVenmoAppLabel=false&flow=subscription_setup&currency=USD&intent=capture&commit=true&vault=false&renderedButtons.0=paypal&renderedButtons.1=card&debug=false&applePaySupport=false&supportsPopups=true&supportedNativeBrowser=false&allowBillingPayments=true:1342:198816)
at Module.Gr (buttons?style.label=paypal&style.layout=vertical&style.color=gold&style.shape=rect&style.tagline=false&style.menuPlacement=below&components.0=buttons&locale.country=US&locale.lang=en&sdkMeta=eyJ1cmwiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3Nkay9qcz9jbGllbnQtaWQ9QVFNVjZVSndXRWxVWXNReWNTRzRJQ1RnUmlLMDdiYTBOLUx4eGJIVHBlZmVZYlViSTd2X3BxQkFqNy1uSGlhTHZMTUZfYmdQOGlqajBHUFUiLCJhdHRycyI6eyJkYXRhLXVpZCI6InVpZF9hd2Vpb21pYnhzc3Z4anppc2V3eXdmcnFjY3lwenMifX0&clientID=AQMV6UJwWElUYsQycSG4ICTgRiK07ba0N-LxxbHTpefeYbUbI7v_pqBAj7-nHiaLvLMF_bgP8ijj0GPU&sdkCorrelationID=f1660485acc9c&storageID=uid_131275b7a3_mdy6mji6mdu&sessionID=uid_b2cb1206b2_mta6mzq6ndg&buttonSessionID=uid_94923624b6_mta6mzu6nta&env=production&buttonSize=medium&fundingEligibility=eyJwYXlwYWwiOnsiZWxpZ2libGUiOnRydWUsInZhdWx0YWJsZSI6ZmFsc2V9LCJwYXlsYXRlciI6eyJlbGlnaWJsZSI6ZmFsc2UsIm1lcmNoYW50Q29uZmlnSGFzaCI6IjZiNThjYWEyNzg5YmQwOWJlOTdiYWMyOTBmYjA0NmIyZWU4M2QwMjEiLCJwcm9kdWN0cyI6eyJwYXlJbjMiOnsiZWxpZ2libGUiOmZhbHNlLCJ2YXJpYW50IjpudWxsfSwicGF5SW40Ijp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH0sInBheWxhdGVyIjp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH19fSwiY2FyZCI6eyJlbGlnaWJsZSI6dHJ1ZSwiYnJhbmRlZCI6dHJ1ZSwiaW5zdGFsbG1lbnRzIjpmYWxzZSwidmVuZG9ycyI6eyJ2aXNhIjp7ImVsaWdpYmxlIjp0cnVlLCJ2YXVsdGFibGUiOnRydWV9LCJtYXN0ZXJjYXJkIjp7ImVsaWdpYmxlIjp0cnVlLCJ2YXVsdGFibGUiOnRydWV9LCJhbWV4Ijp7ImVsaWdpYmxlIjp0cnVlLCJ2YXVsdGFibGUiOnRydWV9LCJkaXNjb3ZlciI6eyJlbGlnaWJsZSI6ZmFsc2UsInZhdWx0YWJsZSI6dHJ1ZX0sImhpcGVyIjp7ImVsaWdpYmxlIjpmYWxzZSwidmF1bHRhYmxlIjpmYWxzZX0sImVsbyI6eyJlbGlnaWJsZSI6ZmFsc2UsInZhdWx0YWJsZSI6dHJ1ZX0sImpjYiI6eyJlbGlnaWJsZSI6ZmFsc2UsInZhdWx0YWJsZSI6dHJ1ZX19LCJndWVzdEVuYWJsZWQiOmZhbHNlfSwidmVubW8iOnsiZWxpZ2libGUiOmZhbHNlfSwiaXRhdSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJjcmVkaXQiOnsiZWxpZ2libGUiOmZhbHNlfSwiYXBwbGVwYXkiOnsiZWxpZ2libGUiOmZhbHNlfSwic2VwYSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJpZGVhbCI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJiYW5jb250YWN0Ijp7ImVsaWdpYmxlIjpmYWxzZX0sImdpcm9wYXkiOnsiZWxpZ2libGUiOmZhbHNlfSwiZXBzIjp7ImVsaWdpYmxlIjpmYWxzZX0sInNvZm9ydCI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJteWJhbmsiOnsiZWxpZ2libGUiOmZhbHNlfSwicDI0Ijp7ImVsaWdpYmxlIjpmYWxzZX0sInppbXBsZXIiOnsiZWxpZ2libGUiOmZhbHNlfSwid2VjaGF0cGF5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sInBheXUiOnsiZWxpZ2libGUiOmZhbHNlfSwiYmxpayI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJ0cnVzdGx5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sIm94eG8iOnsiZWxpZ2libGUiOmZhbHNlfSwibWF4aW1hIjp7ImVsaWdpYmxlIjpmYWxzZX0sImJvbGV0byI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJtZXJjYWRvcGFnbyI6eyJlbGlnaWJsZSI6ZmFsc2V9fQ&platform=desktop&experiment.enableVenmo=false&experiment.disablePaylater=false&experiment.enableVenmoAppLabel=false&flow=subscription_setup&currency=USD&intent=capture&commit=true&vault=false&renderedButtons.0=paypal&renderedButtons.1=card&debug=false&applePaySupport=false&supportsPopups=true&supportedNativeBrowser=false&allowBillingPayments=true:1342:293740)
at buttons?style.label=paypal&style.layout=vertical&style.color=gold&style.shape=rect&style.tagline=false&style.menuPlacement=below&components.0=buttons&locale.country=US&locale.lang=en&sdkMeta=eyJ1cmwiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3Nkay9qcz9jbGllbnQtaWQ9QVFNVjZVSndXRWxVWXNReWNTRzRJQ1RnUmlLMDdiYTBOLUx4eGJIVHBlZmVZYlViSTd2X3BxQkFqNy1uSGlhTHZMTUZfYmdQOGlqajBHUFUiLCJhdHRycyI6eyJkYXRhLXVpZCI6InVpZF9hd2Vpb21pYnhzc3Z4anppc2V3eXdmcnFjY3lwenMifX0&clientID=AQMV6UJwWElUYsQycSG4ICTgRiK07ba0N-LxxbHTpefeYbUbI7v_pqBAj7-nHiaLvLMF_bgP8ijj0GPU&sdkCorrelationID=f1660485acc9c&storageID=uid_131275b7a3_mdy6mji6mdu&sessionID=uid_b2cb1206b2_mta6mzq6ndg&buttonSessionID=uid_94923624b6_mta6mzu6nta&env=production&buttonSize=medium&fundingEligibility=eyJwYXlwYWwiOnsiZWxpZ2libGUiOnRydWUsInZhdWx0YWJsZSI6ZmFsc2V9LCJwYXlsYXRlciI6eyJlbGlnaWJsZSI6ZmFsc2UsIm1lcmNoYW50Q29uZmlnSGFzaCI6IjZiNThjYWEyNzg5YmQwOWJlOTdiYWMyOTBmYjA0NmIyZWU4M2QwMjEiLCJwcm9kdWN0cyI6eyJwYXlJbjMiOnsiZWxpZ2libGUiOmZhbHNlLCJ2YXJpYW50IjpudWxsfSwicGF5SW40Ijp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH0sInBheWxhdGVyIjp7ImVsaWdpYmxlIjpmYWxzZSwidmFyaWFudCI6bnVsbH19fSwiY2FyZCI6eyJlbGlnaWJsZSI6dHJ1ZSwiYnJhbmRlZCI6dHJ1ZSwiaW5z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payI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJ0cnVzdGx5Ijp7ImVsaWdpYmxlIjpmYWxzZX0sIm94eG8iOnsiZWxpZ2libGUiOmZhbHNlfSwibWF4aW1hIjp7ImVsaWdpYmxlIjpmYWxzZX0sImJvbGV0byI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJtZXJjYWRvcGFnbyI6eyJlbGlnaWJsZSI6ZmFsc2V9fQ&platform=desktop&experiment.enableVenmo=false&experiment.disablePaylater=false&experiment.enableVenmoAppLabel=false&flow=subscription_setup&currency=USD&intent=capture&commit=true&vault=false&renderedButtons.0=paypal&renderedButtons.1=card&debug=false&applePaySupport=false&supportsPopups=true&supportedNativeBrowser=false&allowBillingPayments=true:1343:42

我的代码如下:

import { PayPalButton } from "react-paypal-button-v2"
...
<PayPalButton
amount={amount}
createSubscription={(data, actions) => {
console.log(data, actions)
return actions.subscription.create({
'plan_id': planId
})
}}
onSuccess={(details, data) => {
alert("Transaction completed by " + details.payer.name.given_name);
SilverSubmit()
window.location.reload()
return fetch("/paypal-transaction-complete", {
method: "post",
body: JSON.stringify({
orderId: data.orderID
})
});
}}
options={{
clientId: process.env.SANDBOX_CLIENT_ID,
vault: "true"
}}
style={{
layout: 'vertical',
color: 'gold',
shape: 'rect',
label: 'paypal',
tagline: false
}}
/>

在选项道具中尝试了true作为布尔值和字符串,也尝试了将其作为自己的道具vault={true},但没有成功。

react-paypal-button-v2不是官方模块

使用官方的@paypal/areact paypal js,它支持传递vault=true以及其他可能需要的

请参阅此处的订阅示例

有一个解决方法可以修复问题,但会导致脚本加载两次,如下所示:https://github.com/Luehang/react-paypal-button-v2/issues/54

<script
src="https://www.paypal.com/sdk/js?client-id={CLIENT_ID}&vault=true">
</script>

相关内容

  • 没有找到相关文章

最新更新