目前,我正在尝试在React Native中实现带有订阅付款的条纹。我使用 @Stripe/Stripe-react-Reaction-native库。我做了创建客户和订阅的后端。 后端返回客户ID和SecretClient时起作用。我用脱衣舞夹包装整个应用程序。 initpaymentsheet有效,但现在的付款表不起作用,因为它返回标题中的错误。
I在Internet上进行搜索,解决方案是修改Android的本机代码。这里有没有人遇到此问题,并且知道如何在不修改Android本机代码的情况下解决该问题?我的代码段是这里
1。在app.js中
<StripeProvider
publishableKey={process.env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY}
>
<NavigationContainer theme={MyTheme}>
<RootNavigation />
</NavigationContainer>
</StripeProvider>
2。我需要显示条纹付款表的文件
async function handleEditPaymentMethod() {
const success = await setupStripePaymentSheet();
if (success) {
await openStripeCheckout();
}
}
<ButtonExtend onPress={handleEditPaymentMethod} >
<Text>
Upgrade
</Text>
</ButtonExtend>
3。我实现Initpaymentsheet和prangePaymentsheet和APICall的文件
import {
initPaymentSheet,
presentPaymentSheet,
} from "@stripe/stripe-react-native";
import { supabase } from "./supabase";
const fetchStripekeys = async () => {
const { data, error } = await supabase.functions.invoke("stripe-subscription");
if (error) {
return false;
}
return data;
};
export const setupStripePaymentSheet = async (totalAmount) => {
try {
const { subscriptionId, clientSecret } = await fetchStripekeys(totalAmount);
if (!subscriptionId || !clientSecret) {
return false;
}
const { error } = await initPaymentSheet({
paymentIntentClientSecret: clientSecret,
customerId: subscriptionId,
merchantDisplayName: "My Company",
});
if (error) {
return false;
}
return true;
} catch (error) {
return false;
}
};
export const openStripeCheckout = async () => {
const { error } = await presentPaymentSheet();
if (error) {
return false;
}
return true;
};
以不同的是我的帐户,这是它显示的错误日志