UNPKG

react-native-tamara-sdk

Version:

Tamara React Native SDK

55 lines 1.44 kB
import React from 'react'; import { StyleSheet, View } from 'react-native'; import WebView from 'react-native-webview'; const TamaraCheckoutURL = _ref => { let { checkoutURL, successURL, failURL, cancelURL, onSuccess, onFail, onCancel } = _ref; const handleLoadStart = syntheticEvent => { // Change the event type const { nativeEvent } = syntheticEvent; if (nativeEvent.url && nativeEvent.url.includes(successURL)) { onSuccess(); } else if (nativeEvent.url && nativeEvent.url.includes(failURL)) { onFail(); } else if (nativeEvent.url && nativeEvent.url.includes(cancelURL)) { onCancel(); } }; const handleLoadError = () => { console.log('Webview load url fail'); }; return /*#__PURE__*/React.createElement(View, { style: styles.container }, /*#__PURE__*/React.createElement(WebView, { originWhitelist: ['*'], source: { uri: checkoutURL }, onLoadStart: handleLoadStart, onError: handleLoadError, javaScriptEnabled: true, domStorageEnabled: true, allowsInlineMediaPlayback: true, mediaCapturePermissionGrantType: 'grant', mediaPlaybackRequiresUserAction: false })); }; const styles = StyleSheet.create({ container: { flex: 1, minWidth: '100%', minHeight: 100, backgroundColor: 'gray' } }); export default TamaraCheckoutURL; //# sourceMappingURL=TamaraCheckoutURL.js.map