diff --git a/.gitignore b/.gitignore index 2be18c5..4681f84 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ buck-out/ *.keystore demo/ios/Pods/** +demo/secrets.js diff --git a/demo/App.js b/demo/App.js index b673160..7cdd6ca 100644 --- a/demo/App.js +++ b/demo/App.js @@ -1,20 +1,46 @@ import { StatusBar } from 'expo-status-bar'; import React from 'react'; -import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; +import { StyleSheet, View, Button } from 'react-native'; export default function App() { initStripe = async () => { + const { STRIPE_PAYMENTS_APP_KEY } = require('./secrets'); const { default: stripe } = await import('react-native-stripe-payments'); - stripe.setOptions({ publishingKey: 'STRIPE_PUBLISHING_KEY' }); + stripe.setOptions({ publishingKey: STRIPE_PAYMENTS_APP_KEY }); } + makePayment = async (isCardNeedConfirm) => { + const { default: stripe } = await import('react-native-stripe-payments'); + + const response = await fetch("http://localhost:8000/pay", { method: 'get' }) + let res = await response.json(); + console.log(res); + + const cardDetails = { + number: isCardNeedConfirm ? '4000002500003155' : '4242424242424242', + expMonth: 12, + expYear: 25, + cvc: '888', + }; + let result = await stripe.confirmPayment(res.client_secret, cardDetails); + console.log(result); + } + + this.initStripe(); return ( - this.initStripe()}> - Init Stripe - +