| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- // import React from 'react';
- // import { View, Image, Linking, Button, Alert, StyleSheet, Text } from 'react-native';
- // import axios from 'axios';
- // import sha256 from 'crypto-js/sha256';
- // export default function Test() {
- // const handleSubmitPayment = async () => {
- // const origin = 'https://openapi-hk.qfapi.com/checkstand/#/?';
- // const obj = {
- // // appcode: 'F8A0AC83C61A40D3840CA9FA930C5D66',
- // appcode: process.env.QFPAY_CODE,
- // goods_name: 'Crazy Charge 錢包增值',
- // out_trade_no: '13422916216626244614',
- // paysource: 'crazycharge_checkout',
- // return_url: 'https://www.google.com',
- // failed_url: 'https://www.google.com',
- // notify_url: 'https://api.crazycharge.com.hk/api/v1/clients/qfpay/webhook',
- // sign_type: 'sha256',
- // txamt: '100',
- // txcurrcd: 'HKD',
- // txdtm: '2020-06-28 18:33:20'
- // };
- // const paramStringify = (json, flag?) => {
- // let str = '';
- // let keysArr = Object.keys(json);
- // keysArr.sort().forEach((val) => {
- // if (!json[val]) return;
- // str += `${val}=${flag ? encodeURIComponent(json[val]) : json[val]}&`;
- // });
- // return str.slice(0, -1);
- // };
- // // const api_key = '5BA7EC74416D4146B9C4E9D71A84D930';
- // const api_key = process.env.QFPAY_KEY;
- // const params = paramStringify(obj);
- // const sign = sha256(`${params}${api_key}`).toString();
- // const url = `${origin}${paramStringify(obj, true)}&sign=${sign}`;
- // try {
- // const supported = await Linking.canOpenURL(url);
- // if (supported) {
- // await Linking.openURL(url);
- // } else {
- // Alert.alert('錯誤', '請稍後再試');
- // }
- // } catch (error) {
- // console.error('Payment error:', error);
- // Alert.alert('Error', 'Failed to submit payment');
- // }
- // };
- // return (
- // <View style={{ flex: 1 }} className="items-center justify-center bg-gray-50 ">
- // <Button
- // title="abc"
- // onPress={() => {
- // console.log('pressed');
- // handleSubmitPayment();
- // }}
- // />
- // <Text>{process.env.QFPAY_KEY}</Text>
- // </View>
- // );
- // }
- // // const handleRedirect = async () => {
- // // const wechatPayUrl =
- // // 'https://cashiermd.95516.com/b2c/api/unifiedOrder.action?tn=560492826346743689323&sign=87d11db496ba7631e44863b49490657b2968af15021d4812b5bde9ca9eb78df4&__log_id_=ACP0240827121309434f0050468870';
- // // try {
- // // const supported = await Linking.canOpenURL(wechatPayUrl);
- // // if (supported) {
- // // await Linking.openURL(wechatPayUrl);
- // // } else {
- // // console.log("Don't know how to open URI: " + wechatPayUrl);
- // // alert('WeChat Pay is not available on this device.');
- // // }
- // // } catch (err) {
- // // console.error('An error occurred', err);
- // // alert('An error occurred while trying to open WeChat Pay.');
- // // }
- // // };
|