test.tsx 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // import React from 'react';
  2. // import { View, Image, Linking, Button, Alert, StyleSheet, Text } from 'react-native';
  3. // import axios from 'axios';
  4. // import sha256 from 'crypto-js/sha256';
  5. // export default function Test() {
  6. // const handleSubmitPayment = async () => {
  7. // const origin = 'https://openapi-hk.qfapi.com/checkstand/#/?';
  8. // const obj = {
  9. // // appcode: 'F8A0AC83C61A40D3840CA9FA930C5D66',
  10. // appcode: process.env.QFPAY_CODE,
  11. // goods_name: 'Crazy Charge 錢包增值',
  12. // out_trade_no: '13422916216626244614',
  13. // paysource: 'crazycharge_checkout',
  14. // return_url: 'https://www.google.com',
  15. // failed_url: 'https://www.google.com',
  16. // notify_url: 'https://api.crazycharge.com.hk/api/v1/clients/qfpay/webhook',
  17. // sign_type: 'sha256',
  18. // txamt: '100',
  19. // txcurrcd: 'HKD',
  20. // txdtm: '2020-06-28 18:33:20'
  21. // };
  22. // const paramStringify = (json, flag?) => {
  23. // let str = '';
  24. // let keysArr = Object.keys(json);
  25. // keysArr.sort().forEach((val) => {
  26. // if (!json[val]) return;
  27. // str += `${val}=${flag ? encodeURIComponent(json[val]) : json[val]}&`;
  28. // });
  29. // return str.slice(0, -1);
  30. // };
  31. // // const api_key = '5BA7EC74416D4146B9C4E9D71A84D930';
  32. // const api_key = process.env.QFPAY_KEY;
  33. // const params = paramStringify(obj);
  34. // const sign = sha256(`${params}${api_key}`).toString();
  35. // const url = `${origin}${paramStringify(obj, true)}&sign=${sign}`;
  36. // try {
  37. // const supported = await Linking.canOpenURL(url);
  38. // if (supported) {
  39. // await Linking.openURL(url);
  40. // } else {
  41. // Alert.alert('錯誤', '請稍後再試');
  42. // }
  43. // } catch (error) {
  44. // console.error('Payment error:', error);
  45. // Alert.alert('Error', 'Failed to submit payment');
  46. // }
  47. // };
  48. // return (
  49. // <View style={{ flex: 1 }} className="items-center justify-center bg-gray-50 ">
  50. // <Button
  51. // title="abc"
  52. // onPress={() => {
  53. // console.log('pressed');
  54. // handleSubmitPayment();
  55. // }}
  56. // />
  57. // <Text>{process.env.QFPAY_KEY}</Text>
  58. // </View>
  59. // );
  60. // }
  61. // // const handleRedirect = async () => {
  62. // // const wechatPayUrl =
  63. // // 'https://cashiermd.95516.com/b2c/api/unifiedOrder.action?tn=560492826346743689323&sign=87d11db496ba7631e44863b49490657b2968af15021d4812b5bde9ca9eb78df4&__log_id_=ACP0240827121309434f0050468870';
  64. // // try {
  65. // // const supported = await Linking.canOpenURL(wechatPayUrl);
  66. // // if (supported) {
  67. // // await Linking.openURL(wechatPayUrl);
  68. // // } else {
  69. // // console.log("Don't know how to open URI: " + wechatPayUrl);
  70. // // alert('WeChat Pay is not available on this device.');
  71. // // }
  72. // // } catch (err) {
  73. // // console.error('An error occurred', err);
  74. // // alert('An error occurred while trying to open WeChat Pay.');
  75. // // }
  76. // // };