简体   繁体   English

如何在 React Native 上实现条带结帐

[英]How to implement stripe checkout on react native

I am new to react native and I'm currently working on an eCommerce app and trying to figure out how to implement stripe checkout.我是 React Native 的新手,我目前正在开发电子商务应用程序并试图弄清楚如何实施条带结帐。 Would there be any good example or tutorial I can watch to find and implement stripe checkout?是否有任何好的示例或教程可供我观看以查找和实施条带结帐?

I have tried to implement it on my own, I'm not exactly sure where I can find the session key.我试图自己实现它,我不确定在哪里可以找到 session 密钥。 Leaving it empty just keeps the payment on loading.将其留空只会使付款保持在加载状态。

If anyone can help or share a guide I can follow that would be great thanks.如果有人可以提供帮助或分享我可以遵循的指南,那将非常感谢。

import StripeCheckout from 'react-native-stripe-checkout-webview';


export default class CheckOutScreen extends Component {

  render() {
        return (
          <StripeCheckout
            stripePublicKey='pk_test_ox4IkFUhPnLRLsQSfVDyo--------'
            checkoutSessionInput={{
              sessionId: ' ',
            }}
            onSuccess={({ checkoutSessionId }) => {
              console.log(`Stripe checkout session succeeded. session id: ${checkoutSessionId}.`);
            }}
            onCancel={() => {
              console.log(`Stripe checkout session cancelled.`);
            }}
          />
        );
  }

}

You can follow the example on their GitHub .您可以按照他们的 GitHub 上的示例进行操作 However, this is a third-party library library (not developed by Stripe).不过,这是一个第三方库库(不是Stripe开发的)。 You can follow the official React Native Stripe guide here .您可以在此处遵循官方 React Native Stripe 指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM