Skip to content

Instantly share code, notes, and snippets.

View callstack-bot's full-sized avatar

Callstack Community Bot callstack-bot

View GitHub Profile
const { confirmPayment, loading } = useConfirmPayment();
const handlePayPress = async () => {
// step 1
// step 2
const { error, paymentIntent } = await confirmPayment(clientSecret, {
type: 'Card',
billingDetails,
});
// step 4
};
const handlePayPress = async () => {
// step 1
const billingDetails = {
email: 'email@stripe.com',
phone: '+48888000888',
addressCity: 'Houston',
addressCountry: 'US',
addressLine1: '1459 Circle Drive',
addressLine2: 'Texas',
addressPostalCode: '77063',
const fetchPaymentIntentClientSecret = async () => {
const response = await fetch(`${API_URL}/create-payment-intent`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
currency: 'usd',
items: [{ id: 'id' }],
}),
});
const { clientSecret } = await response.json();
// ...your imports
import { View, StyleSheet } from 'react-native';
import {
StripeProvider, CardField
} from '@stripe/stripe-react-native';
import { Button } from 'react-native-paper';
export default function App() {
return (
<StripeProvider
import * as React from 'react';
import { Text} from 'react-native';
import Constants from 'expo-constants';
import {
StripeProvider,
} from '@stripe/stripe-react-native';
// find your publishable key at https://dashboard.stripe.com/test/apikeys
const STRIPE_PUBLBISHABLE_KEY = “pk_test_YOUR_KEY_HERE”;
"@stripe/stripe-react-native": "0.2.3"
// when on web, "react-native" becomes "react-native-web", no code changes necessary
import { View } from 'react-native';
import { View } from 'react-native';
import { TouchableOpacity, Text, SecondaryText } from './component-library';
const MyButton = ({ children, onPress, subtext }) => (
<TouchableOpacity onPress={onPress}>
<Text>{children}</Text>
<SecondaryText>{subtext}</SecondaryText>
</TouchableOpacity>
);
import { Text } from './component-library';
const MyButton = ({ children, onPress, subtext }) => (
<div onClick={onPress}>
<Text>{children}</Text>
<span>{subtext}</span>
</div>
);