import React, {useEffect, useState} from 'react';
import {
  SafeAreaView,
  Text,
  StatusBar,
  TouchableOpacity,
  DeviceEventEmitter,
  NativeEventEmitter,
  Alert,
  View,
} from 'react-native';

import create_payment_link from './setup';

// import VnpayMerchant, {VnpayMerchantModule} from 'react-native-vnpay-merchant';
// const eventEmitter = new NativeEventEmitter(VnpayMerchantModule);

const Payment = (props) => {
  const [text, setText] = useState('OpenSDK');

  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <TouchableOpacity
        style={{
          paddingHorizontal: 24,
          paddingVertical: 10,
          backgroundColor: 'blue',
          borderRadius: 10,
        }}
        onPress={() => {
          VnpayMerchant.show({
            iconBackName: 'ic_back',
            paymentUrl: create_payment_link(),
            scheme: 'sampleapp',
            tmn_code: 'FAHASA03',
          });
          setText('Sdk opened');
        }}>
        <Text style={{color: 'white'}}>{text}</Text>
      </TouchableOpacity>
    </View>
  );
};

export default Payment;
