Skip to content

Instantly share code, notes, and snippets.

View vivekvardhanadepu's full-sized avatar

Vivek Vardhan Adepu vivekvardhanadepu

View GitHub Profile
@vivekvardhanadepu
vivekvardhanadepu / StripeTerminalInit.js
Created December 31, 2021 11:05
Initialising Stripe Terminal
import { Platform } from "react-native";
import StripeTerminal from "react-native-stripe-terminal";
import RNAndroidLocationEnabler from "react-native-android-location-enabler";
import { PERMISSIONS, request, RESULTS } from "react-native-permissions";
// can be similarly done for componentDidMount
useEffect(() => {
request(Platform.select({
android: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
ios: PERMISSIONS.IOS.LOCATION_ALWAYS,
@vivekvardhanadepu
vivekvardhanadepu / StripeReaderUtilities.js
Created December 31, 2021 10:42
react-native-stripe-terminal reader functionalities
import StripeTerminal from 'react-native-stripe-terminal';
// discovering Readers
StripeTerminal.discoverReaders(
StripeTerminalModule.DiscoveryMethodBluetoothScan, // discovery method
SIMULATED // 0 for real devices, 1 for simulated devices
)
.then((readers) => {
console.log("readers", readers);
})
@vivekvardhanadepu
vivekvardhanadepu / StripeTerminalPayment.js
Created December 31, 2021 10:26
Payment functions in react-native-stripe-terminal
import StripeTerminal from "react-native-stripe-terminal";
// Creating payment intent in backend
axios.post("https://your.backend.com/create_payment_intent", {})
.then((paymentIntent) => {
const clientSecret = paymentIntent.client_secret;
return StripeTerminal.retrievePaymentIntent(clientSecret);
})
//--------or---------//
@vivekvardhanadepu
vivekvardhanadepu / StripeTerminalListeners.js
Last active December 31, 2021 10:05
Event Listeners in react-native-stripe-terminal package
import StripeTerminal from 'react-native-stripe-terminal';
// Add a listener to handle when readers are discovered.
// You could display the readers to the user to select, or just
// auto-connect to the first available reader.
const discoverListener = StripeTerminal.addReadersDiscoveredListener(discoveredReaders => {
console.log("discoveredReaders", discoveredReaders);
});
// This firing without error does not mean the SDK is not still discovering. Just that it found readers.
@vivekvardhanadepu
vivekvardhanadepu / gist:c3eb36b5c2b814a1ea15c6a9e3049209
Created January 30, 2021 14:32 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: