SHARE
TWEET

Untitled

a guest Dec 9th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { View } from 'react-native';
  3. import { WebView } from 'react-native-webview';
  4.  
  5. export default class App extends Component {
  6.   render() {
  7.     const html = `
  8.       <html>
  9.       <head></head>
  10.  
  11.       <body >
  12.       <h1>ola mundo </h1>
  13.       <script type="text/javascript"
  14.           src="https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js"></script>
  15.  
  16.       <script type="text/javascript">
  17.      
  18.       const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));
  19.  
  20.    
  21.  
  22.       setTimeout(function () {
  23.         //window.ReactNativeWebView.postMessage("Hello!")
  24.        try {
  25.  
  26.  
  27.           if (PagSeguroDirectPayment==null){alert("null")};
  28.  
  29.           alert(PagSeguroDirectPayment);
  30.  
  31.           PagSeguroDirectPayment.onSenderHashReady(function (response) {
  32.             alert(response);
  33.             if (response.status === 'error') {
  34.               window.ReactNativeWebView.postMessage("Capera");
  35.                 alert(response.message);
  36.                 window.senderHash = false;
  37.             }
  38.            
  39.             window.senderHash = response.senderHash;
  40.             alert("sdfs");
  41.             console.log(window.senderHash);
  42.         });
  43.  
  44.  
  45.        } catch(error){
  46.          alert(error);
  47.        }
  48.  
  49.      
  50.  
  51.       }, 3000);
  52.  
  53.          
  54.       // window.senderHash = null;
  55.       // window.onload = () => {
  56.       //  PagSeguroDirectPayment.onSenderHashReady(function (response) {
  57.       //     if (response.status === 'error') {
  58.       //       window.ReactNativeWebView.postMessage("Capera");
  59.       //         console.log(response.message);
  60.       //         window.senderHash = false;
  61.       //     }
  62.       //     window.senderHash = response.senderHash;
  63.       //     window.ReactNativeWebView.postMessage("Capera");
  64.       //     console.log(window.senderHash);
  65.       // })};
  66.  
  67.  
  68.  
  69.       </script>
  70.   </body>
  71.  
  72.  
  73.       </html>
  74.     `;
  75.  
  76.     return (
  77.       <View style={{ flex: 1 }}>
  78.         <WebView
  79.           source={{ html }}
  80.           onMessage={event => {
  81.             alert(event.nativeEvent.data);
  82.           }}
  83.         />
  84.       </View>
  85.     );
  86.   }
  87.  
  88. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top