This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createPaymentMethod = (number, month, year, cvc) => { | |
const cardDetails = { | |
"card[number]": number, | |
"card[exp_month]": month, | |
"card[exp_year]": year, | |
"card[cvc]": cvc | |
}; | |
let formBody = []; | |
for (let property in cardDetails) { | |
let encodedKey = encodeURIComponent(property); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createPaymentIntent = (amount, currency, payment_method, description) => { | |
let truncated = parseFloat(amount).toFixed(2); | |
let stripeAmount = truncated * 100; | |
fetch('https://api.stripe.com/v1/payment_intents?amount=' + stripeAmount + '¤cy='+ currency +'&payment_method_types[]=card&payment_method=' + payment_method + '&confirmation_method=automatic&confirm=true&description=' + description, { | |
method: 'POST', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
'Authorization': 'Bearer ' + secret_key | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const confirmPaymentIntent = (payment_method) => { | |
fetch('https://api.stripe.com/v1/payment_intents/' + payment_method, { | |
method: 'POST', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
'Authorization': 'Bearer ' + secret_key | |
}, | |
}) | |
.then((response) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DeviceInfoModule.java | |
package com.deviceinfoexample; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.Callback; | |
import com.facebook.react.bridge.ReactMethod; | |
import com.facebook.react.uimanager.IllegalViewOperationException; | |
import com.facebook.react.bridge.Callback; | |
import android.app.PendingIntent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DeviceInfoPackage.java | |
package com.deviceinfoexample; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.uimanager.ViewManager; | |
import com.smsautomatic.DeviceInfoModule; | |
import java.util.ArrayList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.deviceinfoexample; | |
import android.app.Application; | |
import com.facebook.react.ReactApplication; | |
import com.facebook.react.ReactNativeHost; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.react.shell.MainReactPackage; | |
import com.facebook.soloader.SoLoader; | |
import com.smsautomatic.DeviceInfoPackage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react'; | |
import { NativeModules } from 'react-native'; | |
var DeviceInfo = NativeModules.DeviceInfoGet; | |
export default const DeviceInfoComponent = props => { | |
useEffect(() => { | |
DeviceInfo.getDeviceID((err, deviceID) => { | |
if (err) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {forwardRef, useRef, useState, useImperativeHandle} from 'react'; | |
import {View, Animated, Text, StatusBar, StyleSheet} from 'react-native'; | |
const Toast = forwardRef((props, ref) => { | |
const animatedValue = useRef(new Animated.Value(0)).current; | |
const [modalShown, setModalShown] = useState(false); | |
const [message, setMessage] = useState('Success!'); | |
const [toastColor, setToastColor] = useState('green'); | |
const [textColor, setTextColor] = useState('black'); |