【问题标题】:Expo stripe library not working世博条纹库不工作
【发布时间】:2017-09-23 07:15:44
【问题描述】:

我正在考虑改用 expo 来开发我的 react 原生应用程序。

唯一的障碍是,要使用 Stripe 进行支付,您需要将项目从 expo 中分离出来,这会导致失去 Expo 提供的一些有趣功能,例如帮助发布到苹果和安卓商店、推送通知......除非我错了。

我尝试了这个很有前途的库,但我无法让它工作:

stripe-expo

刚刚尝试使用文档的令牌创建示例,但我从 createToken 调用中得到空答案:

代码

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

var stripe = require('stripe-client')('test publishable key I use normally');

export default class App extends React.Component {

componentDidMount() {

let card = stripe.createToken({
  card: {
    "number": '4242424242424242',
    "exp_month": 12,
    "exp_year": 2018,
    "cvc": '123'
  }
});
    console.log(card);

  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
      </View>
    );
  }
}

回应

Promise {
  "_40": 0,
  "_55": null,
  "_65": 0,
  "_72": null,
}

有什么想法吗?

【问题讨论】:

    标签: react-native


    【解决方案1】:

    正如documentation of stripe-expo 中所述,createToken 返回一个Promise

    stripe.createToken(...) 返回一个令牌对象的 Promise

    你需要这样使用,

    stripe.createToken({
      card: {
        "number": '4242424242424242',
        "exp_month": 12,
        "exp_year": 2018,
        "cvc": '123'
      }
    }).then((token_object) => {
      console.log(token_object);
    });
    

    【讨论】:

    • 愚蠢的我...谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 2015-10-07
    • 2021-08-09
    • 2021-06-12
    • 2020-08-09
    • 1970-01-01
    相关资源
    最近更新 更多